[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-vesa: Changes to 'upstream-experimental'



 .cvsignore      |   19 -
 .gitignore      |   20 +
 COPYING         |   30 ++
 configure.ac    |   28 +-
 man/.cvsignore  |    2 
 man/.gitignore  |    2 
 man/Makefile.am |    1 
 src/.cvsignore  |    6 
 src/.gitignore  |    6 
 src/vesa.c      |  571 ++++++++++++++++++++++++--------------------------------
 src/vesa.h      |   23 --
 11 files changed, 322 insertions(+), 386 deletions(-)

New commits:
commit c7f6d282ccbe1931f5ae6472cbfb4f80fc749525
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Dec 22 12:36:21 2008 +1000

    vesa 2.1.0

diff --git a/configure.ac b/configure.ac
index de2456a..62e710f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-vesa],
-        2.0.0,
+        2.1.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-vesa)
 

commit d994a9abbda582ccd6d38447ca2201de10cc36a5
Author: Adam Jackson <ajax@redhat.com>
Date:   Sun Nov 23 17:28:33 2008 -0500

    Make ISA support optional.

diff --git a/configure.ac b/configure.ac
index 027a5cf..de2456a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,14 @@ sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
 save_CFLAGS="$CFLAGS"
 CFLAGS="$XORG_CFLAGS"
+AC_CHECK_DECL(xf86ConfigIsaEntity,
+	      [AC_DEFINE(HAVE_ISA, 1, [Have ISA support])],
+	      [],
+	      [#include "xf86.h"])
+CFLAGS="$save_CFLAGS"
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$XORG_CFLAGS"
 AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
               [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
               [#include "xorg-server.h"])
diff --git a/src/vesa.c b/src/vesa.c
index 61461ab..2e1b2f7 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -138,10 +138,12 @@ static PciChipsets VESAPCIchipsets[] = {
 };
 #endif
 
+#ifdef HAVE_ISA
 static IsaChipsets VESAISAchipsets[] = {
   {CHIP_VESA_GENERIC, RES_EXCLUSIVE_VGA},
   {-1,		0 }
 };
+#endif
 
 
 /* 
@@ -446,6 +448,7 @@ VESAProbe(DriverPtr drv, int flags)
     }
 #endif
 
+#ifdef HAVE_ISA
     /* Isa Bus */
     numUsed = xf86MatchIsaInstances(VESA_NAME,VESAChipsets,
 				    VESAISAchipsets, drv,
@@ -465,12 +468,14 @@ VESAProbe(DriverPtr drv, int flags)
 	}
 	xfree(usedChips);
     }
+#endif
 
     xfree(devSections);
 
     return (foundScreen);
 }
 
+#ifdef HAVE_ISA
 static int
 VESAFindIsaDevice(GDevPtr dev)
 {
@@ -495,6 +500,7 @@ VESAFindIsaDevice(GDevPtr dev)
 #endif
     return (int)CHIP_VESA_GENERIC;
 }
+#endif
 
 static void
 VESAFreeRec(ScrnInfoPtr pScrn)

commit 38431c99ccb625d0fd784f86f6a8a9cdbfbf872e
Author: Luc Verhaegen <lverhaegen@ridcully.suse.de>
Date:   Thu Sep 18 16:58:59 2008 +0200

    VESASetMode: be verbose about the mode that's being set.

diff --git a/src/vesa.c b/src/vesa.c
index 2efe2d5..61461ab 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -1099,6 +1099,10 @@ VESASetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode)
 
     data = (VbeModeInfoData*)pMode->Private;
 
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+	       "Setting up VESA Mode 0x%X (%dx%d)\n",
+	       data->mode & 0x7FF, pMode->HDisplay, pMode->VDisplay);
+
     /* careful, setting the bit means don't clear the screen */
     mode = data->mode | (pVesa->ModeSetClearScreen ? 0 : (1U << 15));
 

commit e670b3e4a1102a36a01edf1fd38676b9b13fb957
Author: Julien Cristau <jcristau@debian.org>
Date:   Tue Jul 15 00:26:12 2008 +0200

    Properly define the driver version
    
    Define VESA_VERSION_MAJOR/MINOR/PATCHLEVEL using the version from
    configure.ac.

diff --git a/src/vesa.h b/src/vesa.h
index 562cd76..1b8f4e5 100644
--- a/src/vesa.h
+++ b/src/vesa.h
@@ -78,9 +78,9 @@
 #define VESA_VERSION		4000
 #define VESA_NAME		"VESA"
 #define VESA_DRIVER_NAME	"vesa"
