Patch from Jon McClintock <jonm@bluemug.com>
authorEric Andersen <andersen@codepoet.org>
Wed, 12 Jul 2000 23:01:04 +0000 (23:01 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 12 Jul 2000 23:01:04 +0000 (23:01 -0000)
>The attached patch adds the ability to parse the actual mode specifier in
>fbset. So now
>
>    fbset -n 640x480-72
>
>Will actually work. I don't know if I've reinvented the wheel though...

 -Erik

fbset.c
util-linux/fbset.c

diff --git a/fbset.c b/fbset.c
index 3f36a701122898623a7a4637024c8a7938b2b914..9fde6a19d988d4ab224efcccf2fc96991fc82a8c 100644 (file)
--- a/fbset.c
+++ b/fbset.c
@@ -158,7 +158,73 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
                                        continue;       /* almost, but not quite */
                                while (!feof(f)) {
                                        fgets(buf, sizeof(buf), f);
-                                       if (!strstr(buf, "endmode"))
+
+                    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;
+                        }
+                    }
+                    
+                                       if (strstr(buf, "endmode"))
                                                return 1;
                                }
                        }
index 3f36a701122898623a7a4637024c8a7938b2b914..9fde6a19d988d4ab224efcccf2fc96991fc82a8c 100644 (file)
@@ -158,7 +158,73 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
                                        continue;       /* almost, but not quite */
                                while (!feof(f)) {
                                        fgets(buf, sizeof(buf), f);
-                                       if (!strstr(buf, "endmode"))
+
+                    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;
+                        }
+                    }
+                    
+                                       if (strstr(buf, "endmode"))
                                                return 1;
                                }
                        }