Patchwork psplash: add support for systems without mmap support.

login
register
mail settings
Submitter Yevhen Kyriukha
Date Dec. 10, 2013, 5:18 p.m.
Message ID <1386695884-27586-1-git-send-email-kirgene@gmail.com>
Download mbox | patch
Permalink /patch/63161/
State New
Headers show

Comments

Yevhen Kyriukha - Dec. 10, 2013, 5:18 p.m.
Signed-off-by: Yevhen Kyriukha <kirgene@gmail.com>
---
 ...-support-for-systems-without-mmap-support.patch | 133 +++++++++++++++++++++
 meta/recipes-core/psplash/psplash_git.bb           |   3 +-
 2 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/psplash/files/0001-Add-support-for-systems-without-mmap-support.patch
Ross Burton - Dec. 10, 2013, 5:21 p.m.
Surely if your system has a broken mmap() you've got far bigger
problems than the splash screen not working?

Also, we're upstream for this so instead of patching the recipe, file
a bug with a patch for psplash itself.

Ross
Yevhen Kyriukha - Dec. 10, 2013, 6:31 p.m.
2013/12/10 Burton, Ross <ross.burton@intel.com>:
> Surely if your system has a broken mmap() you've got far bigger
> problems than the splash screen not working?

I'm using Intel Cedartrail platform where mmap is not working properly
with framebuffer.
It's a framebuffer driver problem and such problem may be present on
other platforms too.
Everything else is working as expected.

>
> Also, we're upstream for this so instead of patching the recipe, file
> a bug with a patch for psplash itself.

I had already asked a question here about how I can submit this changes.
I was told to send email to someone of developers of psplash.
I send email to Richard Purdie but there was no reply.

So now I decided to send a patch for psplash recipe.

Best regards,
Yevhen

Patch

diff --git a/meta/recipes-core/psplash/files/0001-Add-support-for-systems-without-mmap-support.patch b/meta/recipes-core/psplash/files/0001-Add-support-for-systems-without-mmap-support.patch
new file mode 100644
index 0000000..76b21f5
--- /dev/null
+++ b/meta/recipes-core/psplash/files/0001-Add-support-for-systems-without-mmap-support.patch
@@ -0,0 +1,133 @@ 
+Add support for systems without mmap support.
+
+Patch adds support to display splash image on systems
+where mmap syscall is not available or is not working properly.
+
+Upstream-Status: Pending
+
+Signed-off-by: Yevhen Kyriukha <kirgene@gmail.com>
+---
+ psplash-fb.c |   24 +++++++++++++++++++++---
+ psplash-fb.h |    4 ++++
+ psplash.c    |    6 ++++++
+ 3 files changed, 31 insertions(+), 3 deletions(-)
+
+diff --git a/psplash-fb.c b/psplash-fb.c
+index 71740cd..17893ab 100644
+--- a/psplash-fb.c
++++ b/psplash-fb.c
+@@ -19,12 +19,21 @@
+ void
+ psplash_fb_destroy (PSplashFB *fb)
+ {
++  if (fb->alloc == 1)
++      free(fb->base);
+   if (fb->fd >= 0)
+     close (fb->fd);
+ 
+   free(fb);
+ }
+ 
++void
++psplash_fb_flush (PSplashFB *fb)
++{
++  if (fb->alloc == 1)
++      pwrite(fb->fd, fb->base, fb->stride * fb->height, 0);
++}
++
+ static int
+ attempt_to_change_pixel_format (PSplashFB *fb,
+                                 struct fb_var_screeninfo *fb_var)
+@@ -119,6 +128,7 @@ psplash_fb_new (int angle)
+   memset (fb, 0, sizeof(PSplashFB));
+ 
+   fb->fd = -1;
++  fb->alloc = -1;
+ 
+   if ((fb->fd = open (fbdev, O_RDWR)) < 0)
+     {
+@@ -194,17 +204,25 @@ psplash_fb_new (int angle)
+   DBG("width: %i, height: %i, bpp: %i, stride: %i",
+       fb->width, fb->height, fb->bpp, fb->stride);
+ 
++  size_t size = fb->stride * fb->height;
++
+   fb->base = (char *) mmap ((caddr_t) NULL,
+ 			    /*fb_fix.smem_len */
+-			    fb->stride * fb->height,
++			    size,
+ 			    PROT_READ|PROT_WRITE,
+ 			    MAP_SHARED,
+ 			    fb->fd, 0);
+ 
+   if (fb->base == (char *)-1)
+     {
+-      perror("Error cannot mmap framebuffer ");
+-      goto fail;
++      fprintf(stdout, "Error cannot mmap framebuffer. Using malloc instead.\n");
++	  fb->base = (char*)malloc(size);
++      if (!fb->base)
++        {
++          perror("Error cannot allocate memory.");
++          goto fail;
++        }
++      fb->alloc = 1;
+     }
+ 
+   off = (unsigned long) fb_fix.smem_start % (unsigned long) getpagesize();
+diff --git a/psplash-fb.h b/psplash-fb.h
+index ef5b39e..0dbc5ea 100644
+--- a/psplash-fb.h
++++ b/psplash-fb.h
+@@ -48,6 +48,7 @@ typedef struct PSplashFB
+   int            green_length;
+   int            blue_offset;
+   int            blue_length;
++  int            alloc;
+ }
+ PSplashFB;
+ 
+@@ -57,6 +58,9 @@ psplash_fb_destroy (PSplashFB *fb);
+ PSplashFB*
+ psplash_fb_new (int angle);
+ 
++void
++psplash_fb_flush (PSplashFB *fb);
++
+ inline void
+ psplash_fb_plot_pixel (PSplashFB    *fb, 
+ 		       int          x, 
+diff --git a/psplash.c b/psplash.c
+index 09cf0d0..524d37d 100644
+--- a/psplash.c
++++ b/psplash.c
+@@ -57,6 +57,8 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
+ 			PSPLASH_TEXT_COLOR,
+ 			&radeon_font,
+ 			msg);
++
++  psplash_fb_flush (fb);
+ }
+ 
+ void
+@@ -90,6 +92,8 @@ psplash_draw_progress (PSplashFB *fb, int value)
+ 			    PSPLASH_BAR_COLOR);
+     }
+ 
++  psplash_fb_flush (fb);
++
+   DBG("value: %i, width: %i, barwidth :%i\n", value, 
+ 		width, barwidth);
+ }
+@@ -289,6 +293,8 @@ main (int argc, char** argv)
+ 
+   psplash_draw_msg (fb, MSG);
+ 
++  psplash_fb_flush (fb);
++
+   psplash_main (fb, pipe_fd, 0);
+ 
+ 
+-- 
+1.7.9.5
+
diff --git a/meta/recipes-core/psplash/psplash_git.bb b/meta/recipes-core/psplash/psplash_git.bb
index 1cab296..91c3fef 100644
--- a/meta/recipes-core/psplash/psplash_git.bb
+++ b/meta/recipes-core/psplash/psplash_git.bb
@@ -7,9 +7,10 @@  LIC_FILES_CHKSUM = "file://psplash.h;beginline=1;endline=16;md5=840fb2356b10a85b
 
 SRCREV = "afd4e228c606a9998feae44a3fed4474803240b7"
 PV = "0.1+git${SRCPV}"
-PR = "r15"
+PR = "r16"
 
 SRC_URI = "git://git.yoctoproject.org/${BPN} \
+           file://0001-Add-support-for-systems-without-mmap-support.patch \
            file://psplash-init \
            ${SPLASH_IMAGES}"