Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Apr 2017 14:49:19 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317142 - head/sys/dev/fb
Message-ID:  <201704191449.v3JEnJl1039274@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Wed Apr 19 14:49:18 2017
New Revision: 317142
URL: https://svnweb.freebsd.org/changeset/base/317142

Log:
  When we don't use the parameter table in the BIOS, also don't use most
  of our tweaked modes based on it.  In practice, this means limiting the
  tweaked modes to at most 80x50 based on 80x25, so there are no 90-column,
  80x30 or 80x60 modes.
  
  This happens when the the initial mode is is not in the parameter
  table.  We always detected this case, but assumed that the (necessarily
  nonstandard) parameters of the initial mode could be tweaked just as
  blindly as the probably-standard parameters of initial modes in the
  table.
  
  On 1 laptop system with near-VGA where the initial mode is nonstandard,
  this is because the hardware apparently doesn't support 9-bit mode,
  but otherwise has standard timing.  The initial mode has 8-bit mode
  CRTC horizontal parameters similar to those in syscons' 90-column modes
  and in EGA modes.  Tweaking these values for the 90-column modes has
  little effect except to print the extra 10 columns off the screen.
  Tweaking from 80x25 to 80x30 requires changing from 400 scan lines to
  480.  This can probably be made to work, but syscons blindly applies
  values based on standard timing.  This gives blank output.  Tweaking
  from 80x25 to 80x50 doesn't change the CRTC timing and works.

Modified:
  head/sys/dev/fb/vga.c

Modified: head/sys/dev/fb/vga.c
==============================================================================
--- head/sys/dev/fb/vga.c	Wed Apr 19 14:43:51 2017	(r317141)
+++ head/sys/dev/fb/vga.c	Wed Apr 19 14:49:18 2017	(r317142)
@@ -939,7 +939,7 @@ probe_adapters(void)
 #if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
     u_char *mp;
 #endif
-    int i;
+    int height, i, width;
 
     /* do this test only once */
     if (vga_init_done)
@@ -1134,15 +1134,34 @@ probe_adapters(void)
 		case COMP_DIFFERENT:
 		default:
 		    /*
-		     * Don't use the parameter table in BIOS. It doesn't
-		     * look familiar to us. Video mode switching is allowed
-		     * only if the new mode is the same as or based on
-		     * the initial mode. 
+		     * Don't use the parameter table in the BIOS, since
+		     * even the BIOS doesn't use it for the initial mode.
+		     * Restrict the tweaked modes to (in practice) 80x50
+		     * from 80x25 with 400 scan lines, since the only safe
+		     * tweak is changing the characters from 8x16 to 8x8.
 		     */
 		    video_mode_ptr = NULL;
 		    bzero(mode_map, sizeof(mode_map));
 		    mode_map[adp->va_initial_mode] = adpstate.regs;
 		    rows_offset = 1;
+
+		    width = height = -1;
+		    for (i = 0; i < nitems(bios_vmode); ++i) {
+			if (bios_vmode[i].vi_mode == adp->va_initial_mode) {
+			    width = bios_vmode[i].vi_width;
+			    height = bios_vmode[i].vi_height;
+			    break;
+			}
+		    }
+		    for (i = 0; i < nitems(bios_vmode); ++i) {
+			if (bios_vmode[i].vi_mode != adp->va_initial_mode &&
+			    map_mode_num(bios_vmode[i].vi_mode) ==
+			     adp->va_initial_mode &&
+			    (bios_vmode[i].vi_width != width ||
+			     bios_vmode[i].vi_height != 2 * height)) {
+			    bios_vmode[i].vi_mode = NA;
+			}
+		    }
 		    break;
 		}
 	    }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704191449.v3JEnJl1039274>