aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-09-07 11:48:25 +0100
committerRon Yorston <rmy@pobox.com>2012-09-07 11:48:25 +0100
commitfecf687cc358883de2da21de33346f0df204c80b (patch)
treed22c606157926fb659374ae68d55e3a874bacf25 /miscutils
parentb25a7c28a0f684087fa6ccbbc7e265a9cac0f0fa (diff)
parent6d463de46b418e6c4c8d1397033608f78b33ab21 (diff)
downloadbusybox-w32-fecf687cc358883de2da21de33346f0df204c80b.tar.gz
busybox-w32-fecf687cc358883de2da21de33346f0df204c80b.tar.bz2
busybox-w32-fecf687cc358883de2da21de33346f0df204c80b.zip
Merge branch 'busybox' into merge
Conflicts: include/libbb.h shell/ash.c
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/fbsplash.c27
-rw-r--r--miscutils/man.c14
-rw-r--r--miscutils/nandwrite.c2
-rw-r--r--miscutils/time.c1
4 files changed, 28 insertions, 16 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 988439b25..37ca66559 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -50,6 +50,10 @@ struct globals {
50 struct fb_var_screeninfo scr_var; 50 struct fb_var_screeninfo scr_var;
51 struct fb_fix_screeninfo scr_fix; 51 struct fb_fix_screeninfo scr_fix;
52 unsigned bytes_per_pixel; 52 unsigned bytes_per_pixel;
53 // cached (8 - scr_var.COLOR.length):
54 unsigned red_shift;
55 unsigned green_shift;
56 unsigned blue_shift;
53}; 57};
54#define G (*ptr_to_globals) 58#define G (*ptr_to_globals)
55#define INIT_G() do { \ 59#define INIT_G() do { \
@@ -139,6 +143,9 @@ static void fb_open(const char *strfb_device)
139 break; 143 break;
140 } 144 }
141 145
146 G.red_shift = 8 - G.scr_var.red.length;
147 G.green_shift = 8 - G.scr_var.green.length;
148 G.blue_shift = 8 - G.scr_var.blue.length;
142 G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3; 149 G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3;
143 150
144 // map the device in memory 151 // map the device in memory
@@ -155,10 +162,13 @@ static void fb_open(const char *strfb_device)
155 162
156 163
157/** 164/**
158 * Return pixel value of the passed RGB color 165 * Return pixel value of the passed RGB color.
166 * This is performance critical fn.
159 */ 167 */
160static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b) 168static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b)
161{ 169{
170 /* We assume that the r,g,b values are <= 255 */
171
162 if (G.bytes_per_pixel == 1) { 172 if (G.bytes_per_pixel == 1) {
163 r = r & 0xe0; // 3-bit red 173 r = r & 0xe0; // 3-bit red
164 g = (g >> 3) & 0x1c; // 3-bit green 174 g = (g >> 3) & 0x1c; // 3-bit green
@@ -166,10 +176,17 @@ static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b)
166 return r + g + b; 176 return r + g + b;
167 } 177 }
168 if (G.bytes_per_pixel == 2) { 178 if (G.bytes_per_pixel == 2) {
169 r = (r & 0xf8) << 8; // 5-bit red 179 // ARM PL110 on Integrator/CP has RGBA5551 bit arrangement.
170 g = (g & 0xfc) << 3; // 6-bit green 180 // We want to support bit locations like that.
171 b = b >> 3; // 5-bit blue 181 //
172 return r + g + b; 182 // First shift out unused bits
183 r = r >> G.red_shift;
184 g = g >> G.green_shift;
185 b = b >> G.blue_shift;
186 // Then shift the remaining bits to their offset
187 return (r << G.scr_var.red.offset) +
188 (g << G.scr_var.green.offset) +
189 (b << G.scr_var.blue.offset);
173 } 190 }
174 // RGB 888 191 // RGB 888
175 return b + (g << 8) + (r << 16); 192 return b + (g << 8) + (r << 16);
diff --git a/miscutils/man.c b/miscutils/man.c
index 236fdcebd..b8b15b83b 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -129,27 +129,21 @@ static int show_manpage(const char *pager, char *man_filename, int man, int leve
129#endif 129#endif
130#if ENABLE_FEATURE_SEAMLESS_XZ 130#if ENABLE_FEATURE_SEAMLESS_XZ
131 strcpy(ext, "xz"); 131 strcpy(ext, "xz");
132 if (run_pipe(pager, man_filename, man, level)) 132 if (run_pipe(pager, filename_with_zext, man, level))
133 return 1; 133 return 1;
134#endif 134#endif
135#if ENABLE_FEATURE_SEAMLESS_BZ2 135#if ENABLE_FEATURE_SEAMLESS_BZ2
136 strcpy(ext, "bz2"); 136 strcpy(ext, "bz2");
137 if (run_pipe(pager, man_filename, man, level)) 137 if (run_pipe(pager, filename_with_zext, man, level))
138 return 1; 138 return 1;
139#endif 139#endif
140#if ENABLE_FEATURE_SEAMLESS_GZ 140#if ENABLE_FEATURE_SEAMLESS_GZ
141 strcpy(ext, "gz"); 141 strcpy(ext, "gz");
142 if (run_pipe(pager, man_filename, man, level)) 142 if (run_pipe(pager, filename_with_zext, man, level))
143 return 1; 143 return 1;
144#endif 144#endif
145 145
146#if SEAMLESS_COMPRESSION 146 return run_pipe(pager, man_filename, man, level);
147 ext[-1] = '\0';
148#endif
149 if (run_pipe(pager, man_filename, man, level))
150 return 1;
151
152 return 0;
153} 147}
154 148
155int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 149int man_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index 2ba6e3fe5..c636a5aa2 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -129,7 +129,7 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
129 xmove_fd(tmp_fd, IS_NANDDUMP ? STDOUT_FILENO : STDIN_FILENO); 129 xmove_fd(tmp_fd, IS_NANDDUMP ? STDOUT_FILENO : STDIN_FILENO);
130 } 130 }
131 131
132 fd = xopen(argv[0], O_RDWR); 132 fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
133 xioctl(fd, MEMGETINFO, &meminfo); 133 xioctl(fd, MEMGETINFO, &meminfo);
134 134
135 mtdoffset = xstrtou(opt_s, 0); 135 mtdoffset = xstrtou(opt_s, 0);
diff --git a/miscutils/time.c b/miscutils/time.c
index 945f15f0d..ffed38632 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -16,6 +16,7 @@
16//usage: "\n -v Verbose" 16//usage: "\n -v Verbose"
17 17
18#include "libbb.h" 18#include "libbb.h"
19#include <sys/resource.h> /* getrusage */
19 20
20/* Information on the resources used by a child process. */ 21/* Information on the resources used by a child process. */
21typedef struct { 22typedef struct {