diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 16:28:30 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 16:28:30 +0000 |
commit | 39d551fd1570ca760582777b325ae3396d49ebf3 (patch) | |
tree | c0af0cad727962fb27c28c26dbd41e6e36b18614 | |
parent | 274b8c0639ae3b733c63252959c3a7fa4025b5cc (diff) | |
download | busybox-w32-39d551fd1570ca760582777b325ae3396d49ebf3.tar.gz busybox-w32-39d551fd1570ca760582777b325ae3396d49ebf3.tar.bz2 busybox-w32-39d551fd1570ca760582777b325ae3396d49ebf3.zip |
fbset: store short string in the structure itself instead of the pointer
(small size saving)
-rw-r--r-- | util-linux/fbset.c | 416 |
1 files changed, 203 insertions, 213 deletions
diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 9ca3e1b64..bc8ec1806 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c | |||
@@ -70,94 +70,92 @@ enum { | |||
70 | FBIOPUT_VSCREENINFO = 0x4601 | 70 | FBIOPUT_VSCREENINFO = 0x4601 |
71 | }; | 71 | }; |
72 | struct fb_bitfield { | 72 | struct fb_bitfield { |
73 | uint32_t offset; /* beginning of bitfield */ | 73 | uint32_t offset; /* beginning of bitfield */ |
74 | uint32_t length; /* length of bitfield */ | 74 | uint32_t length; /* length of bitfield */ |
75 | uint32_t msb_right; /* != 0 : Most significant bit is */ | 75 | uint32_t msb_right; /* !=0: Most significant bit is right */ |
76 | /* right */ | ||
77 | }; | 76 | }; |
78 | struct fb_var_screeninfo { | 77 | struct fb_var_screeninfo { |
79 | uint32_t xres; /* visible resolution */ | 78 | uint32_t xres; /* visible resolution */ |
80 | uint32_t yres; | 79 | uint32_t yres; |
81 | uint32_t xres_virtual; /* virtual resolution */ | 80 | uint32_t xres_virtual; /* virtual resolution */ |
82 | uint32_t yres_virtual; | 81 | uint32_t yres_virtual; |
83 | uint32_t xoffset; /* offset from virtual to visible */ | 82 | uint32_t xoffset; /* offset from virtual to visible */ |
84 | uint32_t yoffset; /* resolution */ | 83 | uint32_t yoffset; /* resolution */ |
85 | 84 | ||
86 | uint32_t bits_per_pixel; /* guess what */ | 85 | uint32_t bits_per_pixel; |
87 | uint32_t grayscale; /* != 0 Graylevels instead of colors */ | 86 | uint32_t grayscale; /* !=0 Graylevels instead of colors */ |
88 | 87 | ||
89 | struct fb_bitfield red; /* bitfield in fb mem if true color, */ | 88 | struct fb_bitfield red; /* bitfield in fb mem if true color, */ |
90 | struct fb_bitfield green; /* else only length is significant */ | 89 | struct fb_bitfield green; /* else only length is significant */ |
91 | struct fb_bitfield blue; | 90 | struct fb_bitfield blue; |
92 | struct fb_bitfield transp; /* transparency */ | 91 | struct fb_bitfield transp; /* transparency */ |
93 | 92 | ||
94 | uint32_t nonstd; /* != 0 Non standard pixel format */ | 93 | uint32_t nonstd; /* !=0 Non standard pixel format */ |
95 | 94 | ||
96 | uint32_t activate; /* see FB_ACTIVATE_* */ | 95 | uint32_t activate; /* see FB_ACTIVATE_x */ |
97 | 96 | ||
98 | uint32_t height; /* height of picture in mm */ | 97 | uint32_t height; /* height of picture in mm */ |
99 | uint32_t width; /* width of picture in mm */ | 98 | uint32_t width; /* width of picture in mm */ |
100 | 99 | ||
101 | uint32_t accel_flags; /* acceleration flags (hints) */ | 100 | uint32_t accel_flags; /* acceleration flags (hints) */ |
102 | 101 | ||
103 | /* Timing: All values in pixclocks, except pixclock (of course) */ | 102 | /* Timing: All values in pixclocks, except pixclock (of course) */ |
104 | uint32_t pixclock; /* pixel clock in ps (pico seconds) */ | 103 | uint32_t pixclock; /* pixel clock in ps (pico seconds) */ |
105 | uint32_t left_margin; /* time from sync to picture */ | 104 | uint32_t left_margin; /* time from sync to picture */ |
106 | uint32_t right_margin; /* time from picture to sync */ | 105 | uint32_t right_margin; /* time from picture to sync */ |
107 | uint32_t upper_margin; /* time from sync to picture */ | 106 | uint32_t upper_margin; /* time from sync to picture */ |
108 | uint32_t lower_margin; | 107 | uint32_t lower_margin; |
109 | uint32_t hsync_len; /* length of horizontal sync */ | 108 | uint32_t hsync_len; /* length of horizontal sync */ |
110 | uint32_t vsync_len; /* length of vertical sync */ | 109 | uint32_t vsync_len; /* length of vertical sync */ |
111 | uint32_t sync; /* see FB_SYNC_* */ | 110 | uint32_t sync; /* see FB_SYNC_x */ |
112 | uint32_t vmode; /* see FB_VMODE_* */ | 111 | uint32_t vmode; /* see FB_VMODE_x */ |
113 | uint32_t reserved[6]; /* Reserved for future compatibility */ | 112 | uint32_t reserved[6]; /* Reserved for future compatibility */ |
114 | }; | 113 | }; |
115 | 114 | ||
116 | 115 | ||
117 | static const struct cmdoptions_t { | 116 | static const struct cmdoptions_t { |
118 | const char *name; | 117 | const char name[10]; |
119 | const unsigned char param_count; | 118 | const unsigned char param_count; |
120 | const unsigned char code; | 119 | const unsigned char code; |
121 | } g_cmdoptions[] = { | 120 | } g_cmdoptions[] = { |
122 | { | 121 | { "-fb", 1, CMD_FB }, |
123 | "-fb", 1, CMD_FB}, { | 122 | { "-db", 1, CMD_DB }, |
124 | "-db", 1, CMD_DB}, { | 123 | { "-a", 0, CMD_ALL }, |
125 | "-a", 0, CMD_ALL}, { | 124 | { "-i", 0, CMD_INFO }, |
126 | "-i", 0, CMD_INFO}, { | 125 | { "-g", 5, CMD_GEOMETRY }, |
127 | "-g", 5, CMD_GEOMETRY}, { | 126 | { "-t", 7, CMD_TIMING }, |
128 | "-t", 7, CMD_TIMING}, { | 127 | { "-accel", 1, CMD_ACCEL }, |
129 | "-accel", 1, CMD_ACCEL}, { | 128 | { "-hsync", 1, CMD_HSYNC }, |
130 | "-hsync", 1, CMD_HSYNC}, { | 129 | { "-vsync", 1, CMD_VSYNC }, |
131 | "-vsync", 1, CMD_VSYNC}, { | 130 | { "-laced", 1, CMD_LACED }, |
132 | "-laced", 1, CMD_LACED}, { | 131 | { "-double", 1, CMD_DOUBLE }, |
133 | "-double", 1, CMD_DOUBLE}, { | 132 | { "-n", 0, CMD_CHANGE }, |
134 | "-n", 0, CMD_CHANGE}, { | ||
135 | #ifdef CONFIG_FEATURE_FBSET_FANCY | 133 | #ifdef CONFIG_FEATURE_FBSET_FANCY |
136 | "-all", 0, CMD_ALL}, { | 134 | { "-all", 0, CMD_ALL }, |
137 | "-xres", 1, CMD_XRES}, { | 135 | { "-xres", 1, CMD_XRES }, |
138 | "-yres", 1, CMD_YRES}, { | 136 | { "-yres", 1, CMD_YRES }, |
139 | "-vxres", 1, CMD_VXRES}, { | 137 | { "-vxres", 1, CMD_VXRES }, |
140 | "-vyres", 1, CMD_VYRES}, { | 138 | { "-vyres", 1, CMD_VYRES }, |
141 | "-depth", 1, CMD_DEPTH}, { | 139 | { "-depth", 1, CMD_DEPTH }, |
142 | "-match", 0, CMD_MATCH}, { | 140 | { "-match", 0, CMD_MATCH }, |
143 | "-geometry", 5, CMD_GEOMETRY}, { | 141 | { "-geometry", 5, CMD_GEOMETRY }, |
144 | "-pixclock", 1, CMD_PIXCLOCK}, { | 142 | { "-pixclock", 1, CMD_PIXCLOCK }, |
145 | "-left", 1, CMD_LEFT}, { | 143 | { "-left", 1, CMD_LEFT }, |
146 | "-right", 1, CMD_RIGHT}, { | 144 | { "-right", 1, CMD_RIGHT }, |
147 | "-upper", 1, CMD_UPPER}, { | 145 | { "-upper", 1, CMD_UPPER }, |
148 | "-lower", 1, CMD_LOWER}, { | 146 | { "-lower", 1, CMD_LOWER }, |
149 | "-hslen", 1, CMD_HSLEN}, { | 147 | { "-hslen", 1, CMD_HSLEN }, |
150 | "-vslen", 1, CMD_VSLEN}, { | 148 | { "-vslen", 1, CMD_VSLEN }, |
151 | "-timings", 7, CMD_TIMING}, { | 149 | { "-timings", 7, CMD_TIMING }, |
152 | "-csync", 1, CMD_CSYNC}, { | 150 | { "-csync", 1, CMD_CSYNC }, |
153 | "-gsync", 1, CMD_GSYNC}, { | 151 | { "-gsync", 1, CMD_GSYNC }, |
154 | "-extsync", 1, CMD_EXTSYNC}, { | 152 | { "-extsync", 1, CMD_EXTSYNC }, |
155 | "-bcast", 1, CMD_BCAST}, { | 153 | { "-bcast", 1, CMD_BCAST }, |
156 | "-rgba", 1, CMD_RGBA}, { | 154 | { "-rgba", 1, CMD_RGBA }, |
157 | "-step", 1, CMD_STEP}, { | 155 | { "-step", 1, CMD_STEP }, |
158 | "-move", 1, CMD_MOVE}, { | 156 | { "-move", 1, CMD_MOVE }, |
159 | #endif | 157 | #endif |
160 | 0, 0, 0} | 158 | { "", 0, 0 } |
161 | }; | 159 | }; |
162 | 160 | ||
163 | #ifdef CONFIG_FEATURE_FBSET_READMODE | 161 | #ifdef CONFIG_FEATURE_FBSET_READMODE |
@@ -171,6 +169,7 @@ enum { | |||
171 | FB_SYNC_COMP_HIGH_ACT = 8 /* composite sync high active */ | 169 | FB_SYNC_COMP_HIGH_ACT = 8 /* composite sync high active */ |
172 | }; | 170 | }; |
173 | #endif | 171 | #endif |
172 | |||
174 | static int readmode(struct fb_var_screeninfo *base, const char *fn, | 173 | static int readmode(struct fb_var_screeninfo *base, const char *fn, |
175 | const char *mode) | 174 | const char *mode) |
176 | { | 175 | { |
@@ -182,89 +181,82 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, | |||
182 | f = xfopen(fn, "r"); | 181 | f = xfopen(fn, "r"); |
183 | while (!feof(f)) { | 182 | while (!feof(f)) { |
184 | fgets(buf, sizeof(buf), f); | 183 | fgets(buf, sizeof(buf), f); |
185 | if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) { | 184 | if (!(p = strstr(buf, "mode ")) && !(p = strstr(buf, "mode\t"))) |
186 | p += 5; | 185 | continue; |
187 | if ((p = strstr(buf, mode))) { | 186 | p += 5; |
188 | p += strlen(mode); | 187 | if (!(p = strstr(buf, mode))) |
189 | if (!isspace(*p) && (*p != 0) && (*p != '"') | 188 | continue; |
190 | && (*p != '\r') && (*p != '\n')) | 189 | p += strlen(mode); |
191 | continue; /* almost, but not quite */ | 190 | if (!isspace(*p) && (*p != 0) && (*p != '"') |
192 | while (!feof(f)) { | 191 | && (*p != '\r') && (*p != '\n')) |
193 | fgets(buf, sizeof(buf), f); | 192 | continue; /* almost, but not quite */ |
194 | 193 | ||
195 | if ((p = strstr(buf, "geometry "))) { | 194 | while (!feof(f)) { |
196 | p += 9; | 195 | fgets(buf, sizeof(buf), f); |
197 | 196 | if ((p = strstr(buf, "geometry "))) { | |
198 | sscanf(p, "%d %d %d %d %d", | 197 | p += 9; |
199 | &(base->xres), &(base->yres), | 198 | /* FIXME: catastrophic on arches with 64bit ints */ |
200 | &(base->xres_virtual), &(base->yres_virtual), | 199 | sscanf(p, "%d %d %d %d %d", |
201 | &(base->bits_per_pixel)); | 200 | &(base->xres), &(base->yres), |
202 | } else if ((p = strstr(buf, "timings "))) { | 201 | &(base->xres_virtual), &(base->yres_virtual), |
203 | p += 8; | 202 | &(base->bits_per_pixel)); |
204 | 203 | } else if ((p = strstr(buf, "timings "))) { | |
205 | sscanf(p, "%d %d %d %d %d %d %d", | 204 | p += 8; |
206 | &(base->pixclock), | 205 | sscanf(p, "%d %d %d %d %d %d %d", |
207 | &(base->left_margin), &(base->right_margin), | 206 | &(base->pixclock), |
208 | &(base->upper_margin), &(base->lower_margin), | 207 | &(base->left_margin), &(base->right_margin), |
209 | &(base->hsync_len), &(base->vsync_len)); | 208 | &(base->upper_margin), &(base->lower_margin), |
210 | } else if ((p = strstr(buf, "laced "))) { | 209 | &(base->hsync_len), &(base->vsync_len)); |
211 | p += 6; | 210 | } else if ((p = strstr(buf, "laced "))) { |
212 | 211 | //p += 6; | |
213 | if (strstr(buf, "false")) { | 212 | if (strstr(buf, "false")) { |
214 | base->vmode &= ~FB_VMODE_INTERLACED; | 213 | base->vmode &= ~FB_VMODE_INTERLACED; |
215 | } else { | 214 | } else { |
216 | base->vmode |= FB_VMODE_INTERLACED; | 215 | base->vmode |= FB_VMODE_INTERLACED; |
217 | } | 216 | } |
218 | } else if ((p = strstr(buf, "double "))) { | 217 | } else if ((p = strstr(buf, "double "))) { |
219 | p += 7; | 218 | //p += 7; |
220 | 219 | if (strstr(buf, "false")) { | |
221 | if (strstr(buf, "false")) { | 220 | base->vmode &= ~FB_VMODE_DOUBLE; |
222 | base->vmode &= ~FB_VMODE_DOUBLE; | 221 | } else { |
223 | } else { | 222 | base->vmode |= FB_VMODE_DOUBLE; |
224 | base->vmode |= FB_VMODE_DOUBLE; | 223 | } |
225 | } | 224 | } else if ((p = strstr(buf, "vsync "))) { |
226 | } else if ((p = strstr(buf, "vsync "))) { | 225 | //p += 6; |
227 | p += 6; | 226 | if (strstr(buf, "low")) { |
228 | 227 | base->sync &= ~FB_SYNC_VERT_HIGH_ACT; | |
229 | if (strstr(buf, "low")) { | 228 | } else { |
230 | base->sync &= ~FB_SYNC_VERT_HIGH_ACT; | 229 | base->sync |= FB_SYNC_VERT_HIGH_ACT; |
231 | } else { | 230 | } |
232 | base->sync |= FB_SYNC_VERT_HIGH_ACT; | 231 | } else if ((p = strstr(buf, "hsync "))) { |
233 | } | 232 | //p += 6; |
234 | } else if ((p = strstr(buf, "hsync "))) { | 233 | if (strstr(buf, "low")) { |
235 | p += 6; | 234 | base->sync &= ~FB_SYNC_HOR_HIGH_ACT; |
236 | 235 | } else { | |
237 | if (strstr(buf, "low")) { | 236 | base->sync |= FB_SYNC_HOR_HIGH_ACT; |
238 | base->sync &= ~FB_SYNC_HOR_HIGH_ACT; | 237 | } |
239 | } else { | 238 | } else if ((p = strstr(buf, "csync "))) { |
240 | base->sync |= FB_SYNC_HOR_HIGH_ACT; | 239 | //p += 6; |
241 | } | 240 | if (strstr(buf, "low")) { |
242 | } else if ((p = strstr(buf, "csync "))) { | 241 | base->sync &= ~FB_SYNC_COMP_HIGH_ACT; |
243 | p += 6; | 242 | } else { |
244 | 243 | base->sync |= FB_SYNC_COMP_HIGH_ACT; | |
245 | if (strstr(buf, "low")) { | 244 | } |
246 | base->sync &= ~FB_SYNC_COMP_HIGH_ACT; | 245 | } else if ((p = strstr(buf, "extsync "))) { |
247 | } else { | 246 | //p += 8; |
248 | base->sync |= FB_SYNC_COMP_HIGH_ACT; | 247 | if (strstr(buf, "false")) { |
249 | } | 248 | base->sync &= ~FB_SYNC_EXT; |
250 | } else if ((p = strstr(buf, "extsync "))) { | 249 | } else { |
251 | p += 8; | 250 | base->sync |= FB_SYNC_EXT; |
252 | |||
253 | if (strstr(buf, "false")) { | ||
254 | base->sync &= ~FB_SYNC_EXT; | ||
255 | } else { | ||
256 | base->sync |= FB_SYNC_EXT; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | if (strstr(buf, "endmode")) | ||
261 | return 1; | ||
262 | } | 251 | } |
263 | } | 252 | } |
253 | |||
254 | if (strstr(buf, "endmode")) | ||
255 | return 1; | ||
264 | } | 256 | } |
265 | } | 257 | } |
266 | #else | 258 | #else |
267 | bb_error_msg( "mode reading not compiled in"); | 259 | bb_error_msg("mode reading not compiled in"); |
268 | #endif | 260 | #endif |
269 | return 0; | 261 | return 0; |
270 | } | 262 | } |
@@ -290,28 +282,28 @@ static inline void showmode(struct fb_var_screeninfo *v) | |||
290 | 282 | ||
291 | if (v->pixclock) { | 283 | if (v->pixclock) { |
292 | drate = 1e12 / v->pixclock; | 284 | drate = 1e12 / v->pixclock; |
293 | hrate = | 285 | hrate = drate / (v->left_margin + v->xres + v->right_margin + v->hsync_len); |
294 | drate / (v->left_margin + v->xres + v->right_margin + | 286 | vrate = hrate / (v->upper_margin + v->yres + v->lower_margin + v->vsync_len); |
295 | v->hsync_len); | ||
296 | vrate = | ||
297 | hrate / (v->upper_margin + v->yres + v->lower_margin + | ||
298 | v->vsync_len); | ||
299 | } | 287 | } |
300 | printf("\nmode \"%ux%u-%u\"\n" | 288 | printf("\nmode \"%ux%u-%u\"\n" |
301 | #ifdef CONFIG_FEATURE_FBSET_FANCY | 289 | #ifdef CONFIG_FEATURE_FBSET_FANCY |
302 | "\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n" | 290 | "\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n" |
303 | #endif | 291 | #endif |
304 | "\tgeometry %u %u %u %u %u\n\ttimings %u %u %u %u %u %u %u\n\taccel %s\n\trgba %u/%u,%u/%u,%u/%u,%u/%u\nendmode\n\n", | 292 | "\tgeometry %u %u %u %u %u\n" |
305 | v->xres, v->yres, (int) (vrate + 0.5), | 293 | "\ttimings %u %u %u %u %u %u %u\n" |
294 | "\taccel %s\n" | ||
295 | "\trgba %u/%u,%u/%u,%u/%u,%u/%u\n" | ||
296 | "endmode\n\n", | ||
297 | v->xres, v->yres, (int) (vrate + 0.5), | ||
306 | #ifdef CONFIG_FEATURE_FBSET_FANCY | 298 | #ifdef CONFIG_FEATURE_FBSET_FANCY |
307 | drate / 1e6, hrate / 1e3, vrate, | 299 | drate / 1e6, hrate / 1e3, vrate, |
308 | #endif | 300 | #endif |
309 | v->xres, v->yres, v->xres_virtual, v->yres_virtual, | 301 | v->xres, v->yres, v->xres_virtual, v->yres_virtual, v->bits_per_pixel, |
310 | v->bits_per_pixel, v->pixclock, v->left_margin, | 302 | v->pixclock, v->left_margin, v->right_margin, v->upper_margin, v->lower_margin, |
311 | v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len, | 303 | v->hsync_len, v->vsync_len, |
312 | v->vsync_len, (v->accel_flags > 0 ? "true" : "false"), v->red.length, | 304 | (v->accel_flags > 0 ? "true" : "false"), |
313 | v->red.offset, v->green.length, v->green.offset, v->blue.length, | 305 | v->red.length, v->red.offset, v->green.length, v->green.offset, |
314 | v->blue.offset, v->transp.length, v->transp.offset); | 306 | v->blue.length, v->blue.offset, v->transp.length, v->transp.offset); |
315 | } | 307 | } |
316 | 308 | ||
317 | #ifdef STANDALONE | 309 | #ifdef STANDALONE |
@@ -332,73 +324,71 @@ int fbset_main(int argc, char **argv) | |||
332 | argv++; | 324 | argv++; |
333 | argc--; | 325 | argc--; |
334 | for (; argc > 0 && (thisarg = *argv); argc--, argv++) { | 326 | for (; argc > 0 && (thisarg = *argv); argc--, argv++) { |
335 | for (i = 0; g_cmdoptions[i].name; i++) { | 327 | for (i = 0; g_cmdoptions[i].name[0]; i++) { |
336 | if (!strcmp(thisarg, g_cmdoptions[i].name)) { | 328 | if (strcmp(thisarg, g_cmdoptions[i].name)) |
337 | if (argc - 1 < g_cmdoptions[i].param_count) | 329 | continue; |
338 | bb_show_usage(); | 330 | if (argc-1 < g_cmdoptions[i].param_count) |
339 | switch (g_cmdoptions[i].code) { | 331 | bb_show_usage(); |
340 | case CMD_FB: | 332 | |
341 | fbdev = argv[1]; | 333 | switch (g_cmdoptions[i].code) { |
342 | break; | 334 | case CMD_FB: |
343 | case CMD_DB: | 335 | fbdev = argv[1]; |
344 | modefile = argv[1]; | 336 | break; |
345 | break; | 337 | case CMD_DB: |
346 | case CMD_GEOMETRY: | 338 | modefile = argv[1]; |
347 | varset.xres = strtoul(argv[1], 0, 0); | 339 | break; |
348 | varset.yres = strtoul(argv[2], 0, 0); | 340 | case CMD_GEOMETRY: |
349 | varset.xres_virtual = strtoul(argv[3], 0, 0); | 341 | varset.xres = strtoul(argv[1], 0, 0); |
350 | varset.yres_virtual = strtoul(argv[4], 0, 0); | 342 | varset.yres = strtoul(argv[2], 0, 0); |
351 | varset.bits_per_pixel = strtoul(argv[5], 0, 0); | 343 | varset.xres_virtual = strtoul(argv[3], 0, 0); |
352 | break; | 344 | varset.yres_virtual = strtoul(argv[4], 0, 0); |
353 | case CMD_TIMING: | 345 | varset.bits_per_pixel = strtoul(argv[5], 0, 0); |
354 | varset.pixclock = strtoul(argv[1], 0, 0); | 346 | break; |
355 | varset.left_margin = strtoul(argv[2], 0, 0); | 347 | case CMD_TIMING: |
356 | varset.right_margin = strtoul(argv[3], 0, 0); | 348 | varset.pixclock = strtoul(argv[1], 0, 0); |
357 | varset.upper_margin = strtoul(argv[4], 0, 0); | 349 | varset.left_margin = strtoul(argv[2], 0, 0); |
358 | varset.lower_margin = strtoul(argv[5], 0, 0); | 350 | varset.right_margin = strtoul(argv[3], 0, 0); |
359 | varset.hsync_len = strtoul(argv[6], 0, 0); | 351 | varset.upper_margin = strtoul(argv[4], 0, 0); |
360 | varset.vsync_len = strtoul(argv[7], 0, 0); | 352 | varset.lower_margin = strtoul(argv[5], 0, 0); |
361 | break; | 353 | varset.hsync_len = strtoul(argv[6], 0, 0); |
362 | case CMD_ALL: | 354 | varset.vsync_len = strtoul(argv[7], 0, 0); |
363 | g_options |= OPT_ALL; | 355 | break; |
364 | break; | 356 | case CMD_ALL: |
365 | case CMD_CHANGE: | 357 | g_options |= OPT_ALL; |
366 | g_options |= OPT_CHANGE; | 358 | break; |
367 | break; | 359 | case CMD_CHANGE: |
360 | g_options |= OPT_CHANGE; | ||
361 | break; | ||
368 | #ifdef CONFIG_FEATURE_FBSET_FANCY | 362 | #ifdef CONFIG_FEATURE_FBSET_FANCY |
369 | case CMD_XRES: | 363 | case CMD_XRES: |
370 | varset.xres = strtoul(argv[1], 0, 0); | 364 | varset.xres = strtoul(argv[1], 0, 0); |
371 | break; | ||
372 | case CMD_YRES: | ||
373 | varset.yres = strtoul(argv[1], 0, 0); | ||
374 | break; | ||
375 | case CMD_DEPTH: | ||
376 | varset.bits_per_pixel = strtoul(argv[1], 0, 0); | ||
377 | break; | ||
378 | #endif | ||
379 | } | ||
380 | argc -= g_cmdoptions[i].param_count; | ||
381 | argv += g_cmdoptions[i].param_count; | ||
382 | break; | 365 | break; |
366 | case CMD_YRES: | ||
367 | varset.yres = strtoul(argv[1], 0, 0); | ||
368 | break; | ||
369 | case CMD_DEPTH: | ||
370 | varset.bits_per_pixel = strtoul(argv[1], 0, 0); | ||
371 | break; | ||
372 | #endif | ||
383 | } | 373 | } |
374 | argc -= g_cmdoptions[i].param_count; | ||
375 | argv += g_cmdoptions[i].param_count; | ||
376 | break; | ||
384 | } | 377 | } |
385 | if (!g_cmdoptions[i].name) { | 378 | if (!g_cmdoptions[i].name[0]) { |
386 | if (argc == 1) { | 379 | if (argc != 1) |
387 | mode = *argv; | ||
388 | g_options |= OPT_READMODE; | ||
389 | } else { | ||
390 | bb_show_usage(); | 380 | bb_show_usage(); |
391 | } | 381 | mode = *argv; |
382 | g_options |= OPT_READMODE; | ||
392 | } | 383 | } |
393 | } | 384 | } |
394 | 385 | ||
395 | fh = xopen(fbdev, O_RDONLY); | 386 | fh = xopen(fbdev, O_RDONLY); |
396 | if (ioctl(fh, FBIOGET_VSCREENINFO, &var)) | 387 | if (ioctl(fh, FBIOGET_VSCREENINFO, &var)) |
397 | bb_perror_msg_and_die("fbset(ioctl)"); | 388 | bb_perror_msg_and_die("ioctl(%sT_VSCREENINFO)", "GE"); |
398 | if (g_options & OPT_READMODE) { | 389 | if (g_options & OPT_READMODE) { |
399 | if (!readmode(&var, modefile, mode)) { | 390 | if (!readmode(&var, modefile, mode)) { |
400 | bb_error_msg("unknown video mode '%s'", mode); | 391 | bb_error_msg_and_die("unknown video mode '%s'", mode); |
401 | return EXIT_FAILURE; | ||
402 | } | 392 | } |
403 | } | 393 | } |
404 | 394 | ||
@@ -407,7 +397,7 @@ int fbset_main(int argc, char **argv) | |||
407 | if (g_options & OPT_ALL) | 397 | if (g_options & OPT_ALL) |
408 | var.activate = FB_ACTIVATE_ALL; | 398 | var.activate = FB_ACTIVATE_ALL; |
409 | if (ioctl(fh, FBIOPUT_VSCREENINFO, &var)) | 399 | if (ioctl(fh, FBIOPUT_VSCREENINFO, &var)) |
410 | bb_perror_msg_and_die("fbset(ioctl)"); | 400 | bb_perror_msg_and_die("ioctl(%sT_VSCREENINFO)", "PU"); |
411 | } | 401 | } |
412 | showmode(&var); | 402 | showmode(&var); |
413 | /* Don't close the file, as exiting will take care of that */ | 403 | /* Don't close the file, as exiting will take care of that */ |