[AD] fbcon patch, for mode timings

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


This patch makes the fbcon driver able to tweak the mode timings
when it sets a video mode.  Normally it just leaves the timings
how they were before, but this isn't right with the Matrox
driver at least -- the sync rates in low resolution modes go
through the roof, and in high resolution modes the screen
flickers or goes into power saving mode.

I think this is a problem with the Allegro fbcon driver, because
I can't see any way in the fbcon API to ask it to fill the
values in itself; I can't see how it is supposed to know that
Allegro wants it to, so it must assume the passed values (which
are what it returned in querying the startup mode) are what
Allegro wants.

This patch makes the fbcon driver look in the config file for
mode information.  It's very easy to write this information,
based on either fbset data (in fb.modes) or X modelines.  I
mentioned in the sample allegro.cfg how to convert fb.modes
data; to convert X modelines, see the kernel documentation:

    /usr/src/linux/Documentation/fb/framebuffer.txt

where it describes converting X data to fbset data, and continue
from there.

I think I'm going to make the setup program auto-convert
information from fb.modes, maybe provide a dotclock probing
system, and probably provide an equivalent of xvidtune.

Again, I'd appreciate it if you could Cc any comments to me as
well as the list, because I can't receive mail from canvaslink
at the moment.

-- 
George

diff -urN allegro-3.9.24-4/allegro.cfg allegro-3.9.24-5/allegro.cfg
--- allegro-3.9.24-4/allegro.cfg	Tue Jul 20 23:38:19 1999
+++ allegro-3.9.24-5/allegro.cfg	Fri Jul 23 17:58:13 1999
@@ -67,6 +67,22 @@
 
 framebuffer =
 
+# Still Linux/fbcon only: mode timings.  Duplicate then fill in `X', `Y' and 
+# the timings themselves.  You can copy them from fb.modes directly -- the
+# first two figures on the geometry line are X and Y here, and the figures
+# on the timings line are the first fields here (up to `vsync_len').
+
+[fb_mode_XxY]
+pixclock = 
+left_margin = 
+right_margin = 
+upper_margin = 
+lower_margin = 
+hsync_len = 
+vsync_len = 
+vmode = 
+sync = (unused)
+
 
 
 # Keyboard mapping file (this can be a .cfg file on disk, or an object from
diff -urN allegro-3.9.24-4/src/linux/fbcon.c allegro-3.9.24-5/src/linux/fbcon.c
--- allegro-3.9.24-4/src/linux/fbcon.c	Tue Jul 20 23:38:19 1999
+++ allegro-3.9.24-5/src/linux/fbcon.c	Fri Jul 23 17:43:01 1999
@@ -88,6 +88,10 @@
 
 
 
+
+static void update_timings(struct fb_var_screeninfo *mode);
+
+
 /* fb_init:
  *  Sets a graphics mode.
  */
@@ -224,6 +228,9 @@
       my_mode.green.msb_right = 0;
       my_mode.blue.msb_right = 0;
 
+      /* fill in the timings */
+      update_timings(&my_mode);
+
       /* try to set the mode */
       if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0)
 	 goto got_a_nice_mode;
@@ -515,6 +522,73 @@
    fb_vsync();
 
    ioctl(fbfd, FBIOPUTCMAP, &cmap);
+}
+
+
+
+char _fb_config_section[1024];
+int  _fb_pixclock;
+int  _fb_left_margin;
+int  _fb_right_margin;
+int  _fb_upper_margin;
+int  _fb_lower_margin;
+int  _fb_hsync_len;
+int  _fb_vsync_len;
+int  _fb_vmode;
+int  _fb_sync;
+
+
+
+/* update_timings:
+ *  Updates the timing section of the mode info.  Maybe we can make
+ *  this algorithmic, as a backup, at some point.  For now it searches
+ *  the config file for the data.
+ *  
+ *  We could make the init routine give up if the data isn't there, or 
+ *  use an algorithmic guesser. 
+ *  
+ *  If we go right ahead with this system, I think the setup program 
+ *  should offer quite a few options -- dotclock probing might be useful,
+ *  along with the functionality of xvidtune.
+ */
+static void update_timings(struct fb_var_screeninfo *mode)
+{
+   char sec[1024], buffer[1024], *x;
+
+   usprintf(sec, get_config_text("fb_mode_%dx%d"), mode->xres, mode->yres);
+
+   #define get_info(info) mode->info = get_config_int(sec, uconvert_ascii(#info, buffer), mode->info)
+   get_info(pixclock);
+   get_info(left_margin);
+   get_info(right_margin);
+   get_info(upper_margin);
+   get_info(lower_margin);
+   get_info(hsync_len);
+   get_info(vsync_len);
+   #undef get_info
+
+   if ((x = get_config_string(sec, uconvert_ascii("vmode", buffer), NULL))) {
+      if (!ustrcmp (x, "none"))
+	 mode->vmode = FB_VMODE_NONINTERLACED;
+      else if (!ustrcmp (x, "interlaced"))
+	 mode->vmode = FB_VMODE_INTERLACED;
+      else if (!ustrcmp (x, "doublescan"))
+	 mode->vmode = FB_VMODE_DOUBLE;
+   }
+
+   /* TODO -- sync? */
+
+   /* for debugging, maybe for the setup program too */
+   ustrcpy (_fb_config_section, sec);
+   _fb_pixclock = mode->pixclock;
+   _fb_left_margin = mode->left_margin;
+   _fb_right_margin = mode->right_margin;
+   _fb_upper_margin = mode->upper_margin;
+   _fb_lower_margin = mode->lower_margin;
+   _fb_hsync_len = mode->hsync_len;
+   _fb_vsync_len = mode->vsync_len;
+   _fb_vmode = mode->vmode;
+   _fb_sync = mode->sync;
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/