From 5f82ef966776c9520af8ca59d12260d7e908e464 Mon Sep 17 00:00:00 2001 From: Vasyl Vavrychuk Date: Mon, 25 Apr 2022 10:59:41 +0300 Subject: [PATCH 02/17] Trim trailing spaces drm-backend backport from: https://patchwork.yoctoproject.org/project/yocto/cover/20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com/ Signed-off-by: Vasyl Vavrychuk --- psplash-console.c | 34 +++++++++++----------- psplash-console.h | 8 ++--- psplash-fb.c | 4 +-- psplash-fb.h | 34 +++++++++++----------- psplash-write.c | 14 ++++----- psplash.c | 74 +++++++++++++++++++++++------------------------ psplash.h | 4 +-- 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/psplash-console.c b/psplash-console.c index 3a40620..c00c6fe 100644 --- a/psplash-console.c +++ b/psplash-console.c @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -27,12 +27,12 @@ vt_request (int UNUSED(sig)) perror("Error cannot switch away from console"); Visible = 0; - /* FIXME: - * We likely now want to signal the main loop as to exit + /* FIXME: + * We likely now want to signal the main loop as to exit * and we've now likely switched to the X tty. Note, this * seems to happen anyway atm due to select() call getting * a signal interuption error - not sure if this is really - * reliable however. + * reliable however. */ } else @@ -49,7 +49,7 @@ psplash_console_ignore_switches (void) { struct sigaction act; struct vt_mode vt_mode; - + if (ioctl(ConsoleFd, VT_GETMODE, &vt_mode) < 0) { perror("Error VT_SETMODE failed"); @@ -60,7 +60,7 @@ psplash_console_ignore_switches (void) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + vt_mode.mode = VT_AUTO; vt_mode.relsig = 0; vt_mode.acqsig = 0; @@ -74,7 +74,7 @@ psplash_console_handle_switches (void) { struct sigaction act; struct vt_mode vt_mode; - + if (ioctl(ConsoleFd, VT_GETMODE, &vt_mode) < 0) { perror("Error VT_SETMODE failed"); @@ -85,7 +85,7 @@ psplash_console_handle_switches (void) sigemptyset (&act.sa_mask); act.sa_flags = 0; sigaction (SIGUSR1, &act, 0); - + vt_mode.mode = VT_PROCESS; vt_mode.relsig = SIGUSR1; vt_mode.acqsig = SIGUSR1; @@ -94,8 +94,8 @@ psplash_console_handle_switches (void) perror("Error VT_SETMODE failed"); } -void -psplash_console_switch (void) +void +psplash_console_switch (void) { char vtname[10]; int fd; @@ -114,9 +114,9 @@ psplash_console_switch (void) close(fd); return; } - + close(fd); - + sprintf(vtname,"/dev/tty%d", VTNum); if ((ConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0) @@ -134,12 +134,12 @@ psplash_console_switch (void) if (ioctl(ConsoleFd, VT_ACTIVATE, VTNum) != 0) perror("Error VT_ACTIVATE failed"); - + if (ioctl(ConsoleFd, VT_WAITACTIVE, VTNum) != 0) perror("Error VT_WAITACTIVE failed\n"); psplash_console_handle_switches (); - + if (ioctl(ConsoleFd, KDSETMODE, KD_GRAPHICS) < 0) perror("Error KDSETMODE KD_GRAPHICS failed\n"); @@ -156,7 +156,7 @@ psplash_console_reset (void) return; /* Back to text mode */ - ioctl(ConsoleFd, KDSETMODE, KD_TEXT); + ioctl(ConsoleFd, KDSETMODE, KD_TEXT); psplash_console_ignore_switches (); @@ -175,7 +175,7 @@ psplash_console_reset (void) /* Cleanup */ - close(ConsoleFd); + close(ConsoleFd); if ((fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0)) >= 0) { diff --git a/psplash-console.h b/psplash-console.h index c893bf2..ad51ef2 100644 --- a/psplash-console.h +++ b/psplash-console.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -10,8 +10,8 @@ #ifndef _HAVE_PSPLASH_CONSOLE_H #define _HAVE_PSPLASH_CONSOLE_H -void -psplash_console_switch (void); +void +psplash_console_switch (void); void psplash_console_reset (void); diff --git a/psplash-fb.c b/psplash-fb.c index 2babb5f..1d2d7db 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -429,13 +429,13 @@ psplash_fb_plot_pixel (PSplashFB *fb, { case 32: *(volatile uint32_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) + = ((red >> (8 - fb->red_length)) << fb->red_offset) | ((green >> (8 - fb->green_length)) << fb->green_offset) | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); break; case 16: *(volatile uint16_t *) (fb->bdata + off) - = ((red >> (8 - fb->red_length)) << fb->red_offset) + = ((red >> (8 - fb->red_length)) << fb->red_offset) | ((green >> (8 - fb->green_length)) << fb->green_offset) | ((blue >> (8 - fb->blue_length)) << fb->blue_offset); break; diff --git a/psplash-fb.h b/psplash-fb.h index 16e2b20..eafa293 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -20,11 +20,11 @@ enum RGBMode { typedef struct PSplashFB { - int fd; + int fd; struct fb_var_screeninfo fb_var; - struct termios save_termios; - int type; - int visual; + struct termios save_termios; + int type; + int visual; int width, height; int bpp; int stride; @@ -56,20 +56,20 @@ PSplashFB* psplash_fb_new (int angle, int fbdev_id); void -psplash_fb_draw_rect (PSplashFB *fb, - int x, - int y, - int width, +psplash_fb_draw_rect (PSplashFB *fb, + int x, + int y, + int width, int height, uint8 red, uint8 green, uint8 blue); void -psplash_fb_draw_image (PSplashFB *fb, - int x, - int y, - int img_width, +psplash_fb_draw_image (PSplashFB *fb, + int x, + int y, + int img_width, int img_height, int img_bytes_pre_pixel, int img_rowstride, @@ -82,9 +82,9 @@ psplash_fb_text_size (int *width, const char *text); void -psplash_fb_draw_text (PSplashFB *fb, - int x, - int y, +psplash_fb_draw_text (PSplashFB *fb, + int x, + int y, uint8 red, uint8 green, uint8 blue, diff --git a/psplash-write.c b/psplash-write.c index a12467a..eee0ea3 100644 --- a/psplash-write.c +++ b/psplash-write.c @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * @@ -19,7 +19,7 @@ #include #include "psplash.h" -int main(int argc, char **argv) +int main(int argc, char **argv) { char *rundir; int pipe_fd; @@ -29,17 +29,17 @@ int main(int argc, char **argv) if (!rundir) rundir = "/run"; - if (argc!=2) + if (argc!=2) { fprintf(stderr, "Wrong number of arguments\n"); exit(-1); } - + chdir(rundir); - + if ((pipe_fd = open (PSPLASH_FIFO,O_WRONLY|O_NONBLOCK)) == -1) { - /* Silently error out instead of covering the boot process in + /* Silently error out instead of covering the boot process in errors when psplash has exitted due to a VC switch */ /* perror("Error unable to open fifo"); */ exit (-1); diff --git a/psplash.c b/psplash.c index ee1af6b..838ac13 100644 --- a/psplash.c +++ b/psplash.c @@ -1,9 +1,9 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * - * Parts of this file ( fifo handling ) based on 'usplash' copyright + * Parts of this file ( fifo handling ) based on 'usplash' copyright * Matthew Garret. * * SPDX-License-Identifier: GPL-2.0-or-later @@ -46,15 +46,15 @@ psplash_draw_msg (PSplashFB *fb, const char *msg) /* Clear */ - psplash_fb_draw_rect (fb, - 0, - SPLIT_LINE_POS(fb) - h, + psplash_fb_draw_rect (fb, + 0, + SPLIT_LINE_POS(fb) - h, fb->width, h, PSPLASH_BACKGROUND_COLOR); psplash_fb_draw_text (fb, - (fb->width-w)/2, + (fb->width-w)/2, SPLIT_LINE_POS(fb) - h, PSPLASH_TEXT_COLOR, &FONT_DEF, @@ -70,13 +70,13 @@ psplash_draw_progress (PSplashFB *fb, int value) /* 4 pix border */ x = ((fb->width - BAR_IMG_WIDTH)/2) + 4 ; y = SPLIT_LINE_POS(fb) + 4; - width = BAR_IMG_WIDTH - 8; + width = BAR_IMG_WIDTH - 8; height = BAR_IMG_HEIGHT - 8; if (value > 0) { barwidth = (CLAMP(value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x + barwidth, y, + psplash_fb_draw_rect (fb, x + barwidth, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); psplash_fb_draw_rect (fb, x, y, barwidth, @@ -85,7 +85,7 @@ psplash_draw_progress (PSplashFB *fb, int value) else { barwidth = (CLAMP(-value,0,100) * width) / 100; - psplash_fb_draw_rect (fb, x, y, + psplash_fb_draw_rect (fb, x, y, width - barwidth, height, PSPLASH_BAR_BACKGROUND_COLOR); psplash_fb_draw_rect (fb, x + width - barwidth, @@ -93,18 +93,18 @@ psplash_draw_progress (PSplashFB *fb, int value) PSPLASH_BAR_COLOR); } - DBG("value: %i, width: %i, barwidth :%i\n", value, + DBG("value: %i, width: %i, barwidth :%i\n", value, width, barwidth); } #endif /* PSPLASH_SHOW_PROGRESS_BAR */ -static int +static int parse_command (PSplashFB *fb, char *string) { char *command; DBG("got cmd %s", string); - + if (strcmp(string,"QUIT") == 0) return 1; @@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string) if (arg) psplash_draw_msg (fb, arg); - } + } #ifdef PSPLASH_SHOW_PROGRESS_BAR else if (!strcmp(command,"PROGRESS")) { @@ -124,9 +124,9 @@ parse_command (PSplashFB *fb, char *string) if (arg) psplash_draw_progress (fb, atoi(arg)); - } + } #endif - else if (!strcmp(command,"QUIT")) + else if (!strcmp(command,"QUIT")) { return 1; } @@ -135,8 +135,8 @@ parse_command (PSplashFB *fb, char *string) return 0; } -void -psplash_main (PSplashFB *fb, int pipe_fd, int timeout) +void +psplash_main (PSplashFB *fb, int pipe_fd, int timeout) { int err; ssize_t length = 0; @@ -154,14 +154,14 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) end = command; - while (1) + while (1) { - if (timeout != 0) + if (timeout != 0) err = select(pipe_fd+1, &descriptors, NULL, NULL, &tv); else err = select(pipe_fd+1, &descriptors, NULL, NULL, NULL); - - if (err <= 0) + + if (err <= 0) { /* if (errno == EINTR) @@ -169,10 +169,10 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) */ return; } - + length += read (pipe_fd, end, sizeof(command) - (end - command)); - if (length == 0) + if (length == 0) { /* Reopen to see if there's anything more for us */ close(pipe_fd); @@ -208,10 +208,10 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) out: end = &command[length]; - + tv.tv_sec = timeout; tv.tv_usec = 0; - + FD_ZERO(&descriptors); FD_SET(pipe_fd,&descriptors); } @@ -219,8 +219,8 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout) return; } -int -main (int argc, char** argv) +int +main (int argc, char** argv) { char *rundir; int pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0; @@ -253,8 +253,8 @@ main (int argc, char** argv) } fail: - fprintf(stderr, - "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", + fprintf(stderr, + "Usage: %s [-n|--no-console-switch][-a|--angle <0|90|180|270>][-f|--fbdev <0..9>]\n", argv[0]); exit(-1); } @@ -268,7 +268,7 @@ main (int argc, char** argv) if (mkfifo(PSPLASH_FIFO, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)) { - if (errno!=EEXIST) + if (errno!=EEXIST) { perror("mkfifo"); exit(-1); @@ -276,8 +276,8 @@ main (int argc, char** argv) } pipe_fd = open (PSPLASH_FIFO,O_RDONLY|O_NONBLOCK); - - if (pipe_fd==-1) + + if (pipe_fd==-1) { perror("pipe open"); exit(-2); @@ -301,8 +301,8 @@ main (int argc, char** argv) PSPLASH_BACKGROUND_COLOR); /* Draw the Poky logo */ - psplash_fb_draw_image (fb, - (fb->width - POKY_IMG_WIDTH)/2, + psplash_fb_draw_image (fb, + (fb->width - POKY_IMG_WIDTH)/2, #if PSPLASH_IMG_FULLSCREEN (fb->height - POKY_IMG_HEIGHT)/2, #else @@ -317,8 +317,8 @@ main (int argc, char** argv) #ifdef PSPLASH_SHOW_PROGRESS_BAR /* Draw progress bar border */ - psplash_fb_draw_image (fb, - (fb->width - BAR_IMG_WIDTH)/2, + psplash_fb_draw_image (fb, + (fb->width - BAR_IMG_WIDTH)/2, SPLIT_LINE_POS(fb), BAR_IMG_WIDTH, BAR_IMG_HEIGHT, diff --git a/psplash.h b/psplash.h index 9be44ba..e8b6660 100644 --- a/psplash.h +++ b/psplash.h @@ -1,5 +1,5 @@ -/* - * pslash - a lightweight framebuffer splashscreen for embedded devices. +/* + * pslash - a lightweight framebuffer splashscreen for embedded devices. * * Copyright (c) 2006 Matthew Allum * -- 2.25.1