[xserver-commit] xserver/hw/kdrive/vesa Makefile.am,1.11,1.12 vesa.c,1.26,1.27 vesa.h,1.16,1.17 vesainit.c,1.10,1.11

Keith Packard xserver-commit@pdx.freedesktop.org
Sun, 02 Nov 2003 11:56:12 -0800


Committed by: keithp

Update of /cvs/xserver/xserver/hw/kdrive/vesa
In directory pdx:/tmp/cvs-serv23831/hw/kdrive/vesa

Modified Files:
	Makefile.am vesa.c vesa.h vesainit.c 
Log Message:
	merge xfixes_2_branch back to HEAD


Index: Makefile.am
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am	15 Oct 2003 04:59:45 -0000	1.11
+++ Makefile.am	2 Nov 2003 19:56:10 -0000	1.12
@@ -1,12 +1,6 @@
 INCLUDES = 					\
-	-I$(top_srcdir)/fb			\
-	-I$(top_srcdir)/hw/kdrive/src		\
-	-I$(top_srcdir)/mi			\
-	-I$(top_srcdir)/miext/layer		\
-	-I$(top_srcdir)/miext/shadow		\
-	-I$(top_srcdir)/randr			\
-	-I$(top_srcdir)/render			\
-	$(XSERVER_CFLAGS)
+	@KDRIVE_INCS@				\
+	@XSERVER_CFLAGS@
 
 noinst_LIBRARIES = libvesa.a
 
@@ -23,20 +17,9 @@
 
 Xvesa_LDADD = \
 	libvesa.a 				\
-	$(top_builddir)/dix/libdix.a		\
-	$(top_builddir)/os/libos.a		\
-	$(top_builddir)/miext/layer/liblayer.a	\
-	$(top_builddir)/hw/kdrive/src/libkdrive.a  \
-	$(top_builddir)/hw/kdrive/linux/liblinux.a  \
-	$(top_builddir)/miext/shadow/libshadow.a \
-	$(top_builddir)/randr/librandr.a	\
-	$(top_builddir)/render/librender.a	\
-	$(top_builddir)/xfixes/libxfixes.a	\
-	$(top_builddir)/fb/libfb.a		\
-	$(top_builddir)/mi/libmi.a		\
-	$(top_builddir)/Xext/libXext.a		\
-	$(top_builddir)/randr/librandr.a	\
-	$(top_builddir)/render/librender.a	\
-	$(top_builddir)/xfixes/libxfixes.a	\
-	$(top_builddir)/dix/libxpstubs.a	\
-	$(XSERVER_LIBS)
+	@KDRIVE_LIBS@				\
+	@XSERVER_LIBS@
+
+Xvesa_DEPENDENCIES = \
+	libvesa.a				\
+	@KDRIVE_LIBS@

Index: vesa.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesa.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- vesa.c	15 Oct 2003 01:00:38 -0000	1.26
+++ vesa.c	2 Nov 2003 19:56:10 -0000	1.27
@@ -463,8 +463,6 @@
     pscr->randr = screen->randr;
     pscr->shadow = vesa_shadow;
     pscr->origDepth = screen->fb[0].depth;
-    pscr->layerKind = LAYER_FB;
-
     /*
      * Compute visual support for the selected depth
      */
@@ -683,7 +681,7 @@
 vesaUpdateMono (ScreenPtr	pScreen,
 		shadowBufPtr	pBuf)
 {
-    RegionPtr	damage = &pBuf->damage;
+    RegionPtr	damage = shadowDamage(pBuf);
     PixmapPtr	pShadow = pBuf->pPixmap;
     int		nbox = REGION_NUM_RECTS (damage);
     BoxPtr	pbox = REGION_RECTS (damage);
@@ -791,30 +789,13 @@
 }
 
 void
