*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
*
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
*
* This is a from-scratch implementation of fbset; but the de facto fbset
* implementation was a good reference. fbset (original) is released under
* Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
*/
+//usage:#define fbset_trivial_usage
+//usage: "[OPTIONS] [MODE]"
+//usage:#define fbset_full_usage "\n\n"
+//usage: "Show and modify frame buffer settings"
+//usage:
+//usage:#define fbset_example_usage
+//usage: "$ fbset\n"
+//usage: "mode \"1024x768-76\"\n"
+//usage: " # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz\n"
+//usage: " geometry 1024 768 1024 768 16\n"
+//usage: " timings 12714 128 32 16 4 128 4\n"
+//usage: " accel false\n"
+//usage: " rgba 5/11,6/5,5/0,0/0\n"
+//usage: "endmode\n"
+
#include "libbb.h"
#define DEFAULTFBDEV FB_0
struct fb_bitfield {
uint32_t offset; /* beginning of bitfield */
- uint32_t length; /* length of bitfield */
+ uint32_t length; /* length of bitfield */
uint32_t msb_right; /* !=0: Most significant bit is right */
};
struct fb_var_screeninfo {
uint32_t height; /* height of picture in mm */
uint32_t width; /* width of picture in mm */
- uint32_t accel_flags; /* acceleration flags (hints) */
+ uint32_t accel_flags; /* acceleration flags (hints) */
/* Timing: All values in pixclocks, except pixclock (of course) */
uint32_t pixclock; /* pixel clock in ps (pico seconds) */
#endif
};
-#if ENABLE_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
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 */
+#if ENABLE_FEATURE_FBSET_READMODE
+ FB_VMODE_INTERLACED = 1, /* interlaced */
+ FB_VMODE_DOUBLE = 2, /* double scan */
FB_SYNC_EXT = 4, /* external sync */
FB_SYNC_COMP_HIGH_ACT = 8, /* composite sync high active */
-};
#endif
+};
#if ENABLE_FEATURE_FBSET_READMODE
static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what)
}
p = token[1];
i = index_in_strings(
- "geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0",
+ "geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0rgba\0",
token[0]);
switch (i) {
case 0:
}
case 4:
case 5:
- case 6: {
+ case 6: {
static const uint32_t syncs[] = {FB_SYNC_VERT_HIGH_ACT, FB_SYNC_HOR_HIGH_ACT, FB_SYNC_COMP_HIGH_ACT};
ss(&base->sync, syncs[i-4], p, "low");
//bb_info_msg("SYNC[%s]", p);
ss(&base->sync, FB_SYNC_EXT, p, "false");
//bb_info_msg("EXTSYNC[%s]", p);
break;
+ case 8: {
+ int red_offset, red_length;
+ int green_offset, green_length;
+ int blue_offset, blue_length;
+ int transp_offset, transp_length;
+
+ sscanf(p, "%d/%d,%d/%d,%d/%d,%d/%d",
+ &red_offset, &red_length,
+ &green_offset, &green_length,
+ &blue_offset, &blue_length,
+ &transp_offset, &transp_length);
+ base->red.offset = red_offset;
+ base->red.length = red_length;
+ base->red.msb_right = 0;
+ base->green.offset = green_offset;
+ base->green.length = green_length;
+ base->green.msb_right = 0;
+ base->blue.offset = blue_offset;
+ base->blue.length = blue_length;
+ base->blue.msb_right = 0;
+ base->transp.offset = transp_offset;
+ base->transp.length = transp_length;
+ base->transp.msb_right = 0;
+ }
}
}
return 0;
OPT_CHANGE = (1 << 0),
OPT_SHOW = (1 << 1),
OPT_READMODE = (1 << 2),
- OPT_ALL = (1 << 9),
+ OPT_ALL = (1 << 3),
};
struct fb_var_screeninfo var_old, var_set;
int fh, i;
argv++;
argc--;
for (; argc > 0 && (thisarg = *argv) != NULL; argc--, argv++) {
- if (thisarg[0] == '-') for (i = 0; i < ARRAY_SIZE(g_cmdoptions); i++) {
+ if (thisarg[0] != '-') {
+ if (!ENABLE_FEATURE_FBSET_READMODE || argc != 1)
+ bb_show_usage();
+ mode = thisarg;
+ options |= OPT_READMODE;
+ goto contin;
+ }
+ for (i = 0; i < ARRAY_SIZE(g_cmdoptions); i++) {
if (strcmp(thisarg + 1, g_cmdoptions[i].name) != 0)
continue;
if (argc <= g_cmdoptions[i].param_count)
argv += g_cmdoptions[i].param_count;
goto contin;
}
- if (!ENABLE_FEATURE_FBSET_READMODE || argc != 1)
- bb_show_usage();
- mode = *argv;
- options |= OPT_READMODE;
+ bb_show_usage();
contin: ;
}
if (!read_mode_db(&var_old, modefile, mode)) {
bb_error_msg_and_die("unknown video mode '%s'", mode);
}
+ options |= OPT_CHANGE;
#endif
}