aboutsummaryrefslogtreecommitdiff
path: root/miscutils/fbsplash.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-28 11:17:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-28 11:17:35 +0000
commita38ba59cc3e78db0234cf4c224de6749d8ce759d (patch)
tree9a9bb30709829c57ff1280e027f03b372f31a9fb /miscutils/fbsplash.c
parentc4523c2b3da206312ed0b007a46eace58659ec31 (diff)
downloadbusybox-w32-a38ba59cc3e78db0234cf4c224de6749d8ce759d.tar.gz
busybox-w32-a38ba59cc3e78db0234cf4c224de6749d8ce759d.tar.bz2
busybox-w32-a38ba59cc3e78db0234cf4c224de6749d8ce759d.zip
fbsplash: move to /sbin; small shrink
function old new delta fb_drawprogressbar 413 423 +10 fbsplash_main 1146 1121 -25
Diffstat (limited to 'miscutils/fbsplash.c')
-rw-r--r--miscutils/fbsplash.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index f254f5630..e8bdb405d 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -95,16 +95,15 @@ static void fb_open(const char *strfb_device)
95 95
96/** 96/**
97 * Draw hollow rectangle on framebuffer 97 * Draw hollow rectangle on framebuffer
98 * \param nx1pos,ny1pos upper left position
99 * \param nx2pos,ny2pos down right position
100 * \param nred,ngreen,nblue rgb color
101 */ 98 */
102static void fb_drawrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos, 99static void fb_drawrectangle(void)
103 unsigned char nred, unsigned char ngreen, unsigned char nblue)
104{ 100{
105 int cnt; 101 int cnt;
106 DATA thispix; 102 DATA thispix;
107 DATA *ptr1, *ptr2; 103 DATA *ptr1, *ptr2;
104 unsigned char nred = G.nbar_colr/2;
105 unsigned char ngreen = G.nbar_colg/2;
106 unsigned char nblue = G.nbar_colb/2;
108 107
109 nred >>= 3; // 5-bit red 108 nred >>= 3; // 5-bit red
110 ngreen >>= 2; // 6-bit green 109 ngreen >>= 2; // 6-bit green
@@ -112,18 +111,18 @@ static void fb_drawrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
112 thispix = nblue + (ngreen << 5) + (nred << (5+6)); 111 thispix = nblue + (ngreen << 5) + (nred << (5+6));
113 112
114 // horizontal lines 113 // horizontal lines
115 ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); 114 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
116 ptr2 = (DATA*)(G.addr + (ny2pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); 115 ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
117 cnt = nx2pos - nx1pos; 116 cnt = G.nbar_width - 1;
118 do { 117 do {
119 *ptr1++ = thispix; 118 *ptr1++ = thispix;
120 *ptr2++ = thispix; 119 *ptr2++ = thispix;
121 } while (--cnt >= 0); 120 } while (--cnt >= 0);
122 121
123 // vertical lines 122 // vertical lines
124 ptr1 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); 123 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL);
125 ptr2 = (DATA*)(G.addr + (ny1pos * G.scr_var.xres + nx2pos) * BYTES_PER_PIXEL); 124 ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL);
126 cnt = ny2pos - ny1pos; 125 cnt = G.nbar_posy + G.nbar_height - 1 - G.nbar_posy;
127 do { 126 do {
128 *ptr1 = thispix; ptr1 += G.scr_var.xres; 127 *ptr1 = thispix; ptr1 += G.scr_var.xres;
129 *ptr2 = thispix; ptr2 += G.scr_var.xres; 128 *ptr2 = thispix; ptr2 += G.scr_var.xres;
@@ -179,10 +178,7 @@ static void fb_drawprogressbar(unsigned percent)
179 if ((height | width) < 0) 178 if ((height | width) < 0)
180 return; 179 return;
181 // NB: "width" of 1 actually makes rect with width of 2! 180 // NB: "width" of 1 actually makes rect with width of 2!
182 fb_drawrectangle( 181 fb_drawrectangle();
183 left_x, top_y,
184 left_x + width, top_y + height,
185 G.nbar_colr/2, G.nbar_colg/2, G.nbar_colb/2);
186 182
187 // inner "empty" rectangle 183 // inner "empty" rectangle
188 left_x++; 184 left_x++;
@@ -279,9 +275,10 @@ static void fb_drawimage(void)
279 275
280 276
281/** 277/**
282 * Parse configuration file 278 * Parse configuration file
279 * \param *cfg_filename name of the configuration file
283 */ 280 */
284static void init(const char *ini_filename) 281static void init(const char *cfg_filename)
285{ 282{
286 static const char const param_names[] ALIGN1 = 283 static const char const param_names[] ALIGN1 =
287 "BAR_LEFT\0" "BAR_TOP\0" 284 "BAR_LEFT\0" "BAR_TOP\0"
@@ -295,7 +292,7 @@ static void init(const char *ini_filename)
295 FILE *inifile; 292 FILE *inifile;
296 char *buf; 293 char *buf;
297 294
298 inifile = xfopen_stdin(ini_filename); 295 inifile = xfopen_stdin(cfg_filename);
299 296
300 while ((buf = xmalloc_fgetline(inifile)) != NULL) { 297 while ((buf = xmalloc_fgetline(inifile)) != NULL) {
301 char *value_str; 298 char *value_str;
@@ -361,7 +358,7 @@ static void init(const char *ini_filename)
361int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 358int fbsplash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
362int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv) 359int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
363{ 360{
364 const char *fb_device, *ini_filename, *fifo_filename; 361 const char *fb_device, *cfg_filename, *fifo_filename;
365 FILE *fp = fp; // for compiler 362 FILE *fp = fp; // for compiler
366 bool bCursorOff; 363 bool bCursorOff;
367 364
@@ -369,22 +366,19 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
369 366
370 // parse command line options 367 // parse command line options
371 fb_device = "/dev/fb0"; 368 fb_device = "/dev/fb0";
372 ini_filename = NULL; 369 cfg_filename = NULL;
373 fifo_filename = NULL; 370 fifo_filename = NULL;
374 bCursorOff = 1 & getopt32(argv, "cs:d:i:f:", 371 bCursorOff = 1 & getopt32(argv, "cs:d:i:f:",
375 &G.image_filename, &fb_device, &ini_filename, &fifo_filename); 372 &G.image_filename, &fb_device, &cfg_filename, &fifo_filename);
376 373
377 // parse configuration file 374 // parse configuration file
378 if (ini_filename) 375 if (cfg_filename)
379 init(ini_filename); 376 init(cfg_filename);
380 377
381 // We must have -s IMG 378 // We must have -s IMG
382 if (!G.image_filename) 379 if (!G.image_filename)
383 bb_show_usage(); 380 bb_show_usage();
384 381
385 if (fifo_filename)
386 fp = xfopen_stdin(fifo_filename);
387
388 fb_open(fb_device); 382 fb_open(fb_device);
389 383
390 if (fifo_filename && bCursorOff) { 384 if (fifo_filename && bCursorOff) {
@@ -394,7 +388,12 @@ int fbsplash_main(int argc ATTRIBUTE_UNUSED, char **argv)
394 388
395 fb_drawimage(); 389 fb_drawimage();
396 390
397 if (fifo_filename) while (1) { 391 if (!fifo_filename)
392 return EXIT_SUCCESS;
393
394 fp = xfopen_stdin(fifo_filename);
395
396 while (1) {
398 struct stat statbuf; 397 struct stat statbuf;
399 unsigned num; 398 unsigned num;
400 char *num_buf; 399 char *num_buf;