-vesaConfigureScreen (ScreenPtr pScreen)
+vesaSetScreenSizes (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
     KdScreenInfo	*screen = pScreenPriv->screen;
-    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
-
-    KdMouseMatrix	m;
+    VesaScreenPrivPtr	pscr = screen->driver;
 
-    if (pscr->mapping == VESA_PLANAR || pscr->mapping == VESA_MONO)
-    {
-	pscr->shadow = TRUE;
-	pscr->randr = RR_Rotate_0;
-    } 
-    else if (pscr->mapping == VESA_WINDOWED)
-	pscr->shadow = TRUE;
-    else if (pscr->randr != RR_Rotate_0)
-	pscr->shadow = TRUE;
-    else
-	pscr->shadow = vesa_shadow;
-    
-    KdComputeMouseMatrix (&m, pscr->randr, 
-			  pscr->mode.XResolution, pscr->mode.YResolution);
-    
-    if (m.matrix[0][0])
+    if (pscr->randr & (RR_Rotate_0|RR_Rotate_180))
     {
 	pScreen->width = pscr->mode.XResolution;
 	pScreen->height = pscr->mode.YResolution;
@@ -828,67 +809,45 @@
 	pScreen->mmWidth = screen->height_mm;
 	pScreen->mmHeight = screen->width_mm;
     }
-    KdSetMouseMatrix (&m);
 }
 
-LayerPtr
-vesaLayerCreate (ScreenPtr pScreen)
+Bool
+vesaSetShadow (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
-    KdScreenInfo	*screen = pScreenPriv->screen;
     VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
     ShadowUpdateProc	update;
     ShadowWindowProc	window = 0;
-    PixmapPtr		pPixmap;
-    int			kind;
 
-    if (pscr->shadow)
-    {
-	if (pscr->randr != RR_Rotate_0)
-	    update = shadowUpdateRotatePacked;
+    if (pscr->randr != RR_Rotate_0)
+	update = shadowUpdateRotatePacked;
+    else
+	update = shadowUpdatePacked;
+    switch (pscr->mapping) {
+    case VESA_LINEAR:
+	window = vesaWindowLinear;
+	break;
+    case VESA_WINDOWED:
+	window = vesaWindowWindowed;
+	break;
+    case VESA_PLANAR:
+	pScreen->CreateColormap = vesaCreateColormap16;
+	if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
+	    update = shadowUpdatePlanar4x8;
+	else
+	    update = shadowUpdatePlanar4;
+	window = vesaWindowPlanar;
+	break;
+    case VESA_MONO:
+	update = vesaUpdateMono;
+	if (pscr->mode.mode < 8)
+	    window = vesaWindowCga;
 	else
-	    update = shadowUpdatePacked;
-	switch (pscr->mapping) {
-	case VESA_LINEAR:
 	    window = vesaWindowLinear;
-	    break;
-	case VESA_WINDOWED:
-	    window = vesaWindowWindowed;
-	    break;
-	case VESA_PLANAR:
-	    pScreen->CreateColormap = vesaCreateColormap16;
-	    if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
-		update = shadowUpdatePlanar4x8;
-	    else
-		update = shadowUpdatePlanar4;
-	    window = vesaWindowPlanar;
-	    break;
-	case VESA_MONO:
-	    update = vesaUpdateMono;
-	    if (pscr->mode.mode < 8)
-		window = vesaWindowCga;
-	    else
-		window = vesaWindowLinear;
-	    break;
-	}
-	
-	kind = LAYER_SHADOW;
-	pPixmap = 0;
-    }
-    else
-    {
-	kind = pscr->layerKind;
-	pPixmap = LAYER_SCREEN_PIXMAP;
-	update = 0;
-	window = 0;
+	break;
     }
-
-    if (vesa_verbose)
-	ErrorF ("Mode selected %dx%dx%d\n",
-		pScreen->width, pScreen->height, screen->fb[0].depth);
-
-    return LayerCreate (pScreen, kind, screen->fb[0].depth, 
-			pPixmap, update, window, pscr->randr, 0);
+    
+    return KdShadowSet (pScreen, pscr->randr, update, window);
 }
 
 Bool
@@ -898,11 +857,18 @@
     VesaScreenPrivPtr	pscr = screen->driver;
     int			depth, bpp, fbbpp;
     Pixel		allbits;
+    KdMouseMatrix	m;
 
     if (vesa_linear_fb)
+    {
 	pscr->mapping = VESA_LINEAR;
+	pscr->shadow = FALSE;
+    }
     else
+    {
 	pscr->mapping = VESA_WINDOWED;
+	pscr->shadow = TRUE;
+    }
     
     depth = vesaDepth (&pscr->mode);
     bpp = pscr->mode.BitsPerPixel;
@@ -963,9 +929,10 @@
 			bpp, depth);
 	}
 	pscr->randr = RR_Rotate_0;
+	pscr->shadow = TRUE;
 	break;
     default:
