diff options
author | Julien Gueytat <contact@jgueytat.fr> | 2016-06-01 00:11:35 +0200 |
---|---|---|
committer | Ross Burton <ross.burton@intel.com> | 2016-06-05 22:14:59 +0100 |
commit | 5b3c1cc28f5abdc2c33830150b48b278cc4f7bca (patch) | |
tree | b21f04b412ae6ee03c462b274df571b441298a05 | |
parent | 42780c0e6a3d2b4ed33f14cb5400036cc09ca79b (diff) | |
download | psplash-5b3c1cc28f5abdc2c33830150b48b278cc4f7bca.tar.gz psplash-5b3c1cc28f5abdc2c33830150b48b278cc4f7bca.tar.bz2 psplash-5b3c1cc28f5abdc2c33830150b48b278cc4f7bca.zip |
Add --fbdev option to psplash like --rotation.
A new fbdev file is needed and should be overrided if needed.
The number contained in fbdev will be used as X in /dev/fbX.
By overriding fbdev you can have a splash screen on another
framebuffer than /dev/fbO.
The getenv(FBDEV) line has been replaced by this option since
the environment variables are not read yet when psplash starts.
Signed-off-by: Julien Gueytat <contact@jgueytat.fr>
Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | psplash-fb.c | 16 | ||||
-rw-r--r-- | psplash-fb.h | 4 | ||||
-rw-r--r-- | psplash.c | 49 |
4 files changed, 41 insertions, 29 deletions
@@ -1,6 +1,7 @@ List of contributors (in alphabetical order): Aws Ismail <aws.ismail@windriver.com> +Julien Gueytat <contact@jgueytat.fr> Juro Bystricky <juro.bystricky@intel.com> Khem Raj <raj.khem@gmail.com> Matthew Allum <mallum@openedhand.com> diff --git a/psplash-fb.c b/psplash-fb.c index 8daaf6f..d344e5a 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -99,18 +99,20 @@ attempt_to_change_pixel_format (PSplashFB *fb, } PSplashFB* -psplash_fb_new (int angle) +psplash_fb_new (int angle, int fbdev_id) { struct fb_var_screeninfo fb_var; struct fb_fix_screeninfo fb_fix; int off; - char *fbdev; + char fbdev[9] = "/dev/fb0"; PSplashFB *fb = NULL; - fbdev = getenv("FBDEV"); - if (fbdev == NULL) - fbdev = "/dev/fb0"; + if (fbdev_id > 0 && fbdev_id < 10) + { + // Conversion from integer to ascii. + fbdev[7] = fbdev_id + 48; + } if ((fb = malloc (sizeof(PSplashFB))) == NULL) { @@ -124,7 +126,9 @@ psplash_fb_new (int angle) if ((fb->fd = open (fbdev, O_RDWR)) < 0) { - perror ("Error opening /dev/fb0"); + fprintf(stderr, + "Error opening %s\n", + fbdev); goto fail; } diff --git a/psplash-fb.h b/psplash-fb.h index a4a0f4c..d0dce10 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -38,7 +38,7 @@ typedef struct PSplashFB char *data; char *base; - int angle; + int angle, fbdev_id; int real_width, real_height; enum RGBMode rgbmode; @@ -55,7 +55,7 @@ void psplash_fb_destroy (PSplashFB *fb); PSplashFB* -psplash_fb_new (int angle); +psplash_fb_new (int angle, int fbdev_id); void psplash_fb_draw_rect (PSplashFB *fb, @@ -205,35 +205,41 @@ int main (int argc, char** argv) { char *tmpdir; - int pipe_fd, i = 0, angle = 0, ret = 0; + int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; PSplashFB *fb; bool disable_console_switch = FALSE; - + signal(SIGHUP, psplash_exit); signal(SIGINT, psplash_exit); signal(SIGQUIT, psplash_exit); - while (++i < argc) - { - if (!strcmp(argv[i],"-n") || !strcmp(argv[i],"--no-console-switch")) - { - disable_console_switch = TRUE; - continue; - } + while (++i < argc) { + if (!strcmp(argv[i],"-n") || !strcmp(argv[i],"--no-console-switch")) + { + disable_console_switch = TRUE; + continue; + } + + if (!strcmp(argv[i],"-a") || !strcmp(argv[i],"--angle")) + { + if (++i >= argc) goto fail; + angle = atoi(argv[i]); + continue; + } + + if (!strcmp(argv[i],"-f") || !strcmp(argv[i],"--fbdev")) + { + if (++i >= argc) goto fail; + fbdev_id = atoi(argv[i]); + continue; + } - if (!strcmp(argv[i],"-a") || !strcmp(argv[i],"--angle")) - { - if (++i >= argc) goto fail; - angle = atoi(argv[i]); - continue; - } - fail: fprintf(stderr, - "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>]\n", - argv[0]); + "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", + argv[0]); exit(-1); - } + } tmpdir = getenv("TMPDIR"); @@ -262,10 +268,11 @@ main (int argc, char** argv) if (!disable_console_switch) psplash_console_switch (); - if ((fb = psplash_fb_new(angle)) == NULL) { + if ((fb = psplash_fb_new(angle,fbdev_id)) == NULL) + { ret = -1; goto fb_fail; - } + } /* Clear the background with #ecece1 */ psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height, |