-#define VESA_MAJOR_VERSION	1
-#define VESA_MINOR_VERSION	3
-#define VESA_PATCHLEVEL		0
+#define VESA_MAJOR_VERSION	PACKAGE_VERSION_MAJOR
+#define VESA_MINOR_VERSION	PACKAGE_VERSION_MINOR
+#define VESA_PATCHLEVEL		PACKAGE_VERSION_PATCHLEVEL
 
 /*XXX*/
 

commit 4939ada882feeafe4b2f233a4a27d6ad38d5bf99
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 14:27:48 2008 -0400

    Default VESAValidMode to returning MODE_BAD.

diff --git a/src/vesa.c b/src/vesa.c
index ffe40c5..2efe2d5 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -286,7 +286,7 @@ VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
     ScrnInfoPtr pScrn = xf86Screens[scrn];
     VESAPtr pVesa = VESAGetRec(pScrn);
     MonPtr mon = pScrn->monitor;
-    ModeStatus ret;
+    ModeStatus ret = MODE_BAD;
     DisplayModePtr mode;
     float v;
 

commit 9d27e31dca8e0bddbf82ef2f19064160cff3a59e
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 14:19:04 2008 -0400

    Add a TODO list.

diff --git a/src/vesa.c b/src/vesa.c
index b23a04e..ffe40c5 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -31,6 +31,14 @@
  *          Adam Jackson <ajax@redhat.com>
  */
 
+/*
+ * TODO:
+ * - PanelID might give us useful size hints.
+ * - Port to RANDR 1.2 setup to make mode selection slightly better
+ * - Port to RANDR 1.2 to drop the old-school DGA junk
+ * - VBE/SCI for secondary DDC method?
+ */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif

commit bcf3514b99431b6935ea568b59d94f266ccd7aeb
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 14:09:00 2008 -0400

    Warning cleanup.

diff --git a/src/vesa.c b/src/vesa.c
index 865bdb0..b23a04e 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -93,8 +93,6 @@ static void RestoreFonts(ScrnInfoPtr pScrn);
 static Bool 
 VESASaveRestore(ScrnInfoPtr pScrn, vbeSaveRestoreFunction function);
 
-static void *VESAWindowPlanar(ScreenPtr pScrn, CARD32 row, CARD32 offset,
-			      int mode, CARD32 *size, void *closure);
 static void *VESAWindowLinear(ScreenPtr pScrn, CARD32 row, CARD32 offset,
 			      int mode, CARD32 *size, void *closure);
 static void *VESAWindowWindowed(ScreenPtr pScrn, CARD32 row, CARD32 offset,
@@ -125,10 +123,12 @@ static SymTabRec VESAChipsets[] =
     {-1,		 NULL}
 };
 
+#ifndef XSERVER_LIBPCIACCESS
 static PciChipsets VESAPCIchipsets[] = {
   { CHIP_VESA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA },
   { -1,		-1,	   RES_UNDEFINED },
 };
+#endif
 
 static IsaChipsets VESAISAchipsets[] = {
   {CHIP_VESA_GENERIC, RES_EXCLUSIVE_VGA},
@@ -1232,28 +1232,6 @@ VESAUnmapVidMem(ScrnInfoPtr pScrn)
     pVesa->base = NULL;
 }
 
-void *
-VESAWindowPlanar(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode,
-		 CARD32 *size, void *closure)
-{
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    VESAPtr pVesa = VESAGetRec(pScrn);
-    VbeModeInfoBlock *data = ((VbeModeInfoData*)(pScrn->currentMode->Private))->data;
-    int window;
-    int mask = 1 << (offset & 3);
-
-    outb(pVesa->ioBase + VGA_SEQ_INDEX, 2);
-    outb(pVesa->ioBase + VGA_SEQ_DATA, mask);
-    offset = (offset >> 2) + pVesa->maxBytesPerScanline * row;
-    window = offset / (data->WinGranularity * 1024);
-    pVesa->windowAoffset = window * data->WinGranularity * 1024;
-    VESABankSwitch(pScreen, window);
-    *size = data->WinSize * 1024 - (offset - pVesa->windowAoffset);
-
-    return (void *)((unsigned long)pVesa->base +
-		   (offset - pVesa->windowAoffset));
-}
-
 static void *
 VESAWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode,
 		 CARD32 *size, void *closure)