-	return 0;
+	return FALSE;
     }
 
     switch (fbbpp) {
@@ -978,15 +945,17 @@
 	break;
     }
     
-    screen->width = pscr->mode.XResolution;
-    screen->height = pscr->mode.YResolution;
-    screen->fb[0].depth = depth;
-    screen->fb[0].bitsPerPixel = bpp;
-    screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
-    screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / fbbpp);
+    if (pscr->randr != RR_Rotate_0)
+	pscr->shadow = TRUE;
+    
+    if (vesa_shadow)
+	pscr->shadow = vesa_shadow;
 
     if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR))
+    {
 	pscr->mapping = VESA_WINDOWED;
+	pscr->shadow = TRUE;
+    }
     
     screen->softCursor = TRUE;
 
@@ -1013,7 +982,35 @@
 	pscr->fb = NULL;
 	break;
     }
-    screen->fb[0].frameBuffer = (CARD8 *)(pscr->fb);
+    
+    KdComputeMouseMatrix (&m, pscr->randr, 
+			  pscr->mode.XResolution, pscr->mode.YResolution);
+    
+    KdSetMouseMatrix (&m);
+    
+    screen->width = pscr->mode.XResolution;
+    screen->height = pscr->mode.YResolution;
+    screen->memory_base = pscr->fb;
+    screen->memory_size = pscr->fb_size;
+    screen->fb[0].depth = depth;
+    screen->fb[0].bitsPerPixel = bpp;
+    
+    if (pscr->shadow)
+    {
+	if (!KdShadowFbAlloc (screen, 0, 
+			      pscr->randr & (RR_Rotate_90|RR_Rotate_270)))
+	    return FALSE;
+	screen->off_screen_base = screen->memory_size;
+    }
+    else
+    {
+	screen->fb[0].frameBuffer = (CARD8 *) (pscr->fb);
+	screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
+	screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) / 
+				     screen->fb[0].bitsPerPixel);
+	screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+    }
+    
     return TRUE;
 }
 
@@ -1023,6 +1020,7 @@
     VesaCardPrivPtr	    priv = screen->card->driver;
     VesaScreenPrivPtr	    pscr = screen->driver;
     
+    KdShadowFbFree (screen, 0);
     if (pscr->fb)
     {
 	if (pscr->mode.vbe)
@@ -1108,29 +1106,6 @@
     return TRUE;
 }
 
-int
-vesaLayerAdd (WindowPtr pWin, pointer value)
-{
-    ScreenPtr	    pScreen = pWin->drawable.pScreen;
-    LayerPtr	    pLayer = (LayerPtr) value;
-
-    if (!LayerWindowAdd (pScreen, pLayer, pWin))
-	return WT_STOPWALKING;
-
-    return WT_WALKCHILDREN;
-}
-
-int
-vesaLayerRemove (WindowPtr pWin, pointer value)
-{
-    ScreenPtr	    pScreen = pWin->drawable.pScreen;
-    LayerPtr	    pLayer = (LayerPtr) value;
-
-    LayerWindowRemove (pScreen, pLayer, pWin);
-
-    return WT_WALKCHILDREN;
-}
-
 Bool
 vesaRandRSetConfig (ScreenPtr		pScreen,
 		    Rotation		randr,
@@ -1150,7 +1125,6 @@
     int			oldheight;
     int			oldmmwidth;
     int			oldmmheight;
-    LayerPtr		pNewLayer;
     int			newwidth, newheight;
 
     if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
@@ -1225,54 +1199,29 @@
 	break;
     }
 
+    KdOffscreenSwapOut (screen->pScreen);
+    
     vesaUnmapFramebuffer (screen);
+    
     if (!vesaMapFramebuffer (screen))
 	goto bail3;
     
-#if 0
-    /*
-     * XXX can't switch depths yet
-     */
-    screen->fb[0].depth = depth;
-    screen->fb[0].bitsPerPixel = bpp;
-#endif
-    screen->fb[0].byteStride = mode->BytesPerScanLine;
-    screen->fb[0].pixelStride = ((mode->BytesPerScanLine * 8) / screen->fb[0].bitsPerPixel);
+    vesaSetScreenSizes (screen->pScreen);
+    
+    if (!vesaSetShadow (screen->pScreen))
+	goto bail4;
     
