[xserver-commit] xserver/hw/kdrive/fbdev fbdev.c,1.37.2.1,1.37.2.2 fbdev.h,1.14.2.1,1.14.2.2 fbinit.c,1.12,1.12.2.1
Keith Packard
xserver-commit@pdx.freedesktop.org
Fri, 24 Oct 2003 02:34:35 -0700
Committed by: keithp
Update of /cvs/xserver/xserver/hw/kdrive/fbdev
In directory pdx:/tmp/cvs-serv4383/hw/kdrive/fbdev
Modified Files:
Tag: xfixes_2_branch
fbdev.c fbdev.h fbinit.c
Log Message:
* hw/kdrive/fbdev/fbdev.c: (fbdevScreenInitialize),
(fbdevMapFramebuffer), (fbdevSetScreenSizes),
(fbdevUnmapFramebuffer), (fbdevSetShadow), (fbdevRandRSetConfig),
(fbdevInitScreen), (fbdevFinishInitScreen), (fbdevCreateResources):
* hw/kdrive/fbdev/fbdev.h:
* hw/kdrive/fbdev/fbinit.c:
* hw/kdrive/mach64/mach64.c: (mach64CreateResources):
* hw/kdrive/mga/Makefile.am:
* hw/kdrive/mga/mga.c: (mgaCreateResources):
* hw/kdrive/nvidia/Makefile.am:
* hw/kdrive/nvidia/nvidia.c:
* hw/kdrive/r128/Makefile.am:
* hw/kdrive/r128/r128.c:
* hw/kdrive/r128/r128draw.c: (r128PrepareSolid), (r128PrepareCopy):
* hw/kdrive/smi/Makefile.am:
* hw/kdrive/smi/smi.c:
* hw/kdrive/smi/smi.h:
* hw/kdrive/src/kdrive.c: (KdCreateScreenResources),
(KdScreenInit):
* hw/kdrive/src/kdrive.h:
* hw/kdrive/src/kshadow.c: (KdShadowFbAlloc), (KdShadowFbFree),
(KdShadowSet), (KdShadowUnset):
* hw/kdrive/vesa/vesa.c: (vesaSetScreenSizes), (vesaSetShadow),
(vesaMapFramebuffer), (vesaUnmapFramebuffer), (vesaRandRSetConfig),
(vesaInitScreen), (vesaFinishInitScreen), (vesaCreateResources),
(vesaScreenFini):
* hw/kdrive/vesa/vesa.h:
* hw/kdrive/vesa/vesainit.c:
Add function called at CreateScreenResources to get shadow set up
on pixmap correctly. Rework vesa and fbdev code to handle
shadows right with the non-layer world.
* mi/misprite.c:
* mi/mispritest.h:
Use GetScreenPixmap directly for damage detection of sprite.
Avoids problems during server shutdown with windows disappearing
before the sprite layer is closed.
Index: fbdev.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/fbdev/fbdev.c,v
retrieving revision 1.37.2.1
retrieving revision 1.37.2.2
diff -u -d -r1.37.2.1 -r1.37.2.2
--- fbdev.c 22 Oct 2003 06:00:49 -0000 1.37.2.1
+++ fbdev.c 24 Oct 2003 09:34:33 -0000 1.37.2.2
@@ -29,9 +29,6 @@
#include "fbdev.h"
#include <sys/ioctl.h>
-/* this code was used to debug MSB 24bpp code on a 16bpp frame buffer */
-#undef FAKE24_ON_16
-
extern int KdTsPhyScreen;
Bool
@@ -114,9 +111,6 @@
Pixel allbits;
int depth;
Bool gray;
-#ifdef FAKE24_ON_16
- Bool fake24;
-#endif
depth = priv->var.bits_per_pixel;
gray = priv->var.grayscale;
@@ -191,33 +185,7 @@
screen->rate = 72;
scrpriv->randr = screen->randr;
-#ifdef FAKE24_ON_16
- if (screen->fb[0].depth == 24 && screen->fb[0].bitsPerPixel == 24 &&
- priv->var.bits_per_pixel == 16)
- {
- fake24 = TRUE;
- scrpriv->shadow = TRUE;
- scrpriv->rotation = 0;
- screen->fb[0].redMask = 0xff0000;
- screen->fb[0].greenMask = 0x00ff00;
- screen->fb[0].blueMask = 0x0000ff;
- screen->width = priv->var.xres;
- screen->height = priv->var.yres;
- screen->softCursor = TRUE;
- }
- else
-#endif
- {
- screen->fb[0].depth = depth;
- screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
- screen->width = priv->var.xres;
- screen->height = priv->var.yres;
- screen->fb[0].byteStride = priv->fix.line_length;
- screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
- priv->var.bits_per_pixel);
- screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
- }
- return TRUE;
+ return fbdevMapFramebuffer (screen);
}
Bool
@@ -255,177 +223,93 @@
return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
}
-#ifdef FAKE24_ON_16
-void
-fbdevUpdateFake24 (ScreenPtr pScreen,
- PixmapPtr pShadow,
- RegionPtr damage)
+Bool
+fbdevMapFramebuffer (KdScreenInfo *screen)
{
- shadowScrPriv(pScreen);
- int nbox = REGION_NUM_RECTS (damage);
- BoxPtr pbox = REGION_RECTS (damage);
- FbBits *shaBits;
- CARD8 *shaBase, *shaLine, *sha;
- CARD16 s;
- FbStride shaStride;
- int scrBase, scrLine, scr;
- int shaBpp;
- int x, y, w, h, width;
- int i;
- CARD16 *winBase, *winLine, *win;
- CARD32 winSize;
+ FbdevScrPriv *scrpriv = screen->driver;
+ KdMouseMatrix m;
+ FbdevPriv *priv = screen->card->driver;
- fbGetDrawable (&pShadow->drawable, shaBits, shaStride, shaBpp);
- shaStride = shaStride * sizeof (FbBits) / sizeof (CARD8);
- shaBase = (CARD8 *) shaBits;
- while (nbox--)
+ if (scrpriv->randr != RR_Rotate_0)
+ scrpriv->shadow = TRUE;
+ else
+ scrpriv->shadow = FALSE;
+
+ KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
+
+ KdSetMouseMatrix (&m);
+
+ screen->width = priv->var.xres;
+ screen->height = priv->var.yres;
+ screen->memory_base = (CARD8 *) (priv->fb);
+ screen->memory_size = 0;
+ screen->off_screen_base = 0;
+ screen->fb[0].depth = priv->var.bits_per_pixel;
+ screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
+
+ if (scrpriv->shadow)
{
- x = pbox->x1;
- y = pbox->y1;
- w = (pbox->x2 - pbox->x1);
- h = pbox->y2 - pbox->y1;
-
- shaLine = shaBase + y * shaStride + x * 3;
-
- while (h--)
- {
- winSize = 0;
- scrBase = 0;
- width = w;
- scr = x;
- sha = shaLine;
- while (width) {
- /* how much remains in this window */
- i = scrBase + winSize - scr;
- if (i <= 0 || scr < scrBase)
- {
- winBase = (CARD16 *) (*pScrPriv->window) (pScreen,
- y,
- scr * sizeof (CARD16),
- SHADOW_WINDOW_WRITE,
- &winSize);
- if(!winBase)
- return;
- scrBase = scr;
- winSize /= sizeof (CARD16);
- i = winSize;
- }
- win = winBase + (scr - scrBase);
- if (i > width)
- i = width;
- width -= i;
- scr += i;
- while (i--)
- {
-#if IMAGE_BYTE_ORDER == MSBFirst
- *win++ = ((sha[2] >> 3) |
- ((sha[1] & 0xf8) << 2) |
- ((sha[0] & 0xf8) << 7));
-#else
- *win++ = ((sha[0] >> 3) |
- ((sha[1] & 0xfc) << 3) |
- ((sha[2] & 0xf8) << 8));
-#endif
- sha += 3;
- }
- }
- shaLine += shaStride;
- y++;
- }
- pbox++;
+ if (!KdShadowFbAlloc (screen, 0,
+ scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
+ return FALSE;
+ }
+ else
+ {
+ screen->fb[0].byteStride = priv->fix.line_length;
+ screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
+ priv->var.bits_per_pixel);
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
}
+
+ return TRUE;
}
-#endif /* FAKE24_ON_16 */
void
-fbdevConfigureScreen (ScreenPtr pScreen)
+fbdevSetScreenSizes (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
FbdevScrPriv *scrpriv = screen->driver;
- KdMouseMatrix m;
+ FbdevPriv *priv = screen->card->driver;
-#ifdef FAKE24_ON_16
- if (fake24)
- {
- scrpriv->randr = RR_Rotate_0;
- scrpriv->shadow = TRUE;
- }
- else
-#endif /* FAKE24_ON_16 */
- {
- if (scrpriv->randr != RR_Rotate_0)
- scrpriv->shadow = TRUE;
- else
- scrpriv->shadow = FALSE;
- }
-
- KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
-
- if (m.matrix[0][0])
+ if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
{
- pScreen->width = screen->width;
- pScreen->height = screen->height;
+ pScreen->width = priv->var.xres;
+ pScreen->height = priv->var.yres;
pScreen->mmWidth = screen->width_mm;
pScreen->mmHeight = screen->height_mm;
}
else
{
- pScreen->width = screen->height;
- pScreen->height = screen->width;
+ pScreen->width = priv->var.yres;
+ pScreen->height = priv->var.xres;
pScreen->mmWidth = screen->height_mm;
pScreen->mmHeight = screen->width_mm;
}
- KdSetMouseMatrix (&m);
}
-PixmapPtr
-fbdevGetPixmap (ScreenPtr pScreen)
+Bool
+fbdevUnmapFramebuffer (KdScreenInfo *screen)
+{
+ KdShadowFbFree (screen, 0);
+}
+
+Bool
+fbdevSetShadow (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
FbdevScrPriv *scrpriv = screen->driver;
ShadowUpdateProc update;
ShadowWindowProc window;
- PixmapPtr pShadow, pPixmap;
- if (scrpriv->shadow)
- {
- window = fbdevWindowLinear;
- update = 0;
-#ifdef FAKE24_ON_16
- if (pScreenPriv->screen->fb[0].bitsPerPixel == 24 && priv->var.bits_per_pixel == 16)
- {
- update = fbdevUpdateFake24;
- }
- else
-#endif /* FAKE24_ON_16 */
- {
- if (scrpriv->randr)
- update = shadowUpdateRotatePacked;
- else
- update = shadowUpdatePacked;
- }
- pPixmap = (*pScreen->CreatePixmap) (pScreen,
- pScreen->width,
- pScreen->height,
- screen->fb[0].depth);
- if (!pPixmap)
- return FALSE;
- shadowSet (pScreen, pPixmap, update, window, scrpriv->randr, 0);
- pShadow = pPixmap;
- }
+ window = fbdevWindowLinear;
+ update = 0;
+ if (scrpriv->randr)
+ update = shadowUpdateRotatePacked;
else
- {
- pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
- pShadow = 0;
- }
-
- if (scrpriv->pShadow)
- (*pScreen->DestroyPixmap) (scrpriv->pShadow);
- scrpriv->pShadow = pShadow;
-
- return pPixmap;
+ update = shadowUpdatePacked;
+ return KdShadowSet (pScreen, scrpriv->randr, update, window);
}
@@ -461,16 +345,6 @@
return TRUE;
}
-int
-fbdevPixmapSet (WindowPtr pWin, pointer value)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- PixmapPtr pPixmap = value;
-
- (*pScreen->SetWindowPixmap) (pWin, pPixmap);
- return WT_WALKCHILDREN;
-}
-
Bool
fbdevRandRSetConfig (ScreenPtr pScreen,
Rotation randr,
@@ -516,16 +390,30 @@
scrpriv->randr = KdAddRotation (screen->randr, randr);
- fbdevConfigureScreen (pScreen);
+ KdOffscreenSwapOut (screen->pScreen);
- /*
- * Get the pixmap that windows live in
- */
- pPixmap = fbdevGetPixmap (pScreen);
- if (!pPixmap)
+ fbdevUnmapFramebuffer (screen);
+
+ if (!fbdevMapFramebuffer (screen))
goto bail4;
- WalkTree (pScreen, fbdevPixmapSet, (pointer) pPixmap);
+ if (!fbdevSetShadow (screen->pScreen))
+ goto bail4;
+
+ fbdevSetScreenSizes (screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
KdSetSubpixelOrder (pScreen, scrpriv->randr);
if (wasEnabled)
@@ -534,11 +422,14 @@
return TRUE;
bail4:
+ fbdevUnmapFramebuffer (screen);
+ *scrpriv = oldscr;
+ (void) fbdevMapFramebuffer (screen);
pScreen->width = oldwidth;
pScreen->height = oldheight;
pScreen->mmWidth = oldmmwidth;
pScreen->mmHeight = oldmmheight;
- *scrpriv = oldscr;
+
if (wasEnabled)
KdEnableScreen (pScreen);
return FALSE;
@@ -601,18 +492,13 @@
#endif
pScreen->CreateColormap = fbdevCreateColormap;
- return shadowSetup (pScreen);
+ return TRUE;
}
Bool
fbdevFinishInitScreen (ScreenPtr pScreen)
{
- PixmapPtr pPixmap;
-
- fbdevConfigureScreen (pScreen);
-
- pPixmap = fbdevGetPixmap (pScreen);
- if (!pPixmap)
+ if (!shadowSetup (pScreen))
return FALSE;
#ifdef RANDR
@@ -623,6 +509,13 @@
return TRUE;
}
+
+Bool
+fbdevCreateResources (ScreenPtr pScreen)
+{
+ return fbdevSetShadow (pScreen);
+}
+
void
fbdevPreserve (KdCardInfo *card)
{
Index: fbdev.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/fbdev/fbdev.h,v
retrieving revision 1.14.2.1
retrieving revision 1.14.2.2
diff -u -d -r1.14.2.1 -r1.14.2.2
--- fbdev.h 22 Oct 2003 06:00:49 -0000 1.14.2.1
+++ fbdev.h 24 Oct 2003 09:34:33 -0000 1.14.2.2
@@ -69,6 +69,12 @@
Bool
fbdevInitScreen (ScreenPtr pScreen);
+Bool
+fbdevFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+fbdevCreateResources (ScreenPtr pScreen);
+
void
fbdevPreserve (KdCardInfo *card);
@@ -96,7 +102,4 @@
void
fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
-Bool
-fbdevFinishInitScreen (ScreenPtr pScreen);
-
#endif /* _FBDEV_H_ */
Index: fbinit.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/fbdev/fbinit.c,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -u -d -r1.12 -r1.12.2.1
--- fbinit.c 5 Oct 2003 05:22:35 -0000 1.12
+++ fbinit.c 24 Oct 2003 09:34:33 -0000 1.12.2.1
@@ -63,6 +63,8 @@
fbdevCardInit, /* cardinit */
fbdevScreenInit, /* scrinit */
fbdevInitScreen, /* initScreen */
+ fbdevFinishInitScreen, /* finishInitScreen */
+ fbdevCreateResources, /* createRes */
fbdevPreserve, /* preserve */
fbdevEnable, /* enable */
fbdevDPMS, /* dpms */
@@ -85,6 +87,4 @@
fbdevGetColors, /* getColors */
fbdevPutColors, /* putColors */
-
- fbdevFinishInitScreen, /* finishInitScreen */
};