@@ -1393,13 +1371,6 @@ ReadGr(VESAPtr pVesa, int index)
     outb(pVesa->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_INDEX_OFFSET), index); \
     outb(pVesa->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_DATA_OFFSET), value)
 
-static int
-ReadCrtc(VESAPtr pVesa, int index)
-{
-    outb(pVesa->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_INDEX_OFFSET), index);
-    return inb(pVesa->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_DATA_OFFSET));
-}
-
 static void
 SeqReset(VESAPtr pVesa, Bool start)
 {

commit ea57dcf423ebc3cb24060eebfc1943703448c320
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 14:07:15 2008 -0400

    Use VBE services for DPMS instead of banging VGA registers manually.

diff --git a/src/vesa.c b/src/vesa.c
index f0f2522..865bdb0 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -1656,45 +1656,13 @@ VESADisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
                 int flags)
 {
     VESAPtr pVesa = VESAGetRec(pScrn);
-    unsigned char seq1 = 0, crtc17 = 0;
 
     if (!pScrn->vtSema)
 	return;
 
-    switch (mode) {
-	case DPMSModeOn:
-	    /* Screen: On; HSync: On, VSync: On */
-	    seq1 = 0x00;
-	    crtc17 = 0x80;
-	    break;
-	case DPMSModeStandby:
-	    /* Screen: Off; HSync: Off, VSync: On -- Not Supported */
-	    seq1 = 0x20;
-	    crtc17 = 0x80;
-	    break;
-	case DPMSModeSuspend:
-	    /* Screen: Off; HSync: On, VSync: Off -- Not Supported */
-	    seq1 = 0x20;
-	    crtc17 = 0x80;
-	    break;
-	case DPMSModeOff:
-	    /* Screen: Off; HSync: Off, VSync: Off */
-	    seq1 = 0x20;
-	    crtc17 = 0x00;
-	    break;
-    }
-    WriteSeq(0x00, 0x01);		  /* Synchronous Reset */
-    seq1 |= ReadSeq(pVesa, 0x01) & ~0x20;
-    WriteSeq(0x01, seq1);
-    crtc17 |= ReadCrtc(pVesa, 0x17) & ~0x80;
-    usleep(10000);
-    WriteCrtc(0x17, crtc17);
-    WriteSeq(0x00, 0x03);		  /* End Reset */
+    VBEDPMSSet(pVesa->pVbe, mode);
 }
 
-
-
-
 /***********************************************************************
  * DGA stuff
  ***********************************************************************/

commit 3631892e0c53568b9f6b0c4aeacd2354305376e6
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 13:41:07 2008 -0400

    vesa 2.0.0

diff --git a/configure.ac b/configure.ac
index 84d19b0..027a5cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-vesa],
-        1.99.1,
+        2.0.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-vesa)
 

commit eb4216dbb392a78d15cde8232d4d951ad876518e
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 13:40:16 2008 -0400

    Un-duplicate some init code.

diff --git a/src/vesa.c b/src/vesa.c
index fbaad21..f0f2522 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -352,6 +352,23 @@ VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
     return ret;
 }
 