-    /*
-     * Compute screen geometry 
-     */
-    vesaConfigureScreen (pScreen);
-
     /*
      * Set frame buffer mapping
      */
-    if (!pscr->shadow)
-    {
-	(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
-					pScreen->width,
-					pScreen->height,
-					screen->fb[0].depth,
-					screen->fb[0].bitsPerPixel,
-					screen->fb[0].byteStride,
-					screen->fb[0].frameBuffer);
-    }
-	
-    /*
-     * Create the layer
-     */
-    pNewLayer = vesaLayerCreate (pScreen);
-    if (!pNewLayer)
-	goto bail4;
-    
-    if (WalkTree (pScreen, vesaLayerAdd, (pointer) pNewLayer) == WT_STOPWALKING)
-	goto bail5;
+    (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+				    pScreen->width,
+				    pScreen->height,
+				    screen->fb[0].depth,
+				    screen->fb[0].bitsPerPixel,
+				    screen->fb[0].byteStride,
+				    screen->fb[0].frameBuffer);
     
-    WalkTree (pScreen, vesaLayerRemove, (pointer) pscr->pLayer);
-    LayerDestroy (pScreen, pscr->pLayer);
-
-    pscr->pLayer = pNewLayer;
-
     /* set the subpixel order */
     KdSetSubpixelOrder (pScreen, pscr->randr);
 
@@ -1281,9 +1230,6 @@
 
     return TRUE;
 
-bail5:
-    WalkTree (pScreen, vesaLayerRemove, (pointer) pNewLayer);
-    LayerDestroy (pScreen, pNewLayer);
 bail4:
     vesaUnmapFramebuffer (screen);
     *pscr = oldscr;
@@ -1298,22 +1244,7 @@
 bail2:
     *pscr = oldscr;
     
-    /*
-     * Set frame buffer mapping
-     */
-    if (!pscr->shadow)
-    {
-	(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
-					pScreen->width,
-					pScreen->height,
-					screen->fb[0].depth,
-					screen->fb[0].bitsPerPixel,
-					screen->fb[0].byteStride,
-					screen->fb[0].frameBuffer);
-    }
-
     (void) vesaSetMode (pScreen, &pscr->mode);
-
 bail1:
     if (wasEnabled)
 	KdEnableScreen (pScreen);
@@ -1340,27 +1271,13 @@
 Bool
 vesaInitScreen(ScreenPtr pScreen)
 {
-    if (!LayerStartInit (pScreen))
-	return FALSE;
-    
     return TRUE;
 }
 
 Bool
 vesaFinishInitScreen (ScreenPtr pScreen)
 {
-    KdScreenPriv(pScreen);
-    VesaScreenPrivPtr	pscr = pScreenPriv->screen->driver;
-    
-    pscr->layerKind = LayerNewKind (pScreen);
-
-    if (!LayerFinishInit (pScreen))
-	return FALSE;
-
-    vesaConfigureScreen (pScreen);
-
-    pscr->pLayer = vesaLayerCreate (pScreen);
-    if (!pscr->pLayer)
+    if (!shadowSetup (pScreen))
 	return FALSE;
     
 #ifdef RANDR
@@ -1372,6 +1289,12 @@
 }
 
 Bool
+vesaCreateResources (ScreenPtr pScreen)
+{
+    return vesaSetShadow (pScreen);
+}
+
+Bool
 vesaSetMode (ScreenPtr	    pScreen,
 	     VesaModePtr    mode)
 {
@@ -1668,6 +1591,7 @@
 {
     VesaScreenPrivPtr	pscr = screen->driver;
     
+    KdShadowFbFree (screen, 0);
     vesaUnmapFramebuffer (screen);
     screen->fb[0].depth = pscr->origDepth;
 }

Index: vesa.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesa.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- vesa.h	14 Oct 2003 05:08:35 -0000	1.16
+++ vesa.h	2 Nov 2003 19:56:10 -0000	1.17
@@ -25,7 +25,7 @@
 #define _VESA_H_
 
 #include "kdrive.h"
-#include "layer.h"
+#include "shadow.h"
 #include "vm86.h"
 #ifdef RANDR
 #include "randrstr.h"
@@ -98,17 +98,92 @@
     Rotation	randr;
     int		mapping;
     int		origDepth;
-    int		layerKind;
     void	*fb;
     int		fb_size;
     CARD32	fb_phys;
-    LayerPtr	pLayer;
+    PixmapPtr	pShadow;
 } VesaScreenPrivRec, *VesaScreenPrivPtr;
 
 extern int vesa_video_mode;
 extern Bool vesa_force_mode;
 
 void
