aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-11-22 08:59:20 +0000
committerTimo Teräs <timo.teras@iki.fi>2014-11-22 08:59:46 +0000
commit9cfd4b125daacff3e09c527e020432e3660ce1f8 (patch)
tree4f3fc6f702606c7fa2e35add924dc64db16611ba /main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
parentc3752969e308ec6d7f9eab043d79cb6d31dcfc62 (diff)
downloadaports-9cfd4b125daacff3e09c527e020432e3660ce1f8.tar.gz
aports-9cfd4b125daacff3e09c527e020432e3660ce1f8.tar.bz2
aports-9cfd4b125daacff3e09c527e020432e3660ce1f8.tar.xz
main/busybox: fixes and minor new features to fbsplash
Diffstat (limited to 'main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch')
-rw-r--r--main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch184
1 files changed, 184 insertions, 0 deletions
diff --git a/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch b/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
new file mode 100644
index 0000000000..2ed0fa050d
--- /dev/null
+++ b/main/busybox/1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
@@ -0,0 +1,184 @@
+From 99d9c9a46b47190f1d2f061ba11c767b4089cf0a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Fri, 21 Nov 2014 16:06:34 +0200
+Subject: [PATCH] fbsplash: support image and bar alignment and positioning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ miscutils/fbsplash.c | 91 +++++++++++++++++++++++++++++++++++++++++++---------
+ 1 file changed, 76 insertions(+), 15 deletions(-)
+
+diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
+index 8599f78..660fddd 100644
+--- a/miscutils/fbsplash.c
++++ b/miscutils/fbsplash.c
+@@ -28,6 +28,7 @@
+ //usage: "\n -c Hide cursor"
+ //usage: "\n -d Framebuffer device (default /dev/fb0)"
+ //usage: "\n -i Config file (var=value):"
++//usage: "\n IMAGE_ALIGN"
+ //usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
+ //usage: "\n BAR_R,BAR_G,BAR_B"
+ //usage: "\n -f Control pipe (else exit after drawing image)"
+@@ -45,13 +46,38 @@
+ /* If you want logging messages on /tmp/fbsplash.log... */
+ #define DEBUG 0
+
++enum {
++ image_align,
++
++ image_posx,
++ image_posy,
++ bar_width,
++ bar_height,
++ bar_posx,
++ bar_posy,
++ bar_colr,
++ bar_colg,
++ bar_colb,
++
++ debug
++};
++
++#define nimage_align ns[image_align]
++#define nbar_width ns[bar_width]
++#define nbar_height ns[bar_height]
++#define nbar_posx ns[bar_posx]
++#define nbar_posy ns[bar_posy]
++#define nbar_colr ns[bar_colr]
++#define nbar_colg ns[bar_colg]
++#define nbar_colb ns[bar_colb]
++
+ struct globals {
+ #if DEBUG
+ bool bdebug_messages; // enable/disable logging
+ FILE *logfile_fd; // log file
+ #endif
+ unsigned char *addr; // pointer to framebuffer memory
+- unsigned ns[7]; // n-parameters
++ unsigned ns[debug+1]; // n-parameters
+ const char *image_filename;
+ int silent_tty, fd_tty_s;
+ bool do_not_draw;
+@@ -68,14 +94,6 @@ struct globals {
+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
+ } while (0)
+
+-#define nbar_width ns[0] // progress bar width
+-#define nbar_height ns[1] // progress bar height
+-#define nbar_posx ns[2] // progress bar horizontal position
+-#define nbar_posy ns[3] // progress bar vertical position
+-#define nbar_colr ns[4] // progress bar color red component
+-#define nbar_colg ns[5] // progress bar color green component
+-#define nbar_colb ns[6] // progress bar color blue component
+-
+ #if DEBUG
+ #define DEBUG_MESSAGE(strMessage, args...) \
+ if (G.bdebug_messages) { \
+@@ -356,7 +374,7 @@ static void fb_drawimage(void)
+ FILE *theme_file;
+ char *read_ptr;
+ unsigned char *pixline;
+- unsigned i, j, width, height, line_size;
++ int i, j, width, height, line_size, xoffs, yoffs, xstart;
+
+ if (LONE_DASH(G.image_filename)) {
+ theme_file = stdin;
+@@ -404,18 +422,46 @@ static void fb_drawimage(void)
+ line_size = width*3;
+ pixline = xmalloc(line_size);
+
++#if 0
+ if (width > G.scr_var.xres)
+ width = G.scr_var.xres;
+ if (height > G.scr_var.yres)
+ height = G.scr_var.yres;
+- for (j = 0; j < height; j++) {
++#endif
++
++ xoffs = yoffs = 0;
++ switch (G.nimage_align % 3) {
++ case 1: xoffs = (G.scr_var.xres - width) / 2; break;
++ case 2: xoffs = G.scr_var.xres - width; break;
++ }
++ xstart = 0;
++ if (xoffs < 0) {
++ xstart = -xoffs;
++ width -= xstart;
++ xoffs = 0;
++ }
++ xoffs *= G.bytes_per_pixel;
++ if (width > G.scr_var.xres)
++ width = G.scr_var.xres;
++
++ switch (G.nimage_align / 3) {
++ case 1: yoffs = (G.scr_var.yres - height) / 2; break;
++ case 2: yoffs = G.scr_var.yres - height; break;
++ }
++
++ for (j = 0; j < height && yoffs < G.scr_var.yres; j++, yoffs++) {
+ unsigned char *pixel;
+ unsigned char *src;
+
+ if (fread(pixline, 1, line_size, theme_file) != line_size)
+ bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
++
++ if (yoffs < 0)
++ continue;
++
+ pixel = pixline;
+- src = G.addr + j * G.scr_fix.line_length;
++ src = G.addr + yoffs * G.scr_fix.line_length + xoffs;
++
+ for (i = 0; i < width; i++) {
+ unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
+ fb_write_pixel(src, thispix);
+@@ -434,9 +480,17 @@ static void fb_drawimage(void)
+ */
+ static void init(const char *cfg_filename)
+ {
++ static const char align_names[] ALIGN1 =
++ "LT\0" "CT\0" "RT\0"
++ "LM\0" "CM\0" "RM\0"
++ "LB\0" "CB\0" "RB\0";
+ static const char param_names[] ALIGN1 =
++ "IMAGE_ALIGN\0"
++
++ "IMAGE_X\0" "IMAGE_Y\0"
+ "BAR_WIDTH\0" "BAR_HEIGHT\0"
+ "BAR_LEFT\0" "BAR_TOP\0"
++
+ "BAR_R\0" "BAR_G\0" "BAR_B\0"
+ #if DEBUG
+ "DEBUG\0"
+@@ -446,14 +500,21 @@ static void init(const char *cfg_filename)
+ parser_t *parser = config_open2(cfg_filename, xfopen_stdin);
+ while (config_read(parser, token, 2, 2, "#=",
+ (PARSE_NORMAL | PARSE_MIN_DIE) & ~(PARSE_TRIM | PARSE_COLLAPSE))) {
+- unsigned val = xatoi_positive(token[1]);
++ unsigned val;
+ int i = index_in_strings(param_names, token[0]);
++
+ if (i < 0)
+ bb_error_msg_and_die("syntax error: %s", token[0]);
+- if (i >= 0 && i < 7)
++
++ if (i <= image_align)
++ val = index_in_strings(align_names, token[1]);
++ else
++ val = xatoi_positive(token[1]);
++
++ if (i < debug)
+ G.ns[i] = val;
+ #if DEBUG
+- if (i == 7) {
++ if (i == debug) {
+ G.bdebug_messages = val;
+ if (G.bdebug_messages)
+ G.logfile_fd = xfopen_for_write("/tmp/fbsplash.log");
+--
+2.1.3
+