Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/util-linux/fbset.c

    r821 r1770  
    1313 */
    1414
    15 #include <stdio.h>
    16 #include <stdlib.h>
    17 #include <unistd.h>
    18 #include <fcntl.h>
    19 #include <errno.h>
    20 #include <ctype.h>
    21 #include <string.h>
    22 #include <stdint.h>
    23 #include <sys/ioctl.h>
    24 #include "busybox.h"
     15#include "libbb.h"
    2516
    2617#define DEFAULTFBDEV  FB_0
     
    3122    OPT_INFO     = (1 << 1),
    3223    OPT_READMODE = (1 << 2),
     24    OPT_ALL      = (1 << 9),
    3325
    3426    CMD_FB = 1,
     
    4638    CMD_CHANGE = 13,
    4739
    48 #ifdef CONFIG_FEATURE_FBSET_FANCY
     40#if ENABLE_FEATURE_FBSET_FANCY
    4941    CMD_XRES = 100,
    5042    CMD_YRES = 101,
     
    7062};
    7163
    72 static unsigned int g_options = 0;
     64static unsigned g_options;
    7365
    7466/* Stuff stolen from the kernel's fb.h */
     67#define FB_ACTIVATE_ALL 64
    7568enum {
    7669    FBIOGET_VSCREENINFO = 0x4600,
     
    7871};
    7972struct fb_bitfield {
    80     uint32_t offset;            /* beginning of bitfield    */
    81     uint32_t length;            /* length of bitfield       */
    82     uint32_t msb_right;     /* != 0 : Most significant bit is */
    83                     /* right */
     73    uint32_t offset;                /* beginning of bitfield */
     74    uint32_t length;        /* length of bitfield */
     75    uint32_t msb_right;             /* !=0: Most significant bit is right */
    8476};
    8577struct fb_var_screeninfo {
    86     uint32_t xres;          /* visible resolution       */
     78    uint32_t xres;                  /* visible resolution */
    8779    uint32_t yres;
    88     uint32_t xres_virtual;      /* virtual resolution       */
     80    uint32_t xres_virtual;          /* virtual resolution */
    8981    uint32_t yres_virtual;
    90     uint32_t xoffset;           /* offset from virtual to visible */
    91     uint32_t yoffset;           /* resolution           */
    92 
    93     uint32_t bits_per_pixel;        /* guess what           */
    94     uint32_t grayscale;     /* != 0 Graylevels instead of colors */
    95 
    96     struct fb_bitfield red;     /* bitfield in fb mem if true color, */
    97     struct fb_bitfield green;   /* else only length is significant */
     82    uint32_t xoffset;               /* offset from virtual to visible */
     83    uint32_t yoffset;               /* resolution */
     84
     85    uint32_t bits_per_pixel;
     86    uint32_t grayscale;             /* !=0 Graylevels instead of colors */
     87
     88    struct fb_bitfield red;         /* bitfield in fb mem if true color, */
     89    struct fb_bitfield green;       /* else only length is significant */
    9890    struct fb_bitfield blue;
    99     struct fb_bitfield transp;  /* transparency         */
    100 
    101     uint32_t nonstd;            /* != 0 Non standard pixel format */
    102 
    103     uint32_t activate;          /* see FB_ACTIVATE_*        */
    104 
    105     uint32_t height;            /* height of picture in mm    */
    106     uint32_t width;         /* width of picture in mm    */
     91    struct fb_bitfield transp;      /* transparency */
     92
     93    uint32_t nonstd;                /* !=0 Non standard pixel format */
     94
     95    uint32_t activate;              /* see FB_ACTIVATE_x */
     96
     97    uint32_t height;                /* height of picture in mm */
     98    uint32_t width;                 /* width of picture in mm */
    10799
    108100    uint32_t accel_flags;       /* acceleration flags (hints)   */
    109101
    110102    /* Timing: All values in pixclocks, except pixclock (of course) */
    111     uint32_t pixclock;          /* pixel clock in ps (pico seconds) */
    112     uint32_t left_margin;       /* time from sync to picture    */
    113     uint32_t right_margin;      /* time from picture to sync    */
    114     uint32_t upper_margin;      /* time from sync to picture    */
     103    uint32_t pixclock;              /* pixel clock in ps (pico seconds) */
     104    uint32_t left_margin;           /* time from sync to picture */
     105    uint32_t right_margin;          /* time from picture to sync */
     106    uint32_t upper_margin;          /* time from sync to picture */
    115107    uint32_t lower_margin;
    116     uint32_t hsync_len;     /* length of horizontal sync    */
    117     uint32_t vsync_len;     /* length of vertical sync  */
    118     uint32_t sync;          /* see FB_SYNC_*        */
    119     uint32_t vmode;         /* see FB_VMODE_*       */
    120     uint32_t reserved[6];       /* Reserved for future compatibility */
     108    uint32_t hsync_len;             /* length of horizontal sync */
     109    uint32_t vsync_len;             /* length of vertical sync */
     110    uint32_t sync;                  /* see FB_SYNC_x */
     111    uint32_t vmode;                 /* see FB_VMODE_x */
     112    uint32_t reserved[6];           /* Reserved for future compatibility */
    121113};
    122114
    123115
    124116static const struct cmdoptions_t {
    125     const char *name;
     117    const char name[10];
    126118    const unsigned char param_count;
    127119    const unsigned char code;
    128120} g_cmdoptions[] = {
    129     {
    130     "-fb", 1, CMD_FB}, {
    131     "-db", 1, CMD_DB}, {
    132     "-a", 0, CMD_ALL}, {
    133     "-i", 0, CMD_INFO}, {
    134     "-g", 5, CMD_GEOMETRY}, {
    135     "-t", 7, CMD_TIMING}, {
    136     "-accel", 1, CMD_ACCEL}, {
    137     "-hsync", 1, CMD_HSYNC}, {
    138     "-vsync", 1, CMD_VSYNC}, {
    139     "-laced", 1, CMD_LACED}, {
    140     "-double", 1, CMD_DOUBLE}, {
    141     "-n", 0, CMD_CHANGE}, {
    142 #ifdef CONFIG_FEATURE_FBSET_FANCY
    143     "-all", 0, CMD_ALL}, {
    144     "-xres", 1, CMD_XRES}, {
    145     "-yres", 1, CMD_YRES}, {
    146     "-vxres", 1, CMD_VXRES}, {
    147     "-vyres", 1, CMD_VYRES}, {
    148     "-depth", 1, CMD_DEPTH}, {
    149     "-match", 0, CMD_MATCH}, {
    150     "-geometry", 5, CMD_GEOMETRY}, {
    151     "-pixclock", 1, CMD_PIXCLOCK}, {
    152     "-left", 1, CMD_LEFT}, {
    153     "-right", 1, CMD_RIGHT}, {
    154     "-upper", 1, CMD_UPPER}, {
    155     "-lower", 1, CMD_LOWER}, {
    156     "-hslen", 1, CMD_HSLEN}, {
    157     "-vslen", 1, CMD_VSLEN}, {
    158     "-timings", 7, CMD_TIMING}, {
    159     "-csync", 1, CMD_CSYNC}, {
    160     "-gsync", 1, CMD_GSYNC}, {
    161     "-extsync", 1, CMD_EXTSYNC}, {
    162     "-bcast", 1, CMD_BCAST}, {
    163     "-rgba", 1, CMD_RGBA}, {
    164     "-step", 1, CMD_STEP}, {
    165     "-move", 1, CMD_MOVE}, {
    166 #endif
    167     0, 0, 0}
    168 };
    169 
    170 #ifdef CONFIG_FEATURE_FBSET_READMODE
     121    { "-fb", 1, CMD_FB },
     122    { "-db", 1, CMD_DB },
     123    { "-a", 0, CMD_ALL },
     124    { "-i", 0, CMD_INFO },
     125    { "-g", 5, CMD_GEOMETRY },
     126    { "-t", 7, CMD_TIMING },
     127    { "-accel", 1, CMD_ACCEL },
     128    { "-hsync", 1, CMD_HSYNC },
     129    { "-vsync", 1, CMD_VSYNC },
     130    { "-laced", 1, CMD_LACED },
     131    { "-double", 1, CMD_DOUBLE },
     132    { "-n", 0, CMD_CHANGE },
     133#if ENABLE_FEATURE_FBSET_FANCY
     134    { "-all", 0, CMD_ALL },
     135    { "-xres", 1, CMD_XRES },
     136    { "-yres", 1, CMD_YRES },
     137    { "-vxres", 1, CMD_VXRES },
     138    { "-vyres", 1, CMD_VYRES },
     139    { "-depth", 1, CMD_DEPTH },
     140    { "-match", 0, CMD_MATCH },
     141    { "-geometry", 5, CMD_GEOMETRY },
     142    { "-pixclock", 1, CMD_PIXCLOCK },
     143    { "-left", 1, CMD_LEFT },
     144    { "-right", 1, CMD_RIGHT },
     145    { "-upper", 1, CMD_UPPER },
     146    { "-lower", 1, CMD_LOWER },
     147    { "-hslen", 1, CMD_HSLEN },
     148    { "-vslen", 1, CMD_VSLEN },
     149    { "-timings", 7, CMD_TIMING },
     150    { "-csync", 1, CMD_CSYNC },
     151    { "-gsync", 1, CMD_GSYNC },
     152    { "-extsync", 1, CMD_EXTSYNC },
     153    { "-bcast", 1, CMD_BCAST },
     154    { "-rgba", 1, CMD_RGBA },
     155    { "-step", 1, CMD_STEP },
     156    { "-move", 1, CMD_MOVE },
     157#endif
     158    { "", 0, 0 }
     159};
     160
     161#if ENABLE_FEATURE_FBSET_READMODE
    171162/* taken from linux/fb.h */
    172163enum {
     
    179170};
    180171#endif
     172
    181173static int readmode(struct fb_var_screeninfo *base, const char *fn,
    182174                    const char *mode)
    183175{
    184 #ifdef CONFIG_FEATURE_FBSET_READMODE
     176#if ENABLE_FEATURE_FBSET_READMODE
    185177    FILE *f;
    186178    char buf[256];
    187179    char *p = buf;
    188180
    189     f = bb_xfopen(fn, "r");
     181    f = xfopen(fn, "r");
    190182    while (!feof(f)) {
    191183        fgets(buf, sizeof(buf), f);
    192         if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
    193             p += 5;
    194             if ((p = strstr(buf, mode))) {
    195                 p += strlen(mode);
    196                 if (!isspace(*p) && (*p != 0) && (*p != '"')
    197                     && (*p != '\r') && (*p != '\n'))
    198                     continue;   /* almost, but not quite */
    199                 while (!feof(f)) {
    200                     fgets(buf, sizeof(buf), f);
    201 
    202             if ((p = strstr(buf, "geometry "))) {
    203             p += 9;
    204 
    205             sscanf(p, "%d %d %d %d %d",
    206                 &(base->xres), &(base->yres),
    207                 &(base->xres_virtual), &(base->yres_virtual),
    208                 &(base->bits_per_pixel));
    209             } else if ((p = strstr(buf, "timings "))) {
    210             p += 8;
    211 
    212             sscanf(p, "%d %d %d %d %d %d %d",
    213                 &(base->pixclock),
    214                 &(base->left_margin), &(base->right_margin),
    215                 &(base->upper_margin), &(base->lower_margin),
    216                 &(base->hsync_len), &(base->vsync_len));
    217             } else if ((p = strstr(buf, "laced "))) {
    218             p += 6;
    219 
    220             if (strstr(buf, "false")) {
    221                 base->vmode &= ~FB_VMODE_INTERLACED;
    222             } else {
    223                 base->vmode |= FB_VMODE_INTERLACED;
     184        if (!(p = strstr(buf, "mode ")) && !(p = strstr(buf, "mode\t")))
     185            continue;
     186        p += 5;
     187        if (!(p = strstr(buf, mode)))
     188            continue;
     189        p += strlen(mode);
     190        if (!isspace(*p) && (*p != 0) && (*p != '"')
     191                && (*p != '\r') && (*p != '\n'))
     192            continue;   /* almost, but not quite */
     193
     194        while (!feof(f)) {
     195            fgets(buf, sizeof(buf), f);
     196            if ((p = strstr(buf, "geometry "))) {
     197                p += 9;
     198                /* FIXME: catastrophic on arches with 64bit ints */
     199                sscanf(p, "%d %d %d %d %d",
     200                    &(base->xres), &(base->yres),
     201                    &(base->xres_virtual), &(base->yres_virtual),
     202                    &(base->bits_per_pixel));
     203            } else if ((p = strstr(buf, "timings "))) {
     204                p += 8;
     205                sscanf(p, "%d %d %d %d %d %d %d",
     206                    &(base->pixclock),
     207                    &(base->left_margin), &(base->right_margin),
     208                    &(base->upper_margin), &(base->lower_margin),
     209                    &(base->hsync_len), &(base->vsync_len));
     210            } else if ((p = strstr(buf, "laced "))) {
     211                //p += 6;
     212                if (strstr(buf, "false")) {
     213                    base->vmode &= ~FB_VMODE_INTERLACED;
     214                } else {
     215                    base->vmode |= FB_VMODE_INTERLACED;
     216                }
     217            } else if ((p = strstr(buf, "double "))) {
     218                //p += 7;
     219                if (strstr(buf, "false")) {
     220                    base->vmode &= ~FB_VMODE_DOUBLE;
     221                } else {
     222                    base->vmode |= FB_VMODE_DOUBLE;
     223                }
     224            } else if ((p = strstr(buf, "vsync "))) {
     225                //p += 6;
     226                if (strstr(buf, "low")) {
     227                    base->sync &= ~FB_SYNC_VERT_HIGH_ACT;
     228                } else {
     229                    base->sync |= FB_SYNC_VERT_HIGH_ACT;
     230                }
     231            } else if ((p = strstr(buf, "hsync "))) {
     232                //p += 6;
     233                if (strstr(buf, "low")) {
     234                    base->sync &= ~FB_SYNC_HOR_HIGH_ACT;
     235                } else {
     236                    base->sync |= FB_SYNC_HOR_HIGH_ACT;
     237                }
     238            } else if ((p = strstr(buf, "csync "))) {
     239                //p += 6;
     240                if (strstr(buf, "low")) {
     241                    base->sync &= ~FB_SYNC_COMP_HIGH_ACT;
     242                } else {
     243                    base->sync |= FB_SYNC_COMP_HIGH_ACT;
     244                }
     245            } else if ((p = strstr(buf, "extsync "))) {
     246                //p += 8;
     247                if (strstr(buf, "false")) {
     248                    base->sync &= ~FB_SYNC_EXT;
     249                } else {
     250                    base->sync |= FB_SYNC_EXT;
     251                }
    224252            }
    225             } else if ((p = strstr(buf, "double "))) {
    226             p += 7;
    227 
    228             if (strstr(buf, "false")) {
    229                 base->vmode &= ~FB_VMODE_DOUBLE;
    230             } else {
    231                 base->vmode |= FB_VMODE_DOUBLE;
    232             }
    233             } else if ((p = strstr(buf, "vsync "))) {
    234             p += 6;
    235 
    236             if (strstr(buf, "low")) {
    237                 base->sync &= ~FB_SYNC_VERT_HIGH_ACT;
    238             } else {
    239                 base->sync |= FB_SYNC_VERT_HIGH_ACT;
    240             }
    241             } else if ((p = strstr(buf, "hsync "))) {
    242             p += 6;
    243 
    244             if (strstr(buf, "low")) {
    245                 base->sync &= ~FB_SYNC_HOR_HIGH_ACT;
    246             } else {
    247                 base->sync |= FB_SYNC_HOR_HIGH_ACT;
    248             }
    249             } else if ((p = strstr(buf, "csync "))) {
    250             p += 6;
    251 
    252             if (strstr(buf, "low")) {
    253                 base->sync &= ~FB_SYNC_COMP_HIGH_ACT;
    254             } else {
    255                 base->sync |= FB_SYNC_COMP_HIGH_ACT;
    256             }
    257             } else if ((p = strstr(buf, "extsync "))) {
    258             p += 8;
    259 
    260             if (strstr(buf, "false")) {
    261                 base->sync &= ~FB_SYNC_EXT;
    262             } else {
    263                 base->sync |= FB_SYNC_EXT;
    264             }
    265             }
    266 
    267                     if (strstr(buf, "endmode"))
    268                         return 1;
    269                 }
    270             }
     253
     254            if (strstr(buf, "endmode"))
     255                return 1;
    271256        }
    272257    }
    273258#else
    274     bb_error_msg( "mode reading not compiled in");
     259    bb_error_msg("mode reading not compiled in");
    275260#endif
    276261    return 0;
     
    298283    if (v->pixclock) {
    299284        drate = 1e12 / v->pixclock;
    300         hrate =
    301             drate / (v->left_margin + v->xres + v->right_margin +
    302                      v->hsync_len);
    303         vrate =
    304             hrate / (v->upper_margin + v->yres + v->lower_margin +
    305                      v->vsync_len);
     285        hrate = drate / (v->left_margin + v->xres + v->right_margin + v->hsync_len);
     286        vrate = hrate / (v->upper_margin + v->yres + v->lower_margin + v->vsync_len);
    306287    }
    307288    printf("\nmode \"%ux%u-%u\"\n"
    308 #ifdef CONFIG_FEATURE_FBSET_FANCY
     289#if ENABLE_FEATURE_FBSET_FANCY
    309290    "\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n"
    310291#endif
    311     "\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",
    312            v->xres, v->yres, (int) (vrate + 0.5),
    313 #ifdef CONFIG_FEATURE_FBSET_FANCY
    314            drate / 1e6, hrate / 1e3, vrate,
    315 #endif
    316            v->xres, v->yres, v->xres_virtual, v->yres_virtual,
    317            v->bits_per_pixel, v->pixclock, v->left_margin,
    318            v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
    319            v->vsync_len, (v->accel_flags > 0 ? "true" : "false"), v->red.length,
    320            v->red.offset, v->green.length, v->green.offset, v->blue.length,
    321            v->blue.offset, v->transp.length, v->transp.offset);
     292    "\tgeometry %u %u %u %u %u\n"
     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),
     298#if ENABLE_FEATURE_FBSET_FANCY
     299        drate / 1e6, hrate / 1e3, vrate,
     300#endif
     301        v->xres, v->yres, v->xres_virtual, v->yres_virtual, v->bits_per_pixel,
     302        v->pixclock, v->left_margin, v->right_margin, v->upper_margin, v->lower_margin,
     303            v->hsync_len, v->vsync_len,
     304        (v->accel_flags > 0 ? "true" : "false"),
     305        v->red.length, v->red.offset, v->green.length, v->green.offset,
     306            v->blue.length, v->blue.offset, v->transp.length, v->transp.offset);
    322307}
    323308
     
    325310int main(int argc, char **argv)
    326311#else
     312int fbset_main(int argc, char **argv);
    327313int fbset_main(int argc, char **argv)
    328314#endif
     
    330316    struct fb_var_screeninfo var, varset;
    331317    int fh, i;
    332     char *fbdev = DEFAULTFBDEV;
    333     char *modefile = DEFAULTFBMODE;
     318    const char *fbdev = DEFAULTFBDEV;
     319    const char *modefile = DEFAULTFBMODE;
    334320    char *thisarg, *mode = NULL;
    335321
     
    340326    argc--;
    341327    for (; argc > 0 && (thisarg = *argv); argc--, argv++) {
    342         for (i = 0; g_cmdoptions[i].name; i++) {
    343             if (!strcmp(thisarg, g_cmdoptions[i].name)) {
    344                 if (argc - 1 < g_cmdoptions[i].param_count)
    345                     bb_show_usage();
    346                 switch (g_cmdoptions[i].code) {
    347                 case CMD_FB:
    348                     fbdev = argv[1];
    349                     break;
    350                 case CMD_DB:
    351                     modefile = argv[1];
    352                     break;
    353                 case CMD_GEOMETRY:
    354                     varset.xres = strtoul(argv[1], 0, 0);
    355                     varset.yres = strtoul(argv[2], 0, 0);
    356                     varset.xres_virtual = strtoul(argv[3], 0, 0);
    357                     varset.yres_virtual = strtoul(argv[4], 0, 0);
    358                     varset.bits_per_pixel = strtoul(argv[5], 0, 0);
    359                     break;
    360                 case CMD_TIMING:
    361                     varset.pixclock = strtoul(argv[1], 0, 0);
    362                     varset.left_margin = strtoul(argv[2], 0, 0);
    363                     varset.right_margin = strtoul(argv[3], 0, 0);
    364                     varset.upper_margin = strtoul(argv[4], 0, 0);
    365                     varset.lower_margin = strtoul(argv[5], 0, 0);
    366                     varset.hsync_len = strtoul(argv[6], 0, 0);
    367                     varset.vsync_len = strtoul(argv[7], 0, 0);
    368                     break;
    369         case CMD_CHANGE:
    370             g_options |= OPT_CHANGE;
    371             break;
    372 #ifdef CONFIG_FEATURE_FBSET_FANCY
    373                 case CMD_XRES:
    374                     varset.xres = strtoul(argv[1], 0, 0);
    375                     break;
    376                 case CMD_YRES:
    377                     varset.yres = strtoul(argv[1], 0, 0);
    378                     break;
    379                case CMD_DEPTH:
    380                     varset.bits_per_pixel = strtoul(argv[1], 0, 0);
    381                     break;
    382 #endif
    383                 }
    384                 argc -= g_cmdoptions[i].param_count;
    385                 argv += g_cmdoptions[i].param_count;
    386                 break;
     328        for (i = 0; g_cmdoptions[i].name[0]; i++) {
     329            if (strcmp(thisarg, g_cmdoptions[i].name))
     330                continue;
     331            if (argc-1 < g_cmdoptions[i].param_count)
     332                bb_show_usage();
     333
     334            switch (g_cmdoptions[i].code) {
     335            case CMD_FB:
     336                fbdev = argv[1];
     337                break;
     338            case CMD_DB:
     339                modefile = argv[1];
     340                break;
     341            case CMD_GEOMETRY:
     342                varset.xres = xatou32(argv[1]);
     343                varset.yres = xatou32(argv[2]);
     344                varset.xres_virtual = xatou32(argv[3]);
     345                varset.yres_virtual = xatou32(argv[4]);
     346                varset.bits_per_pixel = xatou32(argv[5]);
     347                break;
     348            case CMD_TIMING:
     349                varset.pixclock = xatou32(argv[1]);
     350                varset.left_margin = xatou32(argv[2]);
     351                varset.right_margin = xatou32(argv[3]);
     352                varset.upper_margin = xatou32(argv[4]);
     353                varset.lower_margin = xatou32(argv[5]);
     354                varset.hsync_len = xatou32(argv[6]);
     355                varset.vsync_len = xatou32(argv[7]);
     356                break;
     357            case CMD_ALL:
     358                g_options |= OPT_ALL;
     359                break;
     360            case CMD_CHANGE:
     361                g_options |= OPT_CHANGE;
     362                break;
     363#if ENABLE_FEATURE_FBSET_FANCY
     364            case CMD_XRES:
     365                varset.xres = xatou32(argv[1]);
     366                break;
     367            case CMD_YRES:
     368                varset.yres = xatou32(argv[1]);
     369                break;
     370            case CMD_DEPTH:
     371                varset.bits_per_pixel = xatou32(argv[1]);
     372                break;
     373#endif
    387374            }
     375            argc -= g_cmdoptions[i].param_count;
     376            argv += g_cmdoptions[i].param_count;
     377            break;
    388378        }
    389         if (!g_cmdoptions[i].name) {
    390             if (argc == 1) {
    391                 mode = *argv;
    392                 g_options |= OPT_READMODE;
    393             } else {
     379        if (!g_cmdoptions[i].name[0]) {
     380            if (argc != 1)
    394381                bb_show_usage();
    395             }
     382            mode = *argv;
     383            g_options |= OPT_READMODE;
    396384        }
    397385    }
    398386
    399     fh = bb_xopen(fbdev, O_RDONLY);
    400     if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
    401         bb_perror_msg_and_die("fbset(ioctl)");
     387    fh = xopen(fbdev, O_RDONLY);
     388    xioctl(fh, FBIOGET_VSCREENINFO, &var);
    402389    if (g_options & OPT_READMODE) {
    403390        if (!readmode(&var, modefile, mode)) {
    404             bb_error_msg("Unknown video mode `%s'", mode);
    405             return EXIT_FAILURE;
     391            bb_error_msg_and_die("unknown video mode '%s'", mode);
    406392        }
    407393    }
    408394
    409395    setmode(&var, &varset);
    410     if (g_options & OPT_CHANGE)
    411         if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
    412             bb_perror_msg_and_die("fbset(ioctl)");
     396    if (g_options & OPT_CHANGE) {
     397        if (g_options & OPT_ALL)
     398            var.activate = FB_ACTIVATE_ALL;
     399        xioctl(fh, FBIOPUT_VSCREENINFO, &var);
     400    }
    413401    showmode(&var);
    414402    /* Don't close the file, as exiting will take care of that */
Note: See TracChangeset for help on using the changeset viewer.