+vesaReportMode (VesaModePtr mode);
+
+VesaModePtr
+vesaGetModes (Vm86InfoPtr vi, int *ret_nmode);
+
+void
+vesaTestMode (void);
+
+void *
+vesaSetWindowPlanar(ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size);
+
+void *
+vesaSetWindowLinear (ScreenPtr	pScreen,
+		     CARD32	row,
+		     CARD32	offset,
+		     int	mode,
+		     CARD32	*size);
+
+void *
+vesaSetWindowWindowed (ScreenPtr    pScreen,
+		       CARD32	    row,
+		       CARD32	    offset,
+		       int	    mode,
+		       CARD32	    *size);
+
+void *
+vesaWindowPlanar (ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size,
+		  void	    *closure);
+
+void *
+vesaWindowLinear (ScreenPtr pScreen,
+		  CARD32    row,
+		  CARD32    offset,
+		  int	    mode,
+		  CARD32    *size,
+		  void	    *closure);
+
+void *
+vesaWindowWindowed (ScreenPtr	pScreen,
+		    CARD32	row,
+		    CARD32	offset,
+		    int		mode,
+		    CARD32	*size,
+		    void	*closure);
+
+void *
+vesaWindowCga (ScreenPtr    pScreen,
+	       CARD32	    row,
+	       CARD32	    offset,
+	       int	    mode,
+	       CARD32	    *size,
+	       void	    *closure);
+
+void
+vesaUpdateMono (ScreenPtr	pScreen,
+		shadowBufPtr	pBuf);
+
+Bool
+vesaCreateColormap16 (ColormapPtr pmap);
+
+void
+vesaSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+vesaSetShadow (ScreenPtr pScreen);
+
+
+void
 vesaListModes(void);
 
 Bool
@@ -145,12 +220,15 @@
 Bool
 vesaScreenInit(KdScreenInfo *screen);    
 
-LayerPtr
-vesaLayerCreate (ScreenPtr pScreen);
+PixmapPtr
+vesaGetPixmap (ScreenPtr pScreen);
 
 Bool
 vesaMapFramebuffer (KdScreenInfo    *screen);
 
+void
+vesaUnmapFramebuffer (KdScreenInfo  *screen);
+
 Bool
 vesaInitScreen(ScreenPtr pScreen);
 
@@ -158,6 +236,9 @@
 vesaFinishInitScreen(ScreenPtr pScreen);
 
 Bool
+vesaCreateResources (ScreenPtr pScreen);
+
+Bool
 vesaSetMode (ScreenPtr	    pScreen,
 	     VesaModePtr    mode);
 
@@ -182,6 +263,12 @@
 void
 vesaScreenFini(KdScreenInfo *screen);
 
+int 
+vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries);
+
+int 
+vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries);
+
 void
 vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
 
@@ -193,10 +280,19 @@
 
 #ifdef RANDR
 Bool
+vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
 vesaRandRSetConfig (ScreenPtr		pScreen,
 		    Rotation		randr,
 		    int			rate,
 		    RRScreenSizePtr	pSize);
+Bool
+vesaRandRInit (ScreenPtr pScreen);
+
 #endif
 
+Bool
+toshibaDPMS (ScreenPtr pScreen, int mode);
+
 #endif /* _VESA_H_ */

Index: vesainit.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/vesa/vesainit.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- vesainit.c	11 Sep 2003 05:12:51 -0000	1.10
+++ vesainit.c	2 Nov 2003 19:56:10 -0000	1.11
@@ -30,6 +30,8 @@
     vesaCardInit,               /* cardinit */
     vesaScreenInit,             /* scrinit */
     vesaInitScreen,             /* initScreen */
+    vesaFinishInitScreen,	/* finishInitScreen */
+    vesaCreateResources,	/* createRes */
     vesaPreserve,               /* preserve */
     vesaEnable,                 /* enable */
     vesaDPMS,                   /* dpms */
@@ -52,8 +54,6 @@
     
     vesaGetColors,              /* getColors */
     vesaPutColors,              /* putColors */
-
-    vesaFinishInitScreen,	/* finishInitScreen */
 };
 
 void