+static void
+VESAInitScrn(ScrnInfoPtr pScrn)
+{
+    pScrn->driverVersion = VESA_VERSION;
+    pScrn->driverName    = VESA_DRIVER_NAME;
+    pScrn->name		 = VESA_NAME;
+    pScrn->Probe	 = VESAProbe;
+    pScrn->PreInit       = VESAPreInit;
+    pScrn->ScreenInit    = VESAScreenInit;
+    pScrn->SwitchMode    = VESASwitchMode;
+    pScrn->ValidMode     = VESAValidMode;
+    pScrn->AdjustFrame   = VESAAdjustFrame;
+    pScrn->EnterVT       = VESAEnterVT;
+    pScrn->LeaveVT       = VESALeaveVT;
+    pScrn->FreeScreen    = VESAFreeScreen;
+}
+
 /*
  * This function is called once, at the start of the first server generation to
  * do a minimal probe for supported hardware.
@@ -369,22 +386,10 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
     if (pScrn != NULL) {
 	VESAPtr pVesa = VESAGetRec(pScrn);
 
-	pScrn->driverVersion = VESA_VERSION;
-	pScrn->driverName    = VESA_DRIVER_NAME;
-	pScrn->name	     = VESA_NAME;
-	pScrn->Probe	     = VESAProbe;
-	pScrn->PreInit       = VESAPreInit;
-	pScrn->ScreenInit    = VESAScreenInit;
-	pScrn->SwitchMode    = VESASwitchMode;
-	pScrn->ValidMode     = VESAValidMode;
-	pScrn->AdjustFrame   = VESAAdjustFrame;
-	pScrn->EnterVT       = VESAEnterVT;
-	pScrn->LeaveVT       = VESALeaveVT;
-	pScrn->FreeScreen    = VESAFreeScreen;
-	
+	VESAInitScrn(pScrn);
 	pVesa->pciInfo = dev;
     }
-    
+
     return (pScrn != NULL);
 }
 #endif
@@ -423,18 +428,7 @@ VESAProbe(DriverPtr drv, int flags)
 		    if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
 						     VESAPCIchipsets,NULL,
 						     NULL,NULL,NULL,NULL))) {
-			pScrn->driverVersion = VESA_VERSION;
-			pScrn->driverName    = VESA_DRIVER_NAME;
-			pScrn->name	     = VESA_NAME;
-			pScrn->Probe	     = VESAProbe;
-			pScrn->PreInit       = VESAPreInit;
-			pScrn->ScreenInit    = VESAScreenInit;
-			pScrn->SwitchMode    = VESASwitchMode;
-			pScrn->ValidMode     = VESAValidMode;
-			pScrn->AdjustFrame   = VESAAdjustFrame;
-			pScrn->EnterVT       = VESAEnterVT;
-			pScrn->LeaveVT       = VESALeaveVT;
-			pScrn->FreeScreen    = VESAFreeScreen;
+			VESAInitScrn(pScrn);
 			foundScreen = TRUE;
 		    }
 		}
@@ -457,19 +451,7 @@ VESAProbe(DriverPtr drv, int flags)
 	    if ((pScrn = xf86ConfigIsaEntity(pScrn, 0,usedChips[i],
 					     VESAISAchipsets, NULL,
 					     NULL, NULL, NULL, NULL))) {
-	    
-		pScrn->driverVersion = VESA_VERSION;
-		pScrn->driverName    = VESA_DRIVER_NAME;
-		pScrn->name	     = VESA_NAME;
-		pScrn->Probe	     = VESAProbe;
-		pScrn->PreInit       = VESAPreInit;
-		pScrn->ScreenInit    = VESAScreenInit;
-		pScrn->SwitchMode    = VESASwitchMode;
-		pScrn->ValidMode     = VESAValidMode;
-		pScrn->AdjustFrame   = VESAAdjustFrame;
-		pScrn->EnterVT       = VESAEnterVT;
-		pScrn->LeaveVT       = VESALeaveVT;
-		pScrn->FreeScreen    = VESAFreeScreen;
+		VESAInitScrn(pScrn);
 		foundScreen = TRUE;
 	    }
 	}

commit 8ec1f02475bc4267050239c6840fa6738b0caefb
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Jul 1 13:23:31 2008 -0400

    Remove unused ->device

diff --git a/src/vesa.c b/src/vesa.c
index bcde762..fbaad21 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -565,8 +565,6 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 
     pVesa = VESAGetRec(pScrn);
     pVesa->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
-    pVesa->device = xf86GetDevFromEntity(pScrn->entityList[0],
-					 pScrn->entityInstanceList[0]);
 
     /* Load vbe module */
     if (!xf86LoadSubModule(pScrn, "vbe"))
diff --git a/src/vesa.h b/src/vesa.h
index f6a03fb..562cd76 100644
--- a/src/vesa.h
+++ b/src/vesa.h
@@ -90,7 +90,6 @@ typedef struct _VESARec
     EntityInfoPtr pEnt;
     CARD16 major, minor;
     VbeInfoBlock *vbeInfo;
-    GDevPtr device;
 #ifdef XSERVER_LIBPCIACCESS
     struct pci_device *pciInfo;
 #else

commit 1f1e72fd965443e61ec10442044f554afd77db36
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 15:22:14 2008 -0400

    vesa 1.99.1

diff --git a/configure.ac b/configure.ac
index 876bc07..84d19b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-vesa],
-        1.3.0,
+        1.99.1,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-vesa)
 

commit 419b7d46f2abab5506c89f3b2b3e7a50a5dbf3a7
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 14:30:51 2008 -0400

    Update copyright.

