2000-02-09 03:58:47 +08:00
|
|
|
/* vi: set sw=4 ts=4: */
|
1999-12-17 04:59:36 +08:00
|
|
|
/*
|
|
|
|
* Mini fbset implementation for busybox
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
|
|
|
|
*
|
2006-04-13 01:55:51 +08:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
1999-12-17 04:59:36 +08:00
|
|
|
*
|
|
|
|
* This is a from-scratch implementation of fbset; but the de facto fbset
|
|
|
|
* implementation was a good reference. fbset (original) is released under
|
2004-03-15 16:29:22 +08:00
|
|
|
* the GPL, and is (c) 1995-1999 by:
|
1999-12-17 04:59:36 +08:00
|
|
|
* Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
|
|
|
|
*/
|
|
|
|
|
2001-02-20 14:14:08 +08:00
|
|
|
#include "busybox.h"
|
1999-12-17 04:59:36 +08:00
|
|
|
|
2003-11-14 11:11:29 +08:00
|
|
|
#define DEFAULTFBDEV FB_0
|
1999-12-17 04:59:36 +08:00
|
|
|
#define DEFAULTFBMODE "/etc/fb.modes"
|
|
|
|
|
2001-01-24 06:30:04 +08:00
|
|
|
enum {
|
2006-03-11 03:22:06 +08:00
|
|
|
OPT_CHANGE = (1 << 0),
|
|
|
|
OPT_INFO = (1 << 1),
|
|
|
|
OPT_READMODE = (1 << 2),
|
|
|
|
|
2001-01-24 06:30:04 +08:00
|
|
|
CMD_FB = 1,
|
|
|
|
CMD_DB = 2,
|
|
|
|
CMD_GEOMETRY = 3,
|
|
|
|
CMD_TIMING = 4,
|
|
|
|
CMD_ACCEL = 5,
|
|
|
|
CMD_HSYNC = 6,
|
|
|
|
CMD_VSYNC = 7,
|
|
|
|
CMD_LACED = 8,
|
|
|
|
CMD_DOUBLE = 9,
|
2006-01-25 08:08:53 +08:00
|
|
|
/* CMD_XCOMPAT = 10, */
|
2001-01-24 06:30:04 +08:00
|
|
|
CMD_ALL = 11,
|
|
|
|
CMD_INFO = 12,
|
|
|
|
CMD_CHANGE = 13,
|
1999-12-17 04:59:36 +08:00
|
|
|
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_FANCY
|
2001-01-24 06:30:04 +08:00
|
|
|
CMD_XRES = 100,
|
|
|
|
CMD_YRES = 101,
|
|
|
|
CMD_VXRES = 102,
|
|
|
|
CMD_VYRES = 103,
|
|
|
|
CMD_DEPTH = 104,
|
|
|
|
CMD_MATCH = 105,
|
|
|
|
CMD_PIXCLOCK = 106,
|
|
|
|
CMD_LEFT = 107,
|
|
|
|
CMD_RIGHT = 108,
|
|
|
|
CMD_UPPER = 109,
|
|
|
|
CMD_LOWER = 110,
|
|
|
|
CMD_HSLEN = 111,
|
|
|
|
CMD_VSLEN = 112,
|
|
|
|
CMD_CSYNC = 113,
|
|
|
|
CMD_GSYNC = 114,
|
|
|
|
CMD_EXTSYNC = 115,
|
|
|
|
CMD_BCAST = 116,
|
|
|
|
CMD_RGBA = 117,
|
|
|
|
CMD_STEP = 118,
|
|
|
|
CMD_MOVE = 119,
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
2001-01-24 06:30:04 +08:00
|
|
|
};
|
1999-12-17 04:59:36 +08:00
|
|
|
|
|
|
|
static unsigned int g_options = 0;
|
|
|
|
|
2000-09-21 12:09:58 +08:00
|
|
|
/* Stuff stolen from the kernel's fb.h */
|
2006-03-11 03:22:06 +08:00
|
|
|
enum {
|
|
|
|
FBIOGET_VSCREENINFO = 0x4600,
|
|
|
|
FBIOPUT_VSCREENINFO = 0x4601
|
|
|
|
};
|
2000-09-21 12:09:58 +08:00
|
|
|
struct fb_bitfield {
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t offset; /* beginning of bitfield */
|
|
|
|
uint32_t length; /* length of bitfield */
|
2004-03-15 16:29:22 +08:00
|
|
|
uint32_t msb_right; /* != 0 : Most significant bit is */
|
|
|
|
/* right */
|
2000-09-21 12:09:58 +08:00
|
|
|
};
|
|
|
|
struct fb_var_screeninfo {
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t xres; /* visible resolution */
|
|
|
|
uint32_t yres;
|
|
|
|
uint32_t xres_virtual; /* virtual resolution */
|
|
|
|
uint32_t yres_virtual;
|
|
|
|
uint32_t xoffset; /* offset from virtual to visible */
|
|
|
|
uint32_t yoffset; /* resolution */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t bits_per_pixel; /* guess what */
|
|
|
|
uint32_t grayscale; /* != 0 Graylevels instead of colors */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
|
|
|
struct fb_bitfield red; /* bitfield in fb mem if true color, */
|
|
|
|
struct fb_bitfield green; /* else only length is significant */
|
|
|
|
struct fb_bitfield blue;
|
2004-03-15 16:29:22 +08:00
|
|
|
struct fb_bitfield transp; /* transparency */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t nonstd; /* != 0 Non standard pixel format */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t activate; /* see FB_ACTIVATE_* */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t height; /* height of picture in mm */
|
|
|
|
uint32_t width; /* width of picture in mm */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t accel_flags; /* acceleration flags (hints) */
|
2000-09-21 12:09:58 +08:00
|
|
|
|
|
|
|
/* Timing: All values in pixclocks, except pixclock (of course) */
|
2003-07-15 03:32:40 +08:00
|
|
|
uint32_t pixclock; /* pixel clock in ps (pico seconds) */
|
|
|
|
uint32_t left_margin; /* time from sync to picture */
|
|
|
|
uint32_t right_margin; /* time from picture to sync */
|
|
|
|
uint32_t upper_margin; /* time from sync to picture */
|
|
|
|
uint32_t lower_margin;
|
|
|
|
uint32_t hsync_len; /* length of horizontal sync */
|
|
|
|
uint32_t vsync_len; /* length of vertical sync */
|
|
|
|
uint32_t sync; /* see FB_SYNC_* */
|
|
|
|
uint32_t vmode; /* see FB_VMODE_* */
|
|
|
|
uint32_t reserved[6]; /* Reserved for future compatibility */
|
2000-09-21 12:09:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-01 20:41:35 +08:00
|
|
|
static const struct cmdoptions_t {
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
const char *name;
|
|
|
|
const unsigned char param_count;
|
|
|
|
const unsigned char code;
|
1999-12-17 04:59:36 +08:00
|
|
|
} g_cmdoptions[] = {
|
2000-02-09 03:58:47 +08:00
|
|
|
{
|
|
|
|
"-fb", 1, CMD_FB}, {
|
|
|
|
"-db", 1, CMD_DB}, {
|
|
|
|
"-a", 0, CMD_ALL}, {
|
|
|
|
"-i", 0, CMD_INFO}, {
|
|
|
|
"-g", 5, CMD_GEOMETRY}, {
|
|
|
|
"-t", 7, CMD_TIMING}, {
|
|
|
|
"-accel", 1, CMD_ACCEL}, {
|
|
|
|
"-hsync", 1, CMD_HSYNC}, {
|
|
|
|
"-vsync", 1, CMD_VSYNC}, {
|
|
|
|
"-laced", 1, CMD_LACED}, {
|
2000-04-14 02:49:43 +08:00
|
|
|
"-double", 1, CMD_DOUBLE}, {
|
2000-07-07 01:23:23 +08:00
|
|
|
"-n", 0, CMD_CHANGE}, {
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_FANCY
|
2000-02-09 03:58:47 +08:00
|
|
|
"-all", 0, CMD_ALL}, {
|
|
|
|
"-xres", 1, CMD_XRES}, {
|
|
|
|
"-yres", 1, CMD_YRES}, {
|
|
|
|
"-vxres", 1, CMD_VXRES}, {
|
|
|
|
"-vyres", 1, CMD_VYRES}, {
|
|
|
|
"-depth", 1, CMD_DEPTH}, {
|
|
|
|
"-match", 0, CMD_MATCH}, {
|
2000-05-13 03:41:47 +08:00
|
|
|
"-geometry", 5, CMD_GEOMETRY}, {
|
2000-02-09 03:58:47 +08:00
|
|
|
"-pixclock", 1, CMD_PIXCLOCK}, {
|
|
|
|
"-left", 1, CMD_LEFT}, {
|
|
|
|
"-right", 1, CMD_RIGHT}, {
|
|
|
|
"-upper", 1, CMD_UPPER}, {
|
|
|
|
"-lower", 1, CMD_LOWER}, {
|
|
|
|
"-hslen", 1, CMD_HSLEN}, {
|
|
|
|
"-vslen", 1, CMD_VSLEN}, {
|
2000-05-13 03:41:47 +08:00
|
|
|
"-timings", 7, CMD_TIMING}, {
|
2000-02-09 03:58:47 +08:00
|
|
|
"-csync", 1, CMD_CSYNC}, {
|
|
|
|
"-gsync", 1, CMD_GSYNC}, {
|
|
|
|
"-extsync", 1, CMD_EXTSYNC}, {
|
|
|
|
"-bcast", 1, CMD_BCAST}, {
|
|
|
|
"-rgba", 1, CMD_RGBA}, {
|
|
|
|
"-step", 1, CMD_STEP}, {
|
2000-04-14 02:49:43 +08:00
|
|
|
"-move", 1, CMD_MOVE}, {
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
2000-02-09 03:58:47 +08:00
|
|
|
0, 0, 0}
|
1999-12-17 04:59:36 +08:00
|
|
|
};
|
|
|
|
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_READMODE
|
2000-10-29 00:56:32 +08:00
|
|
|
/* taken from linux/fb.h */
|
2006-03-11 03:22:06 +08:00
|
|
|
enum {
|
|
|
|
FB_VMODE_INTERLACED = 1, /* interlaced */
|
|
|
|
FB_VMODE_DOUBLE = 2, /* double scan */
|
|
|
|
FB_SYNC_HOR_HIGH_ACT = 1, /* horizontal sync high active */
|
|
|
|
FB_SYNC_VERT_HIGH_ACT = 2, /* vertical sync high active */
|
|
|
|
FB_SYNC_EXT = 4, /* external sync */
|
|
|
|
FB_SYNC_COMP_HIGH_ACT = 8 /* composite sync high active */
|
|
|
|
};
|
2000-10-29 00:56:32 +08:00
|
|
|
#endif
|
1999-12-17 04:59:36 +08:00
|
|
|
static int readmode(struct fb_var_screeninfo *base, const char *fn,
|
2000-02-09 03:58:47 +08:00
|
|
|
const char *mode)
|
1999-12-17 04:59:36 +08:00
|
|
|
{
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_READMODE
|
2000-02-09 03:58:47 +08:00
|
|
|
FILE *f;
|
|
|
|
char buf[256];
|
|
|
|
char *p = buf;
|
|
|
|
|
2006-08-03 23:41:12 +08:00
|
|
|
f = xfopen(fn, "r");
|
2000-02-09 03:58:47 +08:00
|
|
|
while (!feof(f)) {
|
|
|
|
fgets(buf, sizeof(buf), f);
|
|
|
|
if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
|
|
|
|
p += 5;
|
|
|
|
if ((p = strstr(buf, mode))) {
|
|
|
|
p += strlen(mode);
|
|
|
|
if (!isspace(*p) && (*p != 0) && (*p != '"')
|
|
|
|
&& (*p != '\r') && (*p != '\n'))
|
|
|
|
continue; /* almost, but not quite */
|
|
|
|
while (!feof(f)) {
|
|
|
|
fgets(buf, sizeof(buf), f);
|
2000-07-13 07:01:04 +08:00
|
|
|
|
2006-01-25 08:08:53 +08:00
|
|
|
if ((p = strstr(buf, "geometry "))) {
|
|
|
|
p += 9;
|
|
|
|
|
|
|
|
sscanf(p, "%d %d %d %d %d",
|
|
|
|
&(base->xres), &(base->yres),
|
|
|
|
&(base->xres_virtual), &(base->yres_virtual),
|
|
|
|
&(base->bits_per_pixel));
|
|
|
|
} else if ((p = strstr(buf, "timings "))) {
|
|
|
|
p += 8;
|
|
|
|
|
|
|
|
sscanf(p, "%d %d %d %d %d %d %d",
|
|
|
|
&(base->pixclock),
|
|
|
|
&(base->left_margin), &(base->right_margin),
|
|
|
|
&(base->upper_margin), &(base->lower_margin),
|
|
|
|
&(base->hsync_len), &(base->vsync_len));
|
|
|
|
} else if ((p = strstr(buf, "laced "))) {
|
|
|
|
p += 6;
|
|
|
|
|
|
|
|
if (strstr(buf, "false")) {
|
|
|
|
base->vmode &= ~FB_VMODE_INTERLACED;
|
|
|
|
} else {
|
|
|
|
base->vmode |= FB_VMODE_INTERLACED;
|
|
|
|
}
|
|
|
|
} else if ((p = strstr(buf, "double "))) {
|
|
|
|
p += 7;
|
|
|
|
|
|
|
|
if (strstr(buf, "false")) {
|
|
|
|
base->vmode &= ~FB_VMODE_DOUBLE;
|
|
|
|
} else {
|
|
|
|
base->vmode |= FB_VMODE_DOUBLE;
|
|
|
|
}
|
|
|
|
} else if ((p = strstr(buf, "vsync "))) {
|
|
|
|
p += 6;
|
|
|
|
|
|
|
|
if (strstr(buf, "low")) {
|
|
|
|
base->sync &= ~FB_SYNC_VERT_HIGH_ACT;
|
|
|
|
} else {
|
|
|
|
base->sync |= FB_SYNC_VERT_HIGH_ACT;
|
|
|
|
}
|
|
|
|
} else if ((p = strstr(buf, "hsync "))) {
|
|
|
|
p += 6;
|
|
|
|
|
|
|
|
if (strstr(buf, "low")) {
|
|
|
|
base->sync &= ~FB_SYNC_HOR_HIGH_ACT;
|
|
|
|
} else {
|
|
|
|
base->sync |= FB_SYNC_HOR_HIGH_ACT;
|
|
|
|
}
|
|
|
|
} else if ((p = strstr(buf, "csync "))) {
|
|
|
|
p += 6;
|
|
|
|
|
|
|
|
if (strstr(buf, "low")) {
|
|
|
|
base->sync &= ~FB_SYNC_COMP_HIGH_ACT;
|
|
|
|
} else {
|
|
|
|
base->sync |= FB_SYNC_COMP_HIGH_ACT;
|
|
|
|
}
|
|
|
|
} else if ((p = strstr(buf, "extsync "))) {
|
|
|
|
p += 8;
|
|
|
|
|
|
|
|
if (strstr(buf, "false")) {
|
|
|
|
base->sync &= ~FB_SYNC_EXT;
|
|
|
|
} else {
|
|
|
|
base->sync |= FB_SYNC_EXT;
|
|
|
|
}
|
|
|
|
}
|
2004-03-15 16:29:22 +08:00
|
|
|
|
2000-07-13 07:01:04 +08:00
|
|
|
if (strstr(buf, "endmode"))
|
2000-02-09 03:58:47 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_error_msg( "mode reading not compiled in");
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
2000-02-09 03:58:47 +08:00
|
|
|
return 0;
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
static inline void setmode(struct fb_var_screeninfo *base,
|
2000-02-09 03:58:47 +08:00
|
|
|
struct fb_var_screeninfo *set)
|
1999-12-17 04:59:36 +08:00
|
|
|
{
|
2000-02-09 03:58:47 +08:00
|
|
|
if ((int) set->xres > 0)
|
|
|
|
base->xres = set->xres;
|
|
|
|
if ((int) set->yres > 0)
|
|
|
|
base->yres = set->yres;
|
|
|
|
if ((int) set->xres_virtual > 0)
|
|
|
|
base->xres_virtual = set->xres_virtual;
|
|
|
|
if ((int) set->yres_virtual > 0)
|
|
|
|
base->yres_virtual = set->yres_virtual;
|
|
|
|
if ((int) set->bits_per_pixel > 0)
|
|
|
|
base->bits_per_pixel = set->bits_per_pixel;
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
static inline void showmode(struct fb_var_screeninfo *v)
|
1999-12-17 04:59:36 +08:00
|
|
|
{
|
2000-02-09 03:58:47 +08:00
|
|
|
double drate = 0, hrate = 0, vrate = 0;
|
|
|
|
|
|
|
|
if (v->pixclock) {
|
|
|
|
drate = 1e12 / v->pixclock;
|
|
|
|
hrate =
|
|
|
|
drate / (v->left_margin + v->xres + v->right_margin +
|
|
|
|
v->hsync_len);
|
|
|
|
vrate =
|
|
|
|
hrate / (v->upper_margin + v->yres + v->lower_margin +
|
|
|
|
v->vsync_len);
|
|
|
|
}
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
printf("\nmode \"%ux%u-%u\"\n"
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_FANCY
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
"\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n"
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
"\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",
|
|
|
|
v->xres, v->yres, (int) (vrate + 0.5),
|
|
|
|
#ifdef CONFIG_FEATURE_FBSET_FANCY
|
|
|
|
drate / 1e6, hrate / 1e3, vrate,
|
|
|
|
#endif
|
|
|
|
v->xres, v->yres, v->xres_virtual, v->yres_virtual,
|
|
|
|
v->bits_per_pixel, v->pixclock, v->left_margin,
|
2000-02-09 03:58:47 +08:00
|
|
|
v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
|
minor fixes for fbset bloat
<mjn3> printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
<mjn3> v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
<mjn3> printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
<mjn3> v->right_margin, v->upper_margin, v->lower_margin, v->hsync_l
<mjn3> en,
<mjn3> v->vsync_len);
<mjn3> printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
<mjn3> printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
<mjn3> v->red.offset, v->green.length, v->green.offset, v->blue.leng
<mjn3> th,
<mjn3> v->blue.offset, v->transp.length, v->transp.offset);
<mjn3> printf("endmode\n\n");
<mjn3> whay have multiple printf calls when one would do?
<mjn3> and this:
<mjn3> static struct cmdoptions_t {
<mjn3> char *name;
<mjn3> unsigned char param_count;
<mjn3> unsigned char code;
<mjn3> } g_cmdoptions[] = {
<mjn3> {
<mjn3> "-fb", 1, CMD_FB}, {
<mjn3> (repeated entries)
<mjn3> why isn't this constant? what about struct packing?
inline the helper functions that are only referenced once.
2002-08-13 12:19:23 +08:00
|
|
|
v->vsync_len, (v->accel_flags > 0 ? "true" : "false"), v->red.length,
|
2000-02-09 03:58:47 +08:00
|
|
|
v->red.offset, v->green.length, v->green.offset, v->blue.length,
|
|
|
|
v->blue.offset, v->transp.length, v->transp.offset);
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef STANDALONE
|
|
|
|
int main(int argc, char **argv)
|
2000-02-09 03:58:47 +08:00
|
|
|
#else
|
2006-03-07 04:47:33 +08:00
|
|
|
int fbset_main(int argc, char **argv)
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
|
|
|
{
|
2000-02-09 03:58:47 +08:00
|
|
|
struct fb_var_screeninfo var, varset;
|
|
|
|
int fh, i;
|
|
|
|
char *fbdev = DEFAULTFBDEV;
|
|
|
|
char *modefile = DEFAULTFBMODE;
|
|
|
|
char *thisarg, *mode = NULL;
|
|
|
|
|
|
|
|
memset(&varset, 0xFF, sizeof(varset));
|
1999-12-17 04:59:36 +08:00
|
|
|
|
2000-02-09 03:58:47 +08:00
|
|
|
/* parse cmd args.... why do they have to make things so difficult? */
|
|
|
|
argv++;
|
|
|
|
argc--;
|
|
|
|
for (; argc > 0 && (thisarg = *argv); argc--, argv++) {
|
|
|
|
for (i = 0; g_cmdoptions[i].name; i++) {
|
|
|
|
if (!strcmp(thisarg, g_cmdoptions[i].name)) {
|
|
|
|
if (argc - 1 < g_cmdoptions[i].param_count)
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_show_usage();
|
2000-02-09 03:58:47 +08:00
|
|
|
switch (g_cmdoptions[i].code) {
|
|
|
|
case CMD_FB:
|
|
|
|
fbdev = argv[1];
|
|
|
|
break;
|
|
|
|
case CMD_DB:
|
|
|
|
modefile = argv[1];
|
|
|
|
break;
|
|
|
|
case CMD_GEOMETRY:
|
|
|
|
varset.xres = strtoul(argv[1], 0, 0);
|
|
|
|
varset.yres = strtoul(argv[2], 0, 0);
|
|
|
|
varset.xres_virtual = strtoul(argv[3], 0, 0);
|
|
|
|
varset.yres_virtual = strtoul(argv[4], 0, 0);
|
|
|
|
varset.bits_per_pixel = strtoul(argv[5], 0, 0);
|
|
|
|
break;
|
|
|
|
case CMD_TIMING:
|
|
|
|
varset.pixclock = strtoul(argv[1], 0, 0);
|
|
|
|
varset.left_margin = strtoul(argv[2], 0, 0);
|
|
|
|
varset.right_margin = strtoul(argv[3], 0, 0);
|
|
|
|
varset.upper_margin = strtoul(argv[4], 0, 0);
|
|
|
|
varset.lower_margin = strtoul(argv[5], 0, 0);
|
|
|
|
varset.hsync_len = strtoul(argv[6], 0, 0);
|
|
|
|
varset.vsync_len = strtoul(argv[7], 0, 0);
|
|
|
|
break;
|
2006-01-25 08:08:53 +08:00
|
|
|
case CMD_CHANGE:
|
|
|
|
g_options |= OPT_CHANGE;
|
|
|
|
break;
|
2001-10-24 13:00:29 +08:00
|
|
|
#ifdef CONFIG_FEATURE_FBSET_FANCY
|
2000-02-09 03:58:47 +08:00
|
|
|
case CMD_XRES:
|
|
|
|
varset.xres = strtoul(argv[1], 0, 0);
|
|
|
|
break;
|
|
|
|
case CMD_YRES:
|
|
|
|
varset.yres = strtoul(argv[1], 0, 0);
|
|
|
|
break;
|
2002-09-17 16:44:56 +08:00
|
|
|
case CMD_DEPTH:
|
|
|
|
varset.bits_per_pixel = strtoul(argv[1], 0, 0);
|
|
|
|
break;
|
1999-12-17 04:59:36 +08:00
|
|
|
#endif
|
2000-02-09 03:58:47 +08:00
|
|
|
}
|
|
|
|
argc -= g_cmdoptions[i].param_count;
|
|
|
|
argv += g_cmdoptions[i].param_count;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!g_cmdoptions[i].name) {
|
|
|
|
if (argc == 1) {
|
|
|
|
mode = *argv;
|
|
|
|
g_options |= OPT_READMODE;
|
|
|
|
} else {
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_show_usage();
|
2000-02-09 03:58:47 +08:00
|
|
|
}
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-03 23:41:12 +08:00
|
|
|
fh = xopen(fbdev, O_RDONLY);
|
2000-02-09 03:58:47 +08:00
|
|
|
if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_perror_msg_and_die("fbset(ioctl)");
|
2000-02-09 03:58:47 +08:00
|
|
|
if (g_options & OPT_READMODE) {
|
|
|
|
if (!readmode(&var, modefile, mode)) {
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_error_msg("Unknown video mode `%s'", mode);
|
2000-12-01 10:55:13 +08:00
|
|
|
return EXIT_FAILURE;
|
2000-02-09 03:58:47 +08:00
|
|
|
}
|
1999-12-17 04:59:36 +08:00
|
|
|
}
|
|
|
|
|
2000-02-09 03:58:47 +08:00
|
|
|
setmode(&var, &varset);
|
|
|
|
if (g_options & OPT_CHANGE)
|
|
|
|
if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
|
2003-03-19 17:13:01 +08:00
|
|
|
bb_perror_msg_and_die("fbset(ioctl)");
|
2000-02-09 03:58:47 +08:00
|
|
|
showmode(&var);
|
2000-03-23 09:09:18 +08:00
|
|
|
/* Don't close the file, as exiting will take care of that */
|
|
|
|
/* close(fh); */
|
1999-12-17 04:59:36 +08:00
|
|
|
|
2000-12-01 10:55:13 +08:00
|
|
|
return EXIT_SUCCESS;
|
2000-02-09 03:58:47 +08:00
|
|
|
}
|