1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-11-27 18:18:27 +02:00

ubb-vga.c (list_modes, usage, main): new option -l to list available modes

This commit is contained in:
Werner Almesberger 2011-05-01 23:12:38 -03:00
parent b184fbbe74
commit 4450a30456

View File

@ -415,15 +415,36 @@ static void session(void (*gen)(void **fb, int xres, int yres), int frames)
} }
static void list_modes(void)
{
const struct mode *m;
for (m = mode_db; m->name; m++) {
printf("\"%s\", %dx%d:\n", m->name, m->xres, m->yres);
printf("\t336/%d = %5.2f MHz\n",
m->clkdiv+1, 336.0/(m->clkdiv+1));
printf("\tH: %4.2f+...+%4.2f = %5.2f us\n",
CYCLES(m->hsync_cycles), CYCLES(m->hback_cycles),
CYCLES(m->line_cycles));
printf("\tV: %d+%d+%d+%d lines, %5.2f Hz\n",
m->vsync_lines, m->vfront_lines, m->yres, m->vback_lines,
112000000.0/m->line_cycles/
(m->vsync_lines+m->vfront_lines+m->yres+m->vback_lines));
}
}
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-t] [-r resolution] frames [file]\n\n" "usage: %s [-t] [-r resolution] [frames [file]]\n"
" %s -l\n\n"
" frames number of frames to display\n" " frames number of frames to display\n"
" file PPM file\n\n" " file PPM file\n\n"
" -l list available modes\n"
" -m mode select the display mode, default \"%s\"\n" " -m mode select the display mode, default \"%s\"\n"
" -t generate a test image\n" " -t generate a test image\n"
, name, mode_db[0].name); , name, name, mode_db[0].name);
exit(1); exit(1);
} }
@ -434,8 +455,11 @@ int main(int argc, char *const *argv)
int frames = 0; int frames = 0;
int c; int c;
while ((c = getopt(argc, argv, "m:t")) != EOF) while ((c = getopt(argc, argv, "lm:t")) != EOF)
switch (c) { switch (c) {
case 'l':
list_modes();
exit(0);
case 'm': case 'm':
for (mode = mode_db; mode->name; mode++) for (mode = mode_db; mode->name; mode++)
if (!strcmp(mode->name, optarg)) if (!strcmp(mode->name, optarg))
@ -466,12 +490,6 @@ int main(int argc, char *const *argv)
usage(*argv); usage(*argv);
} }
#if 0
printf("V: %d+%d+%d+%d\n", mode->vsync_lines, mode->vfront_lines,
mode->yres, mode->vback_lines);
printf("H: %4.1f+?+?+%4.1f (%4.1f)\n", CYCLES(mode->hsync_cycles),
CYCLES(mode->hback_cycles), CYCLES(mode->line_cycles));
#endif
setup(); setup();
session(gen, frames); session(gen, frames);
cleanup(); cleanup();