diff --git a/src/vesa.c b/src/vesa.c
index cb1be0d..bcde762 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -1,6 +1,7 @@
 #define DEBUG_VERB 2
 /*
  * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * Copyright 2008 Red Hat, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -27,7 +28,7 @@
  *
  * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
  *          David Dawes <dawes@xfree86.org>
- *
+ *          Adam Jackson <ajax@redhat.com>
  */
 
 #ifdef HAVE_CONFIG_H

commit f807c82506f42c1e1fa63cfa56d7c79b653e46f8
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 14:19:12 2008 -0400

    Clean up memory model checking, and properly refuse unsupported models.

diff --git a/src/vesa.c b/src/vesa.c
index 974a94d..cb1be0d 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -764,17 +764,8 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 
     mode = ((VbeModeInfoData*)pScrn->modes->Private)->data;
     switch (mode->MemoryModel) {
-	case 0x0:	/* Text mode */
-	case 0x1:	/* CGA graphics */
-	case 0x2:	/* Hercules graphics */
-	case 0x3:	/* Planar */
-	case 0x5:	/* Non-chain 4, 256 color */
-	case 0x7:	/* YUV */
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Unsupported Memory Model: %d", mode->MemoryModel);
-	    break;
 	case 0x4:	/* Packed pixel */
-	case 0x6:	/*  Direct Color */
+	case 0x6:	/* Direct Color */
 	    pScrn->bitmapBitOrder = BITMAP_BIT_ORDER; 
 
 	    switch (pScrn->bitsPerPixel) {
@@ -790,6 +781,10 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 		    return FALSE;
 	    }
 	    break;
+	default:
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		       "Unsupported Memory Model: %d", mode->MemoryModel);
+	    return FALSE;
     }
 
     if (pVesa->shadowFB) {
@@ -925,17 +920,8 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
     mode = ((VbeModeInfoData*)pScrn->modes->Private)->data;
     switch (mode->MemoryModel) {
-	case 0x0:	/* Text mode */
-	case 0x1:	/* CGA graphics */
-	case 0x2:	/* Hercules graphics */
-	case 0x3:	/* Planar */
-	case 0x5:	/* Non-chain 4, 256 color */
-	case 0x7:	/* YUV */
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Unsupported Memory Model: %d", mode->MemoryModel);
-	    return (FALSE);
 	case 0x4:	/* Packed pixel */
-	case 0x6:	/*  Direct Color */
+	case 0x6:	/* Direct Color */
 	    switch (pScrn->bitsPerPixel) {
 		case 8:
 		case 16:
@@ -955,6 +941,10 @@ VESAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 		    return (FALSE);
 	    }
 	    break;
+	default:
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		       "Unsupported Memory Model: %d", mode->MemoryModel);
+	    return (FALSE);
     }
 
 

commit 99d2cc8676a93ec21f5ca1cec3525a8dff8a6acd
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 14:16:52 2008 -0400

    Add semi-reasonable mode validation.

diff --git a/src/vesa.c b/src/vesa.c
index 8595798..974a94d 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -47,6 +47,7 @@
 /* Colormap handling */
 #include "micmap.h"
 #include "xf86cmap.h"
+#include "xf86Modes.h"
 
 /* DPMS */
 #define DPMS_SERVER
@@ -228,6 +229,128 @@ VESAIdentify(int flags)
     xf86PrintChipsets(VESA_NAME, "driver for VESA chipsets", VESAChipsets);
 }
 
