From 91a30d5622174febaa2107b010effcf2fb5b9a2e Mon Sep 17 00:00:00 2001
From: marha <marha@users.sourceforge.net>
Date: Fri, 8 Jan 2010 13:17:02 +0000
Subject: Git update 8 jan 2010

---
 xorg-server/hw/kdrive/ephyr/ephyr.c      | 131 ++++++++++++++++---------------
 xorg-server/hw/kdrive/ephyr/ephyr.h      |   6 +-
 xorg-server/hw/kdrive/ephyr/ephyr_draw.c |   7 +-
 xorg-server/hw/kdrive/ephyr/ephyrinit.c  |  15 ++--
 xorg-server/hw/kdrive/ephyr/ephyrvideo.c |   2 +-
 5 files changed, 85 insertions(+), 76 deletions(-)

(limited to 'xorg-server/hw/kdrive/ephyr')

diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index b6a2adaff..b21559bba 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -101,77 +101,77 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
     }
 
   if (EphyrWantGrayScale)
-    screen->fb[0].depth = 8;
+    screen->fb.depth = 8;
 
-  if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth())
+  if (screen->fb.depth && screen->fb.depth != hostx_get_depth())
     {
-      if (screen->fb[0].depth < hostx_get_depth()
-	  && (screen->fb[0].depth == 24 || screen->fb[0].depth == 16
-	      || screen->fb[0].depth == 8))
+      if (screen->fb.depth < hostx_get_depth()
+	  && (screen->fb.depth == 24 || screen->fb.depth == 16
+	      || screen->fb.depth == 8))
 	{
-	  hostx_set_server_depth(screen, screen->fb[0].depth);
+	  hostx_set_server_depth(screen, screen->fb.depth);
 	}
       else
 	ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
     }
   
-  screen->fb[0].depth = hostx_get_server_depth(screen);
+  screen->fb.depth = hostx_get_server_depth(screen);
   screen->rate = 72;
   
-  if (screen->fb[0].depth <= 8)
+  if (screen->fb.depth <= 8)
     {
       if (EphyrWantGrayScale)
-	screen->fb[0].visuals = ((1 << StaticGray) | (1 << GrayScale));
+	screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale));
       else
-	screen->fb[0].visuals = ((1 << StaticGray) |
-				 (1 << GrayScale) |
-				 (1 << StaticColor) |
-				 (1 << PseudoColor) |
-				 (1 << TrueColor) |
-				 (1 << DirectColor));
+	screen->fb.visuals = ((1 << StaticGray) |
+			      (1 << GrayScale) |
+			      (1 << StaticColor) |
+			      (1 << PseudoColor) |
+			      (1 << TrueColor) |
+			      (1 << DirectColor));
       
-      screen->fb[0].redMask   = 0x00;
-      screen->fb[0].greenMask = 0x00;
-      screen->fb[0].blueMask  = 0x00;
-      screen->fb[0].depth        = 8;
-      screen->fb[0].bitsPerPixel = 8;
+      screen->fb.redMask   = 0x00;
+      screen->fb.greenMask = 0x00;
+      screen->fb.blueMask  = 0x00;
+      screen->fb.depth        = 8;
+      screen->fb.bitsPerPixel = 8;
     }
   else 
     {
-      screen->fb[0].visuals = (1 << TrueColor);
+      screen->fb.visuals = (1 << TrueColor);
       
-      if (screen->fb[0].depth <= 15)
+      if (screen->fb.depth <= 15)
 	{
-	  screen->fb[0].depth = 15;
-	  screen->fb[0].bitsPerPixel = 16;
+	  screen->fb.depth = 15;
+	  screen->fb.bitsPerPixel = 16;
 	}
-      else if (screen->fb[0].depth <= 16)
+      else if (screen->fb.depth <= 16)
 	{
-	  screen->fb[0].depth = 16;
-	  screen->fb[0].bitsPerPixel = 16;
+	  screen->fb.depth = 16;
+	  screen->fb.bitsPerPixel = 16;
 	}
-      else if (screen->fb[0].depth <= 24)
+      else if (screen->fb.depth <= 24)
 	{
-	  screen->fb[0].depth = 24;
-	  screen->fb[0].bitsPerPixel = 32;
+	  screen->fb.depth = 24;
+	  screen->fb.bitsPerPixel = 32;
 	}
-      else if (screen->fb[0].depth <= 30)
+      else if (screen->fb.depth <= 30)
 	{
-	  screen->fb[0].depth = 30;
-	  screen->fb[0].bitsPerPixel = 32;
+	  screen->fb.depth = 30;
+	  screen->fb.bitsPerPixel = 32;
 	}
       else
 	{
 	  ErrorF("\nXephyr: Unsupported screen depth %d\n",
-	         screen->fb[0].depth);
+	         screen->fb.depth);
 	  return FALSE;
 	}
 
       hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
 
