[psplash,1/2] Allow users to specify a horizontal offset parameter

Submitted by Philipp Schrader on May 14, 2019, 12:22 a.m. | Patch ID: 161274

Details

Message ID 1557793380-10881-1-git-send-email-philipp@peloton-tech.com
State New
Headers show

Commit Message

Philipp Schrader May 14, 2019, 12:22 a.m.
I have a system where the framebuffer size doesn't match the display
size. In order to figure out which portion of the framebuffer makes it
to the screen I wanted a way to quickly move the picture around. I
decided to add a command line option for a horizontal offset that at
runtime lets you change where exactly the image gets written.

This patch adds a new --horizontal-offset argument to let the user
specify this offset. I was tempted to make the short option "-h"
instead of "-o", but figured that was a bit misleading. "-h" is very
often used for a help.

Signed-off-by: Philipp Schrader <philipp@peloton-tech.com>
---
 psplash.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/psplash.c b/psplash.c
index 992e199..166db73 100644
--- a/psplash.c
+++ b/psplash.c
@@ -206,6 +206,7 @@  main (int argc, char** argv)
 {
   char      *tmpdir;
   int        pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0;
+  int        horizontal_offset = 0;
   PSplashFB *fb;
   bool       disable_console_switch = FALSE;
 
@@ -234,9 +235,16 @@  main (int argc, char** argv)
         continue;
       }
 
+    if (!strcmp(argv[i],"-o") || !strcmp(argv[i],"--horizontal-offset"))
+      {
+        if (++i >= argc) goto fail;
+        horizontal_offset = atoi(argv[i]);
+        continue;
+      }
+
     fail:
       fprintf(stderr, 
-              "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", 
+              "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>][-o|--horizontal-offset X]\n", 
               argv[0]);
       exit(-1);
   }
@@ -280,7 +288,7 @@  main (int argc, char** argv)
 
   /* Draw the Poky logo  */
   psplash_fb_draw_image (fb, 
-			 (fb->width  - POKY_IMG_WIDTH)/2, 
+			 (fb->width  - POKY_IMG_WIDTH)/2 + horizontal_offset, 
 #if PSPLASH_IMG_FULLSCREEN
 			 (fb->height - POKY_IMG_HEIGHT)/2,
 #else