+static VESAPtr
+VESAGetRec(ScrnInfoPtr pScrn)
+{
+    if (!pScrn->driverPrivate)
+	pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1);
+
+    return ((VESAPtr)pScrn->driverPrivate);
+}
+
+/* Only a little like VBESetModeParameters */
+static void
+VESASetModeParameters(vbeInfoPtr pVbe, DisplayModePtr vbemode,
+		      DisplayModePtr ddcmode)
+{
+    VbeModeInfoData *data;
+    int clock;
+
+    data = (VbeModeInfoData *)vbemode->Private;
+
+    data->block = xcalloc(sizeof(VbeCRTCInfoBlock), 1);
+    data->block->HorizontalTotal = ddcmode->HTotal;
+    data->block->HorizontalSyncStart = ddcmode->HSyncStart;
+    data->block->HorizontalSyncEnd = ddcmode->HSyncEnd;
+    data->block->VerticalTotal = ddcmode->VTotal;
+    data->block->VerticalSyncStart = ddcmode->VSyncStart;
+    data->block->VerticalSyncEnd = ddcmode->VSyncEnd;
+    data->block->Flags = ((ddcmode->Flags & V_NHSYNC) ? CRTC_NHSYNC : 0) |
+	                 ((ddcmode->Flags & V_NVSYNC) ? CRTC_NVSYNC : 0);
+    data->block->PixelClock = ddcmode->Clock * 1000;
+
+    /* ask the BIOS to figure out the real clock */
+    clock = VBEGetPixelClock(pVbe, data->mode, data->block->PixelClock);
+    if (clock)
+	data->block->PixelClock = clock;
+
+    data->mode |= (1 << 11);
+    data->block->RefreshRate = 100 * ((double)(data->block->PixelClock) /
+				(double)(ddcmode->HTotal * ddcmode->VTotal));
+}
+
+static ModeStatus
+VESAValidMode(int scrn, DisplayModePtr p, Bool flag, int pass)
+{
+    static int warned = 0;
+    int found = 0;
+    ScrnInfoPtr pScrn = xf86Screens[scrn];
+    VESAPtr pVesa = VESAGetRec(pScrn);
+    MonPtr mon = pScrn->monitor;
+    ModeStatus ret;
+    DisplayModePtr mode;
+    float v;
+
+    pVesa = VESAGetRec(pScrn);
+
+    if (pass != MODECHECK_FINAL) {
+	if (!warned) {
+	    xf86DrvMsg(scrn, X_WARNING, "VESAValidMode called unexpectedly\n");
+	    warned = 1;
+	}
+	return MODE_OK;
+    }
+
+    /*
+     * This is suboptimal.  We pass in just the barest description of a mode
+     * we can get away with to VBEValidateModes, so it can't really throw
+     * out anything we give it.  But we need to filter the list so that we
+     * don't populate the mode list with things the monitor can't do.
+     *
+     * So first off, if this isn't a mode we handed to the server (ie,
+     * M_T_BUILTIN), then we know we can't do it.
+     */
+    if (!(p->type & M_T_BUILTIN))
+	return MODE_NOMODE;
+
+    if (pVesa->strict_validation) {
+	/*
+	 * If it's our first pass at mode validation, we'll try for a strict
+	 * intersection between the VBE and DDC mode lists.
+	 */
+	if (pScrn->monitor->DDC) {
+	    for (mode = pScrn->monitor->Modes; mode; mode = mode->next) {
+		if (mode->type & M_T_DRIVER && 
+			mode->HDisplay == p->HDisplay &&
+			mode->VDisplay == p->VDisplay) {
+		    if (xf86CheckModeForMonitor(mode, mon) == MODE_OK) {
+			found = 1;
+			break;
+		    }
+		}
+		if (mode == pScrn->monitor->Last)
+		    break;
+	    }
+	    if (!found)
+		return MODE_NOMODE;
+
+	    /* having found a matching mode, stash the CRTC values aside */
+	    VESASetModeParameters(pVesa->pVbe, p, mode);
+	    return MODE_OK;
+	}
+
+	/* No DDC and no modes make Homer something something... */
+	return MODE_NOMODE;
+    }
+
+    /*
+     * Finally, walk through the vsync rates 1Hz at a time looking for a mode
+     * that will fit.  This is assuredly a terrible way to do this, but
+     * there's no obvious method for computing a mode of a given size that
+     * will pass xf86CheckModeForMonitor.  XXX this path is terrible, but
+     * then, by this point, you're well into despair territory.
+     */
+    for (v = mon->vrefresh[0].lo; v <= mon->vrefresh[0].hi; v++) {
+	mode = xf86GTFMode(p->HDisplay, p->VDisplay, v, 0, 0);
+	ret = xf86CheckModeForMonitor(mode, mon);
+	xfree(mode);
+	if (ret == MODE_OK)
+	    break;
+    }
+
+    return ret;
+}
+
 /*
  * This function is called once, at the start of the first server generation to
  * do a minimal probe for supported hardware.
@@ -252,6 +375,7 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
 	pScrn->PreInit       = VESAPreInit;
 	pScrn->ScreenInit    = VESAScreenInit;
 	pScrn->SwitchMode    = VESASwitchMode;
+	pScrn->ValidMode     = VESAValidMode;
 	pScrn->AdjustFrame   = VESAAdjustFrame;
 	pScrn->EnterVT       = VESAEnterVT;
 	pScrn->LeaveVT       = VESALeaveVT;
@@ -305,6 +429,7 @@ VESAProbe(DriverPtr drv, int flags)
 			pScrn->PreInit       = VESAPreInit;
 			pScrn->ScreenInit    = VESAScreenInit;
 			pScrn->SwitchMode    = VESASwitchMode;
+			pScrn->ValidMode     = VESAValidMode;
 			pScrn->AdjustFrame   = VESAAdjustFrame;
 			pScrn->EnterVT       = VESAEnterVT;
 			pScrn->LeaveVT       = VESALeaveVT;
@@ -339,6 +464,7 @@ VESAProbe(DriverPtr drv, int flags)
 		pScrn->PreInit       = VESAPreInit;
 		pScrn->ScreenInit    = VESAScreenInit;
 		pScrn->SwitchMode    = VESASwitchMode;
+		pScrn->ValidMode     = VESAValidMode;
 		pScrn->AdjustFrame   = VESAAdjustFrame;
 		pScrn->EnterVT       = VESAEnterVT;
 		pScrn->LeaveVT       = VESALeaveVT;
@@ -379,15 +505,6 @@ VESAFindIsaDevice(GDevPtr dev)
     return (int)CHIP_VESA_GENERIC;
 }
 
-static VESAPtr
-VESAGetRec(ScrnInfoPtr pScrn)
-{
-    if (!pScrn->driverPrivate)
-	pScrn->driverPrivate = xcalloc(sizeof(VESARec), 1);
-
-    return ((VESAPtr)pScrn->driverPrivate);
-}
-
 static void
 VESAFreeRec(ScrnInfoPtr pScrn)
 {
@@ -569,6 +686,7 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 
     VBESetModeNames(pScrn->modePool);
 
+    pVesa->strict_validation = TRUE;
     i = VBEValidateModes(pScrn, NULL, pScrn->display->modes, 
 			  NULL, NULL, 0, 2048, 1, 0, 2048,
 			  pScrn->display->virtualX,
@@ -576,6 +694,20 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 			  pVesa->mapSize, LOOKUP_BEST_REFRESH);
 
     if (i <= 0) {
+	DisplayModePtr mode;
+	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		"No valid modes left.  Trying less strict filter...\n");
+	for (mode = pScrn->monitor->Modes; mode; mode = mode->next)
+	    mode->status = MODE_OK;
+	pVesa->strict_validation = FALSE;
+	i = VBEValidateModes(pScrn, NULL, pScrn->display->modes, 
+		NULL, NULL, 0, 2048, 1, 0, 2048,
+		pScrn->display->virtualX,
+		pScrn->display->virtualY,
+		pVesa->mapSize, LOOKUP_BEST_REFRESH);
+    }
+
+    if (i <= 0) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes\n");
         vbeFree(pVesa->pVbe);
 	return (FALSE);
@@ -627,7 +759,7 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 			     FALSE))
 	pVesa->ModeSetClearScreen = TRUE;
 
-    if (!pVesa->defaultRefresh)
+    if (!pVesa->defaultRefresh && !pVesa->strict_validation)
 	VBESetModeParameters(pScrn, pVesa->pVbe);
 
     mode = ((VbeModeInfoData*)pScrn->modes->Private)->data;
diff --git a/src/vesa.h b/src/vesa.h
index 6c5b8c0..f6a03fb 100644
--- a/src/vesa.h
+++ b/src/vesa.h
@@ -108,7 +108,7 @@ typedef struct _VESARec
     CARD32 *pal, *savedPal;
     CARD8 *fonts;
     xf86MonPtr monitor;
-    Bool shadowFB;
+    Bool shadowFB, strict_validation;
     CARD32 windowAoffset;
     /* Don't override the default refresh rate. */
     Bool defaultRefresh;