-      screen->fb[0].redMask = (Pixel) redMask;
-      screen->fb[0].greenMask = (Pixel) greenMask;
-      screen->fb[0].blueMask = (Pixel) blueMask;
+      screen->fb.redMask = (Pixel) redMask;
+      screen->fb.greenMask = (Pixel) greenMask;
+      screen->fb.blueMask = (Pixel) blueMask;
 
     }
   
@@ -220,6 +220,22 @@ ephyrWindowLinear (ScreenPtr	pScreen,
   return priv->base + row * priv->bytes_per_line + offset;
 }
 
+/**
+ * Figure out display buffer size. If fakexa is enabled, allocate a larger
+ * buffer so that fakexa has space to put offscreen pixmaps.
+ */
+int
+ephyrBufferHeight(KdScreenInfo *screen)
+{
+    int buffer_height;
+    if (ephyrFuncs.initAccel == NULL)
+	buffer_height = screen->height;
+    else
+	buffer_height = 3 * screen->height;
+    return buffer_height;
+}
+
+
 Bool
 ephyrMapFramebuffer (KdScreenInfo *screen)
 {
@@ -234,30 +250,19 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
   KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
   KdSetPointerMatrix (&m);
   
-  priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
-  
-  /* point the framebuffer to the data in an XImage */
-  /* If fakexa is enabled, allocate a larger buffer so that fakexa has space to
-   * put offscreen pixmaps.
-   */
-  if (ephyrFuncs.initAccel == NULL)
-    buffer_height = screen->height;
-  else
-    buffer_height = 3 * screen->height;
+  priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
+
+  buffer_height = ephyrBufferHeight(screen);
 
   priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
 
-  screen->memory_base  = (CARD8 *) (priv->base);
-  screen->memory_size  = priv->bytes_per_line * buffer_height;
-  screen->off_screen_base = priv->bytes_per_line * screen->height;
-  
   if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
     {
       scrpriv->shadow = FALSE;
       
-      screen->fb[0].byteStride = priv->bytes_per_line;
-      screen->fb[0].pixelStride = screen->width;
-      screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
+      screen->fb.byteStride = priv->bytes_per_line;
+      screen->fb.pixelStride = screen->width;
+      screen->fb.frameBuffer = (CARD8 *) (priv->base);
     }
   else
     {
@@ -266,7 +271,7 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
       
       EPHYR_LOG("allocing shadow");
       
-      KdShadowFbAlloc (screen, 0, 
+      KdShadowFbAlloc (screen,
 		       scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
     }
   
@@ -302,7 +307,7 @@ ephyrUnmapFramebuffer (KdScreenInfo *screen)
   EphyrScrPriv  *scrpriv = screen->driver;
   
   if (scrpriv->shadow)
-    KdShadowFbFree (screen, 0);
+    KdShadowFbFree (screen);
   
   /* Note, priv->base will get freed when XImage recreated */
   
@@ -566,10 +571,10 @@ ephyrRandRSetConfig (ScreenPtr		pScreen,
   (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
 				  pScreen->width,
 				  pScreen->height,
-				  screen->fb[0].depth,
-				  screen->fb[0].bitsPerPixel,
-				  screen->fb[0].byteStride,
-				  screen->fb[0].frameBuffer);
+				  screen->fb.depth,
+				  screen->fb.bitsPerPixel,
+				  screen->fb.byteStride,
+				  screen->fb.frameBuffer);
   
   /* set the subpixel order */
   
@@ -730,7 +735,7 @@ ephyrScreenFini (KdScreenInfo *screen)
 {
     EphyrScrPriv  *scrpriv = screen->driver;
     if (scrpriv->shadow) {
-        KdShadowFbFree (screen, 0);
+        KdShadowFbFree (screen);
     }
     xfree(screen->driver);
     screen->driver = NULL;
@@ -1022,7 +1027,7 @@ ephyrCardFini (KdCardInfo *card)
 }
 
 void
-ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
 {
   /* XXX Not sure if this is right */
   
@@ -1039,7 +1044,7 @@ ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
 }
 
 void
-ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
 {
   int min, max, p;
 
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
index f5ea144b3..41a82bf9d 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -116,10 +116,10 @@ void
 ephyrCardFini (KdCardInfo *card);
 
 void
-ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
 
 void
-ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
 
 Bool
 ephyrMapFramebuffer (KdScreenInfo *screen);
@@ -180,6 +180,8 @@ extern Bool ephyrCursorInit(ScreenPtr pScreen);
 
 extern void ephyrCursorEnable(ScreenPtr pScreen);
 
+extern int ephyrBufferHeight(KdScreenInfo *screen);
+
 /* ephyr_draw.c */
 
 Bool
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr_draw.c b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
index 7b579c24b..f9fac8007 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
@@ -428,6 +428,7 @@ ephyrDrawInit(ScreenPtr pScreen)
     KdScreenPriv(pScreen);
     KdScreenInfo *screen = pScreenPriv->screen;
     EphyrScrPriv *scrpriv = screen->driver;
+    EphyrPriv *priv = screen->card->driver;
     EphyrFakexaPriv *fakexa;
     Bool success;
 
@@ -441,9 +442,9 @@ ephyrDrawInit(ScreenPtr pScreen)
 	return FALSE;
     }
 
-    fakexa->exa->memoryBase = screen->memory_base;
-    fakexa->exa->memorySize = screen->memory_size;
-    fakexa->exa->offScreenBase = screen->off_screen_base;
+    fakexa->exa->memoryBase = (CARD8 *) (priv->base);
+    fakexa->exa->memorySize = priv->bytes_per_line * ephyrBufferHeight(screen);
+    fakexa->exa->offScreenBase = priv->bytes_per_line * screen->height;
 
     /* Since we statically link against EXA, we shouldn't have to be smart about
      * versioning.
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index 2b72b4e0a..c7bfb5bec 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -40,17 +40,18 @@ extern Bool noGlxVisualInit;
 #endif
 extern Bool   ephyrNoXV;
 
+#ifdef KDRIVE_EVDEV
+extern KdPointerDriver	LinuxEvdevMouseDriver;
+extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
+#endif
+
 void processScreenArg (char *screen_size, char *parent_id) ;
 
 void
 InitCard (char *name)
 {
-    KdCardAttr	attr;
-
     EPHYR_DBG("mark");
-
-
-    KdCardInfoAdd (&ephyrFuncs, &attr, 0);
+    KdCardInfoAdd (&ephyrFuncs, 0);
 }
 
 void
@@ -66,11 +67,11 @@ InitInput (int argc, char **argv)
   KdPointerInfo *pi;
 
   KdAddKeyboardDriver(&EphyrKeyboardDriver);
-#ifdef linux
+#ifdef KDRIVE_EVDEV
   KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
 #endif
   KdAddPointerDriver(&EphyrMouseDriver);
-#ifdef linux
+#ifdef KDRIVE_EVDEV
   KdAddPointerDriver(&LinuxEvdevMouseDriver);
 #endif
 
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
index bb2ee1032..6624ab98a 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
@@ -302,7 +302,7 @@ ephyrInitVideo (ScreenPtr pScreen)
 
     EPHYR_LOG ("enter\n") ;
 
-    if (screen->fb[0].bitsPerPixel == 8) {
+    if (screen->fb.bitsPerPixel == 8) {
         EPHYR_LOG_ERROR ("8 bits depth not supported\n") ;
         return FALSE ;
     }
-- 
cgit v1.2.3