Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Mini fbset implementation for busybox |
| 4 | * |
| 5 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
| 6 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 8 | * |
| 9 | * This is a from-scratch implementation of fbset; but the de facto fbset |
| 10 | * implementation was a good reference. fbset (original) is released under |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 11 | * the GPL, and is (c) 1995-1999 by: |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 12 | * Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be) |
| 13 | */ |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 14 | //config:config FBSET |
Denys Vlasenko | b097a84 | 2018-12-28 03:20:17 +0100 | [diff] [blame] | 15 | //config: bool "fbset (5.9 kb)" |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 16 | //config: default y |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 17 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 18 | //config: fbset is used to show or change the settings of a Linux frame buffer |
| 19 | //config: device. The frame buffer device provides a simple and unique |
| 20 | //config: interface to access a graphics display. Enable this option |
| 21 | //config: if you wish to enable the 'fbset' utility. |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 22 | //config: |
| 23 | //config:config FEATURE_FBSET_FANCY |
Denys Vlasenko | f560422 | 2017-01-10 14:58:54 +0100 | [diff] [blame] | 24 | //config: bool "Enable extra options" |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 25 | //config: default y |
| 26 | //config: depends on FBSET |
| 27 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 28 | //config: This option enables extended fbset options, allowing one to set the |
| 29 | //config: framebuffer size, color depth, etc. interface to access a graphics |
| 30 | //config: display. Enable this option if you wish to enable extended fbset |
| 31 | //config: options. |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 32 | //config: |
| 33 | //config:config FEATURE_FBSET_READMODE |
Denys Vlasenko | f560422 | 2017-01-10 14:58:54 +0100 | [diff] [blame] | 34 | //config: bool "Enable readmode support" |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 35 | //config: default y |
| 36 | //config: depends on FBSET |
| 37 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 38 | //config: This option allows fbset to read the video mode database stored by |
| 39 | //config: default as /etc/fb.modes, which can be used to set frame buffer |
| 40 | //config: device to pre-defined video modes. |
Denys Vlasenko | dd898c9 | 2016-11-23 11:46:32 +0100 | [diff] [blame] | 41 | |
| 42 | //applet:IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
| 43 | |
| 44 | //kbuild:lib-$(CONFIG_FBSET) += fbset.o |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 45 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 46 | //usage:#define fbset_trivial_usage |
| 47 | //usage: "[OPTIONS] [MODE]" |
| 48 | //usage:#define fbset_full_usage "\n\n" |
| 49 | //usage: "Show and modify frame buffer settings" |
| 50 | //usage: |
| 51 | //usage:#define fbset_example_usage |
| 52 | //usage: "$ fbset\n" |
| 53 | //usage: "mode \"1024x768-76\"\n" |
| 54 | //usage: " # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz\n" |
| 55 | //usage: " geometry 1024 768 1024 768 16\n" |
| 56 | //usage: " timings 12714 128 32 16 4 128 4\n" |
| 57 | //usage: " accel false\n" |
| 58 | //usage: " rgba 5/11,6/5,5/0,0/0\n" |
| 59 | //usage: "endmode\n" |
| 60 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 61 | #include "libbb.h" |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 62 | |
Eric Andersen | 5f28455 | 2003-11-14 03:11:29 +0000 | [diff] [blame] | 63 | #define DEFAULTFBDEV FB_0 |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 64 | #define DEFAULTFBMODE "/etc/fb.modes" |
| 65 | |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 66 | /* Stuff stolen from the kernel's fb.h */ |
Denis Vlasenko | 274b8c0 | 2006-09-30 16:22:59 +0000 | [diff] [blame] | 67 | #define FB_ACTIVATE_ALL 64 |
Rob Landley | bc68cd1 | 2006-03-10 19:22:06 +0000 | [diff] [blame] | 68 | enum { |
| 69 | FBIOGET_VSCREENINFO = 0x4600, |
| 70 | FBIOPUT_VSCREENINFO = 0x4601 |
| 71 | }; |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 72 | |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 73 | struct fb_bitfield { |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 74 | uint32_t offset; /* beginning of bitfield */ |
Denys Vlasenko | fb132e4 | 2010-10-29 11:46:52 +0200 | [diff] [blame] | 75 | uint32_t length; /* length of bitfield */ |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 76 | uint32_t msb_right; /* !=0: Most significant bit is right */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 77 | }; |
| 78 | struct fb_var_screeninfo { |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 79 | uint32_t xres; /* visible resolution */ |
Eric Andersen | 1eceb12 | 2003-07-14 19:32:40 +0000 | [diff] [blame] | 80 | uint32_t yres; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 81 | uint32_t xres_virtual; /* virtual resolution */ |
Eric Andersen | 1eceb12 | 2003-07-14 19:32:40 +0000 | [diff] [blame] | 82 | uint32_t yres_virtual; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 83 | uint32_t xoffset; /* offset from virtual to visible */ |
| 84 | uint32_t yoffset; /* resolution */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 85 | |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 86 | uint32_t bits_per_pixel; |
| 87 | uint32_t grayscale; /* !=0 Graylevels instead of colors */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 88 | |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 89 | struct fb_bitfield red; /* bitfield in fb mem if true color, */ |
| 90 | struct fb_bitfield green; /* else only length is significant */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 91 | struct fb_bitfield blue; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 92 | struct fb_bitfield transp; /* transparency */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 93 | |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 94 | uint32_t nonstd; /* !=0 Non standard pixel format */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 95 | |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 96 | uint32_t activate; /* see FB_ACTIVATE_x */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 97 | |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 98 | uint32_t height; /* height of picture in mm */ |
| 99 | uint32_t width; /* width of picture in mm */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 100 | |
Denys Vlasenko | fb132e4 | 2010-10-29 11:46:52 +0200 | [diff] [blame] | 101 | uint32_t accel_flags; /* acceleration flags (hints) */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 102 | |
| 103 | /* Timing: All values in pixclocks, except pixclock (of course) */ |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 104 | uint32_t pixclock; /* pixel clock in ps (pico seconds) */ |
| 105 | uint32_t left_margin; /* time from sync to picture */ |
| 106 | uint32_t right_margin; /* time from picture to sync */ |
| 107 | uint32_t upper_margin; /* time from sync to picture */ |
Eric Andersen | 1eceb12 | 2003-07-14 19:32:40 +0000 | [diff] [blame] | 108 | uint32_t lower_margin; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 109 | uint32_t hsync_len; /* length of horizontal sync */ |
| 110 | uint32_t vsync_len; /* length of vertical sync */ |
| 111 | uint32_t sync; /* see FB_SYNC_x */ |
| 112 | uint32_t vmode; /* see FB_VMODE_x */ |
| 113 | uint32_t reserved[6]; /* Reserved for future compatibility */ |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 114 | }; |
| 115 | |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 116 | static void copy_if_gt0(uint32_t *src, uint32_t *dst, unsigned cnt) |
| 117 | { |
| 118 | do { |
| 119 | if ((int32_t) *src > 0) |
| 120 | *dst = *src; |
| 121 | src++; |
| 122 | dst++; |
| 123 | } while (--cnt); |
| 124 | } |
| 125 | |
| 126 | static NOINLINE void copy_changed_values( |
| 127 | struct fb_var_screeninfo *base, |
| 128 | struct fb_var_screeninfo *set) |
| 129 | { |
| 130 | //if ((int32_t) set->xres > 0) base->xres = set->xres; |
| 131 | //if ((int32_t) set->yres > 0) base->yres = set->yres; |
| 132 | //if ((int32_t) set->xres_virtual > 0) base->xres_virtual = set->xres_virtual; |
| 133 | //if ((int32_t) set->yres_virtual > 0) base->yres_virtual = set->yres_virtual; |
| 134 | copy_if_gt0(&set->xres, &base->xres, 4); |
| 135 | |
| 136 | if ((int32_t) set->bits_per_pixel > 0) base->bits_per_pixel = set->bits_per_pixel; |
| 137 | //copy_if_gt0(&set->bits_per_pixel, &base->bits_per_pixel, 1); |
| 138 | |
| 139 | //if ((int32_t) set->pixclock > 0) base->pixclock = set->pixclock; |
| 140 | //if ((int32_t) set->left_margin > 0) base->left_margin = set->left_margin; |
| 141 | //if ((int32_t) set->right_margin > 0) base->right_margin = set->right_margin; |
| 142 | //if ((int32_t) set->upper_margin > 0) base->upper_margin = set->upper_margin; |
| 143 | //if ((int32_t) set->lower_margin > 0) base->lower_margin = set->lower_margin; |
| 144 | //if ((int32_t) set->hsync_len > 0) base->hsync_len = set->hsync_len; |
| 145 | //if ((int32_t) set->vsync_len > 0) base->vsync_len = set->vsync_len; |
| 146 | //if ((int32_t) set->sync > 0) base->sync = set->sync; |
| 147 | //if ((int32_t) set->vmode > 0) base->vmode = set->vmode; |
| 148 | copy_if_gt0(&set->pixclock, &base->pixclock, 9); |
| 149 | } |
| 150 | |
| 151 | |
| 152 | enum { |
| 153 | CMD_FB = 1, |
| 154 | CMD_DB = 2, |
| 155 | CMD_GEOMETRY = 3, |
| 156 | CMD_TIMING = 4, |
| 157 | CMD_ACCEL = 5, |
| 158 | CMD_HSYNC = 6, |
| 159 | CMD_VSYNC = 7, |
| 160 | CMD_LACED = 8, |
| 161 | CMD_DOUBLE = 9, |
| 162 | /* CMD_XCOMPAT = 10, */ |
| 163 | CMD_ALL = 11, |
| 164 | CMD_INFO = 12, |
| 165 | CMD_SHOW = 13, |
| 166 | CMD_CHANGE = 14, |
| 167 | |
| 168 | #if ENABLE_FEATURE_FBSET_FANCY |
| 169 | CMD_XRES = 100, |
| 170 | CMD_YRES = 101, |
| 171 | CMD_VXRES = 102, |
| 172 | CMD_VYRES = 103, |
| 173 | CMD_DEPTH = 104, |
| 174 | CMD_MATCH = 105, |
| 175 | CMD_PIXCLOCK = 106, |
| 176 | CMD_LEFT = 107, |
| 177 | CMD_RIGHT = 108, |
| 178 | CMD_UPPER = 109, |
| 179 | CMD_LOWER = 110, |
| 180 | CMD_HSLEN = 111, |
| 181 | CMD_VSLEN = 112, |
| 182 | CMD_CSYNC = 113, |
| 183 | CMD_GSYNC = 114, |
| 184 | CMD_EXTSYNC = 115, |
| 185 | CMD_BCAST = 116, |
| 186 | CMD_RGBA = 117, |
| 187 | CMD_STEP = 118, |
| 188 | CMD_MOVE = 119, |
| 189 | #endif |
| 190 | }; |
Eric Andersen | c873d61 | 2000-09-21 04:09:58 +0000 | [diff] [blame] | 191 | |
"Vladimir N. Oleynik" | b399a96 | 2006-02-01 12:41:35 +0000 | [diff] [blame] | 192 | static const struct cmdoptions_t { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 193 | const char name[9]; |
Aaron Lehmann | 6069441 | 2002-08-13 04:19:23 +0000 | [diff] [blame] | 194 | const unsigned char param_count; |
| 195 | const unsigned char code; |
Denys Vlasenko | 965b795 | 2020-11-30 13:03:03 +0100 | [diff] [blame] | 196 | } g_cmdoptions[] ALIGN1 = { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 197 | /*"12345678" + NUL */ |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 198 | //TODO: convert to index_in_strings() |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 199 | { "fb" , 1, CMD_FB }, |
| 200 | { "db" , 1, CMD_DB }, |
| 201 | { "a" , 0, CMD_ALL }, |
| 202 | { "i" , 0, CMD_INFO }, |
| 203 | { "g" , 5, CMD_GEOMETRY }, |
| 204 | { "t" , 7, CMD_TIMING }, |
| 205 | { "accel" , 1, CMD_ACCEL }, |
| 206 | { "hsync" , 1, CMD_HSYNC }, |
| 207 | { "vsync" , 1, CMD_VSYNC }, |
| 208 | { "laced" , 1, CMD_LACED }, |
| 209 | { "double" , 1, CMD_DOUBLE }, |
Bernhard Reutner-Fischer | 7307e06 | 2009-02-18 15:28:43 +0000 | [diff] [blame] | 210 | { "show" , 0, CMD_SHOW }, |
| 211 | { "s" , 0, CMD_SHOW }, |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 212 | #if ENABLE_FEATURE_FBSET_FANCY |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 213 | { "all" , 0, CMD_ALL }, |
| 214 | { "xres" , 1, CMD_XRES }, |
| 215 | { "yres" , 1, CMD_YRES }, |
| 216 | { "vxres" , 1, CMD_VXRES }, |
| 217 | { "vyres" , 1, CMD_VYRES }, |
| 218 | { "depth" , 1, CMD_DEPTH }, |
| 219 | { "match" , 0, CMD_MATCH }, |
| 220 | { "geometry", 5, CMD_GEOMETRY }, |
| 221 | { "pixclock", 1, CMD_PIXCLOCK }, |
| 222 | { "left" , 1, CMD_LEFT }, |
| 223 | { "right" , 1, CMD_RIGHT }, |
| 224 | { "upper" , 1, CMD_UPPER }, |
| 225 | { "lower" , 1, CMD_LOWER }, |
| 226 | { "hslen" , 1, CMD_HSLEN }, |
| 227 | { "vslen" , 1, CMD_VSLEN }, |
| 228 | { "timings" , 7, CMD_TIMING }, |
| 229 | { "csync" , 1, CMD_CSYNC }, |
| 230 | { "gsync" , 1, CMD_GSYNC }, |
| 231 | { "extsync" , 1, CMD_EXTSYNC }, |
| 232 | { "bcast" , 1, CMD_BCAST }, |
| 233 | { "rgba" , 1, CMD_RGBA }, |
| 234 | { "step" , 1, CMD_STEP }, |
| 235 | { "move" , 1, CMD_MOVE }, |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 236 | #endif |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 237 | }; |
| 238 | |
Matt Kraai | 269e07c | 2000-10-28 16:56:32 +0000 | [diff] [blame] | 239 | /* taken from linux/fb.h */ |
Rob Landley | bc68cd1 | 2006-03-10 19:22:06 +0000 | [diff] [blame] | 240 | enum { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 241 | FB_SYNC_HOR_HIGH_ACT = 1, /* horizontal sync high active */ |
| 242 | FB_SYNC_VERT_HIGH_ACT = 2, /* vertical sync high active */ |
Denys Vlasenko | 6b01b71 | 2010-01-24 22:52:21 +0100 | [diff] [blame] | 243 | #if ENABLE_FEATURE_FBSET_READMODE |
| 244 | FB_VMODE_INTERLACED = 1, /* interlaced */ |
| 245 | FB_VMODE_DOUBLE = 2, /* double scan */ |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 246 | FB_SYNC_EXT = 4, /* external sync */ |
| 247 | FB_SYNC_COMP_HIGH_ACT = 8, /* composite sync high active */ |
Matt Kraai | 269e07c | 2000-10-28 16:56:32 +0000 | [diff] [blame] | 248 | #endif |
Denys Vlasenko | 6b01b71 | 2010-01-24 22:52:21 +0100 | [diff] [blame] | 249 | }; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 250 | |
Denis Vlasenko | d91afa3 | 2008-07-29 11:10:01 +0000 | [diff] [blame] | 251 | #if ENABLE_FEATURE_FBSET_READMODE |
Denis Vlasenko | 8d523cb | 2008-07-27 21:16:30 +0000 | [diff] [blame] | 252 | static void ss(uint32_t *x, uint32_t flag, char *buf, const char *what) |
Denis Vlasenko | 09f5ecf | 2008-07-27 20:25:29 +0000 | [diff] [blame] | 253 | { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 254 | if (strcmp(buf, what) == 0) |
Denis Vlasenko | 09f5ecf | 2008-07-27 20:25:29 +0000 | [diff] [blame] | 255 | *x &= ~flag; |
| 256 | else |
| 257 | *x |= flag; |
| 258 | } |
| 259 | |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 260 | /* Mode db file contains mode definitions like this: |
| 261 | * mode "800x600-48-lace" |
| 262 | * # D: 36.00 MHz, H: 33.835 kHz, V: 96.39 Hz |
| 263 | * geometry 800 600 800 600 8 |
| 264 | * timings 27778 56 80 79 11 128 12 |
| 265 | * laced true |
| 266 | * hsync high |
| 267 | * vsync high |
| 268 | * endmode |
| 269 | */ |
Denys Vlasenko | 53b2fdc | 2021-10-10 13:50:53 +0200 | [diff] [blame] | 270 | static NOINLINE int read_mode_db(struct fb_var_screeninfo *base, const char *fn, |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 271 | const char *mode) |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 272 | { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 273 | char *token[2], *p, *s; |
| 274 | parser_t *parser = config_open(fn); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 275 | |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 276 | while (config_read(parser, token, 2, 1, "# \t\r", PARSE_NORMAL)) { |
| 277 | if (strcmp(token[0], "mode") != 0 || !token[1]) |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 278 | continue; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 279 | p = strstr(token[1], mode); |
Denis Vlasenko | 6bef3d1 | 2007-11-06 03:05:54 +0000 | [diff] [blame] | 280 | if (!p) |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 281 | continue; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 282 | s = p + strlen(mode); |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 283 | //bb_error_msg("CHECK[%s][%s][%d]", mode, p-1, *s); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 284 | /* exact match? */ |
| 285 | if (((!*s || isspace(*s)) && '"' != s[-1]) /* end-of-token */ |
| 286 | || ('"' == *s && '"' == p[-1]) /* ends with " but starts with " too! */ |
Denis Vlasenko | 8d523cb | 2008-07-27 21:16:30 +0000 | [diff] [blame] | 287 | ) { |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 288 | //bb_error_msg("FOUND[%s][%s][%s][%d]", token[1], p, mode, isspace(*s)); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 289 | break; |
Denis Vlasenko | 8d523cb | 2008-07-27 21:16:30 +0000 | [diff] [blame] | 290 | } |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 291 | } |
Eric Andersen | 6f96e67 | 2000-07-12 23:01:04 +0000 | [diff] [blame] | 292 | |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 293 | if (!token[0]) |
| 294 | return 0; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 295 | |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 296 | while (config_read(parser, token, 2, 1, "# \t", PARSE_NORMAL)) { |
| 297 | int i; |
| 298 | |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 299 | //bb_error_msg("???[%s][%s]", token[0], token[1]); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 300 | if (strcmp(token[0], "endmode") == 0) { |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 301 | //bb_error_msg("OK[%s]", mode); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 302 | return 1; |
| 303 | } |
| 304 | p = token[1]; |
| 305 | i = index_in_strings( |
Linus Walleij | b5c7220 | 2012-07-01 22:34:42 +0200 | [diff] [blame] | 306 | "geometry\0timings\0interlaced\0double\0vsync\0hsync\0csync\0extsync\0rgba\0", |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 307 | token[0]); |
| 308 | switch (i) { |
| 309 | case 0: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 310 | if (sizeof(int) == sizeof(base->xres)) { |
| 311 | sscanf(p, "%d %d %d %d %d", |
| 312 | &base->xres, &base->yres, |
| 313 | &base->xres_virtual, &base->yres_virtual, |
| 314 | &base->bits_per_pixel); |
| 315 | } else { |
| 316 | int base_xres, base_yres; |
| 317 | int base_xres_virtual, base_yres_virtual; |
| 318 | int base_bits_per_pixel; |
| 319 | sscanf(p, "%d %d %d %d %d", |
| 320 | &base_xres, &base_yres, |
| 321 | &base_xres_virtual, &base_yres_virtual, |
| 322 | &base_bits_per_pixel); |
| 323 | base->xres = base_xres; |
| 324 | base->yres = base_yres; |
| 325 | base->xres_virtual = base_xres_virtual; |
| 326 | base->yres_virtual = base_yres_virtual; |
| 327 | base->bits_per_pixel = base_bits_per_pixel; |
| 328 | } |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 329 | //bb_error_msg("GEO[%s]", p); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 330 | break; |
| 331 | case 1: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 332 | if (sizeof(int) == sizeof(base->xres)) { |
| 333 | sscanf(p, "%d %d %d %d %d %d %d", |
| 334 | &base->pixclock, |
| 335 | &base->left_margin, &base->right_margin, |
| 336 | &base->upper_margin, &base->lower_margin, |
| 337 | &base->hsync_len, &base->vsync_len); |
| 338 | } else { |
| 339 | int base_pixclock; |
| 340 | int base_left_margin, base_right_margin; |
| 341 | int base_upper_margin, base_lower_margin; |
| 342 | int base_hsync_len, base_vsync_len; |
| 343 | sscanf(p, "%d %d %d %d %d %d %d", |
| 344 | &base_pixclock, |
| 345 | &base_left_margin, &base_right_margin, |
| 346 | &base_upper_margin, &base_lower_margin, |
| 347 | &base_hsync_len, &base_vsync_len); |
| 348 | base->pixclock = base_pixclock; |
| 349 | base->left_margin = base_left_margin; |
| 350 | base->right_margin = base_right_margin; |
| 351 | base->upper_margin = base_upper_margin; |
| 352 | base->lower_margin = base_lower_margin; |
| 353 | base->hsync_len = base_hsync_len; |
| 354 | base->vsync_len = base_vsync_len; |
| 355 | } |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 356 | //bb_error_msg("TIM[%s]", p); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 357 | break; |
| 358 | case 2: |
| 359 | case 3: { |
| 360 | static const uint32_t syncs[] = {FB_VMODE_INTERLACED, FB_VMODE_DOUBLE}; |
| 361 | ss(&base->vmode, syncs[i-2], p, "false"); |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 362 | //bb_error_msg("VMODE[%s]", p); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 363 | break; |
| 364 | } |
| 365 | case 4: |
| 366 | case 5: |
Denys Vlasenko | fb132e4 | 2010-10-29 11:46:52 +0200 | [diff] [blame] | 367 | case 6: { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 368 | static const uint32_t syncs[] = {FB_SYNC_VERT_HIGH_ACT, FB_SYNC_HOR_HIGH_ACT, FB_SYNC_COMP_HIGH_ACT}; |
| 369 | ss(&base->sync, syncs[i-4], p, "low"); |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 370 | //bb_error_msg("SYNC[%s]", p); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 371 | break; |
| 372 | } |
| 373 | case 7: |
| 374 | ss(&base->sync, FB_SYNC_EXT, p, "false"); |
Denys Vlasenko | 76b680c | 2016-03-30 16:04:37 +0200 | [diff] [blame] | 375 | //bb_error_msg("EXTSYNC[%s]", p); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 376 | break; |
Linus Walleij | b5c7220 | 2012-07-01 22:34:42 +0200 | [diff] [blame] | 377 | case 8: { |
| 378 | int red_offset, red_length; |
| 379 | int green_offset, green_length; |
| 380 | int blue_offset, blue_length; |
| 381 | int transp_offset, transp_length; |
| 382 | |
| 383 | sscanf(p, "%d/%d,%d/%d,%d/%d,%d/%d", |
Linus Walleij | 52f2f37 | 2015-07-27 09:59:04 +0200 | [diff] [blame] | 384 | &red_length, &red_offset, |
| 385 | &green_length, &green_offset, |
| 386 | &blue_length, &blue_offset, |
| 387 | &transp_length, &transp_offset); |
Linus Walleij | b5c7220 | 2012-07-01 22:34:42 +0200 | [diff] [blame] | 388 | base->red.offset = red_offset; |
| 389 | base->red.length = red_length; |
| 390 | base->red.msb_right = 0; |
| 391 | base->green.offset = green_offset; |
| 392 | base->green.length = green_length; |
| 393 | base->green.msb_right = 0; |
| 394 | base->blue.offset = blue_offset; |
| 395 | base->blue.length = blue_length; |
| 396 | base->blue.msb_right = 0; |
| 397 | base->transp.offset = transp_offset; |
| 398 | base->transp.length = transp_length; |
| 399 | base->transp.msb_right = 0; |
| 400 | } |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 401 | } |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 402 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 403 | return 0; |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 404 | } |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 405 | #endif |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 406 | |
Denys Vlasenko | ef5bc2c | 2009-10-08 14:54:18 +0200 | [diff] [blame] | 407 | static NOINLINE void showmode(struct fb_var_screeninfo *v) |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 408 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 409 | double drate = 0, hrate = 0, vrate = 0; |
| 410 | |
| 411 | if (v->pixclock) { |
| 412 | drate = 1e12 / v->pixclock; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 413 | hrate = drate / (v->left_margin + v->xres + v->right_margin + v->hsync_len); |
| 414 | vrate = hrate / (v->upper_margin + v->yres + v->lower_margin + v->vsync_len); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 415 | } |
Aaron Lehmann | 6069441 | 2002-08-13 04:19:23 +0000 | [diff] [blame] | 416 | printf("\nmode \"%ux%u-%u\"\n" |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 417 | #if ENABLE_FEATURE_FBSET_FANCY |
Aaron Lehmann | 6069441 | 2002-08-13 04:19:23 +0000 | [diff] [blame] | 418 | "\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n" |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 419 | #endif |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 420 | "\tgeometry %u %u %u %u %u\n" |
| 421 | "\ttimings %u %u %u %u %u %u %u\n" |
| 422 | "\taccel %s\n" |
| 423 | "\trgba %u/%u,%u/%u,%u/%u,%u/%u\n" |
| 424 | "endmode\n\n", |
| 425 | v->xres, v->yres, (int) (vrate + 0.5), |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 426 | #if ENABLE_FEATURE_FBSET_FANCY |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 427 | drate / 1e6, hrate / 1e3, vrate, |
Aaron Lehmann | 6069441 | 2002-08-13 04:19:23 +0000 | [diff] [blame] | 428 | #endif |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 429 | v->xres, v->yres, v->xres_virtual, v->yres_virtual, v->bits_per_pixel, |
| 430 | v->pixclock, v->left_margin, v->right_margin, v->upper_margin, v->lower_margin, |
| 431 | v->hsync_len, v->vsync_len, |
| 432 | (v->accel_flags > 0 ? "true" : "false"), |
| 433 | v->red.length, v->red.offset, v->green.length, v->green.offset, |
| 434 | v->blue.length, v->blue.offset, v->transp.length, v->transp.offset); |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 437 | int fbset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Rob Landley | dfba741 | 2006-03-06 20:47:33 +0000 | [diff] [blame] | 438 | int fbset_main(int argc, char **argv) |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 439 | { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 440 | enum { |
| 441 | OPT_CHANGE = (1 << 0), |
Bernhard Reutner-Fischer | 7307e06 | 2009-02-18 15:28:43 +0000 | [diff] [blame] | 442 | OPT_SHOW = (1 << 1), |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 443 | OPT_READMODE = (1 << 2), |
Denys Vlasenko | 972e046 | 2011-06-06 04:21:39 +0200 | [diff] [blame] | 444 | OPT_ALL = (1 << 3), |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 445 | }; |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 446 | struct fb_var_screeninfo var_old, var_set; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 447 | int fh, i; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 448 | unsigned options = 0; |
| 449 | |
Denis Vlasenko | b6aae0f | 2007-01-29 22:51:25 +0000 | [diff] [blame] | 450 | const char *fbdev = DEFAULTFBDEV; |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 451 | IF_FEATURE_FBSET_READMODE(const char *modefile = DEFAULTFBMODE;) |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 452 | char *thisarg; |
| 453 | char *mode = mode; /* for compiler */ |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 454 | |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 455 | memset(&var_set, 0xff, sizeof(var_set)); /* set all to -1 */ |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 456 | |
| 457 | /* parse cmd args.... why do they have to make things so difficult? */ |
| 458 | argv++; |
| 459 | argc--; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 460 | for (; argc > 0 && (thisarg = *argv) != NULL; argc--, argv++) { |
Denys Vlasenko | 12bc152 | 2011-05-09 03:57:27 +0200 | [diff] [blame] | 461 | if (thisarg[0] != '-') { |
| 462 | if (!ENABLE_FEATURE_FBSET_READMODE || argc != 1) |
| 463 | bb_show_usage(); |
| 464 | mode = thisarg; |
| 465 | options |= OPT_READMODE; |
| 466 | goto contin; |
| 467 | } |
| 468 | for (i = 0; i < ARRAY_SIZE(g_cmdoptions); i++) { |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 469 | if (strcmp(thisarg + 1, g_cmdoptions[i].name) != 0) |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 470 | continue; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 471 | if (argc <= g_cmdoptions[i].param_count) |
Manuel Novoa III | cad5364 | 2003-03-19 09:13:01 +0000 | [diff] [blame] | 472 | bb_show_usage(); |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 473 | |
| 474 | switch (g_cmdoptions[i].code) { |
| 475 | case CMD_FB: |
| 476 | fbdev = argv[1]; |
| 477 | break; |
| 478 | case CMD_DB: |
Denys Vlasenko | 015db58 | 2016-06-19 18:15:33 +0200 | [diff] [blame] | 479 | IF_FEATURE_FBSET_READMODE(modefile = argv[1];) |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 480 | break; |
Bernhard Reutner-Fischer | 7307e06 | 2009-02-18 15:28:43 +0000 | [diff] [blame] | 481 | case CMD_ALL: |
| 482 | options |= OPT_ALL; |
| 483 | break; |
| 484 | case CMD_SHOW: |
| 485 | options |= OPT_SHOW; |
| 486 | break; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 487 | case CMD_GEOMETRY: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 488 | var_set.xres = xatou32(argv[1]); |
| 489 | var_set.yres = xatou32(argv[2]); |
| 490 | var_set.xres_virtual = xatou32(argv[3]); |
| 491 | var_set.yres_virtual = xatou32(argv[4]); |
| 492 | var_set.bits_per_pixel = xatou32(argv[5]); |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 493 | break; |
| 494 | case CMD_TIMING: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 495 | var_set.pixclock = xatou32(argv[1]); |
| 496 | var_set.left_margin = xatou32(argv[2]); |
| 497 | var_set.right_margin = xatou32(argv[3]); |
| 498 | var_set.upper_margin = xatou32(argv[4]); |
| 499 | var_set.lower_margin = xatou32(argv[5]); |
| 500 | var_set.hsync_len = xatou32(argv[6]); |
| 501 | var_set.vsync_len = xatou32(argv[7]); |
| 502 | break; |
| 503 | case CMD_ACCEL: |
| 504 | break; |
| 505 | case CMD_HSYNC: |
| 506 | var_set.sync |= FB_SYNC_HOR_HIGH_ACT; |
| 507 | break; |
| 508 | case CMD_VSYNC: |
| 509 | var_set.sync |= FB_SYNC_VERT_HIGH_ACT; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 510 | break; |
Denis Vlasenko | e324184 | 2007-08-13 10:36:25 +0000 | [diff] [blame] | 511 | #if ENABLE_FEATURE_FBSET_FANCY |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 512 | case CMD_XRES: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 513 | var_set.xres = xatou32(argv[1]); |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 514 | break; |
| 515 | case CMD_YRES: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 516 | var_set.yres = xatou32(argv[1]); |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 517 | break; |
| 518 | case CMD_DEPTH: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 519 | var_set.bits_per_pixel = xatou32(argv[1]); |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 520 | break; |
| 521 | #endif |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 522 | } |
Bernhard Reutner-Fischer | 7307e06 | 2009-02-18 15:28:43 +0000 | [diff] [blame] | 523 | switch (g_cmdoptions[i].code) { |
| 524 | case CMD_FB: |
| 525 | case CMD_DB: |
| 526 | case CMD_ALL: |
| 527 | case CMD_SHOW: |
| 528 | break; |
| 529 | default: |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 530 | /* other commands imply changes */ |
| 531 | options |= OPT_CHANGE; |
Bernhard Reutner-Fischer | 7307e06 | 2009-02-18 15:28:43 +0000 | [diff] [blame] | 532 | } |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 533 | argc -= g_cmdoptions[i].param_count; |
| 534 | argv += g_cmdoptions[i].param_count; |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 535 | goto contin; |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 536 | } |
Denys Vlasenko | 12bc152 | 2011-05-09 03:57:27 +0200 | [diff] [blame] | 537 | bb_show_usage(); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 538 | contin: ; |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 539 | } |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 540 | |
Rob Landley | d921b2e | 2006-08-03 15:41:12 +0000 | [diff] [blame] | 541 | fh = xopen(fbdev, O_RDONLY); |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 542 | xioctl(fh, FBIOGET_VSCREENINFO, &var_old); |
| 543 | |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 544 | if (options & OPT_READMODE) { |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 545 | #if ENABLE_FEATURE_FBSET_READMODE |
| 546 | if (!read_mode_db(&var_old, modefile, mode)) { |
Denis Vlasenko | 39d551f | 2006-09-30 16:28:30 +0000 | [diff] [blame] | 547 | bb_error_msg_and_die("unknown video mode '%s'", mode); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 548 | } |
Denys Vlasenko | 972e046 | 2011-06-06 04:21:39 +0200 | [diff] [blame] | 549 | options |= OPT_CHANGE; |
Denis Vlasenko | 85c2471 | 2008-03-17 09:04:04 +0000 | [diff] [blame] | 550 | #endif |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 551 | } |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 552 | |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 553 | if (options & OPT_CHANGE) { |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 554 | copy_changed_values(&var_old, &var_set); |
Denis Vlasenko | b66d16a | 2008-08-24 16:25:40 +0000 | [diff] [blame] | 555 | if (options & OPT_ALL) |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 556 | var_old.activate = FB_ACTIVATE_ALL; |
| 557 | xioctl(fh, FBIOPUT_VSCREENINFO, &var_old); |
Denis Vlasenko | 274b8c0 | 2006-09-30 16:22:59 +0000 | [diff] [blame] | 558 | } |
Michael Grzeschik | 24dc9ab | 2010-01-23 03:40:28 +0100 | [diff] [blame] | 559 | |
| 560 | if (options == 0 || (options & OPT_SHOW)) |
| 561 | showmode(&var_old); |
| 562 | |
| 563 | if (ENABLE_FEATURE_CLEAN_UP) |
| 564 | close(fh); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 565 | |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 566 | return EXIT_SUCCESS; |
Erik Andersen | 1c5b258 | 1999-12-16 20:59:36 +0000 | [diff] [blame] | 567 | } |