commit 1a256385169d61c6f42cb6f6d0eb1688570fd79e
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 12:06:04 2008 -0400

    Prefer a more modern depth/bpp selection.
    
    24+32, then 24+24, then 16, 15, 8, 4, 1.
    
    See also Red Hat bugs #427383, #445566.

diff --git a/src/vesa.c b/src/vesa.c
index 3ac47e2..8595798 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -439,6 +439,7 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
     int i;
     int flags24 = 0;
     int defaultDepth = 0;
+    int defaultBpp = 0;
     int depths = 0;
 
     if (flags & PROBE_DETECT)
@@ -485,31 +486,29 @@ VESAPreInit(ScrnInfoPtr pScrn, int flags)
 				    V_MODETYPE_VBE);
 
     /* Preferred order for default depth selection. */
-    if (depths & V_DEPTH_16)
+    if (depths & V_DEPTH_24)
+	defaultDepth = 24;
+    else if (depths & V_DEPTH_16)
 	defaultDepth = 16;
     else if (depths & V_DEPTH_15)
 	defaultDepth = 15;
     else if (depths & V_DEPTH_8)
 	defaultDepth = 8;
-    else if (depths & V_DEPTH_24)
-	defaultDepth = 24;
     else if (depths & V_DEPTH_4)
 	defaultDepth = 4;
     else if (depths & V_DEPTH_1)
 	defaultDepth = 1;
 
-    /*
-     * Setting this avoids a "Driver can't support depth 24" message,
-     * which could be misleading.
-     */
-    if (!flags24)
-	flags24 = Support24bppFb;
+    if (defaultDepth == 24 && !(flags24 & Support32bppFb))
+	defaultBpp = 24;
 
-    /* Prefer 24bpp for fb since it potentially allows larger modes. */
+    /* Prefer 32bpp because 1999 called and wants its packed pixels back */
+    if (flags24 & Support32bppFb)
+	flags24 |= SupportConvert24to32 | PreferConvert24to32;
     if (flags24 & Support24bppFb)
-	flags24 |= SupportConvert32to24 | PreferConvert32to24;
+	flags24 |= SupportConvert32to24;
 
-    if (!xf86SetDepthBpp(pScrn, defaultDepth, 0, 0, flags24)) {
+    if (!xf86SetDepthBpp(pScrn, defaultDepth, 0, defaultBpp, flags24)) {
         vbeFree(pVesa->pVbe);
 	return (FALSE);
     }

commit 2760e3e9163768aea85d188ae23b7d9e4e89944b
Author: Adam Jackson <ajax@redhat.com>
Date:   Thu Jun 12 11:31:00 2008 -0400

    Remove some useless module loading cruft.

diff --git a/src/vesa.c b/src/vesa.c
index 42eb3bd..3ac47e2 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -28,7 +28,6 @@
  * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
  *          David Dawes <dawes@xfree86.org>
  *
- * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vesa/vesa.c,v 1.40 2003/11/03 05:11:45 tsi Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -173,57 +172,7 @@ static const OptionInfoRec VESAOptions[] = {
     { -1,		   NULL,		OPTV_NONE,	{0},	FALSE }
 };
 
-/*
- * List of symbols from other modules that this module references.  This
- * list is used to tell the loader that it is OK for symbols here to be
- * unresolved providing that it hasn't been told that they haven't been
- * told that they are essential via a call to xf86LoaderReqSymbols() or
- * xf86LoaderReqSymLists().  The purpose is this is to avoid warnings about
- * unresolved symbols that are not required.
- */
-static const char *fbSymbols[] = {
-    "fbPictureInit",
-    "fbScreenInit",
-    NULL
-};
-
-static const char *shadowSymbols[] = {
-    "shadowInit",
-    "shadowUpdatePackedWeak",
-    "shadowUpdatePlanar4Weak",
-    "shadowUpdatePlanar4x8Weak",
-    NULL
-};
-
-static const char *vbeSymbols[] = {
-    "VBEBankSwitch",
-    "VBEExtendedInit",
-    "VBEFindSupportedDepths",
-    "VBEGetModeInfo",
-    "VBEGetVBEInfo",
-    "VBEGetVBEMode",
-    "VBEPrintModes",
-    "VBESaveRestore",
-    "VBESetDisplayStart",
-    "VBESetGetDACPaletteFormat",
-    "VBESetGetLogicalScanlineLength",
-    "VBESetGetPaletteData",
-    "VBESetModeNames",
-    "VBESetModeParameters",
-    "VBESetVBEMode",
-    "VBEValidateModes",
-    "vbeDoEDID",
-    "vbeFree",
-    NULL
-};
-
 #ifdef XFree86LOADER
-static const char *ddcSymbols[] = {
-    "xf86PrintEDID",
-    "xf86SetDDCproperties",
-    NULL
-};
-
 
 /* Module loader interface */
 static MODULESETUPPROTO(vesaSetup);
@@ -257,11 +206,6 @@ vesaSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor)
     {
 	Initialised = TRUE;
 	xf86AddDriver(&VESA, Module, 1);
-	LoaderRefSymLists(fbSymbols,
-			  shadowSymbols,
-			  vbeSymbols,
-			  ddcSymbols,
-			  NULL);
 	return (pointer)TRUE;
     }


Reply to: