summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86')
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h20
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml74
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile33
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h52
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c84
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c143
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c835
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c53
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h1
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c37
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c122
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile35
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c56
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h362
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h188
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h269
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h111
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c435
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c86
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c116
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c198
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c219
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c490
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux28
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h95
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c28
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c56
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c78
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c21
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c43
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c123
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c43
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c178
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c134
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h132
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c278
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c40
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c1
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h31
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c36
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h1
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c92
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile35
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile29
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h43
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c6
70 files changed, 2086 insertions, 3619 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
index ec6541041..9882cd133 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.67 2000/08/11 21:12:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.72 2000/09/13 15:47:31 martin Exp $ */
/*
* PCI Probe
*
@@ -86,7 +86,6 @@
#define PCI_VENDOR_PICOP 0x1066
#define PCI_VENDOR_MYLEX 0x1069
#define PCI_VENDOR_APPLE 0x106B
-/* Yahama is a guess based on chipset */
#define PCI_VENDOR_YAMAHA 0x1073
#define PCI_VENDOR_NEXGEN 0x1074
#define PCI_VENDOR_QLOGIC 0x1077
@@ -98,6 +97,7 @@
#define PCI_VENDOR_SUN 0x108E
#define PCI_VENDOR_DIAMOND 0x1092
#define PCI_VENDOR_CMD 0x1095
+#define PCI_VENDOR_APPIAN 0x1097
#define PCI_VENDOR_VISION 0x1098
#define PCI_VENDOR_BROOKTREE 0x109E
#define PCI_VENDOR_SIERRA 0x10A8
@@ -478,7 +478,7 @@
#define PCI_CHIP_QUADRO2MXR 0x0113
#define PCI_CHIP_GEFORCE2GTS 0x0150
#define PCI_CHIP_GEFORCE2GTS_1 0x0151
-#define PCI_CHIP_GEFORCE2GTS_2 0x0152
+#define PCI_CHIP_GEFORCE2ULTRA 0x0152
#define PCI_CHIP_QUADRO2PRO 0x0153
/* NVIDIA & SGS */
@@ -556,6 +556,7 @@
#define PCI_CHIP_NM2097 0x0083
#define PCI_CHIP_NM2160 0x0004
#define PCI_CHIP_NM2200 0x0005
+#define PCI_CHIP_NM2230 0x0025
#define PCI_CHIP_NM2360 0x0006
#define PCI_CHIP_NM2380 0x0016
@@ -636,6 +637,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_SUN, "Sun"},
{PCI_VENDOR_DIAMOND, "Diamond"},
{PCI_VENDOR_CMD, "CMD"},
+ {PCI_VENDOR_APPIAN, "Appian Graphics"},
{PCI_VENDOR_VISION, "Vision"},
{PCI_VENDOR_BROOKTREE, "BrookTree"},
{PCI_VENDOR_SIERRA, "Sierra"},
@@ -982,6 +984,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_TI_PERMEDIA2, "Permedia 2",0},
{PCI_CHIP_PCI_1130, "PCI 1130",0},
{PCI_CHIP_PCI_1131, "PCI 1131",0},
+ {0x8019, "TSB12LV23 IEEE1394/FireWire",0},
{0x0000, NULL,0}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_SONY, {
@@ -1036,6 +1039,9 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{0x0001, "Bandit",0 },
{0x0002, "Grand Central",0 },
{0x000E, "Hydra",0 },
+ {0x0019, "Keylargo USB",0 },
+ {0x0020, "Uni-North AGP",0 },
+ {0x0022, "Keylargo I/O",0 },
{0x0000, NULL,0}}},
#ifdef INCLUDE_EMPTY_LISTS
{PCI_VENDOR_NEXGEN, {
@@ -1088,6 +1094,11 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{0x0646, "646",0 },
{0x0670, "670",0 },
{0x0000, NULL,0}}},
+#endif
+ {PCI_VENDOR_APPIAN, {
+ {0x3D32, "Jeronimo 2000 AGP",0 },
+ {0x0000, NULL,0}}},
+#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_VISION, {
{0x0001, "QD 8500",0 },
{0x0002, "QD 8580",0 },
@@ -1156,6 +1167,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_NM2093, "NM2093",0},
{PCI_CHIP_NM2160, "NM2160",0},
{PCI_CHIP_NM2200, "NM2200",0},
+ {PCI_CHIP_NM2230, "NM2230 MagicMedia 256AV+",0},
{PCI_CHIP_NM2360, "NM2360",0},
{PCI_CHIP_NM2380, "NM2380",0},
#ifdef VENDOR_INCLUDE_NONVIDEO
@@ -1189,7 +1201,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_QUADRO2MXR, "GeForce2 MXR",0},
{PCI_CHIP_GEFORCE2GTS, "GeForce2 GTS",0},
{PCI_CHIP_GEFORCE2GTS_1,"GeForce2 GTS (rev 1)",0},
- {PCI_CHIP_GEFORCE2GTS_2,"GeForce2 GTS (rev 2)",0},
+ {PCI_CHIP_GEFORCE2ULTRA,"GeForce2 ultra",0},
{PCI_CHIP_QUADRO2PRO, "Quadro 2 Pro",0},
{0x0000, NULL,0}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
index c8e34f6d3..8d4acb0d6 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
@@ -12,7 +12,7 @@
<author>
<htmlurl url="http://www.valinux.com/"
name="VA Linux Systems, Inc."> Professional Services - Graphics.
- <date>22 August 2000
+ <date>10 October 2000
<ident>
$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.7 2000/08/28 18:24:15 dawes Exp $
@@ -573,7 +573,7 @@
<p>
The Voodoo3 DRI driver requires a special versions of
the 3dfx Glide library.
- It can be downloaded from the DRI web site.
+ It can be downloaded from the DRI website.
<p>
<sect2>Configuration
<p>
@@ -605,7 +605,7 @@
should be installed in /lib/modules/KERNEL-VERSION/misc/.
It will be automatically loaded by the Xserver if needed.
<p>
- The DRI 3D driver for the Voodoo3 should be in
+ The DRI 3D driver for the Voodoo3 hould be in
<tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>.
This will be automatically loaded by libGL.so.
<p>
@@ -614,6 +614,14 @@
<p>
<itemize>
<item>
+ If you try to run an OpenGL application and see an error message
+ similar to
+ <verb>
+ gd error (glide): gd error (glide): grSstSelect: non-existent SSTgd error (glide): grSstSelect: non-existent SSTS
+ </verb>
+ it means that you have the wrong version of the Glide library
+ for your hardware.
+ <item>
3D acceleration for Voodoo3 is only supported in the 16
bit/pixel screen mode.
Use <tt/xdpyinfo/ to verify that all your visuals are depth 16.
@@ -642,7 +650,42 @@
Applications which use that mode, such as the Performer Town
demo, may become sluggish when falling back to software
rendering to render in that mode.
+ <item>
+ The Voodoo3/Banshee driver reverts to software rendering under
+ the following conditions:
+ <itemize>
+ <item>
+ Setting <tt/GL_LIGHT_MODEL_COLOR_CONTROL/ to
+ <tt/GL_SEPARATE_SPECULAR_COLOR/.
+ <item>
+ Enabling line stippline or polygon stippling.
+ <item>
+ Enabling point smoothing or polygon smoothing.
+ <item>
+ Enabling line smoothing when line width is not 1.0.
+ That is, antialiased lines are done in hardware only when
+ the line width is 1.0.
+ <item>
+ Using 1-D or 3-D texture maps.
+ <item>
+ Using the GL_BLEND texture environment.
+ <item>
+ Using stencil operations.
+ <item>
+ Using the accumulation buffer.
+ <item>
+ Using <tt/glBlendEquation(GL_LOGIC_OP)/.
+ <item>
+ Using <tt/glDrawBuffer(GL_FRONT_AND_BACK)/.
+ <item>
+ Using <tt/glPolygonMode(face, GL_POINT)/ or
+ <tt/glPolygonMode(face, GL_LINE)/.
+ <item>
+ Using point size attenuation
+ (i.e. <tt/GL_DISTANCE_ATTENUATION_EXT/).
+ </itemize>
</itemize>
+
<sect2>Known Problems
<p>
<itemize>
@@ -654,7 +697,7 @@
clipping planes.
The office.unc Performer model also suffers from this problem.
<item>
- The lowest mipmap level is sometimes mis-colored in trilinear-
+ The lowest mipmap level is sometimes miscolored in trilinear-
sampled polygons.
</itemize>
@@ -666,7 +709,7 @@
The Voodoo5 DRI driver requires a special versions of
the 3dfx Glide library, different than that used for Voodoo3
hardware.
- It can be downloaded from the DRI web site.
+ It can be downloaded from the DRI website.
<p>
<sect2>Configuration
<p>
@@ -703,7 +746,7 @@
should be installed in /lib/modules/KERNEL-VERSION/misc/.
It will be automatically loaded by the Xserver if needed.
<p>
- The DRI 3D driver for the Voodoo5 should be in
+ The DRI 3D driver for the Voodoo5 hould be in
<tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>.
This will be automatically loaded by libGL.so.
<p>
@@ -725,7 +768,7 @@
Glide on older 3dfx hardware.
<item>
Different versions of Glide are needed for Voodoo3 and Voodoo5.
- See the DRI web site's resources page to download the right
+ See the DRI website's resources page to download the right
version of Glide.
</itemize>
@@ -740,6 +783,17 @@
The value of this variable indicates the maximum number of
swap buffer commands can be buffered.
Zero allows maximum frame rate.
+ <item>
+ Rendering with 16-bit per texel textures is faster than using
+ 32-bit per texel textures. The <tt/internalFormat/ parameter
+ to <tt/glTexImage2D/ can be used to control texel size.
+ <item>
+ The Voodoo5 driver reverts to software rendering under the
+ same conditions Voodoo3 with two exceptions.
+ First, stencil operations are implemented in hardware when the
+ screen is configured for 32 bits/pixel.
+ Second, the <tt/GL_BLEND/ texture env mode is fully supported in
+ hardware.
</itemize>
<sect2>Known Problems
<p>
@@ -749,7 +803,11 @@
be used via the tdfx DRI driver.
<item>
24bpp screen modes are supported by the hardware but not by
- the current driver.
+ the current driver. 32bpp is fully supported.
+ <item>
+ As of October, 2000 the second VSA-100 chip on the Voodoo5 is
+ not yet operational. Therefore, the board isn't being used to
+ its full capacity.
</itemize>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
index 15f2663ef..03b396ad2 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
@@ -459,7 +459,7 @@
To update your X locale information do the following:
<verb>
cd ~/DRI-CVS/build/xc/nls
- xmkmf -a
+ ../config/util/xmkmf -a
make
make install
</verb>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
index d2997aacd..2e97a3c26 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
@@ -135,7 +135,7 @@ I810InitVisualConfigs(ScreenPtr pScreen)
depth = 1;
for (accum = 0; accum <= 1; accum++) {
for (stencil = 0; stencil <= 1; stencil++) {
- for (db = 0; db <= 1; db++) {
+ for (db = 1; db >= 0; db--) {
pConfigs[i].vid = -1;
pConfigs[i].class = -1;
pConfigs[i].rgba = TRUE;
@@ -171,7 +171,7 @@ I810InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].stencilSize = 0;
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
- if (stencil)
+ if (stencil || accum)
pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
else
pConfigs[i].visualRating = GLX_NONE_EXT;
@@ -850,9 +850,6 @@ I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
I810SetupForSolidFill(pScrn, 0, GXcopy, -1);
while (nbox--) {
- I810SelectBuffer(pScrn, I810_FRONT);
- I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
- pbox->x2-pbox->x1, pbox->y2-pbox->y1);
I810SelectBuffer(pScrn, I810_BACK);
I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
pbox->x2-pbox->x1, pbox->y2-pbox->y1);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
index caab501c8..2e55a7849 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
@@ -1900,12 +1900,15 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen)
I810Ptr pI810 = I810PTR(pScrn);
XAAInfoRecPtr infoPtr = pI810->AccelInfoRec;
-
+ if (pScrn->vtSema == TRUE) {
+ I810Restore(pScrn);
+ vgaHWLock(hwp);
+ }
#ifdef XF86DRI
- if (pI810->directRenderingEnabled) {
- I810DRICloseScreen(pScreen);
- pI810->directRenderingEnabled=FALSE;
- }
+ if (pI810->directRenderingEnabled) {
+ I810DRICloseScreen(pScreen);
+ pI810->directRenderingEnabled=FALSE;
+ }
#endif
if(pScrn->vtSema == TRUE) {
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
index 505f9d092..42893411d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
@@ -50,7 +50,6 @@ int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
return 1;
}
-
int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
{
if (size > pool->Size) return 0;
@@ -62,7 +61,6 @@ int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
return 1;
}
-
int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
{
unsigned long size = pScrn->videoRam * 1024;
@@ -94,6 +92,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
if (!xf86BindGARTMemory(pScrn->scrnIndex, key, 0))
return FALSE;
+
pI810->SysMem.Start = 0;
pI810->SysMem.Size = size;
pI810->SysMem.End = size;
@@ -135,6 +134,8 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
size);
pI810->DcacheKey = -1;
}
+
+
/* Mouse cursor -- The i810 (crazy) needs a physical address in
* system memory from which to upload the cursor. We get this from
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
index 4bb3168ad..abfc49e87 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
@@ -6,6 +6,11 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
+#if BuildMatroxHal
+#define IHaveSubdirs
+SUBDIRS=hallib
+#endif
+
#if BuildXF86DRI
DRISRCS = mga_dri.c mga_warp.c mga_wrap.c
DRIOBJS = mga_dri.o mga_warp.o mga_wrap.o
@@ -14,17 +19,31 @@ DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \
DRIDEFINES = $(GLX_DEFINES)
#endif
+#if UseMatroxHal
+MGAHALSRCS = clientlx.c
+MGAHALDEFINES = -DUSEMGAHAL
+#if !BuildMatroxHal
+MGAHALOBJS = clientlx.o HALlib/mgaHALlib.a
+MGAHALINCLUDES = -IHALlib
+#else
+MGAHALOBJS = clientlx.o hallib/libmga_hal.a
+MGAHALINCLUDES = -Ihallib
+hallib/libmga_hal.a: $(SUBDIRS)
+#endif
+#endif
+
SRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \
mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \
- mga_dga.c mga_shadow.c mga_video.c $(DRISRCS)
+ mga_dga.c mga_shadow.c mga_video.c $(MGAHALSRCS) $(DRISRCS)
OBJS = mga_driver.o mga_hwcurs.o /* mga_cmap.o */ mga_dac3026.o mga_dacG.o \
mga_storm8.o mga_storm16.o mga_storm24.o mga_storm32.o mga_arc.o \
- mga_dga.o mga_shadow.o mga_video.o $(DRIOBJS)
+ mga_dga.o mga_shadow.o mga_video.o $(MGAHALOBJS) $(DRIOBJS)
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
#else
-INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \
+INCLUDES = -I. $(MGAHALINCLUDES) -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/fb \
-I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(XF86SRC)/int10 \
-I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \
-I$(XF86SRC)/vgahw -I$(XF86SRC)/fbdevhw \
@@ -36,7 +55,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/fb \
-I$(XF86OSSRC)/vbe $(DRIINCLUDES)
#endif
-DEFINES = $(DRIDEFINES)
+DEFINES = $(MGAHALDEFINES) $(DRIDEFINES)
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -78,3 +97,9 @@ InstallDriverSDKNonExecFile(mga_video.c,$(DRIVERSDKDIR)/drivers/mga)
InstallDriverSDKObjectModule(mga,$(DRIVERSDKMODULEDIR),drivers)
+#if BuildMatroxHal
+MakeSubdirs($(SUBDIRS))
+ForceSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
index e246ba594..26da1dead 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
@@ -32,6 +32,11 @@
#include "mga_dri.h"
#endif
+#ifdef USEMGAHAL
+#include "client.h"
+#endif
+#include "mga_bios.h"
+
#if !defined(EXTRADEBUG)
#define INREG8(addr) MMIO_IN8(pMga->IOBase, addr)
#define INREG16(addr) MMIO_IN16(pMga->IOBase, addr)
@@ -58,6 +63,8 @@ void dbg_outreg32(ScrnInfoPtr,int,int);
#define MGA_VERSION 4000
#define MGA_NAME "MGA"
+#define MGA_C_NAME MGA
+#define MGA_MODULE_DATA mgaModuleData
#define MGA_DRIVER_NAME "mga"
#define MGA_MAJOR_VERSION 1
#define MGA_MINOR_VERSION 0
@@ -137,6 +144,31 @@ typedef struct mgaSave {
#endif
typedef struct {
+ int lastInstance;
+#ifdef USEMGAHAL
+ LPCLIENTDATA pClientStruct;
+ LPBOARDHANDLE pBoard;
+ LPMGAHWINFO pMgaHwInfo;
+#endif
+ int refCount;
+ CARD32 masterFbAddress;
+ long masterFbMapSize;
+ CARD32 slaveFbAddress;
+ long slaveFbMapSize;
+ int mastervideoRam;
+ int slavevideoRam;
+ Bool directRenderingEnabled;
+ ScrnInfoPtr pScrn_1;
+ ScrnInfoPtr pScrn_2;
+} MGAEntRec, *MGAEntPtr;
+
+typedef struct {
+#ifdef USEMGAHAL
+ LPCLIENTDATA pClientStruct;
+ LPBOARDHANDLE pBoard;
+ LPMGAMODEINFO pMgaModeInfo;
+ LPMGAHWINFO pMgaHwInfo;
+#endif
EntityInfoPtr pEnt;
MGABiosInfo Bios;
MGABios2Info Bios2;
@@ -238,6 +270,7 @@ typedef struct {
int expandHeight;
int expandY;
#ifdef XF86DRI
+ int agp_mode;
Bool have_quiescense;
Bool directRenderingEnabled;
DRIInfoPtr pDRIInfo;
@@ -247,8 +280,20 @@ typedef struct {
MGAConfigPrivPtr pVisualConfigsPriv;
MGARegRec DRContextRegs;
MGADRIServerPrivatePtr DRIServerInfo;
+ void (*GetQuiescence)(ScrnInfoPtr pScrn);
#endif
XF86VideoAdaptorPtr adaptor;
+ Bool SecondCrtc;
+ GDevPtr device;
+ /* The hardware's real SrcOrg */
+ int realSrcOrg;
+ MGAEntPtr entityPrivate;
+ void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask);
+ void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h);
+ void (*RestoreAccelState)(ScrnInfoPtr pScrn);
+ int allowedWidth;
void (*VideoTimerCallback)(ScrnInfoPtr, Time);
void (*PaletteLoadCallback)(ScrnInfoPtr);
MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */
@@ -303,6 +348,11 @@ Bool Mga16AccelInit(ScreenPtr pScreen);
Bool Mga24AccelInit(ScreenPtr pScreen);
Bool Mga32AccelInit(ScreenPtr pScreen);
+void Mga8InitSolidFillRectFuncs(MGAPtr pMga);
+void Mga16InitSolidFillRectFuncs(MGAPtr pMga);
+void Mga24InitSolidFillRectFuncs(MGAPtr pMga);
+void Mga32InitSolidFillRectFuncs(MGAPtr pMga);
+
void MGAPolyArcThinSolid(DrawablePtr, GCPtr, int, xArc*);
Bool MGADGAInit(ScreenPtr pScreen);
@@ -319,6 +369,8 @@ Bool MgaCleanupDma(ScrnInfoPtr pScrn);
Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size);
#ifdef XF86DRI
Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags);
+void mgaGetQuiescence(ScrnInfoPtr pScrn);
+void mgaGetQuiescence_shared(ScrnInfoPtr pScrn);
#endif
void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
index 3c2fe556f..091dd3edb 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
@@ -24,7 +24,6 @@
#include "mga_bios.h"
#include "mga_reg.h"
-#include "mga_macros.h"
#include "mga.h"
#include "xf86DDC.h"
@@ -83,6 +82,12 @@ static Bool MGAGInit(ScrnInfoPtr, DisplayModePtr);
static void MGAGLoadPalette(ScrnInfoPtr, int, int*, LOCO*, VisualPtr);
static Bool MGAG_i2cInit(ScrnInfoPtr pScrn);
+
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+/* We don't need anymore: MGAGCalcClock and MGAGSetPCLK function */
+#ifndef USEMGAHAL
/*
* MGAGCalcClock - Calculate the PLL settings (m, n, p, s).
*
@@ -245,6 +250,10 @@ MGAGSetPCLK( ScrnInfoPtr pScrn, long f_out )
pReg->DacRegs[ MGA1064_PIX_PLLC_N ] = n & 0x7F;
pReg->DacRegs[ MGA1064_PIX_PLLC_P ] = (p & 0x07) | ((s & 0x03) << 3);
}
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
/*
* MGAGInit
@@ -283,6 +292,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
BppShift = pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1];
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
/* Allocate the DacRegs space if not done already */
if (pReg->DacRegs == NULL) {
pReg->DacRegs = xnfcalloc(DACREGSIZE, 1);
@@ -423,6 +436,10 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
default:
FatalError("MGA: unsupported depth\n");
}
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
/*
* This will initialize all of the generic VGA registers.
@@ -503,23 +520,49 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pVga->CRTC[21] = vd & 0xFF;
pVga->CRTC[22] = (vt + 1) & 0xFF;
- if (mode->Flags & V_DBLSCAN)
- pVga->CRTC[9] |= 0x80;
-
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_LOW ] =
pMga->FbCursorOffset >> 10;
pReg->DacRegs[ MGA1064_CURSOR_BASE_ADR_HI ] =
pMga->FbCursorOffset >> 18;
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
if (pMga->SyncOnGreen) {
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
pReg->DacRegs[ MGA1064_GEN_CTL ] &= ~0x20;
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
pReg->ExtVga[3] |= 0x40;
}
/* select external clock */
pVga->MiscOutReg |= 0x0C;
-
+
+#ifndef USEMGAHAL
+ if (mode->Flags & V_DBLSCAN)
+ pVga->CRTC[9] |= 0x80;
+#endif
+
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
MGAGSetPCLK( pScrn, mode->Clock );
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
/* This disables the VGA memory aperture */
pVga->MiscOutReg &= ~0x02;
@@ -630,7 +673,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
CARD32 optionMask;
MGAPtr pMga = MGAPTR(pScrn);
- CHECK_DMA_QUIESCENT( pMga, pScrn );
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
/*
* Code is needed to get things back to bank zero.
*/
@@ -665,6 +711,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK,
mgaReg->Option3);
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
/* restore CRTCEXT regs */
for (i = 0; i < 6; i++)
OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i);
@@ -712,12 +762,20 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
int i;
MGAPtr pMga = MGAPTR(pScrn);
- CHECK_DMA_QUIESCENT( pMga, pScrn );
+ if(pMga->SecondCrtc == TRUE) return;
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
/* Allocate the DacRegs space if not done already */
if (mgaReg->DacRegs == NULL) {
mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1);
}
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
/*
* Code is needed to get back to bank zero.
@@ -731,6 +789,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
vgaHWSave(pScrn, vgaReg, VGA_SR_MODE | (saveFonts ? VGA_SR_FONTS : 0));
MGAGSavePalette(pScrn, vgaReg->DAC);
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#ifndef USEMGAHAL
/*
* The port I/O code necessary to read in the extended registers.
*/
@@ -742,6 +804,10 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2);
if (pMga->Chipset == PCI_CHIP_MGAG400)
mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3);
+/*******************/
+/* ADDED BY MATROX */
+/*******************/
+#endif
for (i = 0; i < 6; i++)
{
@@ -833,8 +899,12 @@ MGAGSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
static Bool
MGAGUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs)
{
+ MGAPtr pMga = MGAPTR(xf86Screens[pScrn->myNum]);
+ /* This needs to detect if its on the second dac */
if( XF86SCRNINFO(pScrn)->currentMode->Flags & V_DBLSCAN )
return FALSE;
+ if( pMga->SecondCrtc == TRUE )
+ return FALSE;
return TRUE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
index db75b5985..41b82801c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.7 2000/08/25 13:42:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.5 2000/06/23 23:43:44 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -38,6 +38,11 @@ static void MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
void *readContextStore,
DRIContextType writeContextType,
void *writeContextStore);
+static void MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType readContextType,
+ void *readContextStore,
+ DRIContextType writeContextType,
+ void *writeContextStore);
extern void Mga8DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
extern void Mga8DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index);
@@ -145,7 +150,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
case 24:
break;
case 16:
- numConfigs = 4;
+ numConfigs = 8;
if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
numConfigs))) {
@@ -168,7 +173,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
i = 0;
depth = 1;
for (accum = 0; accum <= 1; accum++) {
- for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */
+ for (stencil = 0; stencil <= 1; stencil++) { /* no stencil for now */
for (db=1; db>=0; db--) {
pConfigs[i].vid = -1;
pConfigs[i].class = -1;
@@ -229,7 +234,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
break;
case 32:
- numConfigs = 4;
+ numConfigs = 8;
if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
numConfigs))) {
@@ -252,7 +257,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
i = 0;
depth = 1;
for (accum = 0; accum <= 1; accum++) {
- for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */
+ for (stencil = 0; stencil <= 1; stencil++) {
for (db=1; db>=0; db--) {
pConfigs[i].vid = -1;
pConfigs[i].class = -1;
@@ -282,7 +287,10 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].stereo = FALSE;
pConfigs[i].bufferSize = 32;
if (depth)
- pConfigs[i].depthSize = 32;
+ if (stencil)
+ pConfigs[i].depthSize = 24;
+ else
+ pConfigs[i].depthSize = 32;
else
pConfigs[i].depthSize = 0;
if (stencil)
@@ -291,7 +299,7 @@ MGAInitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].stencilSize = 0;
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
- if (stencil || accum)
+ if (accum)
pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
else
pConfigs[i].visualRating = GLX_NONE_EXT;
@@ -329,6 +337,39 @@ static unsigned int mylog2(unsigned int n)
return log2;
}
+static unsigned long MGAParseAgpMode(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(pScrn);
+ unsigned long mode_mask;
+
+ switch(pMga->agp_mode) {
+ case 4:
+ mode_mask = ~0x00000003;
+ break;
+ case 2:
+ if (pMga->Chipset == PCI_CHIP_MGAG200) {
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Enabling AGP 2x pll encoding\n");
+ OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_enable);
+ }
+ mode_mask = ~0x00000005;
+ break;
+ default:
+ /* Default to 1X agp mode */
+ case 1:
+ if (pMga->Chipset == PCI_CHIP_MGAG200) {
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Disabling AGP 2x pll encoding\n");
+ OUTREG(MGAREG_AGP_PLL, AGP_PLL_agp2xpllen_disable);
+ }
+ pMga->agp_mode = 1;
+ mode_mask = ~0x00000006;
+ break;
+ }
+
+ return mode_mask;
+}
Bool MGADRIScreenInit(ScreenPtr pScreen)
{
@@ -341,6 +382,7 @@ Bool MGADRIScreenInit(ScreenPtr pScreen)
int prim_size;
int init_offset;
int i;
+ unsigned long mode_mask;
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
* for canonical symbols in each module. */
@@ -442,7 +484,10 @@ Bool MGADRIScreenInit(ScreenPtr pScreen)
pDRIInfo->CreateContext = MGACreateContext;
pDRIInfo->DestroyContext = MGADestroyContext;
- pDRIInfo->SwapContext = MGADRISwapContext;
+ if (xf86IsEntityShared(pScrn->entityList[0]))
+ pDRIInfo->SwapContext = MGADRISwapContext_shared;
+ else
+ pDRIInfo->SwapContext = MGADRISwapContext;
switch( pScrn->bitsPerPixel ) {
case 8:
@@ -476,16 +521,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen)
{
drmVersionPtr version = drmGetVersion(pMGA->drmSubFD);
if (version) {
- if (version->version_major != 1 ||
+ if (version->version_major != 2 ||
version->version_minor != 0 ||
version->version_patchlevel < 0) {
/* incompatible drm version */
xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 2.0.x). Disabling DRI.\n",
version->version_major,
version->version_minor,
version->version_patchlevel);
- MGADRICloseScreen(pScreen);
+/* MGADRICloseScreen(pScreen); */
+
drmFreeVersion(version);
return FALSE;
}
@@ -524,16 +570,17 @@ Bool MGADRIScreenInit(ScreenPtr pScreen)
DRICloseScreen(pScreen);
return FALSE;
}
-
+
+ mode_mask = MGAParseAgpMode(pScreen);
+
pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD);
- /* Default to 1X agp mode */
- pMGADRIServer->agpMode &= ~0x00000002;
+ pMGADRIServer->agpMode &= mode_mask;
if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
- ErrorF("[drm] drmAgpEnabled succeeded\n");
+ ErrorF("[drm] drmAgpEnabled succeeded for AGP mode %dx\n", pMGA->agp_mode);
prim_size = 65536;
init_offset = ((prim_size + pMGADRIServer->warp_ucode_size +
@@ -724,22 +771,16 @@ MGADRICloseScreen(ScreenPtr pScreen)
MGAPtr pMGA = MGAPTR(pScrn);
MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo;
- MgaCleanupDma(pScrn);
-
+/* The DRI will automagically clean these up when driFD is closed */
if(pMGADRIServer->agp_map) {
- ErrorF("Unmapped agp region\n");
drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep);
pMGADRIServer->agp_map = 0;
}
if(pMGADRIServer->agpHandle) {
- ErrorF("Freeing agp memory\n");
- drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle);
pMGADRIServer->agpHandle = 0;
pMGADRIServer->agpSizep = 0;
}
if(pMGADRIServer->agpAcquired == TRUE) {
- ErrorF("releasing agp module\n");
- drmAgpRelease(pMGA->drmSubFD);
pMGADRIServer->agpAcquired = FALSE;
}
@@ -797,7 +838,8 @@ MGADRIFinishScreenInit(ScreenPtr pScreen)
}
-void mgaGetQuiescence( ScrnInfoPtr pScrn )
+void
+mgaGetQuiescence( ScrnInfoPtr pScrn )
{
MGAPtr pMga = MGAPTR(pScrn);
@@ -812,13 +854,13 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn )
OUTREG(MGAREG_MACCESS, pMga->MAccess);
OUTREG(MGAREG_PITCH, pLayout->displayWidth);
pMga->PlaneMask = ~0;
+ OUTREG(MGAREG_PLNWT, pMga->PlaneMask);
pMga->BgColor = 0;
pMga->FgColor = 0;
- OUTREG(MGAREG_PLNWT, ~0);
- OUTREG(MGAREG_BCOL, 0);
- OUTREG(MGAREG_FCOL, 0);
+ OUTREG(MGAREG_BCOL, pMga->BgColor);
+ OUTREG(MGAREG_FCOL, pMga->FgColor);
+ OUTREG(MGAREG_SRCORG, pMga->realSrcOrg);
pMga->SrcOrg = 0;
- OUTREG(MGAREG_SRCORG, 0);
OUTREG(MGAREG_DSTORG, pMga->DstOrg);
OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT);
OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
@@ -829,8 +871,27 @@ void mgaGetQuiescence( ScrnInfoPtr pScrn )
}
+void
+mgaGetQuiescence_shared( ScrnInfoPtr pScrn )
+{
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAEntPtr pMgaEnt = pMga->entityPrivate;
+ MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2);
-void MGASwapContext(ScreenPtr pScreen)
+ pMga = MGAPTR(pMgaEnt->pScrn_1);
+ pMga->have_quiescense = 1;
+ pMga2->have_quiescense = 1;
+
+ if (pMgaEnt->directRenderingEnabled) {
+ MgaLockUpdate(pMgaEnt->pScrn_1, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH));
+ pMga->RestoreAccelState(pScrn);
+ xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex);
+ }
+}
+
+
+void
+MGASwapContext(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MGAPtr pMga = MGAPTR(pScrn);
@@ -842,6 +903,20 @@ void MGASwapContext(ScreenPtr pScreen)
pMga->AccelInfoRec->NeedToSync = TRUE;
}
+void
+MGASwapContext_shared(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAEntPtr pMgaEnt = pMga->entityPrivate;
+ MGAPtr pMga2 = MGAPTR(pMgaEnt->pScrn_2);
+
+ pMga = MGAPTR(pMgaEnt->pScrn_1);
+ pMga->have_quiescense = 0;
+ pMga->AccelInfoRec->NeedToSync = TRUE;
+ pMga2->have_quiescense = 0;
+ pMga2->AccelInfoRec->NeedToSync = TRUE;
+}
/* This is really only called from validate/postvalidate as we
@@ -874,6 +949,18 @@ MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
}
}
+static void
+MGADRISwapContext_shared(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext)
+{
+ if (syncType == DRI_3D_SYNC &&
+ oldContextType == DRI_2D_CONTEXT &&
+ newContextType == DRI_2D_CONTEXT)
+ {
+ MGASwapContext_shared(pScreen);
+ }
+}
void
MGASelectBuffer(ScrnInfoPtr pScrn, int which)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
index ea5d061e1..845e3f85a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
@@ -43,7 +43,7 @@
* Fixed 32bpp hires 8MB horizontal line glitch at middle right
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.167 2000/09/20 00:09:22 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.165 2000/07/11 01:46:36 tsi Exp $ */
/*
* This is a first cut at a non-accelerated version to work with the
@@ -79,11 +79,10 @@
#include "xf86RAC.h"
#include "vbe.h"
-#include "cfb8_32.h"
#include "fb.h"
+#include "cfb8_32.h"
#include "dixstruct.h"
-#include "mga_bios.h"
#include "mga_reg.h"
#include "mga.h"
#include "mga_macros.h"
@@ -118,6 +117,7 @@ static Bool MGAEnterVTFBDev(int scrnIndex, int flags);
static void MGALeaveVT(int scrnIndex, int flags);
static Bool MGACloseScreen(int scrnIndex, ScreenPtr pScreen);
static Bool MGASaveScreen(ScreenPtr pScreen, int mode);
+static Bool MGASaveScreenCrtc2(ScreenPtr pScreen, int mode);
/* This shouldn't be needed since RAC will disable all I/O for MGA cards. */
#ifdef DISABLE_VGA_IO
@@ -141,8 +141,10 @@ static Bool MGAUnmapMem(ScrnInfoPtr pScrn);
static void MGASave(ScrnInfoPtr pScrn);
static void MGARestore(ScrnInfoPtr pScrn);
static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags);
static void MGABlockHandler(int, pointer, pointer, pointer);
+static int MGAEntityIndex = -1;
/*
* This contains the functions needed by the server after loading the
@@ -152,7 +154,7 @@ static void MGABlockHandler(int, pointer, pointer, pointer);
* this DriverRec be an upper-case version of the driver name.
*/
-DriverRec MGA = {
+DriverRec MGA_C_NAME = {
MGA_VERSION,
MGA_DRIVER_NAME,
#if 0
@@ -207,7 +209,10 @@ typedef enum {
OPTION_VIDEO_KEY,
OPTION_ROTATE,
OPTION_TEXTURED_VIDEO,
- OPTION_XAALINES
+ OPTION_XAALINES,
+ OPTION_CRTC2HALF,
+ OPTION_AGP_MODE_2X,
+ OPTION_AGP_MODE_4X
} MGAOpts;
static OptionInfoRec MGAOptions[] = {
@@ -228,6 +233,9 @@ static OptionInfoRec MGAOptions[] = {
{ OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_XAALINES, "XAALines", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_CRTC2HALF, "Crtc2Half", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_AGP_MODE_2X, "AGPMode2x", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_AGP_MODE_4X, "AGPMode4x", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -395,7 +403,7 @@ static MODULESETUPPROTO(mgaSetup);
static XF86ModuleVersionInfo mgaVersRec =
{
- "mga",
+ MGA_DRIVER_NAME,
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
@@ -407,7 +415,7 @@ static XF86ModuleVersionInfo mgaVersRec =
{0,0,0,0}
};
-XF86ModuleData mgaModuleData = { &mgaVersRec, mgaSetup, NULL };
+XF86ModuleData MGA_MODULE_DATA = { &mgaVersRec, mgaSetup, NULL };
static pointer
mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin)
@@ -418,7 +426,7 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin)
if (!setupDone) {
setupDone = TRUE;
- xf86AddDriver(&MGA, module, 0);
+ xf86AddDriver(&MGA_C_NAME, module, 0);
/*
* Modules that this driver always requires may be loaded here
@@ -429,10 +437,11 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin)
* Tell the loader about symbols from other modules that this module
* might refer to.
*/
- LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
+ LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
xf8_32bppSymbols, ramdacSymbols,
ddcSymbols, i2cSymbols, shadowSymbols,
- fbdevHWSymbols, vbeSymbols, fbSymbols,
+ fbdevHWSymbols, vbeSymbols,
+ fbSymbols,
#ifdef XF86DRI
drmSymbols, driSymbols,
#endif
@@ -575,6 +584,7 @@ MGAProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
ScrnInfoPtr pScrn;
+ EntityInfoPtr pEnt;
#ifdef DISABLE_VGA_IO
MgaSavePtr smga;
#endif
@@ -610,6 +620,37 @@ MGAProbe(DriverPtr drv, int flags)
pScrn->ValidMode = MGAValidMode;
foundScreen = TRUE;
}
+
+ /*
+ * For cards that can do dual head per entity, mark the entity
+ * as sharable.
+ */
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+ if (pEnt->chipset == PCI_CHIP_MGAG400) {
+ MGAEntPtr pMgaEnt = NULL;
+ DevUnion *pPriv;
+
+ xf86SetEntitySharable(usedChips[i]);
+ /* Allocate an entity private if necessary */
+ if (MGAEntityIndex < 0)
+ MGAEntityIndex = xf86AllocateEntityPrivateIndex();
+ pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
+ if (!pPriv->ptr) {
+ pPriv->ptr = xnfcalloc(sizeof(MGAEntRec), 1);
+ pMgaEnt = pPriv->ptr;
+ pMgaEnt->lastInstance = -1;
+ } else {
+ pMgaEnt = pPriv->ptr;
+ }
+ /*
+ * Set the entity instance for this instance of the driver. For
+ * dual head per card, instance 0 is the "master" instance, driving
+ * the primary head, and instance 1 is the "slave".
+ */
+ pMgaEnt->lastInstance++;
+ xf86SetEntityInstanceForScreen(pScrn, pScrn->entityList[0],
+ pMgaEnt->lastInstance);
+ }
}
if (usedChips)
xfree(usedChips);
@@ -783,6 +824,7 @@ MGASoftReset(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
+ ErrorF("SoftReset called!!!\n");
pMga->FbMapSize = 8192 * 1024;
MGAMapMem(pScrn);
@@ -1071,8 +1113,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
double real;
int bytesPerPixel;
ClockRangePtr clockRanges;
+ const char *reqSym = NULL;
const char *s;
int flags24;
+ MGAEntPtr pMgaEnt = NULL;
+#ifdef USEMGAHAL
+ MGAMODEINFO mgaModeInfo = {0};
+ ULONG ulBOARDHANDLESize;
+ UCHAR ucMgaBase2;
+ ULONG ulOrgFBuffer;
+#endif
/*
* Note: This function is only called once at server startup, and
@@ -1097,12 +1147,26 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
pMga = MGAPTR(pScrn);
-
+ /* Set here until dri is enabled */
+#ifdef XF86DRI
+ pMga->have_quiescense = 1;
+#endif
/* Get the entity, and make sure it is PCI. */
pMga->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
if (pMga->pEnt->location.type != BUS_PCI)
return FALSE;
+ /* Allocate an entity private if necessary */
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ pMgaEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+ MGAEntityIndex)->ptr;
+ pMga->entityPrivate = pMgaEnt;
+ }
+
+ /* Set pMga->device to the relevant Device section */
+ pMga->device = xf86GetDevFromEntity(pScrn->entityList[0],
+ pScrn->entityInstanceList[0]);
+
if (flags & PROBE_DETECT) {
MGAProbeDDC(pScrn, pMga->pEnt->index);
return TRUE;
@@ -1173,6 +1237,55 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
/* Set pScrn->monitor */
pScrn->monitor = pScrn->confScreen->monitor;
+#if 1
+ /*
+ * XXX This assumes that the lower number screen is always the "master"
+ * head, and that the "master" is the first CRTC. This can result in
+ * unexpected behaviour when the config file marks the primary CRTC
+ * as the second screen.
+ */
+ if(xf86IsEntityShared(pScrn->entityList[0]) &&
+ xf86IsPrimInitDone(pScrn->entityList[0])) {
+ /* This is the second crtc */
+ pMga->SecondCrtc = TRUE;
+ pMga->HWCursor = FALSE;
+ pScrn->AdjustFrame = MGAAdjustFrameCrtc2;
+ pMgaEnt->pScrn_2 = pScrn;
+#ifdef XF86DRI
+ pMga->GetQuiescence = mgaGetQuiescence_shared;
+#endif
+ } else {
+ pMga->SecondCrtc = FALSE;
+ pMga->HWCursor = TRUE;
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ pMgaEnt->pScrn_1 = pScrn;
+#ifdef XF86DRI
+ pMga->GetQuiescence = mgaGetQuiescence_shared;
+#endif
+ } else {
+#ifdef XF86DRI
+ pMga->GetQuiescence = mgaGetQuiescence;
+#endif
+ }
+ }
+#else
+ /*
+ * This is an alternative version that determines which is the secondary
+ * CRTC from the screen field in pMga->device. It doesn't currently
+ * work becasue there are things that assume the primary CRTC is
+ * initialised first.
+ */
+ if (pMga->device->screen == 1) {
+ /* This is the second CRTC */
+ pMga->SecondCrtc = TRUE;
+ pMga->HWCursor = FALSE;
+ pScrn->AdjustFrame = MGAAdjustFrameCrtc2;
+ } else {
+ pMga->SecondCrtc = FALSE;
+ pMga->HWCursor = TRUE;
+ }
+#endif
+
/*
* The first thing we should figure out is the depth, bpp, etc.
* Our default depth is 8, so pass it to the helper function.
@@ -1183,10 +1296,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
flags24 = Support24bppFb | Support32bppFb | SupportConvert32to24;
s = xf86TokenToOptName(MGAOptions, OPTION_OVERLAY);
if (!(xf86FindOption(pScrn->confScreen->options, s) ||
- xf86FindOption(pMga->pEnt->device->options, s))) {
+ xf86FindOption(pMga->device->options, s))) {
flags24 |= PreferConvert32to24;
}
+ if (pMga->SecondCrtc)
+ flags24 = Support32bppFb;
+
if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) {
return FALSE;
} else {
@@ -1243,12 +1359,12 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* Set the Chipset and ChipRev, allowing config file entries to
* override.
*/
- if (pMga->pEnt->device->chipset && *pMga->pEnt->device->chipset) {
- pScrn->chipset = pMga->pEnt->device->chipset;
+ if (pMga->device->chipset && *pMga->device->chipset) {
+ pScrn->chipset = pMga->device->chipset;
pMga->Chipset = xf86StringToToken(MGAChipsets, pScrn->chipset);
from = X_CONFIG;
- } else if (pMga->pEnt->device->chipID >= 0) {
- pMga->Chipset = pMga->pEnt->device->chipID;
+ } else if (pMga->device->chipID >= 0) {
+ pMga->Chipset = pMga->device->chipID;
pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
from = X_CONFIG;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
@@ -1258,8 +1374,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->Chipset = pMga->PciInfo->chipType;
pScrn->chipset = (char *)xf86TokenToString(MGAChipsets, pMga->Chipset);
}
- if (pMga->pEnt->device->chipRev >= 0) {
- pMga->ChipRev = pMga->pEnt->device->chipRev;
+ if (pMga->device->chipRev >= 0) {
+ pMga->ChipRev = pMga->device->chipRev;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
pMga->ChipRev);
} else {
@@ -1305,8 +1421,31 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->numXAALines);
}
+#ifdef XF86DRI
+ {
+ Bool temp;
+
+ from = X_DEFAULT;
+
+ pMga->agp_mode = 1;
+ if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_2X,
+ &temp)) {
+ pMga->agp_mode = 2;
+ from = X_CONFIG;
+ }
+
+ if (xf86GetOptValBool(MGAOptions, OPTION_AGP_MODE_4X,
+ &temp)) {
+ pMga->agp_mode = 4;
+ from = X_CONFIG;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using AGP Mode %dx\n",
+ pMga->agp_mode);
+ }
+#endif
+
from = X_DEFAULT;
- pMga->HWCursor = TRUE;
+
/*
* The preferred method is to use the "hw cursor" option as a tri-state
* option, with the default set above.
@@ -1346,7 +1485,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
if ((s = xf86GetOptValString(MGAOptions, OPTION_OVERLAY))) {
if (!*s || !xf86NameCmp(s, "8,24") || !xf86NameCmp(s, "24,8")) {
- if(pScrn->bitsPerPixel == 32) {
+ if(pScrn->bitsPerPixel == 32 && pMga->SecondCrtc == FALSE) {
pMga->Overlay8Plus24 = TRUE;
if(!xf86GetOptValInteger(
MGAOptions, OPTION_COLOR_KEY,&(pMga->colorKey)))
@@ -1357,13 +1496,15 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
"PseudoColor overlay enabled\n");
} else {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Option \"Overlay\" is only supported in 32 bits per pixel\n");
+ "Option \"Overlay\" is only supported in 32 bits per pixel on"
+ "the first CRTC\n");
}
} else {
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"\"%s\" is not a valid value for Option \"Overlay\"\n", s);
}
}
+
if(xf86GetOptValInteger(MGAOptions, OPTION_VIDEO_KEY, &(pMga->videoKey))) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n",
pMga->videoKey);
@@ -1467,16 +1608,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* For the 2064 and older rev 1064, base0 is the MMIO and base0 is
* the framebuffer is base1. Let the config file override these.
*/
- if (pMga->pEnt->device->MemBase != 0) {
+ if (pMga->device->MemBase != 0) {
/* Require that the config file value matches one of the PCI values. */
- if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->MemBase)) {
+ if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->MemBase)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"MemBase 0x%08lX doesn't match any PCI base register.\n",
- pMga->pEnt->device->MemBase);
+ pMga->device->MemBase);
MGAFreeRec(pScrn);
return FALSE;
}
- pMga->FbAddress = pMga->pEnt->device->MemBase;
+ pMga->FbAddress = pMga->device->MemBase;
from = X_CONFIG;
} else {
/* details: mgabase2 sdk pp 4-12 */
@@ -1493,19 +1634,20 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
}
+
xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n",
(unsigned long)pMga->FbAddress);
- if (pMga->pEnt->device->IOBase != 0) {
+ if (pMga->device->IOBase != 0) {
/* Require that the config file value matches one of the PCI values. */
- if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->pEnt->device->IOBase)) {
+ if (!xf86CheckPciMemBase(pMga->PciInfo, pMga->device->IOBase)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"IOBase 0x%08lX doesn't match any PCI base register.\n",
- pMga->pEnt->device->IOBase);
+ pMga->device->IOBase);
MGAFreeRec(pScrn);
return FALSE;
}
- pMga->IOAddress = pMga->pEnt->device->IOBase;
+ pMga->IOAddress = pMga->device->IOBase;
from = X_CONFIG;
} else {
/* details: mgabase1 sdk pp 4-11 */
@@ -1542,9 +1684,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
*/
pMga->BiosFrom = X_NONE;
- if (pMga->pEnt->device->BiosBase != 0) {
+ if (pMga->device->BiosBase != 0) {
/* XXX This isn't used */
- pMga->BiosAddress = pMga->pEnt->device->BiosBase;
+ pMga->BiosAddress = pMga->device->BiosBase;
pMga->BiosFrom = X_CONFIG;
} else {
/* details: rombase sdk pp 4-15 */
@@ -1591,20 +1733,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* file, we respect that setting.
*/
from = X_PROBED;
- if (pMga->pEnt->device->videoRam != 0) {
- pScrn->videoRam = pMga->pEnt->device->videoRam;
+ if (pMga->device->videoRam != 0) {
+ pScrn->videoRam = pMga->device->videoRam;
from = X_CONFIG;
} else if (pMga->FBDev) {
pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024;
} else {
pScrn->videoRam = MGACountRam(pScrn);
}
+
+ if(xf86IsEntityShared(pScrn->entityList[0])) {
+ /* This takes gives either half or 8 meg to the second head
+ * whichever is less. */
+ if(pMga->SecondCrtc == FALSE) {
+ Bool UseHalf = FALSE;
+ int adjust;
+
+ xf86GetOptValBool(MGAOptions, OPTION_CRTC2HALF, &UseHalf);
+ adjust = pScrn->videoRam / 2;
+
+ if (UseHalf == TRUE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Crtc2 will use %dK of VideoRam\n",
+ adjust);
+ } else {
+ adjust = min(adjust, 8192);
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Crtc2 will use %dK of VideoRam\n",
+ adjust);
+ }
+ pMgaEnt->mastervideoRam = pScrn->videoRam - adjust;
+ pScrn->videoRam = pMgaEnt->mastervideoRam;
+ pMgaEnt->slavevideoRam = adjust;
+ pMgaEnt->masterFbAddress = pMga->FbAddress;
+ pMga->FbMapSize =
+ pMgaEnt->masterFbMapSize = pScrn->videoRam * 1024;
+ pMgaEnt->slaveFbAddress = pMga->FbAddress +
+ pMgaEnt->masterFbMapSize;
+ pMgaEnt->slaveFbMapSize = pMgaEnt->slavevideoRam * 1024;
+ pMga->realSrcOrg = pMga->SrcOrg = 0;
+ pMga->DstOrg = 0;
+ } else {
+ pMga->FbAddress = pMgaEnt->slaveFbAddress;
+ pMga->FbMapSize = pMgaEnt->slaveFbMapSize;
+ pScrn->videoRam = pMgaEnt->slavevideoRam;
+ pMga->DstOrg = pMga->realSrcOrg =
+ pMgaEnt->slaveFbAddress - pMgaEnt->masterFbAddress;
+ pMga->SrcOrg = 0; /* This is not stored in hw format!! */
+ }
+ pMgaEnt->refCount++;
+ } else {
+ /* Normal Handling of video ram etc */
+ pMga->FbMapSize = pScrn->videoRam * 1024;
+ switch(pMga->Chipset) {
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ pMga->SrcOrg = 0;
+ pMga->DstOrg = 0;
+ break;
+ default:
+ break;
+ }
+ }
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
pScrn->videoRam);
-
- pMga->FbMapSize = pScrn->videoRam * 1024;
-
- /* Set the bpp shift value */
+
+ /* Set the bpp shift value */
pMga->BppShifts[0] = 0;
pMga->BppShifts[1] = 1;
pMga->BppShifts[2] = 0;
@@ -1670,25 +1865,25 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* If the user has specified ramdac speed in the XF86Config
* file, we respect that setting.
*/
- if (pMga->pEnt->device->dacSpeeds[0]) {
+ if (pMga->device->dacSpeeds[0]) {
int speed = 0;
switch (pScrn->bitsPerPixel) {
case 8:
- speed = pMga->pEnt->device->dacSpeeds[DAC_BPP8];
+ speed = pMga->device->dacSpeeds[DAC_BPP8];
break;
case 16:
- speed = pMga->pEnt->device->dacSpeeds[DAC_BPP16];
+ speed = pMga->device->dacSpeeds[DAC_BPP16];
break;
case 24:
- speed = pMga->pEnt->device->dacSpeeds[DAC_BPP24];
+ speed = pMga->device->dacSpeeds[DAC_BPP24];
break;
case 32:
- speed = pMga->pEnt->device->dacSpeeds[DAC_BPP32];
+ speed = pMga->device->dacSpeeds[DAC_BPP32];
break;
}
if (speed == 0)
- pMga->MaxClock = pMga->pEnt->device->dacSpeeds[0];
+ pMga->MaxClock = pMga->device->dacSpeeds[0];
else
pMga->MaxClock = speed;
from = X_CONFIG;
@@ -1696,10 +1891,13 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->MaxClock = pMga->Dac.maxPixelClock;
from = pMga->Dac.ClockFrom;
}
+ if(pMga->SecondCrtc == TRUE) {
+ /* Override on 2nd crtc */
+ pMga->MaxClock = 112000;
+ }
xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n",
pMga->MaxClock / 1000);
-
- /*
+ /*
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
@@ -1708,8 +1906,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
clockRanges->minClock = pMga->MinClock;
clockRanges->maxClock = pMga->MaxClock;
clockRanges->clockIndex = -1; /* programmable */
- clockRanges->interlaceAllowed = TRUE;
+#ifdef USEMGAHAL
+ clockRanges->interlaceAllowed = FALSE;
+ clockRanges->doubleScanAllowed = FALSE;
+#else
+ if (pMga->SecondCrtc == TRUE)
+ clockRanges->interlaceAllowed = FALSE;
+ else
+ clockRanges->interlaceAllowed = TRUE;
clockRanges->doubleScanAllowed = TRUE;
+#endif
clockRanges->ClockMulFactor = 1;
clockRanges->ClockDivFactor = 1;
@@ -1788,6 +1994,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
i = 1;
}
if (i == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Validate Modes Failed\n");
MGAFreeRec(pScrn);
return FALSE;
}
@@ -1800,6 +2007,86 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
MGAFreeRec(pScrn);
return FALSE;
}
+ /*******************/
+ /* ADDED BY MATROX */
+ /*******************/
+#ifdef USEMGAHAL
+ if(pMga->SecondCrtc == FALSE) {
+ ulBOARDHANDLESize = MGAGetBOARDHANDLESize();
+ pMga->pBoard = (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) + ulBOARDHANDLESize);
+ pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA));
+ /* Fill the client part */
+ pMga->pClientStruct->pMga = (MGAPtr) pMga;
+
+ /* Determine the Frame buffer limit size */
+ if((pMga->Chipset == PCI_CHIP_MGA1064 && pMga->ChipRev < 3) ||
+ (pMga->Chipset == PCI_CHIP_MGA2064)) {
+ ucMgaBase2 = 0x14;
+ } else {
+ ucMgaBase2 = 0x10;
+ }
+#if 0
+ /*
+ * This is bad for cards where there is less physical memory than
+ * the PCI map size.
+ */
+ ulOrgFBuffer = pciReadLong(pMga->PciTag,ucMgaBase2);
+ pciWriteLong(pMga->PciTag,ucMgaBase2,0xffffffff);
+ pMga->FbMapSize = pciReadLong(pMga->PciTag,ucMgaBase2);
+ pciWriteLong(pMga->PciTag,ucMgaBase2,ulOrgFBuffer);
+ pMga->FbMapSize = ~(pMga->FbMapSize & 0xfffffff0) + 1;
+#endif
+ /* Open the matrox low level library */
+ MGAMapMem(pScrn);
+ MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
+ MGAUnmapMem(pScrn);
+ pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO));
+ MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
+ /* copy the board handles */
+ if(xf86IsEntityShared(pScrn->entityList[0])) {
+ pMgaEnt->pClientStruct = pMga->pClientStruct;
+ pMgaEnt->pBoard = pMga->pBoard;
+ pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
+ }
+ mgaModeInfo.flOutput = MGAMODEINFO_ANALOG1;
+#if 1
+ mgaModeInfo.ulDispWidth = pScrn->virtualX;
+ mgaModeInfo.ulDispHeight = pScrn->virtualY;
+#else
+ mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay;
+ mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay;
+#endif
+ mgaModeInfo.ulDeskWidth = pScrn->virtualX;
+ mgaModeInfo.ulDeskHeight = pScrn->virtualY;
+ mgaModeInfo.ulBpp = pScrn->bitsPerPixel;
+ mgaModeInfo.ulZoom = 1;
+ } else { /* Second CRTC && entity is shared */
+ mgaModeInfo.flOutput = MGAMODEINFO_ANALOG2 |
+ MGAMODEINFO_SECOND_CRTC;
+#if 1
+ mgaModeInfo.ulDispWidth = pScrn->virtualX;
+ mgaModeInfo.ulDispHeight = pScrn->virtualY;
+#else
+ mgaModeInfo.ulDispWidth = pScrn->modes->HDisplay;
+ mgaModeInfo.ulDispHeight = pScrn->modes->VDisplay;
+#endif
+ mgaModeInfo.ulDeskWidth = pScrn->virtualX;
+ mgaModeInfo.ulDeskHeight = pScrn->virtualY;
+ mgaModeInfo.ulBpp = pScrn->bitsPerPixel;
+ mgaModeInfo.ulZoom = 1;
+ pMga->pBoard = pMgaEnt->pBoard;
+ pMga->pClientStruct = pMgaEnt->pClientStruct;
+ pMga->pMgaHwInfo = pMga->pMgaHwInfo;
+ }
+ if(MGAValidateMode(pMga->pBoard,&mgaModeInfo) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "MGAValidateMode found the mode to be invalid\n");
+ return FALSE;
+ }
+
+ pScrn->displayWidth = mgaModeInfo.ulFBPitch;
+
+#endif /* USEMGAHAL */
/*
* Set the CRTC parameters for all of the modes based on the type
@@ -1809,8 +2096,11 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* driver and if the driver doesn't provide code to set them. They
* are not pre-initialised at all.
*/
- xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
-
+#ifdef USEMGAHAL
+ xf86SetCrtcForModes(pScrn, 0);
+#else
+ xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
+#endif
/* Set the current mode to the first in the list */
pScrn->currentMode = pScrn->modes;
@@ -1869,43 +2159,73 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "YDstOrg is set to %d\n",
pMga->YDstOrg);
- pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel;
+ if(xf86IsEntityShared(pScrn->entityList[0])) {
+ if(pMga->SecondCrtc == FALSE) {
+ pMga->FbUsableSize = pMgaEnt->masterFbMapSize;
+ /* Allocate HW cursor buffer at the end of video ram */
+ if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
+ if( pScrn->virtualY * pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8 <=
+ pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) {
+ pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
+ pMga->FbCursorOffset =
+ pMgaEnt->masterFbMapSize -
+ pMga->Dac.CursorOffscreenMemSize;
+ } else {
+ pMga->HWCursor = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Too little offscreen memory for HW cursor; "
+ "using SW cursor\n");
+ }
+ }
+ } else { /* Second CRTC */
+ pMga->FbUsableSize = pMgaEnt->slaveFbMapSize;
+ pMga->HWCursor = FALSE;
+ }
+ } else {
+ pMga->FbUsableSize = pMga->FbMapSize - pMga->YDstOrg * bytesPerPixel;
+ /* Allocate HW cursor buffer at the end of video ram */
+ if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
+ if( pScrn->virtualY * pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8 <=
+ pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) {
+ pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
+ pMga->FbCursorOffset =
+ pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize;
+ } else {
+ pMga->HWCursor = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Too little offscreen memory for HW cursor; "
+ "using SW cursor\n");
+ }
+ }
+ }
/*
* XXX This should be taken into account in some way in the mode valdation
* section.
*/
- /* Allocate HW cursor buffer at the end of video ram */
- if( pMga->HWCursor && pMga->Dac.CursorOffscreenMemSize ) {
- if( pScrn->virtualY * pScrn->displayWidth * pScrn->bitsPerPixel / 8 <=
- pMga->FbUsableSize - pMga->Dac.CursorOffscreenMemSize ) {
- pMga->FbUsableSize -= pMga->Dac.CursorOffscreenMemSize;
- pMga->FbCursorOffset =
- pMga->FbMapSize - pMga->Dac.CursorOffscreenMemSize;
- } else {
- pMga->HWCursor = FALSE;
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Too little offscreen memory for HW cursor; using SW cursor\n");
- }
- }
/* Load the required framebuffer */
- if(pMga->Overlay8Plus24) {
+ if (pMga->Overlay8Plus24) {
if (!xf86LoadSubModule(pScrn, "xf8_32bpp")) {
MGAFreeRec(pScrn);
return FALSE;
}
- xf86LoaderReqSymbols("cfb8_32ScreenInit", NULL);
+ reqSym = "cfb8_32ScreenInit";
} else {
if (!xf86LoadSubModule(pScrn, "fb")) {
MGAFreeRec(pScrn);
return FALSE;
}
+ reqSym = "fbScreenInit";
xf86LoaderReqSymbols("fbScreenInit", NULL);
#ifdef RENDER
xf86LoaderReqSymbols("fbPictureInit", NULL);
#endif
}
+ xf86LoaderReqSymbols(reqSym, NULL);
+
/* Load XAA if needed */
if (!pMga->NoAccel) {
@@ -1942,7 +2262,43 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->CurrentLayout.weight.blue = pScrn->weight.blue;
pMga->CurrentLayout.Overlay8Plus24 = pMga->Overlay8Plus24;
pMga->CurrentLayout.mode = pScrn->currentMode;
+#ifdef USEMGAHAL
+ /* Close the library after preinit */
+ /* This needs to only happen after this board has completed preinit
+ * both times
+ */
+ if(xf86IsEntityShared(pScrn->entityList[0])) {
+ /* Entity is shared make sure refcount == 2 */
+ /* If ref count is 2 then reset it to 0 */
+ if(pMgaEnt->refCount == 2) {
+ /* Both boards have done there initialization */
+ MGACloseLibrary(pMga->pBoard);
+
+ if (pMga->pBoard)
+ xfree(pMga->pBoard);
+ if (pMga->pClientStruct)
+ xfree(pMga->pClientStruct);
+ if (pMga->pMgaModeInfo)
+ xfree(pMga->pMgaModeInfo);
+ if (pMga->pMgaHwInfo)
+ xfree(pMga->pMgaHwInfo);
+ pMgaEnt->refCount = 0;
+ }
+ } else {
+ MGACloseLibrary(pMga->pBoard);
+
+ if (pMga->pBoard)
+ xfree(pMga->pBoard);
+ if (pMga->pClientStruct)
+ xfree(pMga->pClientStruct);
+ if (pMga->pMgaModeInfo)
+ xfree(pMga->pMgaModeInfo);
+ if (pMga->pMgaHwInfo)
+ xfree(pMga->pMgaHwInfo);
+ }
+#endif
+ xf86SetPrimInitDone(pScrn->entityList[0]);
return TRUE;
}
@@ -2089,10 +2445,51 @@ MGASave(ScrnInfoPtr pScrn)
MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg = &pMga->SavedReg;
+#ifdef USEMGAHAL
+ if(pMga->SecondCrtc == TRUE) return;
+
+ if(pMga->pBoard != NULL) {
+ MGASaveVgaState(pMga->pBoard);
+ }
+#endif
+
/* Only save text mode fonts/text for the primary card */
(*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary);
}
+#ifdef USEMGAHAL
+/* Convert DisplayModeRec parameters in MGAMODEINFO parameters. */
+static void FillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ MGAPtr pMga = MGAPTR(pScrn);
+ pMga->pMgaModeInfo = (LPMGAMODEINFO) xalloc (sizeof(MGAMODEINFO));
+
+ pMga->pMgaModeInfo->flOutput = 0;
+ pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay;
+ pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay;
+ pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX;
+ pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY;
+ pMga->pMgaModeInfo->ulFBPitch = 0;
+ pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel;
+ pMga->pMgaModeInfo->ulZoom = 1;
+ pMga->pMgaModeInfo->flSignalMode = 0;
+ pMga->pMgaModeInfo->ulRefreshRate = 0;
+ pMga->pMgaModeInfo->ulHorizRate = 0;
+ pMga->pMgaModeInfo->ulPixClock = mode->Clock;
+ pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay;
+ pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart;
+ pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd;
+ pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay;
+ pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart;
+ pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd;
+ /* Use DstOrg directly */
+ /* This is an offset in pixels not memory */
+ pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
+ pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
+ pMga->pMgaModeInfo->ulPanXGran = 0;
+ pMga->pMgaModeInfo->ulPanYGran = 0;
+}
+#endif /* USEMGAHAL */
/*
* Initialise a new mode. This is currently still using the old
@@ -2123,13 +2520,57 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
vgaReg = &hwp->ModeReg;
mgaReg = &pMga->ModeReg;
+#ifdef USEMGAHAL
+ FillModeInfoStruct(pScrn,mode);
+
+ if(pMga->SecondCrtc == TRUE) {
+ pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG2 |
+ MGAMODEINFO_SECOND_CRTC |
+ MGAMODEINFO_FORCE_PITCH |
+ MGAMODEINFO_FORCE_DISPLAYORG;
+ } else {
+ pMga->pMgaModeInfo->flOutput = MGAMODEINFO_ANALOG1 |
+ MGAMODEINFO_FORCE_PITCH;
+ }
+
+ pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth;
+ if(MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n");
+ return FALSE;
+ }
+
+ if(MGAValidateVideoParameters(pMga->pBoard,pMga->pMgaModeInfo) != 0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"Invalid parameters\n");
+ return FALSE;
+ }
+#endif /* USEMGAHAL */
+
#ifdef XF86DRI
if (pMga->directRenderingEnabled) {
DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
}
#endif
+
+#ifdef USEMGAHAL
+ if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) {
+ return FALSE;
+ }
+
+#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val)
+
+#define outMGAdac(reg, val) \
+ (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val))
+
+ if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
+ outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW, pMga->FbCursorOffset >> 10);
+ outMGAdac(MGA1064_CURSOR_BASE_ADR_HI, pMga->FbCursorOffset >> 18);
+ }
+#endif /* USEMGAHAL */
+
+#ifndef USEMGAHAL
(*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE);
+#endif
MGAStormSync(pScrn);
MGAStormEngineInit(pScrn);
@@ -2163,19 +2604,50 @@ MGARestore(ScrnInfoPtr pScrn)
MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg = &pMga->SavedReg;
- if (pScrn->pScreen != NULL)
- MGAStormSync(pScrn);
+ if (pScrn->pScreen != NULL)
+ MGAStormSync(pScrn);
+
+ if(pMga->SecondCrtc == TRUE) return;
/* Only restore text mode fonts/text for the primary card */
vgaHWProtect(pScrn, TRUE);
- if (pMga->Primary)
+ if (pMga->Primary) {
+#ifdef USEMGAHAL
+ if(pMga->pBoard != NULL) {
+ MGASetVgaMode(pMga->pBoard);
+ MGARestoreVgaState(pMga->pBoard);
+ }
+#endif
(*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
- else
+ } else {
vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+ }
vgaHWProtect(pScrn, FALSE);
}
+/* Workaround for a G400 CRTC2 display problem */
+static void
+MGACrtc2FillStrip(ScrnInfoPtr pScrn)
+{
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ if (pMga->NoAccel) {
+ /* Clears the whole screen, but ... */
+ bzero(pMga->FbStart,
+ (pScrn->bitsPerPixel >> 3) * pScrn->displayWidth * pScrn->virtualY);
+ } else {
+ xf86SetLastScrnFlag(pScrn->entityList[0], pScrn->scrnIndex);
+ pMga->RestoreAccelState(pScrn);
+ pMga->SetupForSolidFill(pScrn, 0, GXcopy, 0xFFFFFFFF);
+ pMga->SubsequentSolidFillRect(pScrn, pScrn->virtualX, 0,
+ pScrn->displayWidth - pScrn->virtualX,
+ pScrn->virtualY);
+ MGAStormSync(pScrn);
+ }
+}
+
+
/* Mandatory */
/* This gets called at the start of each server generation */
@@ -2191,6 +2663,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
VisualPtr visual;
unsigned char *FBStart;
int width, height, displayWidth;
+ MGAEntPtr pMgaEnt = NULL;
+ int f;
/*
* First get the ScrnInfoRec
@@ -2200,6 +2674,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
hwp = VGAHWPTR(pScrn);
pMga = MGAPTR(pScrn);
MGAdac = &pMga->Dac;
+
/* Map the MGA memory and MMIO areas */
if (pMga->FBDev) {
@@ -2210,6 +2685,51 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
}
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ DevUnion *pPriv;
+ pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
+ pMgaEnt = pPriv->ptr;
+ pMgaEnt->refCount++;
+#ifdef USEMGAHAL
+ if(pMgaEnt->refCount == 1) {
+ pMga->pBoard =
+ (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) +
+ MGAGetBOARDHANDLESize());
+ pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA));
+ /* Fill the client part */
+ pMga->pClientStruct->pMga = (MGAPtr) pMga;
+
+ MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
+
+ pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO));
+ MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
+ /* Now copy these to the entitystructure */
+ pMgaEnt->pClientStruct = pMga->pClientStruct;
+ pMgaEnt->pBoard = pMga->pBoard;
+ pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
+ } else { /* Ref count is 2 */
+ pMga->pClientStruct = pMgaEnt->pClientStruct;
+ pMga->pBoard = pMgaEnt->pBoard;
+ pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
+ }
+#endif /* USEMGAHAL */
+ } else {
+#ifdef USEMGAHAL
+ pMga->pBoard =
+ (LPBOARDHANDLE) xalloc (sizeof(CLIENTDATA) +
+ MGAGetBOARDHANDLESize());
+ pMga->pClientStruct = (LPCLIENTDATA) xalloc (sizeof(CLIENTDATA));
+ /* Fill the client part */
+ pMga->pClientStruct->pMga = (MGAPtr) pMga;
+
+ MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
+
+ pMga->pMgaHwInfo = (LPMGAHWINFO) xalloc (sizeof(MGAHWINFO));
+ MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
+#endif /* USEMGAHAL */
+ }
+
+
/* Initialise the MMIO vgahw functions */
vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET);
vgaHWGetIOBase(hwp);
@@ -2238,7 +2758,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Darken the screen for aesthetic reasons and set the viewport */
- MGASaveScreen(pScreen, SCREEN_SAVER_ON);
+ if (pMga->SecondCrtc == TRUE) {
+ MGASaveScreenCrtc2(pScreen, SCREEN_SAVER_ON);
+ } else {
+ MGASaveScreen(pScreen, SCREEN_SAVER_ON);
+ }
pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
/*
@@ -2267,6 +2791,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
if (!miSetVisualTypes(24, TrueColorMask, pScrn->rgbBits, TrueColor))
return FALSE;
+ } else if (pMga->SecondCrtc) {
+ /* No DirectColor on the second head */
+ if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits,
+ TrueColor))
+ return FALSE;
} else {
if (!xf86SetDefaultVisual(pScrn, -1))
return FALSE;
@@ -2313,27 +2842,29 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* The DRI does not work when textured video is enabled at this time.
*/
- if (!pMga->NoAccel && pMga->TexturedVideo != TRUE)
+ if (!pMga->NoAccel && pMga->TexturedVideo != TRUE &&
+ pMga->SecondCrtc == FALSE)
pMga->directRenderingEnabled = MGADRIScreenInit(pScreen);
else
pMga->directRenderingEnabled = FALSE;
#endif
-
- if(pMga->Overlay8Plus24) {
+
+ if (pMga->Overlay8Plus24) {
ret = cfb8_32ScreenInit(pScreen, FBStart,
width, height,
pScrn->xDpi, pScrn->yDpi,
displayWidth);
} else {
ret = fbScreenInit(pScreen, FBStart, width, height,
- pScrn->xDpi, pScrn->yDpi,
- displayWidth, pScrn->bitsPerPixel);
+ pScrn->xDpi, pScrn->yDpi,
+ displayWidth, pScrn->bitsPerPixel);
#ifdef RENDER
if (ret)
fbPictureInit (pScreen, 0, 0);
#endif
}
+
if (!ret)
return FALSE;
@@ -2386,9 +2917,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Initialize colormap layer.
Must follow initialization of the default colormap */
+ if (!pMga->SecondCrtc)
+ f = CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH;
+ else
+ f = CMAP_RELOAD_ON_MODE_SWITCH;
if(!xf86HandleColormaps(pScreen, 256, 8,
- (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL,
- CMAP_PALETTED_TRUECOLOR | CMAP_RELOAD_ON_MODE_SWITCH))
+ (pMga->FBDev ? fbdevHWLoadPalette : MGAdac->LoadPalette), NULL, f))
return FALSE;
if(pMga->Overlay8Plus24) { /* Must come after colormap initialization */
@@ -2436,14 +2970,20 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n");
}
+ if (xf86IsEntityShared(pScrn->entityList[0]) && pMga->SecondCrtc == FALSE)
+ pMgaEnt->directRenderingEnabled = pMga->directRenderingEnabled;
+ pMga->have_quiescense = 1;
#endif
pScrn->memPhysBase = pMga->FbAddress;
pScrn->fbOffset = pMga->YDstOrg * (pScrn->bitsPerPixel / 8);
- MGAInitVideo(pScreen);
-
- pScreen->SaveScreen = MGASaveScreen;
+ if(pMga->SecondCrtc == TRUE) {
+ pScreen->SaveScreen = MGASaveScreenCrtc2;
+ } else {
+ pScreen->SaveScreen = MGASaveScreen;
+ MGAInitVideo(pScreen);
+ }
/* Wrap the current CloseScreen function */
pMga->CloseScreen = pScreen->CloseScreen;
@@ -2454,6 +2994,11 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
}
+ /* For the second head, work around display problem. */
+ if (pMga->SecondCrtc) {
+ MGACrtc2FillStrip(pScrn);
+ }
+
/* Done */
return TRUE;
}
@@ -2512,6 +3057,33 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags)
}
+#define C2STARTADD0 0x3C28
+
+void
+MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn;
+ int Base;
+ MGAFBLayout *pLayout;
+ MGAPtr pMga;
+
+ pScrn = xf86Screens[scrnIndex];
+ pMga = MGAPTR(pScrn);
+ pLayout = &pMga->CurrentLayout;
+
+ if(pMga->ShowCache && y && pScrn->vtSema)
+ y += pScrn->virtualY - 1;
+
+ /* 3-85 c2offset
+ * 3-93 c2startadd0
+ * 3-96 c2vcount
+ */
+
+ Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3;
+ Base += pMga->DstOrg;
+ Base &= 0x01ffffc0;
+ OUTREG(C2STARTADD0, Base);
+}
/*
* This is called when VT switching back to the X server. Its job is
@@ -2525,12 +3097,15 @@ static Bool
MGAEnterVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ MGAPtr pMga;
#ifdef XF86DRI
ScreenPtr pScreen;
- MGAPtr pMGA;
+#endif
- pMGA = MGAPTR(pScrn);
- if (pMGA->directRenderingEnabled) {
+ pMga = MGAPTR(pScrn);
+
+#ifdef XF86DRI
+ if (pMga->directRenderingEnabled) {
pScreen = screenInfo.screens[scrnIndex];
DRIUnlock(pScreen);
}
@@ -2539,6 +3114,12 @@ MGAEnterVT(int scrnIndex, int flags)
if (!MGAModeInit(pScrn, pScrn->currentMode))
return FALSE;
MGAAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ /* For the second head, work around display problem. */
+ if (pMga->SecondCrtc) {
+ MGACrtc2FillStrip(pScrn);
+ }
+
return TRUE;
}
@@ -2610,7 +3191,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
MGAPtr pMga = MGAPTR(pScrn);
-
+ MGAEntPtr pMgaEnt = NULL;
+
if (pScrn->vtSema) {
if (pMga->FBDev) {
fbdevHWRestore(pScrn);
@@ -2628,7 +3210,43 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
pMga->directRenderingEnabled=FALSE;
}
#endif
-
+
+ if (xf86IsEntityShared(pScrn->entityList[0])) {
+ DevUnion *pPriv;
+ pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
+ pMgaEnt = pPriv->ptr;
+ pMgaEnt->refCount--;
+ }
+
+#ifdef USEMGAHAL
+ if(xf86IsEntityShared(pScrn->entityList[0])) {
+ if(pMgaEnt->refCount == 0) {
+ /* Both boards have closed there screen */
+ MGACloseLibrary(pMga->pBoard);
+
+ if (pMga->pBoard)
+ xfree(pMga->pBoard);
+ if (pMga->pClientStruct)
+ xfree(pMga->pClientStruct);
+ if (pMga->pMgaModeInfo)
+ xfree(pMga->pMgaModeInfo);
+ if (pMga->pMgaHwInfo)
+ xfree(pMga->pMgaHwInfo);
+ }
+ } else {
+ MGACloseLibrary(pMga->pBoard);
+
+ if (pMga->pBoard)
+ xfree(pMga->pBoard);
+ if (pMga->pClientStruct)
+ xfree(pMga->pClientStruct);
+ if (pMga->pMgaModeInfo)
+ xfree(pMga->pMgaModeInfo);
+ if (pMga->pMgaHwInfo)
+ xfree(pMga->pMgaHwInfo);
+ }
+#endif /* USEMGAHAL */
+
if (pMga->AccelInfoRec)
XAADestroyInfoRec(pMga->AccelInfoRec);
if (pMga->CursorInfoRec)
@@ -2649,6 +3267,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
if (xf86IsPc98())
outb(0xfac, 0x00);
+ xf86ClearPrimInitDone(pScrn->entityList[0]);
+
if(pMga->BlockHandler)
pScreen->BlockHandler = pMga->BlockHandler;
@@ -2680,6 +3300,8 @@ static int
MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
{
int lace;
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ MGAPtr pMga = MGAPTR(pScrn);
lace = 1 + ((mode->Flags & V_INTERLACE) != 0);
@@ -2691,6 +3313,17 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
(mode->CrtcVSyncStart <= 4096 * lace) &&
(mode->CrtcVSyncEnd <= 4096 * lace) &&
(mode->CrtcVTotal <= 4096 * lace)) {
+
+ /* Can't have horizontal panning for second head of G400 */
+ if (pMga->SecondCrtc) {
+ if (flags == MODECHECK_FINAL) {
+ if (pMga->allowedWidth == 0)
+ pMga->allowedWidth = pScrn->virtualX;
+ if (mode->HDisplay != pMga->allowedWidth)
+ return(MODE_ONE_WIDTH);
+ }
+ }
+
return(MODE_OK);
} else {
return(MODE_BAD);
@@ -2701,6 +3334,36 @@ MGAValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
/* Do screen blanking */
/* Mandatory */
+#define MGAREG_C2CTL 0x3c10
+
+static Bool
+MGASaveScreenCrtc2(ScreenPtr pScreen, int mode)
+{
+ ScrnInfoPtr pScrn = NULL;
+ MGAPtr pMga = NULL;
+ Bool on;
+ CARD32 tmp;
+
+ on = xf86IsUnblank(mode);
+
+ if (on)
+ SetTimeSinceLastInputEvent();
+ if (pScreen != NULL)
+ pScrn = xf86Screens[pScreen->myNum];
+
+ if (pScrn != NULL)
+ pMga = MGAPTR(pScrn);
+
+ if(pMga != NULL && pScrn->vtSema) {
+ tmp = INREG(MGAREG_C2CTL);
+ tmp &= ~0x00000008;
+ if (!on) tmp |= 0x0000008;
+ OUTREG(MGAREG_C2CTL, tmp);
+ }
+
+ return TRUE;
+}
+
static Bool
MGASaveScreen(ScreenPtr pScreen, int mode)
{
@@ -2721,8 +3384,6 @@ MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
MGAPtr pMga = MGAPTR(pScrn);
unsigned char seq1 = 0, crtcext1 = 0;
-ErrorF("MGADisplayPowerManagementSet: %d\n", PowerManagementMode);
-
switch (PowerManagementMode)
{
case DPMSModeOn:
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
index 12538fd3c..3f38943ee 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
@@ -429,6 +429,9 @@
#define MGAREG_DWGSYNC 0x2c4c
+#define MGAREG_AGP_PLL 0x1e4c
+#define AGP_PLL_agp2xpllen_enable 0x1
+#define AGP_PLL_agp2xpllen_disable 0x0
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
index 8bd933bbf..e6bdf32af 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.8 2000/06/17 00:03:21 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.9 2000/09/20 00:09:26 keithp Exp $
XCOMM
XCOMM This is the Imakefile for the ATI Rage 128 (r128) and
XCOMM the ATI Radeon (radeon) driver.
@@ -47,7 +47,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \
- $(DRIINCLUDES)
+ $(DRIINCLUDES) -I$(SERVERSRC)/render
#endif
DEFINES = $(DRIDEFINES)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c
index 5c6f33673..0a1512d9c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/ati2_probe.c
@@ -122,8 +122,6 @@ const char *fbdevHWSymbols[] = {
NULL
};
-#if 0
- /* Not used until DDC is supported. */
const char *ddcSymbols[] = {
"xf86PrintEDID",
"xf86DoEDID_DDC1",
@@ -131,13 +129,6 @@ const char *ddcSymbols[] = {
NULL
};
-const char *i2cSymbols[] = {
- "xf86CreateI2CBusRec",
- "xf86I2CBusInit",
- NULL
-};
-#endif
-
#ifdef XFree86LOADER
#ifdef USE_FB
static const char *fbSymbols[] = {
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
index bcb2d80e7..1f26edb5c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.11 2000/08/04 16:13:32 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.12 2000/09/13 15:47:32 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -179,7 +179,6 @@ typedef struct {
unsigned char *MMIO; /* Map of MMIO region */
unsigned char *FB; /* Map of frame buffer */
- CARD8 *VBIOS; /* Video BIOS pointer */
CARD32 MemCntl;
CARD32 BusCntl;
@@ -188,6 +187,7 @@ typedef struct {
Bool HasPanelRegs; /* Current chip can connect to a FP */
Bool CRTOnly; /* Only use External CRT instead of FP */
+ CARD8 *VBIOS; /* Video BIOS for mode validation on FPs */
int FPBIOSstart; /* Start of the flat panel info */
/* Computed values for FPs */
@@ -204,7 +204,6 @@ typedef struct {
Bool PaletteSavedOnVT; /* Palette saved on last VT switch */
- I2CBusPtr i2c;
XAAInfoRecPtr accel;
Bool accelOn;
xf86CursorInfoPtr cursor;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
index 4d0ab433e..2f7b28187 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.13 2000/06/26 05:41:32 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.14 2000/08/24 22:20:17 tsi Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -791,6 +791,7 @@ static void R128SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
x11perf -putimage100 2150.0/sec 1170.0/sec
x11perf -putimage500 108.0/sec 49.8/sec
*/
+#if R128_IMAGEWRITE
static void R128SetupForScanlineImageWrite(ScrnInfoPtr pScrn,
int rop,
unsigned int planemask,
@@ -911,6 +912,7 @@ static void R128SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno)
}
}
}
+#endif
/* Initialize the acceleration hardware. */
void R128EngineInit(ScrnInfoPtr pScrn)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
index 380fc0c9c..9aea26df5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.5 2000/08/25 13:42:37 dawes Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
index e39828343..50a982597 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.40 2000/08/04 16:13:32 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.46 2000/09/20 00:09:26 keithp Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -120,6 +120,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_sarea.h"
#endif
+#ifdef RENDER
+#include "picturestr.h"
+#endif
/* Driver data structures */
#include "ati2.h"
#include "r128.h"
@@ -245,10 +248,7 @@ R128RAMRec R128RAM[] = { /* Memory Specifications
extern const char *vgahwSymbols[];
extern const char *fbdevHWSymbols[];
-#if 0
extern const char *ddcSymbols[];
-extern const char *i2cSymbols[];
-#endif
/* Allocate our private R128InfoRec. */
static Bool R128GetRec(ScrnInfoPtr pScrn)
@@ -977,33 +977,19 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
static Bool R128PreInitDDC(ScrnInfoPtr pScrn)
{
- /* FIXME: DDC support goes here. */
-#if 0
- /* Using the GPIO_MONID register for DDC2
- does not appear to work as expected.
- Hence, the implementation of DDC is
- deferred. */
R128InfoPtr info = R128PTR(pScrn);
- Bool ret = TRUE;
-
+ vbeInfoPtr pVbe;
+
if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE;
xf86LoaderReqSymLists(ddcSymbols, NULL);
- if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE;
- xf86LoaderReqSymLists(i2cSymbols, NULL);
-
- R128MapMMIO(pScrn);
- if (!R128I2CInit(pScrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n");
- ret = FALSE;
- } else {
- xf86SetDDCProperties(pScrn,xf86PrintEDID(
- xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c)));
- }
- R128UnmapMMIO(pScrn);
- return ret;
-#else
- return TRUE;
-#endif
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ pVbe = VBEInit(NULL,info->pEnt->index);
+ if (!pVbe) return FALSE;
+
+ xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL)));
+ return TRUE;
+ } else
+ return FALSE;
}
/* This is called by R128PreInit to initialize gamma correction. */
@@ -1094,6 +1080,11 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn)
#endif
if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE;
xf86LoaderReqSymbols(Sym, NULL);
+#ifdef USE_FB
+#ifdef RENDER
+ xf86LoaderReqSymbols("fbPictureInit", NULL);
+#endif
+#endif
info->CurrentLayout.displayWidth = pScrn->displayWidth;
info->CurrentLayout.mode = pScrn->currentMode;
@@ -1471,7 +1462,8 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
miGetDefaultVisualMask(pScrn->depth),
pScrn->rgbBits,
pScrn->defaultVisual)) return FALSE;
-
+ miSetPixmapDepths ();
+
#ifdef XF86DRI
/* Setup DRI after visuals have been
established, but before cfbScreenInit is
@@ -1511,6 +1503,9 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth,
pScrn->bitsPerPixel))
return FALSE;
+#ifdef RENDER
+ fbPictureInit (pScreen, 0, 0);
+#endif
#else
switch (pScrn->bitsPerPixel) {
case 8:
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
index 890cf0004..8dc4c44a1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.11 2000/07/01 01:40:46 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.13 2000/09/13 15:47:32 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h
index eb82611a1..600f99bc5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon.h
@@ -215,7 +215,6 @@ typedef struct {
Bool PaletteSavedOnVT; /* Palette saved on last VT switch */
- I2CBusPtr i2c;
XAAInfoRecPtr accel;
Bool accelOn;
xf86CursorInfoPtr cursor;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c
index a04f0adad..6821d48ed 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_accel.c
@@ -668,6 +668,7 @@ static void RADEONSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
}
}
+#if RADEON_IMAGEWRITE
/* Setup for XAA indirect image write. */
static void RADEONSetupForScanlineImageWrite(ScrnInfoPtr pScrn,
int rop,
@@ -780,6 +781,7 @@ static void RADEONSubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno)
}
}
}
+#endif
/* Initialize the acceleration hardware. */
void RADEONEngineInit(ScrnInfoPtr pScrn)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c
index b3f8ce6b7..fe9ebd382 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/radeon_driver.c
@@ -237,10 +237,7 @@ RADEONRAMRec RADEONRAM[] = { /* Memory Specifications
extern const char *vgahwSymbols[];
extern const char *fbdevHWSymbols[];
-#if 0
extern const char *ddcSymbols[];
-extern const char *i2cSymbols[];
-#endif
/* Allocate our private RADEONInfoRec. */
static Bool RADEONGetRec(ScrnInfoPtr pScrn)
@@ -971,33 +968,19 @@ static Bool RADEONPreInitConfig(ScrnInfoPtr pScrn)
static Bool RADEONPreInitDDC(ScrnInfoPtr pScrn)
{
- /* FIXME: DDC support goes here. */
-#if 0
- /* Using the GPIO_MONID register for DDC2
- does not appear to work as expected.
- Hence, the implementation of DDC is
- deferred. */
RADEONInfoPtr info = RADEONPTR(pScrn);
- Bool ret = TRUE;
-
+ vbeInfoPtr pVbe;
+
if (!xf86LoadSubModule(pScrn, "ddc")) return FALSE;
xf86LoaderReqSymLists(ddcSymbols, NULL);
- if (!xf86LoadSubModule(pScrn, "i2c")) return FALSE;
- xf86LoaderReqSymLists(i2cSymbols, NULL);
-
- RADEONMapMMIO(pScrn);
- if (!RADEONI2CInit(pScrn)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I2C initialization failed\n");
- ret = FALSE;
- } else {
- xf86SetDDCProperties(pScrn,xf86PrintEDID(
- xf86DoEDID_DDC2(pScrn->scrnIndex, info->i2c)));
- }
- RADEONUnmapMMIO(pScrn);
- return ret;
-#else
- return TRUE;
-#endif
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ pVbe = VBEInit(NULL,info->pEnt->index);
+ if (!pVbe) return FALSE;
+
+ xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(pVbe,NULL)));
+ return TRUE;
+ } else
+ return FALSE;
}
/* This is called by RADEONPreInit to initialize gamma correction. */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
index c0c3f1433..87960acf3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
@@ -161,12 +161,22 @@ TDFXSetLFBConfig(TDFXPtr pTDFX) {
} else {
int chip;
int stride, bits;
+ int TileAperturePitch, lg2TileAperturePitch;
if (pTDFX->cpp==2) stride=pTDFX->stride;
else stride=4*pTDFX->stride/pTDFX->cpp;
bits=pTDFX->backOffset>>12;
+ for (lg2TileAperturePitch = 0, TileAperturePitch = 1024;
+ (lg2TileAperturePitch < 5) &&
+ TileAperturePitch < stride;
+ lg2TileAperturePitch += 1, TileAperturePitch <<= 1);
+#if 0
+ fprintf(stderr, "Using %d (== lg2(%d)-10) for tile aperture pitch\n",
+ lg2TileAperturePitch, TileAperturePitch);
+ fprintf(stderr, "stride == %d\n", stride);
+#endif
for (chip=0; chip<pTDFX->numChips; chip++) {
TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) |
- SST_RAW_LFB_ADDR_STRIDE_4K |
+ SST_RAW_LFB_ADDR_STRIDE(lg2TileAperturePitch) |
((bits&0x6000)<<10) |
((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
index da906ecde..201216076 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
@@ -643,7 +643,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags)
ClockRangePtr clockRanges;
int i;
MessageType from;
- char *mod=0, *reqSym=0;
int flags24;
rgb defaultWeight = {0, 0, 0};
pciVideoPtr match;
@@ -668,6 +667,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags)
if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE;
+ if (flags & PROBE_DETECT) {
+ TDFXProbeDDC(pScrn, pTDFX->pEnt->index);
+ return TRUE;
+ }
+
/* The vgahw module should be loaded here when needed */
if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE;
@@ -1200,7 +1204,10 @@ CalcPLL(int freq, int *f_out, int isBanshee) {
maxm=24;
} else {
minm=1;
- maxm=64;
+ maxm=57; /* This used to be 64, alas it seems the last 8 (funny that ?)
+ * values cause jittering at lower resolutions. I've not done
+ * any calculations to what the adjustment affects clock ranges,
+ * but I can still run at 1600x1200@75Hz */
}
for (n=1; n<256; n++) {
f_cur=REFFREQ*(n+2);
@@ -1609,15 +1616,6 @@ static void allocateMemory(ScrnInfoPtr pScrn) {
pTDFX = TDFXPTR(pScrn);
pTDFX->stride = pScrn->displayWidth*pTDFX->cpp;
- /* Layout the memory. Start with all the ram */
- memRemaining=pScrn->videoRam<<10;
- /* Remove the cursor space */
- memRemaining-=4096;
- /* Remove the main screen and offscreen pixmaps */
- memRemaining-=pTDFX->stride*(pScrn->virtualY+128);
- /* Remove one scanline for page alignment */
- memRemaining-=4095;
- /* Remove the back and Z buffers */
if (pTDFX->cpp!=3) {
screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
TRUE, pTDFX->cpp);
@@ -1627,41 +1625,77 @@ static void allocateMemory(ScrnInfoPtr pScrn) {
screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
TRUE, 4);
}
- memRemaining-=screenSizeInTiles*2;
-
- /* Give all the rest to textures, rounded down to a page */
- texSize=memRemaining&~0xFFF;
-
- /* Make sure fifo has CMDFIFO_PAGES<fifoSize<255 pages */
- if (memRemaining-texSize<CMDFIFO_PAGES<<12)
- texSize=(memRemaining-(CMDFIFO_PAGES<<12))&~0xFFF;
- /* Fifo uses the remaining space up to 255 pages */
- fifoSize = (memRemaining-texSize)&~0xFFF;
- if (fifoSize>255<<12) fifoSize=255<<12;
-
- /* Assign the variables */
- /* Cursor */
- pTDFX->cursorOffset=0; /* Size 1024 bytes */
-
- /* Point the fifo at the first page */
+ memRemaining=((pScrn->videoRam<<10) - 1) &~ 0xFFF;
+ /* Note that a page is 4096 bytes, and a */
+ /* tile is 32 x 128 = 4096 bytes. So, */
+ /* page and tile boundaries are the same */
+ /* Place the depth offset first, forcing */
+ /* it to be on an *odd* page boundary. */
+ pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF;
+ if ((pTDFX->depthOffset & (0x1 << 12)) == 0) {
+#if 0
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Changing depth offset from 0x%08x to 0x%08x\n",
+ pTDFX->depthOffset,
+ pTDFX->depthOffset - (0x1 << 12));
+#endif
+ pTDFX->depthOffset -= (0x1 << 12);
+ }
+ /* Now, place the back buffer, forcing it */
+ /* to be on an *even* page boundary. */
+ pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF;
+ if (pTDFX->backOffset & (0x1 << 12)) {
+#if 0
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Changing back offset from 0x%08x to 0x%08x\n",
+ pTDFX->backOffset,
+ pTDFX->backOffset - (0x1 << 12));
+#endif
+ pTDFX->backOffset -= (0x1 << 12);
+ }
+ /* Now, place the front buffer, forcing */
+ /* it to be on a page boundary too, just */
+ /* for giggles. */
+ pTDFX->fbOffset
+ = (pTDFX->backOffset - (pScrn->virtualY+128)*pTDFX->stride) &~ 0xFFF;
+ /* Give the cmd fifo at least */
+ /* CMDFIFO_PAGES pages, but no more than */
+ /* 255. */
+ fifoSize = ((255 <= CMDFIFO_PAGES) ? 255 : CMDFIFO_PAGES) << 12;
+ /* We give 4096 bytes to the cursor, fifoSize to the */
+ /* FIFO, and everything to textures. */
+ texSize = (pTDFX->fbOffset - fifoSize - 4096);
+ pTDFX->texOffset = pTDFX->fbOffset - texSize;
+ pTDFX->texSize = texSize;
pTDFX->fifoOffset = 4096;
pTDFX->fifoSize = fifoSize;
-
- /* Textures */
- pTDFX->texOffset = pTDFX->fifoOffset+fifoSize;
- pTDFX->texSize = texSize;
-
- /* Frame buffer */
- pTDFX->fbOffset=pTDFX->texOffset+pTDFX->texSize;
-
- /* Back buffer */
- pTDFX->backOffset=pTDFX->fbOffset+(pScrn->virtualY+128)*pTDFX->stride;
- /* Round off to a page */
- pTDFX->backOffset=(pTDFX->backOffset+4095)&~0xFFF;
-
- /* Depth buffer */
- pTDFX->depthOffset=pTDFX->backOffset+screenSizeInTiles;
-
+ pTDFX->cursorOffset = 0;
+#if 0
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Cursor Offset: [0x%08X,0x%08X)\n",
+ pTDFX->cursorOffset,
+ pTDFX->cursorOffset+1024);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Fifo Offset: [0x%08X, 0x%08X)\n",
+ pTDFX->fifoOffset,
+ pTDFX->fifoOffset+fifoSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Texture Offset: [0x%08X, 0x%08X)\n",
+ pTDFX->texOffset,
+ pTDFX->texOffset + texSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Front Buffer Offset: [0x%08X, 0x%08X)\n",
+ pTDFX->fbOffset,
+ pTDFX->fbOffset + (pScrn->virtualY+128)*pTDFX->stride);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "BackOffset: [0x%08X, 0x%08X)\n",
+ pTDFX->backOffset,
+ pTDFX->backOffset+screenSizeInTiles);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "DepthOffset: [0x%08X, 0x%08X)\n",
+ pTDFX->depthOffset,
+ pTDFX->depthOffset+screenSizeInTiles);
+#endif /* 0/1 */
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Textures Memory %0.02f MB\n",
(float)texSize/1024.0/1024.0);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile
deleted file mode 100644
index 86518badb..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile
+++ /dev/null
@@ -1,35 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile,v 3.4 2000/06/27 14:27:29 tsi Exp $
-
-
-
-
-XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:26 rws $
-
-#include <Server.tmpl>
-
-#if AckToolset
-IOSRC = inout.S
-IOOBJ = inout.o
-#endif
-
-SRCS = am_init.c am_video.c am_io.c ioperm_noop.c \
- VTsw_noop.c $(IOSRC) kmod_noop.c
-OBJS = am_init.o am_video.o am_io.o ioperm_noop.o \
- VTsw_noop.o $(IOOBJ) kmod_noop.o
-
-INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
- -I$(XINCLUDESRC)
-
-SubdirLibraryRule($(OBJS))
-NormalLibraryObjectRule()
-NormalAsmObjectRule()
-
-ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/)
-ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
-ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
-#if AckToolset
-ObjectFromSpecialAsmSource(inout,../shared/inout,/**/)
-#endif
-
-DependTarget()
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c
deleted file mode 100644
index 5a420efc1..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* drmmodule.c -- Module initialization
- * Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com
- * Revised: Fri Jun 4 09:09:22 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.1 1999/06/07 13:01:42 faith Exp $
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c,v 1.1 2000/06/17 00:03:27 martin Exp $
- *
- */
-
-#include "xf86Module.h"
-
-static MODULESETUPPROTO(drmSetup);
-
-static XF86ModuleVersionInfo VersRec =
-{
- "drm",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XF86_VERSION_CURRENT,
- 1, 0, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL };
-
-static pointer
-drmSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- return (void *)1;
-}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h
deleted file mode 100644
index ddad1be7e..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h
+++ /dev/null
@@ -1,362 +0,0 @@
-/* drm.h -- Header for Direct Rendering Manager -*- c -*-
- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- * Acknowledgements:
- * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
- *
- */
-
-#ifndef _DRM_H_
-#define _DRM_H_
-
-#include <sys/ioccom.h> /* For _IO* macros */
-
-#define DRM_DEV_DRM "/dev/drm"
-#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
-#define DRM_DEV_UID 0
-#define DRM_DEV_GID 0
-
-
-#define DRM_NAME "drm" /* Name in kernel, /dev */
-#define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */
-#define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */
-#define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */
-
-#define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
-#define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
-#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
-#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
-#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
-
-typedef unsigned long drm_handle_t;
-typedef unsigned int drm_context_t;
-typedef unsigned int drm_drawable_t;
-typedef unsigned int drm_magic_t;
-
-/* Warning: If you change this structure, make sure you change
- * XF86DRIClipRectRec in the server as well */
-
-typedef struct drm_clip_rect {
- unsigned short x1;
- unsigned short y1;
- unsigned short x2;
- unsigned short y2;
-} drm_clip_rect_t;
-
-/* Seperate include files for the i810/mga/r128 specific structures */
-#include "mga_drm.h"
-#include "i810_drm.h"
-#include "r128_drm.h"
-
-typedef struct drm_version {
- int version_major; /* Major version */
- int version_minor; /* Minor version */
- int version_patchlevel;/* Patch level */
- size_t name_len; /* Length of name buffer */
- char *name; /* Name of driver */
- size_t date_len; /* Length of date buffer */
- char *date; /* User-space buffer to hold date */
- size_t desc_len; /* Length of desc buffer */
- char *desc; /* User-space buffer to hold desc */
-} drm_version_t;
-
-typedef struct drm_unique {
- size_t unique_len; /* Length of unique */
- char *unique; /* Unique name for driver instantiation */
-} drm_unique_t;
-
-typedef struct drm_list {
- int count; /* Length of user-space structures */
- drm_version_t *version;
-} drm_list_t;
-
-typedef struct drm_block {
- int unused;
-} drm_block_t;
-
-typedef struct drm_control {
- enum {
- DRM_ADD_COMMAND,
- DRM_RM_COMMAND,
- DRM_INST_HANDLER,
- DRM_UNINST_HANDLER
- } func;
- int irq;
-} drm_control_t;
-
-typedef enum drm_map_type {
- _DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
- _DRM_REGISTERS = 1, /* no caching, no core dump */
- _DRM_SHM = 2, /* shared, cached */
- _DRM_AGP = 3 /* AGP/GART */
-} drm_map_type_t;
-
-typedef enum drm_map_flags {
- _DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */
- _DRM_READ_ONLY = 0x02,
- _DRM_LOCKED = 0x04, /* shared, cached, locked */
- _DRM_KERNEL = 0x08, /* kernel requires access */
- _DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */
- _DRM_CONTAINS_LOCK = 0x20 /* SHM page that contains lock */
-} drm_map_flags_t;
-
-typedef struct drm_map {
- unsigned long offset; /* Requested physical address (0 for SAREA)*/
- unsigned long size; /* Requested physical size (bytes) */
- drm_map_type_t type; /* Type of memory to map */
- drm_map_flags_t flags; /* Flags */
- void *handle; /* User-space: "Handle" to pass to mmap */
- /* Kernel-space: kernel-virtual address */
- int mtrr; /* MTRR slot used */
- /* Private data */
-} drm_map_t;
-
-typedef enum drm_lock_flags {
- _DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
- _DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
- _DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
- _DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
- /* These *HALT* flags aren't supported yet
- -- they will be used to support the
- full-screen DGA-like mode. */
- _DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
- _DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
-} drm_lock_flags_t;
-
-typedef struct drm_lock {
- int context;
- drm_lock_flags_t flags;
-} drm_lock_t;
-
-typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */
- /* Flags for DMA buffer dispatch */
- _DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched.
- Note, the buffer may not yet have
- been processed by the hardware --
- getting a hardware lock with the
- hardware quiescent will ensure
- that the buffer has been
- processed. */
- _DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
- _DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
-
- /* Flags for DMA buffer request */
- _DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
- _DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
- _DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
-} drm_dma_flags_t;
-
-typedef struct drm_buf_desc {
- int count; /* Number of buffers of this size */
- int size; /* Size in bytes */
- int low_mark; /* Low water mark */
- int high_mark; /* High water mark */
- enum {
- _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */
- _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */
- } flags;
- unsigned long agp_start; /* Start address of where the agp buffers
- * are in the agp aperture */
-} drm_buf_desc_t;
-
-typedef struct drm_buf_info {
- int count; /* Entries in list */
- drm_buf_desc_t *list;
-} drm_buf_info_t;
-
-typedef struct drm_buf_free {
- int count;
- int *list;
-} drm_buf_free_t;
-
-typedef struct drm_buf_pub {
- int idx; /* Index into master buflist */
- int total; /* Buffer size */
- int used; /* Amount of buffer in use (for DMA) */
- void *address; /* Address of buffer */
-} drm_buf_pub_t;
-
-typedef struct drm_buf_map {
- int count; /* Length of buflist */
- void *virtual; /* Mmaped area in user-virtual */
- drm_buf_pub_t *list; /* Buffer information */
-} drm_buf_map_t;
-
-typedef struct drm_dma {
- /* Indices here refer to the offset into
- buflist in drm_buf_get_t. */
- int context; /* Context handle */
- int send_count; /* Number of buffers to send */
- int *send_indices; /* List of handles to buffers */
- int *send_sizes; /* Lengths of data to send */
- drm_dma_flags_t flags; /* Flags */
- int request_count; /* Number of buffers requested */
- int request_size; /* Desired size for buffers */
- int *request_indices; /* Buffer information */
- int *request_sizes;
- int granted_count; /* Number of buffers granted */
-} drm_dma_t;
-
-typedef enum {
- _DRM_CONTEXT_PRESERVED = 0x01,
- _DRM_CONTEXT_2DONLY = 0x02
-} drm_ctx_flags_t;
-
-typedef struct drm_ctx {
- drm_context_t handle;
- drm_ctx_flags_t flags;
-} drm_ctx_t;
-
-typedef struct drm_ctx_res {
- int count;
- drm_ctx_t *contexts;
-} drm_ctx_res_t;
-
-typedef struct drm_draw {
- drm_drawable_t handle;
-} drm_draw_t;
-
-typedef struct drm_auth {
- drm_magic_t magic;
-} drm_auth_t;
-
-typedef struct drm_irq_busid {
- int irq;
- int busnum;
- int devnum;
- int funcnum;
-} drm_irq_busid_t;
-
-typedef struct drm_agp_mode {
- unsigned long mode;
-} drm_agp_mode_t;
-
- /* For drm_agp_alloc -- allocated a buffer */
-typedef struct drm_agp_buffer {
- unsigned long size; /* In bytes -- will round to page boundary */
- unsigned long handle; /* Used for BIND/UNBIND ioctls */
- unsigned long type; /* Type of memory to allocate */
- unsigned long physical; /* Physical used by i810 */
-} drm_agp_buffer_t;
-
- /* For drm_agp_bind */
-typedef struct drm_agp_binding {
- unsigned long handle; /* From drm_agp_buffer */
- unsigned long offset; /* In bytes -- will round to page boundary */
-} drm_agp_binding_t;
-
-typedef struct drm_agp_info {
- int agp_version_major;
- int agp_version_minor;
- unsigned long mode;
- unsigned long aperture_base; /* physical address */
- unsigned long aperture_size; /* bytes */
- unsigned long memory_allowed; /* bytes */
- unsigned long memory_used;
-
- /* PCI information */
- unsigned short id_vendor;
- unsigned short id_device;
-} drm_agp_info_t;
-
-#define DRM_IOCTL_BASE 'd'
-#define DRM_IOCTL_NR(n) ((n) & 0xff)
-#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
-#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
-#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
-#define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size)
-
-
-#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
-#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
-#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t)
-#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
-
-#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
-#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t)
-#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t)
-#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t)
-#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t)
-#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t)
-#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t)
-#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t)
-#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t)
-#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t)
-#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t)
-
-#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t)
-#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t)
-#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t)
-#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t)
-#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t)
-#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t)
-#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t)
-#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t)
-#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t)
-#define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t)
-#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t)
-#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
-#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)
-
-#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
-#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
-#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t)
-#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t)
-#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t)
-#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t)
-#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t)
-#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t)
-
-/* Mga specific ioctls */
-#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
-#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t)
-#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t)
-#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t)
-#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t)
-#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t )
-#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
-
-/* I810 specific ioctls */
-#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t)
-#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t)
-#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t)
-#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
-#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
-#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t)
-#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46)
-
-/* Rage 128 specific ioctls */
-#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
-#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
-#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
-#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43)
-#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
-#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
-
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h
deleted file mode 100644
index 4c8e09f6a..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h
+++ /dev/null
@@ -1,188 +0,0 @@
-#ifndef _I810_DRM_H_
-#define _I810_DRM_H_
-
-/* WARNING: These defines must be the same as what the Xserver uses.
- * if you change them, you must change the defines in the Xserver.
- */
-
-#ifndef _I810_DEFINES_
-#define _I810_DEFINES_
-
-#define I810_DMA_BUF_ORDER 12
-#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
-#define I810_DMA_BUF_NR 256
-#define I810_NR_SAREA_CLIPRECTS 8
-
-/* Each region is a minimum of 64k, and there are at most 64 of them.
- */
-#define I810_NR_TEX_REGIONS 64
-#define I810_LOG_MIN_TEX_REGION_SIZE 16
-#endif
-
-#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
-#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
-#define I810_UPLOAD_CTX 0x4
-#define I810_UPLOAD_BUFFERS 0x8
-#define I810_UPLOAD_TEX0 0x10
-#define I810_UPLOAD_TEX1 0x20
-#define I810_UPLOAD_CLIPRECTS 0x40
-
-
-/* Indices into buf.Setup where various bits of state are mirrored per
- * context and per buffer. These can be fired at the card as a unit,
- * or in a piecewise fashion as required.
- */
-
-/* Destbuffer state
- * - backbuffer linear offset and pitch -- invarient in the current dri
- * - zbuffer linear offset and pitch -- also invarient
- * - drawing origin in back and depth buffers.
- *
- * Keep the depth/back buffer state here to acommodate private buffers
- * in the future.
- */
-#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
-#define I810_DESTREG_DI1 1
-#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
-#define I810_DESTREG_DV1 3
-#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
-#define I810_DESTREG_DR1 5
-#define I810_DESTREG_DR2 6
-#define I810_DESTREG_DR3 7
-#define I810_DESTREG_DR4 8
-#define I810_DEST_SETUP_SIZE 10
-
-/* Context state
- */
-#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
-#define I810_CTXREG_CF1 1
-#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
-#define I810_CTXREG_ST1 3
-#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
-#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
-#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
-#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
-#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
-#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
-#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
-#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
-#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
-#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
-#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
-#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
-#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
-#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
-#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
-#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
-#define I810_CTX_SETUP_SIZE 20
-
-/* Texture state (per tex unit)
- */
-#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
-#define I810_TEXREG_MI1 1
-#define I810_TEXREG_MI2 2
-#define I810_TEXREG_MI3 3
-#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
-#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
-#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
-#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
-#define I810_TEX_SETUP_SIZE 8
-
-#define I810_FRONT 0x1
-#define I810_BACK 0x2
-#define I810_DEPTH 0x4
-
-
-typedef struct _drm_i810_init {
- enum {
- I810_INIT_DMA = 0x01,
- I810_CLEANUP_DMA = 0x02
- } func;
- int ring_map_idx;
- int buffer_map_idx;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
-} drm_i810_init_t;
-
-/* Warning: If you change the SAREA structure you must change the Xserver
- * structure as well */
-
-typedef struct _drm_i810_tex_region {
- unsigned char next, prev; /* indices to form a circular LRU */
- unsigned char in_use; /* owned by a client, or free? */
- int age; /* tracked by clients to update local LRU's */
-} drm_i810_tex_region_t;
-
-typedef struct _drm_i810_sarea {
- unsigned int ContextState[I810_CTX_SETUP_SIZE];
- unsigned int BufferState[I810_DEST_SETUP_SIZE];
- unsigned int TexState[2][I810_TEX_SETUP_SIZE];
- unsigned int dirty;
-
- unsigned int nbox;
- drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS];
-
- /* Maintain an LRU of contiguous regions of texture space. If
- * you think you own a region of texture memory, and it has an
- * age different to the one you set, then you are mistaken and
- * it has been stolen by another client. If global texAge
- * hasn't changed, there is no need to walk the list.
- *
- * These regions can be used as a proxy for the fine-grained
- * texture information of other clients - by maintaining them
- * in the same lru which is used to age their own textures,
- * clients have an approximate lru for the whole of global
- * texture space, and can make informed decisions as to which
- * areas to kick out. There is no need to choose whether to
- * kick out your own texture or someone else's - simply eject
- * them all in LRU order.
- */
-
- drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1];
- /* Last elt is sentinal */
- int texAge; /* last time texture was uploaded */
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int last_quiescent; /* */
- int ctxOwner; /* last context to upload state */
-
- int vertex_prim;
-
-} drm_i810_sarea_t;
-
-typedef struct _drm_i810_clear {
- int clear_color;
- int clear_depth;
- int flags;
-} drm_i810_clear_t;
-
-
-
-/* These may be placeholders if we have more cliprects than
- * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
- * false, indicating that the buffer will be dispatched again with a
- * new set of cliprects.
- */
-typedef struct _drm_i810_vertex {
- int idx; /* buffer index */
- int used; /* nr bytes in use */
- int discard; /* client is finished with the buffer? */
-} drm_i810_vertex_t;
-
-typedef struct drm_i810_dma {
- void *virtual;
- int request_idx;
- int request_size;
- int granted;
-} drm_i810_dma_t;
-
-#endif /* _I810_DRM_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h
deleted file mode 100644
index eefa28d3f..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* mga_drm.h -- Public header for the Matrox g200/g400 driver
- * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors: Jeff Hartmann <jhartmann@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-#ifndef _MGA_DRM_H_
-#define _MGA_DRM_H_
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (xf86drmMga.h)
- */
-#ifndef _MGA_DEFINES_
-#define _MGA_DEFINES_
-
-#define MGA_F 0x1 /* fog */
-#define MGA_A 0x2 /* alpha */
-#define MGA_S 0x4 /* specular */
-#define MGA_T2 0x8 /* multitexture */
-
-#define MGA_WARP_TGZ 0
-#define MGA_WARP_TGZF (MGA_F)
-#define MGA_WARP_TGZA (MGA_A)
-#define MGA_WARP_TGZAF (MGA_F|MGA_A)
-#define MGA_WARP_TGZS (MGA_S)
-#define MGA_WARP_TGZSF (MGA_S|MGA_F)
-#define MGA_WARP_TGZSA (MGA_S|MGA_A)
-#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
-#define MGA_WARP_T2GZ (MGA_T2)
-#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
-#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
-#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
-#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
-#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
-#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
-#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
-
-#define MGA_MAX_G400_PIPES 16
-#define MGA_MAX_G200_PIPES 8 /* no multitex */
-#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
-
-#define MGA_CARD_TYPE_G200 1
-#define MGA_CARD_TYPE_G400 2
-
-#define MGA_FRONT 0x1
-#define MGA_BACK 0x2
-#define MGA_DEPTH 0x4
-
-/* 3d state excluding texture units:
- */
-#define MGA_CTXREG_DSTORG 0 /* validated */
-#define MGA_CTXREG_MACCESS 1
-#define MGA_CTXREG_PLNWT 2
-#define MGA_CTXREG_DWGCTL 3
-#define MGA_CTXREG_ALPHACTRL 4
-#define MGA_CTXREG_FOGCOLOR 5
-#define MGA_CTXREG_WFLAG 6
-#define MGA_CTXREG_TDUAL0 7
-#define MGA_CTXREG_TDUAL1 8
-#define MGA_CTXREG_FCOL 9
-#define MGA_CTX_SETUP_SIZE 10
-
-/* 2d state
- */
-#define MGA_2DREG_PITCH 0
-#define MGA_2D_SETUP_SIZE 1
-
-/* Each texture unit has a state:
- */
-#define MGA_TEXREG_CTL 0
-#define MGA_TEXREG_CTL2 1
-#define MGA_TEXREG_FILTER 2
-#define MGA_TEXREG_BORDERCOL 3
-#define MGA_TEXREG_ORG 4 /* validated */
-#define MGA_TEXREG_ORG1 5
-#define MGA_TEXREG_ORG2 6
-#define MGA_TEXREG_ORG3 7
-#define MGA_TEXREG_ORG4 8
-#define MGA_TEXREG_WIDTH 9
-#define MGA_TEXREG_HEIGHT 10
-#define MGA_TEX_SETUP_SIZE 11
-
-/* What needs to be changed for the current vertex dma buffer?
- */
-#define MGA_UPLOAD_CTX 0x1
-#define MGA_UPLOAD_TEX0 0x2
-#define MGA_UPLOAD_TEX1 0x4
-#define MGA_UPLOAD_PIPE 0x8
-#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
-#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
-#define MGA_UPLOAD_2D 0x40
-#define MGA_WAIT_AGE 0x80 /* handled client-side */
-#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
-#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
- quiescent */
-
-/* 32 buffers of 64k each, total 2 meg.
- */
-#define MGA_DMA_BUF_ORDER 16
-#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER)
-#define MGA_DMA_BUF_NR 31
-
-/* Keep these small for testing.
- */
-#define MGA_NR_SAREA_CLIPRECTS 8
-
-/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
- * regions, subject to a minimum region size of (1<<16) == 64k.
- *
- * Clients may subdivide regions internally, but when sharing between
- * clients, the region size is the minimum granularity.
- */
-
-#define MGA_CARD_HEAP 0
-#define MGA_AGP_HEAP 1
-#define MGA_NR_TEX_HEAPS 2
-#define MGA_NR_TEX_REGIONS 16
-#define MGA_LOG_MIN_TEX_REGION_SIZE 16
-#endif
-
-typedef struct _drm_mga_warp_index {
- int installed;
- unsigned long phys_addr;
- int size;
-} drm_mga_warp_index_t;
-
-typedef struct drm_mga_init {
- enum {
- MGA_INIT_DMA = 0x01,
- MGA_CLEANUP_DMA = 0x02
- } func;
- int reserved_map_agpstart;
- int reserved_map_idx;
- int buffer_map_idx;
- int sarea_priv_offset;
- int primary_size;
- int warp_ucode_size;
- unsigned int frontOffset;
- unsigned int backOffset;
- unsigned int depthOffset;
- unsigned int textureOffset;
- unsigned int textureSize;
- unsigned int agpTextureOffset;
- unsigned int agpTextureSize;
- unsigned int cpp;
- unsigned int stride;
- int sgram;
- int chipset;
- drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES];
- unsigned int mAccess;
-} drm_mga_init_t;
-
-/* Warning: if you change the sarea structure, you must change the Xserver
- * structures as well */
-
-typedef struct _drm_mga_tex_region {
- unsigned char next, prev;
- unsigned char in_use;
- unsigned int age;
-} drm_mga_tex_region_t;
-
-typedef struct _drm_mga_sarea {
- /* The channel for communication of state information to the kernel
- * on firing a vertex dma buffer.
- */
- unsigned int ContextState[MGA_CTX_SETUP_SIZE];
- unsigned int ServerState[MGA_2D_SETUP_SIZE];
- unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
- unsigned int WarpPipe;
- unsigned int dirty;
-
- unsigned int nbox;
- drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
-
-
- /* Information about the most recently used 3d drawable. The
- * client fills in the req_* fields, the server fills in the
- * exported_ fields and puts the cliprects into boxes, above.
- *
- * The client clears the exported_drawable field before
- * clobbering the boxes data.
- */
- unsigned int req_drawable; /* the X drawable id */
- unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
-
- unsigned int exported_drawable;
- unsigned int exported_index;
- unsigned int exported_stamp;
- unsigned int exported_buffers;
- unsigned int exported_nfront;
- unsigned int exported_nback;
- int exported_back_x, exported_front_x, exported_w;
- int exported_back_y, exported_front_y, exported_h;
- drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
-
- /* Counters for aging textures and for client-side throttling.
- */
- unsigned int last_enqueue; /* last time a buffer was enqueued */
- unsigned int last_dispatch; /* age of the most recently dispatched buffer */
- unsigned int last_quiescent; /* */
-
-
- /* LRU lists for texture memory in agp space and on the card
- */
- drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
- unsigned int texAge[MGA_NR_TEX_HEAPS];
-
- /* Mechanism to validate card state.
- */
- int ctxOwner;
-} drm_mga_sarea_t;
-
-/* Device specific ioctls:
- */
-typedef struct _drm_mga_clear {
- unsigned int clear_color;
- unsigned int clear_depth;
- unsigned int flags;
-} drm_mga_clear_t;
-
-typedef struct _drm_mga_swap {
- int dummy;
-} drm_mga_swap_t;
-
-typedef struct _drm_mga_iload {
- int idx;
- int length;
- unsigned int destOrg;
-} drm_mga_iload_t;
-
-typedef struct _drm_mga_vertex {
- int idx; /* buffer to queue */
- int used; /* bytes in use */
- int discard; /* client finished with buffer? */
-} drm_mga_vertex_t;
-
-typedef struct _drm_mga_indices {
- int idx; /* buffer to queue */
- unsigned int start;
- unsigned int end;
- int discard; /* client finished with buffer? */
-} drm_mga_indices_t;
-
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h
deleted file mode 100644
index bff103c23..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
- * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
- *
- * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors: Kevin E. Martin <kevin@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h,v 1.1 2000/06/17 00:03:29 martin Exp $
- */
-
-#ifndef _R128_DRM_H_
-#define _R128_DRM_H_
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (xf86drmR128.h)
- */
-typedef struct drm_r128_init {
- enum {
- R128_INIT_CCE = 0x01,
- R128_CLEANUP_CCE = 0x02
- } func;
- int sarea_priv_offset;
- int is_pci;
- int cce_mode;
- int cce_fifo_size;
- int cce_secure;
- int ring_size;
- int usec_timeout;
-
- int fb_offset;
- int agp_ring_offset;
- int agp_read_ptr_offset;
- int agp_vertbufs_offset;
- int agp_indbufs_offset;
- int agp_textures_offset;
- int mmio_offset;
-} drm_r128_init_t;
-
-typedef struct drm_r128_packet {
- unsigned long *buffer;
- int count;
- int flags;
-} drm_r128_packet_t;
-
-typedef enum drm_r128_prim {
- _DRM_R128_PRIM_NONE = 0x0001,
- _DRM_R128_PRIM_POINT = 0x0002,
- _DRM_R128_PRIM_LINE = 0x0004,
- _DRM_R128_PRIM_POLY_LINE = 0x0008,
- _DRM_R128_PRIM_TRI_LIST = 0x0010,
- _DRM_R128_PRIM_TRI_FAN = 0x0020,
- _DRM_R128_PRIM_TRI_STRIP = 0x0040,
- _DRM_R128_PRIM_TRI_TYPE2 = 0x0080
-} drm_r128_prim_t;
-
-typedef struct drm_r128_vertex {
- /* Indices here refer to the offset into
- buflist in drm_buf_get_t. */
- int send_count; /* Number of buffers to send */
- int *send_indices; /* List of handles to buffers */
- int *send_sizes; /* Lengths of data to send */
- drm_r128_prim_t prim; /* Primitive type */
- int request_count; /* Number of buffers requested */
- int *request_indices; /* Buffer information */
- int *request_sizes;
- int granted_count; /* Number of buffers granted */
-} drm_r128_vertex_t;
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (r128_sarea.h)
- */
-#define R128_LOCAL_TEX_HEAP 0
-#define R128_AGP_TEX_HEAP 1
-#define R128_NR_TEX_HEAPS 2
-#define R128_NR_TEX_REGIONS 64
-#define R128_LOG_TEX_GRANULARITY 16
-
-typedef struct drm_tex_region {
- unsigned char next, prev;
- unsigned char in_use;
- int age;
-} drm_tex_region_t;
-
-typedef struct drm_r128_sarea {
- drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
- int tex_age[R128_NR_TEX_HEAPS];
- int ctx_owner;
- int ring_write;
-} drm_r128_sarea_t;
-
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c
deleted file mode 100644
index 67cd444be..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* xf86drmHash.c -- Small hash table support for integer -> integer mapping
- * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 3 16:11:06 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 1999/06/07 13:01:42 faith Exp $
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c,v 1.1 2000/06/17 00:03:27 martin Exp $
- *
- * DESCRIPTION
- *
- * This file contains a straightforward implementation of a fixed-sized
- * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
- * collision resolution. There are two potentially interesting things
- * about this implementation:
- *
- * 1) The table is power-of-two sized. Prime sized tables are more
- * traditional, but do not have a significant advantage over power-of-two
- * sized table, especially when double hashing is not used for collision
- * resolution.
- *
- * 2) The hash computation uses a table of random integers [Hanson97,
- * pp. 39-41].
- *
- * FUTURE ENHANCEMENTS
- *
- * With a table size of 512, the current implementation is sufficient for a
- * few hundred keys. Since this is well above the expected size of the
- * tables for which this implementation was designed, the implementation of
- * dynamic hash tables was postponed until the need arises. A common (and
- * naive) approach to dynamic hash table implementation simply creates a
- * new hash table when necessary, rehashes all the data into the new table,
- * and destroys the old table. The approach in [Larson88] is superior in
- * two ways: 1) only a portion of the table is expanded when needed,
- * distributing the expansion cost over several insertions, and 2) portions
- * of the table can be locked, enabling a scalable thread-safe
- * implementation.
- *
- * REFERENCES
- *
- * [Hanson97] David R. Hanson. C Interfaces and Implementations:
- * Techniques for Creating Reusable Software. Reading, Massachusetts:
- * Addison-Wesley, 1997.
- *
- * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3:
- * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973.
- *
- * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April
- * 1988, pp. 446-457.
- *
- */
-
-#define HASH_MAIN 0
-
-#if HASH_MAIN
-# include <stdio.h>
-# include <stdlib.h>
-#else
-# include "xf86drm.h"
-# ifdef XFree86LOADER
-# include "xf86.h"
-# include "xf86_ansic.h"
-# else
-# include <stdio.h>
-# include <stdlib.h>
-# endif
-#endif
-
-#define N(x) drm##x
-
-#define HASH_MAGIC 0xdeadbeef
-#define HASH_DEBUG 0
-#define HASH_SIZE 512 /* Good for about 100 entries */
- /* If you change this value, you probably
- have to change the HashHash hashing
- function! */
-
-#if HASH_MAIN
-#define HASH_ALLOC malloc
-#define HASH_FREE free
-#define HASH_RANDOM_DECL
-#define HASH_RANDOM_INIT(seed) srandom(seed)
-#define HASH_RANDOM random()
-#else
-#define HASH_ALLOC drmMalloc
-#define HASH_FREE drmFree
-#define HASH_RANDOM_DECL void *state
-#define HASH_RANDOM_INIT(seed) state = drmRandomCreate(seed)
-#define HASH_RANDOM drmRandom(state)
-
-#endif
-
-typedef struct HashBucket {
- unsigned long key;
- void *value;
- struct HashBucket *next;
-} HashBucket, *HashBucketPtr;
-
-typedef struct HashTable {
- unsigned long magic;
- unsigned long entries;
- unsigned long hits; /* At top of linked list */
- unsigned long partials; /* Not at top of linked list */
- unsigned long misses; /* Not in table */
- HashBucketPtr buckets[HASH_SIZE];
- int p0;
- HashBucketPtr p1;
-} HashTable, *HashTablePtr;
-
-#if HASH_MAIN
-extern void *N(HashCreate)(void);
-extern int N(HashDestroy)(void *t);
-extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value);
-extern int N(HashInsert)(void *t, unsigned long key, unsigned long value);
-extern int N(HashDelete)(void *t, unsigned long key);
-#endif
-
-static unsigned long HashHash(unsigned long key)
-{
- unsigned long hash = 0;
- unsigned long tmp = key;
- static int init = 0;
- static unsigned long scatter[256];
- int i;
-
- if (!init) {
- HASH_RANDOM_DECL;
- HASH_RANDOM_INIT(37);
- for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
- ++init;
- }
-
- while (tmp) {
- hash = (hash << 1) + scatter[tmp & 0xff];
- tmp >>= 8;
- }
-
- hash %= HASH_SIZE;
-#if HASH_DEBUG
- printf( "Hash(%d) = %d\n", key, hash);
-#endif
- return hash;
-}
-
-void *N(HashCreate)(void)
-{
- HashTablePtr table;
- int i;
-
- table = HASH_ALLOC(sizeof(*table));
- if (!table) return NULL;
- table->magic = HASH_MAGIC;
- table->entries = 0;
- table->hits = 0;
- table->partials = 0;
- table->misses = 0;
-
- for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
- return table;
-}
-
-int N(HashDestroy)(void *t)
-{
- HashTablePtr table = (HashTablePtr)t;
- HashBucketPtr bucket;
- HashBucketPtr next;
- int i;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- for (i = 0; i < HASH_SIZE; i++) {
- for (bucket = table->buckets[i]; bucket;) {
- next = bucket->next;
- HASH_FREE(bucket);
- bucket = next;
- }
- }
- HASH_FREE(table);
- return 0;
-}
-
-/* Find the bucket and organize the list so that this bucket is at the
- top. */
-
-static HashBucketPtr HashFind(HashTablePtr table,
- unsigned long key, unsigned long *h)
-{
- unsigned long hash = HashHash(key);
- HashBucketPtr prev = NULL;
- HashBucketPtr bucket;
-
- if (h) *h = hash;
-
- for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
- if (bucket->key == key) {
- if (prev) {
- /* Organize */
- prev->next = bucket->next;
- bucket->next = table->buckets[hash];
- table->buckets[hash] = bucket;
- ++table->partials;
- } else {
- ++table->hits;
- }
- return bucket;
- }
- prev = bucket;
- }
- ++table->misses;
- return NULL;
-}
-
-int N(HashLookup)(void *t, unsigned long key, void **value)
-{
- HashTablePtr table = (HashTablePtr)t;
- HashBucketPtr bucket;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- bucket = HashFind(table, key, NULL);
- if (!bucket) return 1; /* Not found */
- *value = bucket->value;
- return 0; /* Found */
-}
-
-int N(HashInsert)(void *t, unsigned long key, void *value)
-{
- HashTablePtr table = (HashTablePtr)t;
- HashBucketPtr bucket;
- unsigned long hash;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- if (HashFind(table, key, &hash)) return 1; /* Already in table */
-
- bucket = HASH_ALLOC(sizeof(*bucket));
- if (!bucket) return -1; /* Error */
- bucket->key = key;
- bucket->value = value;
- bucket->next = table->buckets[hash];
- table->buckets[hash] = bucket;
-#if HASH_DEBUG
- printf("Inserted %d at %d/%p\n", key, hash, bucket);
-#endif
- return 0; /* Added to table */
-}
-
-int N(HashDelete)(void *t, unsigned long key)
-{
- HashTablePtr table = (HashTablePtr)t;
- unsigned long hash;
- HashBucketPtr bucket;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- bucket = HashFind(table, key, &hash);
-
- if (!bucket) return 1; /* Not found */
-
- table->buckets[hash] = bucket->next;
- HASH_FREE(bucket);
- return 0;
-}
-
-int N(HashNext)(void *t, unsigned long *key, void **value)
-{
- HashTablePtr table = (HashTablePtr)t;
-
- for (; table->p0 < HASH_SIZE;
- ++table->p0, table->p1 = table->buckets[table->p0]) {
- if (table->p1) {
- *key = table->p1->key;
- *value = table->p1->value;
- table->p1 = table->p1->next;
- return 1;
- }
- }
- return 0;
-}
-
-int N(HashFirst)(void *t, unsigned long *key, void **value)
-{
- HashTablePtr table = (HashTablePtr)t;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- table->p0 = 0;
- table->p1 = table->buckets[0];
- return N(HashNext)(table, key, value);
-}
-
-#if HASH_MAIN
-#define DIST_LIMIT 10
-static int dist[DIST_LIMIT];
-
-static void clear_dist(void) {
- int i;
-
- for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
-}
-
-static int count_entries(HashBucketPtr bucket)
-{
- int count = 0;
-
- for (; bucket; bucket = bucket->next) ++count;
- return count;
-}
-
-static void update_dist(int count)
-{
- if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
- else ++dist[count];
-}
-
-static void compute_dist(HashTablePtr table)
-{
- int i;
- HashBucketPtr bucket;
-
- printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n",
- table->entries, table->hits, table->partials, table->misses);
- clear_dist();
- for (i = 0; i < HASH_SIZE; i++) {
- bucket = table->buckets[i];
- update_dist(count_entries(bucket));
- }
- for (i = 0; i < DIST_LIMIT; i++) {
- if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
- else printf("other %10d\n", dist[i]);
- }
-}
-
-static void check_table(HashTablePtr table,
- unsigned long key, unsigned long value)
-{
- unsigned long retval = 0;
- int retcode = N(HashLookup)(table, key, &retval);
-
- switch (retcode) {
- case -1:
- printf("Bad magic = 0x%08lx:"
- " key = %lu, expected = %lu, returned = %lu\n",
- table->magic, key, value, retval);
- break;
- case 1:
- printf("Not found: key = %lu, expected = %lu returned = %lu\n",
- key, value, retval);
- break;
- case 0:
- if (value != retval)
- printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
- key, value, retval);
- break;
- default:
- printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
- retcode, key, value, retval);
- break;
- }
-}
-
-int main(void)
-{
- HashTablePtr table;
- int i;
-
- printf("\n***** 256 consecutive integers ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 256; i++) N(HashInsert)(table, i, i);
- for (i = 0; i < 256; i++) check_table(table, i, i);
- for (i = 256; i >= 0; i--) check_table(table, i, i);
- compute_dist(table);
- N(HashDestroy)(table);
-
- printf("\n***** 1024 consecutive integers ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i);
- for (i = 0; i < 1024; i++) check_table(table, i, i);
- for (i = 1024; i >= 0; i--) check_table(table, i, i);
- compute_dist(table);
- N(HashDestroy)(table);
-
- printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i);
- for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
- for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
- compute_dist(table);
- N(HashDestroy)(table);
-
- printf("\n***** 1024 random integers ****\n");
- table = N(HashCreate)();
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) check_table(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) check_table(table, random(), i);
- compute_dist(table);
- N(HashDestroy)(table);
-
- printf("\n***** 5000 random integers ****\n");
- table = N(HashCreate)();
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) check_table(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) check_table(table, random(), i);
- compute_dist(table);
- N(HashDestroy)(table);
-
- return 0;
-}
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c
deleted file mode 100644
index 067c6376e..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifdef XFree86Server
-# include "xf86.h"
-# include "xf86_OSproc.h"
-# include "xf86_ansic.h"
-# include "xf86Priv.h"
-# define _DRM_MALLOC xalloc
-# define _DRM_FREE xfree
-# ifndef XFree86LOADER
-# include <sys/stat.h>
-# include <sys/mman.h>
-# endif
-#else
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
-# include <string.h>
-# include <ctype.h>
-# include <fcntl.h>
-# include <errno.h>
-# include <signal.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <sys/ioctl.h>
-# include <sys/mman.h>
-# include <sys/time.h>
-# ifdef DRM_USE_MALLOC
-# define _DRM_MALLOC malloc
-# define _DRM_FREE free
-extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
-extern int xf86RemoveSIGIOHandler(int fd);
-# else
-# include <Xlibint.h>
-# define _DRM_MALLOC Xmalloc
-# define _DRM_FREE Xfree
-# endif
-#endif
-
-/* Not all systems have MAP_FAILED defined */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#include "xf86drm.h"
-#include "xf86drmI810.h"
-#include "drm.h"
-
-Bool drmI810CleanupDma(int driSubFD)
-{
- drm_i810_init_t init;
-
- memset(&init, 0, sizeof(drm_i810_init_t));
- init.func = I810_CLEANUP_DMA;
-
- if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool drmI810InitDma(int driSubFD, drmI810Init *info)
-{
- drm_i810_init_t init;
-
- memset(&init, 0, sizeof(drm_i810_init_t));
-
- init.func = I810_INIT_DMA;
- init.ring_map_idx = info->ring_map_idx;
- init.buffer_map_idx = info->buffer_map_idx;
- init.ring_start = info->start;
- init.ring_end = info->end;
- init.ring_size = info->size;
- init.sarea_priv_offset = info->sarea_off;
- init.front_offset = info->front_offset;
- init.back_offset = info->back_offset;
- init.depth_offset = info->depth_offset;
- init.w = info->w;
- init.h = info->h;
- init.pitch = info->pitch;
- init.pitch_bits = info->pitch_bits;
-
- if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
- return FALSE;
- }
- return TRUE;
-}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c
deleted file mode 100644
index aa3a6c745..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifdef XFree86Server
-# include "xf86.h"
-# include "xf86_OSproc.h"
-# include "xf86_ansic.h"
-# include "xf86Priv.h"
-# define _DRM_MALLOC xalloc
-# define _DRM_FREE xfree
-# ifndef XFree86LOADER
-# include <sys/stat.h>
-# include <sys/mman.h>
-# endif
-#else
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
-# include <string.h>
-# include <ctype.h>
-# include <fcntl.h>
-# include <errno.h>
-# include <signal.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <sys/ioctl.h>
-# include <sys/mman.h>
-# include <sys/time.h>
-# ifdef DRM_USE_MALLOC
-# define _DRM_MALLOC malloc
-# define _DRM_FREE free
-extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
-extern int xf86RemoveSIGIOHandler(int fd);
-# else
-# include <Xlibint.h>
-# define _DRM_MALLOC Xmalloc
-# define _DRM_FREE Xfree
-# endif
-#endif
-
-/* Not all systems have MAP_FAILED defined */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#include "xf86drm.h"
-#include "xf86drmMga.h"
-#include "drm.h"
-
-Bool drmMgaCleanupDma(int driSubFD)
-{
- drm_mga_init_t init;
- memset(&init, 0, sizeof(drm_mga_init_t));
- init.func = MGA_CLEANUP_DMA;
- if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags)
-{
- drm_lock_t lock;
-
- memset(&lock, 0, sizeof(drm_lock_t));
-
- if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
- if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
- if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
-
- if(ioctl(driSubFD, DRM_IOCTL_MGA_FLUSH, &lock)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool drmMgaInitDma(int driSubFD, drmMgaInit *info)
-{
- drm_mga_init_t init;
- int i;
-
- memset(&init, 0, sizeof(drm_mga_init_t));
- init.func = MGA_INIT_DMA;
- init.reserved_map_agpstart = info->reserved_map_agpstart;
- init.reserved_map_idx = info->reserved_map_idx;
- init.buffer_map_idx = info->buffer_map_idx;
- init.sarea_priv_offset = info->sarea_priv_offset;
- init.primary_size = info->primary_size;
- init.warp_ucode_size = info->warp_ucode_size;
- init.frontOffset = info->frontOffset;
- init.backOffset = info->backOffset;
- init.depthOffset = info->depthOffset;
- init.textureOffset = info->textureOffset;
- init.textureSize = info->textureSize;
- init.agpTextureSize = info->agpTextureSize;
- init.agpTextureOffset = info->agpTextureOffset;
- init.cpp = info->cpp;
- init.stride = info->stride;
- init.sgram = info->sgram;
- init.chipset = info->chipset;
-
- for(i = 0; i < MGA_MAX_WARP_PIPES; i++) {
- init.WarpIndex[i].installed = info->WarpIndex[i].installed;
- init.WarpIndex[i].phys_addr = info->WarpIndex[i].phys_addr;
- init.WarpIndex[i].size = info->WarpIndex[i].size;
- }
-
- init.mAccess = info->mAccess;
-
-
-
- if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
- return FALSE;
- }
- return TRUE;
-}
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c
deleted file mode 100644
index 07904c754..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* xf86drmR128.c -- User-level interface to Rage 128 DRM device
- * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Kevin E. Martin <kevin@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c,v 1.1 2000/06/17 00:03:27 martin Exp $
- *
- */
-
-#ifdef XFree86Server
-# include "xf86.h"
-# include "xf86_OSproc.h"
-# include "xf86_ansic.h"
-# include "xf86Priv.h"
-# define _DRM_MALLOC xalloc
-# define _DRM_FREE xfree
-# ifndef XFree86LOADER
-# include <sys/stat.h>
-# include <sys/mman.h>
-# endif
-#else
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
-# include <string.h>
-# include <ctype.h>
-# include <fcntl.h>
-# include <errno.h>
-# include <signal.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-# include <sys/ioctl.h>
-# include <sys/mman.h>
-# include <sys/time.h>
-# ifdef DRM_USE_MALLOC
-# define _DRM_MALLOC malloc
-# define _DRM_FREE free
-extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
-extern int xf86RemoveSIGIOHandler(int fd);
-# else
-# include <Xlibint.h>
-# define _DRM_MALLOC Xmalloc
-# define _DRM_FREE Xfree
-# endif
-#endif
-
-/* Not all systems have MAP_FAILED defined */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#include "xf86drm.h"
-#include "xf86drmR128.h"
-#include "drm.h"
-
-int drmR128InitCCE(int fd, drmR128Init *info)
-{
- drm_r128_init_t init;
-
- memset(&init, 0, sizeof(drm_r128_init_t));
-
- init.func = R128_INIT_CCE;
- init.sarea_priv_offset = info->sarea_priv_offset;
- init.is_pci = info->is_pci;
- init.cce_mode = info->cce_mode;
- init.cce_fifo_size = info->cce_fifo_size;
- init.cce_secure = info->cce_secure;
- init.ring_size = info->ring_size;
- init.usec_timeout = info->usec_timeout;
-
- init.fb_offset = info->fb_offset;
- init.agp_ring_offset = info->agp_ring_offset;
- init.agp_read_ptr_offset = info->agp_read_ptr_offset;
- init.agp_vertbufs_offset = info->agp_vertbufs_offset;
- init.agp_indbufs_offset = info->agp_indbufs_offset;
- init.agp_textures_offset = info->agp_textures_offset;
- init.mmio_offset = info->mmio_offset;
-
- if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
-
- return 0;
-}
-
-int drmR128CleanupCCE(int fd)
-{
- drm_r128_init_t init;
-
- memset(&init, 0, sizeof(drm_r128_init_t));
-
- init.func = R128_CLEANUP_CCE;
-
- if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
-
- return 0;
-}
-
-int drmR128EngineReset(int fd)
-{
- if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno;
-
- return 0;
-}
-
-int drmR128EngineFlush(int fd)
-{
- if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno;
-
- return 0;
-}
-
-int drmR128CCEWaitForIdle(int fd)
-{
- if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno;
-
- return 0;
-}
-
-int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags)
-{
- drm_r128_packet_t packet;
- int ret;
-
- memset(&packet, 0, sizeof(drm_r128_packet_t));
-
- packet.count = *count;
- packet.flags = flags;
-
- while (packet.count > 0) {
- packet.buffer = buffer + (*count - packet.count);
- ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet);
- if (ret < 0 && ret != -EAGAIN) {
- *count = packet.count;
- return -errno;
- }
- }
-
- *count = 0;
- return 0;
-}
-
-int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes)
-{
- drm_r128_vertex_t v;
-
- v.send_count = 0;
- v.send_indices = NULL;
- v.send_sizes = NULL;
- v.prim = DRM_R128_PRIM_NONE;
- v.request_count = count;
- v.request_indices = indices;
- v.request_sizes = sizes;
- v.granted_count = 0;
-
- if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno;
-
- return v.granted_count;
-}
-
-int drmR128FlushVertexBuffers(int fd, int count, int *indices,
- int *sizes, drmR128PrimType prim)
-{
- drm_r128_vertex_t v;
-
- v.send_count = count;
- v.send_indices = indices;
- v.send_sizes = sizes;
- v.prim = prim;
- v.request_count = 0;
- v.request_indices = NULL;
- v.request_sizes = NULL;
- v.granted_count = 0;
-
- if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno;
-
- return 0;
-}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c
deleted file mode 100644
index d0f49906b..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
- * Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 24 14:53:45 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 1999/06/24 18:54:55 faith Exp $
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c,v 1.1 2000/06/17 00:03:28 martin Exp $
- *
- * DESCRIPTION
- *
- * This file contains a simple, straightforward implementation of the Park
- * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer
- * multiplicative linear congruential generator (MLCG) with a period of
- * 2^31-1.
- *
- * This implementation is intended to provide a reliable, portable PRNG
- * that is suitable for testing a hash table implementation and for
- * implementing skip lists.
- *
- * FUTURE ENHANCEMENTS
- *
- * If initial seeds are not selected randomly, two instances of the PRNG
- * can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique
- * that can eliminate this problem.
- *
- * If PRNGs are used for simulation, the period of the current
- * implementation may be too short. [LE88] discusses methods of combining
- * MLCGs to produce much longer periods, and suggests some alternative
- * values for A and M. [LE90 and Sch92] also provide information on
- * long-period PRNGs.
- *
- * REFERENCES
- *
- * [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2:
- * Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981.
- *
- * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number
- * Generators". CACM 31(6), June 1988, pp. 742-774.
- *
- * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10,
- * October 1990, pp. 85-97.
- *
- * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators:
- * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201.
- *
- * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit
- * CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40.
- *
- * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In
- * "Technical Correspondence: Remarks on Choosing and Implementing Random
- * Number Generators". CACM 36(7), July 1993, pp. 105-110.
- *
- */
-
-#define RANDOM_MAIN 0
-
-#if RANDOM_MAIN
-# include <stdio.h>
-# include <stdlib.h>
-#else
-# include "xf86drm.h"
-# ifdef XFree86LOADER
-# include "xf86.h"
-# include "xf86_ansic.h"
-# else
-# include <stdio.h>
-# include <stdlib.h>
-# endif
-#endif
-
-#define N(x) drm##x
-
-#define RANDOM_MAGIC 0xfeedbeef
-#define RANDOM_DEBUG 0
-
-#if RANDOM_MAIN
-#define RANDOM_ALLOC malloc
-#define RANDOM_FREE free
-#else
-#define RANDOM_ALLOC drmMalloc
-#define RANDOM_FREE drmFree
-#endif
-
-typedef struct RandomState {
- unsigned long magic;
- unsigned long a;
- unsigned long m;
- unsigned long q; /* m div a */
- unsigned long r; /* m mod a */
- unsigned long check;
- long seed;
-} RandomState;
-
-#if RANDOM_MAIN
-extern void *N(RandomCreate)(unsigned long seed);
-extern int N(RandomDestroy)(void *state);
-extern unsigned long N(Random)(void *state);
-extern double N(RandomDouble)(void *state);
-#endif
-
-void *N(RandomCreate)(unsigned long seed)
-{
- RandomState *state;
-
- state = RANDOM_ALLOC(sizeof(*state));
- if (!state) return NULL;
- state->magic = RANDOM_MAGIC;
-#if 0
- /* Park & Miller, October 1988 */
- state->a = 16807;
- state->m = 2147483647;
- state->check = 1043618065; /* After 10000 iterations */
-#else
- /* Park, Miller, and Stockmeyer, July 1993 */
- state->a = 48271;
- state->m = 2147483647;
- state->check = 399268537; /* After 10000 iterations */
-#endif
- state->q = state->m / state->a;
- state->r = state->m % state->a;
-
- state->seed = seed;
- /* Check for illegal boundary conditions,
- and choose closest legal value. */
- if (state->seed <= 0) state->seed = 1;
- if (state->seed >= state->m) state->seed = state->m - 1;
-
- return state;
-}
-
-int N(RandomDestroy)(void *state)
-{
- RANDOM_FREE(state);
- return 0;
-}
-
-unsigned long N(Random)(void *state)
-{
- RandomState *s = (RandomState *)state;
- long hi;
- long lo;
-
- hi = s->seed / s->q;
- lo = s->seed % s->q;
- s->seed = s->a * lo - s->r * hi;
- if (s->seed <= 0) s->seed += s->m;
-
- return s->seed;
-}
-
-double N(RandomDouble)(void *state)
-{
- RandomState *s = (RandomState *)state;
-
- return (double)N(Random)(state)/(double)s->m;
-}
-
-#if RANDOM_MAIN
-static void check_period(long seed)
-{
- unsigned long count = 0;
- unsigned long initial;
- void *state;
-
- state = N(RandomCreate)(seed);
- initial = N(Random)(state);
- ++count;
- while (initial != N(Random)(state)) {
- if (!++count) break;
- }
- printf("With seed of %10ld, period = %10lu (0x%08lx)\n",
- seed, count, count);
- N(RandomDestroy)(state);
-}
-
-int main(void)
-{
- RandomState *state;
- int i;
- unsigned long rand;
-
- state = N(RandomCreate)(1);
- for (i = 0; i < 10000; i++) {
- rand = N(Random)(state);
- }
- printf("After 10000 iterations: %lu (%lu expected): %s\n",
- rand, state->check,
- rand - state->check ? "*INCORRECT*" : "CORRECT");
- N(RandomDestroy)(state);
-
- printf("Checking periods...\n");
- check_period(1);
- check_period(2);
- check_period(31415926);
-
- return 0;
-}
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c
deleted file mode 100644
index 51a54f934..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/* xf86drmSL.c -- Skip list support
- * Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 3 16:13:01 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.2 1999/06/07 13:01:42 faith Exp $
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c,v 1.1 2000/06/17 00:03:28 martin Exp $
- *
- * DESCRIPTION
- *
- * This file contains a straightforward skip list implementation.n
- *
- * FUTURE ENHANCEMENTS
- *
- * REFERENCES
- *
- * [Pugh90] William Pugh. Skip Lists: A Probabilistic Alternative to
- * Balanced Trees. CACM 33(6), June 1990, pp. 668-676.
- *
- */
-
-#define SL_MAIN 0
-
-#if SL_MAIN
-# include <stdio.h>
-# include <stdlib.h>
-# include <sys/time.h>
-#else
-# include "xf86drm.h"
-# ifdef XFree86LOADER
-# include "xf86.h"
-# include "xf86_ansic.h"
-# else
-# include <stdio.h>
-# include <stdlib.h>
-# endif
-#endif
-
-#define N(x) drm##x
-
-#define SL_LIST_MAGIC 0xfacade00LU
-#define SL_ENTRY_MAGIC 0x00fab1edLU
-#define SL_FREED_MAGIC 0xdecea5edLU
-#define SL_MAX_LEVEL 16
-#define SL_DEBUG 0
-#define SL_RANDOM_SEED 0xc01055a1LU
-
-#if SL_MAIN
-#define SL_ALLOC malloc
-#define SL_FREE free
-#define SL_RANDOM_DECL static int state = 0;
-#define SL_RANDOM_INIT(seed) if (!state) { srandom(seed); ++state; }
-#define SL_RANDOM random()
-#else
-#define SL_ALLOC drmMalloc
-#define SL_FREE drmFree
-#define SL_RANDOM_DECL static void *state = NULL
-#define SL_RANDOM_INIT(seed) if (!state) state = drmRandomCreate(seed)
-#define SL_RANDOM drmRandom(state)
-
-#endif
-
-typedef struct SLEntry {
- unsigned long magic; /* SL_ENTRY_MAGIC */
- unsigned long key;
- void *value;
- int levels;
- struct SLEntry *forward[1]; /* variable sized array */
-} SLEntry, *SLEntryPtr;
-
-typedef struct SkipList {
- unsigned long magic; /* SL_LIST_MAGIC */
- int level;
- int count;
- SLEntryPtr head;
- SLEntryPtr p0; /* Position for iteration */
-} SkipList, *SkipListPtr;
-
-#if SL_MAIN
-extern void *N(SLCreate)(void);
-extern int N(SLDestroy)(void *l);
-extern int N(SLLookup)(void *l, unsigned long key, void **value);
-extern int N(SLInsert)(void *l, unsigned long key, void *value);
-extern int N(SLDelete)(void *l, unsigned long key);
-extern int N(SLNext)(void *l, unsigned long *key, void **value);
-extern int N(SLFirst)(void *l, unsigned long *key, void **value);
-extern void N(SLDump)(void *l);
-extern int N(SLLookupNeighbors)(void *l, unsigned long key,
- unsigned long *prev_key, void **prev_value,
- unsigned long *next_key, void **next_value);
-#endif
-
-static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value)
-{
- SLEntryPtr entry;
-
- if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL;
-
- entry = SL_ALLOC(sizeof(*entry)
- + (max_level + 1) * sizeof(entry->forward[0]));
- if (!entry) return NULL;
- entry->magic = SL_ENTRY_MAGIC;
- entry->key = key;
- entry->value = value;
- entry->levels = max_level + 1;
-
- return entry;
-}
-
-static int SLRandomLevel(void)
-{
- int level = 1;
- SL_RANDOM_DECL;
-
- SL_RANDOM_INIT(SL_RANDOM_SEED);
-
- while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level;
- return level;
-}
-
-void *N(SLCreate)(void)
-{
- SkipListPtr list;
- int i;
-
- list = SL_ALLOC(sizeof(*list));
- if (!list) return NULL;
- list->magic = SL_LIST_MAGIC;
- list->level = 0;
- list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
- list->count = 0;
-
- for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
-
- return list;
-}
-
-int N(SLDestroy)(void *l)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr entry;
- SLEntryPtr next;
-
- if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
- for (entry = list->head; entry; entry = next) {
- if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */
- next = entry->forward[0];
- entry->magic = SL_FREED_MAGIC;
- SL_FREE(entry);
- }
-
- list->magic = SL_FREED_MAGIC;
- SL_FREE(list);
- return 0;
-}
-
-static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr entry;
- int i;
-
- if (list->magic != SL_LIST_MAGIC) return NULL;
-
- for (i = list->level, entry = list->head; i >= 0; i--) {
- while (entry->forward[i] && entry->forward[i]->key < key)
- entry = entry->forward[i];
- update[i] = entry;
- }
-
- return entry->forward[0];
-}
-
-int N(SLInsert)(void *l, unsigned long key, void *value)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr entry;
- SLEntryPtr update[SL_MAX_LEVEL + 1];
- int level;
- int i;
-
- if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
- entry = SLLocate(list, key, update);
-
- if (entry && entry->key == key) return 1; /* Already in list */
-
-
- level = SLRandomLevel();
- if (level > list->level) {
- level = ++list->level;
- update[level] = list->head;
- }
-
- entry = SLCreateEntry(level, key, value);
-
- /* Fix up forward pointers */
- for (i = 0; i <= level; i++) {
- entry->forward[i] = update[i]->forward[i];
- update[i]->forward[i] = entry;
- }
-
- ++list->count;
- return 0; /* Added to table */
-}
-
-int N(SLDelete)(void *l, unsigned long key)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr update[SL_MAX_LEVEL + 1];
- SLEntryPtr entry;
- int i;
-
- if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
- entry = SLLocate(list, key, update);
-
- if (!entry || entry->key != key) return 1; /* Not found */
-
- /* Fix up forward pointers */
- for (i = 0; i <= list->level; i++) {
- if (update[i]->forward[i] == entry)
- update[i]->forward[i] = entry->forward[i];
- }
-
- entry->magic = SL_FREED_MAGIC;
- SL_FREE(entry);
-
- while (list->level && !list->head->forward[list->level]) --list->level;
- --list->count;
- return 0;
-}
-
-int N(SLLookup)(void *l, unsigned long key, void **value)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr update[SL_MAX_LEVEL + 1];
- SLEntryPtr entry;
-
- entry = SLLocate(list, key, update);
-
- if (entry && entry->key == key) {
- *value = entry;
- return 0;
- }
- *value = NULL;
- return -1;
-}
-
-int N(SLLookupNeighbors)(void *l, unsigned long key,
- unsigned long *prev_key, void **prev_value,
- unsigned long *next_key, void **next_value)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr update[SL_MAX_LEVEL + 1];
- SLEntryPtr entry;
- int retcode = 0;
-
- entry = SLLocate(list, key, update);
-
- *prev_key = *next_key = key;
- *prev_value = *next_value = NULL;
-
- if (update[0]) {
- *prev_key = update[0]->key;
- *prev_value = update[0]->value;
- ++retcode;
- if (update[0]->forward[0]) {
- *next_key = update[0]->forward[0]->key;
- *next_value = update[0]->forward[0]->value;
- ++retcode;
- }
- }
- return retcode;
-}
-
-int N(SLNext)(void *l, unsigned long *key, void **value)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr entry;
-
- if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
- entry = list->p0;
-
- if (entry) {
- list->p0 = entry->forward[0];
- *key = entry->key;
- *value = entry->value;
- return 1;
- }
- list->p0 = NULL;
- return 0;
-}
-
-int N(SLFirst)(void *l, unsigned long *key, void **value)
-{
- SkipListPtr list = (SkipListPtr)l;
-
- if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
- list->p0 = list->head->forward[0];
- return N(SLNext)(list, key, value);
-}
-
-/* Dump internal data structures for debugging. */
-void N(SLDump)(void *l)
-{
- SkipListPtr list = (SkipListPtr)l;
- SLEntryPtr entry;
- int i;
-
- if (list->magic != SL_LIST_MAGIC) {
- printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
- list->magic, SL_LIST_MAGIC);
- return;
- }
-
- printf("Level = %d, count = %d\n", list->level, list->count);
- for (entry = list->head; entry; entry = entry->forward[0]) {
- if (entry->magic != SL_ENTRY_MAGIC) {
- printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
- list->magic, SL_ENTRY_MAGIC);
- }
- printf("\nEntry %p <0x%08lx, %p> has %2d levels\n",
- entry, entry->key, entry->value, entry->levels);
- for (i = 0; i < entry->levels; i++) {
- if (entry->forward[i]) {
- printf(" %2d: %p <0x%08lx, %p>\n",
- i,
- entry->forward[i],
- entry->forward[i]->key,
- entry->forward[i]->value);
- } else {
- printf(" %2d: %p\n", i, entry->forward[i]);
- }
- }
- }
-}
-
-#if SL_MAIN
-static void print(SkipListPtr list)
-{
- unsigned long key;
- void *value;
-
- if (N(SLFirst)(list, &key, &value)) {
- do {
- printf("key = %5lu, value = %p\n", key, value);
- } while (N(SLNext)(list, &key, &value));
- }
-}
-
-static double do_time(int size, int iter)
-{
- SkipListPtr list;
- int i, j;
- unsigned long keys[1000000];
- unsigned long previous;
- unsigned long key;
- void *value;
- struct timeval start, stop;
- double usec;
- SL_RANDOM_DECL;
-
- SL_RANDOM_INIT(12345);
-
- list = N(SLCreate)();
-
- for (i = 0; i < size; i++) {
- keys[i] = SL_RANDOM;
- N(SLInsert)(list, keys[i], NULL);
- }
-
- previous = 0;
- if (N(SLFirst)(list, &key, &value)) {
- do {
- if (key <= previous) {
- printf( "%lu !< %lu\n", previous, key);
- }
- previous = key;
- } while (N(SLNext)(list, &key, &value));
- }
-
- gettimeofday(&start, NULL);
- for (j = 0; j < iter; j++) {
- for (i = 0; i < size; i++) {
- if (N(SLLookup)(list, keys[i], &value))
- printf("Error %lu %d\n", keys[i], i);
- }
- }
- gettimeofday(&stop, NULL);
-
- usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec
- - start.tv_sec * 1000000 - start.tv_usec) / (size * iter);
-
- printf("%0.2f microseconds for list length %d\n", usec, size);
-
- N(SLDestroy)(list);
-
- return usec;
-}
-
-static void print_neighbors(void *list, unsigned long key)
-{
- unsigned long prev_key = 0;
- unsigned long next_key = 0;
- void *prev_value;
- void *next_value;
- int retval;
-
- retval = drmSLLookupNeighbors(list, key,
- &prev_key, &prev_value,
- &next_key, &next_value);
- printf("Neighbors of %5lu: %d %5lu %5lu\n",
- key, retval, prev_key, next_key);
-}
-
-int main(void)
-{
- SkipListPtr list;
- double usec, usec2, usec3, usec4;
-
- list = N(SLCreate)();
- printf( "list at %p\n", list);
-
- print(list);
- printf("\n==============================\n\n");
-
- N(SLInsert)(list, 123, NULL);
- N(SLInsert)(list, 213, NULL);
- N(SLInsert)(list, 50, NULL);
- print(list);
- printf("\n==============================\n\n");
-
- print_neighbors(list, 0);
- print_neighbors(list, 50);
- print_neighbors(list, 51);
- print_neighbors(list, 123);
- print_neighbors(list, 200);
- print_neighbors(list, 213);
- print_neighbors(list, 256);
- printf("\n==============================\n\n");
-
- N(SLDelete)(list, 50);
- print(list);
- printf("\n==============================\n\n");
-
- N(SLDump)(list);
- N(SLDestroy)(list);
- printf("\n==============================\n\n");
-
- usec = do_time(100, 10000);
- usec2 = do_time(1000, 500);
- printf("Table size increased by %0.2f, search time increased by %0.2f\n",
- 1000.0/100.0, usec2 / usec);
-
- usec3 = do_time(10000, 50);
- printf("Table size increased by %0.2f, search time increased by %0.2f\n",
- 10000.0/100.0, usec3 / usec);
-
- usec4 = do_time(100000, 4);
- printf("Table size increased by %0.2f, search time increased by %0.2f\n",
- 100000.0/100.0, usec4 / usec);
-
- return 0;
-}
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile
index 7a5fea61c..6457b2732 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imakefile
@@ -2,14 +2,6 @@ XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Imake
#include <Server.tmpl>
-LinkSourceFile(xf86drm.c,..)
-LinkSourceFile(xf86drmHash.c,..)
-LinkSourceFile(xf86drmRandom.c,..)
-LinkSourceFile(xf86drmSL.c,..)
-LinkSourceFile(xf86drm.h,$(XF86OSSRC))
-LinkSourceFile(xf86_OSproc.h,$(XF86OSSRC))
-LinkSourceFile(sigio.c,$(XF86OSSRC)/shared)
-
XCOMM This is a kludge until we determine how best to build the
XCOMM kernel-specific device driver. This allows us to continue
XCOMM to maintain the single Makefile.linux with kernel-specific
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
index a9f744691..506e437b0 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
@@ -24,7 +24,6 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.9 2000/08/04 03:51:47 tsi Exp $
#
# ***** NOTE NOTE NOTE NOTE NOTE *****
# To override the automatic Linux source tree determination, pass the
@@ -50,7 +49,6 @@
MODS= gamma.o tdfx.o r128.o radeon.o
LIBS= libdrm.a
-PROGS= drmstat
DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \
lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o
@@ -68,9 +66,6 @@ R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS)
RADEONOBJS= radeon_drv.o radeon_dma.o radeon_bufs.o radeon_context.o
RADEONHEADERS= radeon_drv.h radeon_drm.h $(DRMHEADERS)
-PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po
-PROGHEADERS= xf86drm.h $(DRMHEADERS)
-
INC= /usr/include
CFLAGS= -O2 $(WARNINGS)
@@ -121,7 +116,9 @@ all:; @echo Error: Could not locate kernel tree in $A $B $C
else
SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'SMP = ' | cut -d' ' -f3)
-MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \
+MODULES := $(shell gcc -E -nostdinc -I $(TREE) picker.c 2>/dev/null \
+ | grep -s 'MODULES = ' | cut -d' ' -f3)
+MODVERSIONS := $(shell gcc -E -nostdinc -I $(TREE) picker.c 2>/dev/null \
| grep -s 'MODVERSIONS = ' | cut -d' ' -f3)
AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'AGP = ' | cut -d' ' -f3)
@@ -165,12 +162,20 @@ SISHEADERS= sis_drv.h sis_ds.h sis_drm.h $(DRMHEADERS)
endif
all::;@echo === KERNEL HEADERS IN $(TREE)
-all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP} SIS=${SIS}
+all::;@echo === SMP=${SMP} MODULES=${MODULES} MODVERSIONS=${MODVERSIONS} AGP=${AGP}
all::;@echo === kill_fasync has $(PARAMS) parameters
all::;@echo === Compiling for machine $(MACHINE)
+
+ifeq ($(MODULES),0)
+all::;@echo
+all::;@echo "*** Kernel modules must be configured. Build aborted."
+all::;@echo
+else
all:: $(LIBS) $(MODS) $(PROGS)
endif
+endif
+
# **** End of SMP/MODVERSIONS detection
# **** Handle SMP/MODVERSIONS
@@ -225,9 +230,6 @@ i810.o: $(I810OBJS) $(LIBS)
$(LD) -r $^ -o $@
endif
-drmstat: $(PROGOBJS)
- $(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@
-
.PHONY: ChangeLog
ChangeLog:
@rm -f Changelog
@@ -241,9 +243,6 @@ ChangeLog:
%.o: %.c
$(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@
-%.po: %.c
- $(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@
-
$(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
@@ -253,7 +252,6 @@ ifeq ($(AGP),1)
$(MGAOBJS): $(MGAHEADERS)
$(I810OBJS): $(I810HEADERS)
endif
-$(PROGOBJS): $(PROGHEADERS)
clean:
- rm -f *.o *.a *.po *~ core $(PROGS)
+ rm -f *.o *.a *~ core
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
index ac2d1bc5a..5cc3ec369 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
@@ -397,10 +397,10 @@ int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *d)
atomic_inc(&q->use_count);
if (atomic_read(&q->block_write)) {
- current->state = TASK_INTERRUPTIBLE;
add_wait_queue(&q->write_queue, &entry);
atomic_inc(&q->block_count);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!atomic_read(&q->block_write)) break;
schedule();
if (signal_pending(current)) {
@@ -486,14 +486,16 @@ static int drm_dma_get_buffers_of_order(drm_device_t *dev, drm_dma_t *d,
buf->pending);
}
buf->pid = current->pid;
- copy_to_user_ret(&d->request_indices[i],
+ if (copy_to_user(&d->request_indices[i],
&buf->idx,
- sizeof(buf->idx),
- -EFAULT);
- copy_to_user_ret(&d->request_sizes[i],
+ sizeof(buf->idx)))
+ return -EFAULT;
+
+ if (copy_to_user(&d->request_sizes[i],
&buf->total,
- sizeof(buf->total),
- -EFAULT);
+ sizeof(buf->total)))
+ return -EFAULT;
+
++d->granted_count;
}
return 0;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
index d5ad7f5fb..6cc9500f1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
@@ -35,7 +35,13 @@
#ifndef _DRM_H_
#define _DRM_H_
+#if defined(__linux__)
#include <asm/ioctl.h> /* For _IO* macros */
+#define DRM_IOCTL_NR(n) _IOC_NR(n)
+#elif defined(__FreeBSD__)
+#include <sys/ioccom.h>
+#define DRM_IOCTL_NR(n) ((n) & 0xff)
+#endif
#define DRM_PROC_DEVICES "/proc/devices"
#define DRM_PROC_MISC "/proc/misc"
@@ -290,7 +296,6 @@ typedef struct drm_agp_info {
} drm_agp_info_t;
#define DRM_IOCTL_BASE 'd'
-#define DRM_IOCTL_NR(n) _IOC_NR(n)
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
index 3d5219db8..6be90c516 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
@@ -28,12 +28,17 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h,v 1.9 2000/08/28 02:43:14 tsi Exp $ */
#ifndef _DRM_P_H_
#define _DRM_P_H_
#ifdef __KERNEL__
+#ifdef __alpha__
+/* add include of current.h so that "current" is defined
+ * before static inline funcs in wait.h. Doing this so we
+ * can build the DRM (part of PI DRI). 4/21/2000 S + B */
+#include <asm/current.h>
+#endif /* __alpha__ */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
@@ -48,6 +53,9 @@
#include <linux/sched.h>
#include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h>
+#ifdef __alpha__
+#include <asm/pgtable.h> /* For pte_wrprotect */
+#endif
#include <asm/io.h>
#include <asm/mman.h>
#include <asm/uaccess.h>
@@ -58,10 +66,13 @@
#include <linux/types.h>
#include <linux/agp_backend.h>
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
+#if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */
#include <linux/tqueue.h>
#include <linux/poll.h>
#endif
+#if LINUX_VERSION_CODE < 0x020400
+#include "compat-pre24.h"
+#endif
#include "drm.h"
#define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
@@ -141,15 +152,75 @@ typedef struct wait_queue *wait_queue_head_t;
#define module_exit(x) void cleanup_module(void) { x(); }
#endif
- /* virt_to_page added in 2.4.0-test6 */
-#if LINUX_VERSION_CODE < 0x020400
-#define virt_to_page(kaddr) (mem_map + MAP_NR(kaddr))
-#endif
-
/* Generic cmpxchg added in 2.3.x */
#ifndef __HAVE_ARCH_CMPXCHG
/* Include this here so that driver can be
used with older kernels. */
+#if defined(__alpha__)
+static __inline__ unsigned long
+__cmpxchg_u32(volatile int *m, int old, int new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldl_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stl_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
+{
+ unsigned long prev, cmp;
+
+ __asm__ __volatile__(
+ "1: ldq_l %0,%2\n"
+ " cmpeq %0,%3,%1\n"
+ " beq %1,2f\n"
+ " mov %4,%1\n"
+ " stq_c %1,%2\n"
+ " beq %1,3f\n"
+ "2: mb\n"
+ ".subsection 2\n"
+ "3: br 1b\n"
+ ".previous"
+ : "=&r"(prev), "=&r"(cmp), "=m"(*m)
+ : "r"((long) old), "r"(new), "m"(*m));
+
+ return prev;
+}
+
+static __inline__ unsigned long
+__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
+{
+ switch (size) {
+ case 4:
+ return __cmpxchg_u32(ptr, old, new);
+ case 8:
+ return __cmpxchg_u64(ptr, old, new);
+ }
+ return old;
+}
+#define cmpxchg(ptr,o,n) \
+ ({ \
+ __typeof__(*(ptr)) _o_ = (o); \
+ __typeof__(*(ptr)) _n_ = (n); \
+ (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
+ (unsigned long)_n_, sizeof(*(ptr))); \
+ })
+
+#elif __i386__
static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
@@ -180,6 +251,7 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
#define cmpxchg(ptr,o,n) \
((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
(unsigned long)(n),sizeof(*(ptr))))
+#endif /* i386 & alpha */
#endif
/* Macros to make printk easier */
@@ -358,6 +430,7 @@ typedef struct drm_file {
struct drm_file *next;
struct drm_file *prev;
struct drm_device *dev;
+ int remove_auth_on_close;
} drm_file_t;
@@ -452,6 +525,11 @@ typedef struct {
extern drm_agp_func_t drm_agp;
#endif
+typedef struct drm_sigdata {
+ int context;
+ drm_hw_lock_t *lock;
+} drm_sigdata_t;
+
typedef struct drm_device {
const char *name; /* Simple driver name */
char *unique; /* Unique identifier: e.g., busid */
@@ -536,6 +614,8 @@ typedef struct drm_device {
#endif
unsigned long *ctx_bitmap;
void *dev_private;
+ drm_sigdata_t sigdata; /* For block_all_signals */
+ sigset_t sigmask;
} drm_device_t;
@@ -730,6 +810,7 @@ extern int drm_flush_unblock(drm_device_t *dev, int context,
drm_lock_flags_t flags);
extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
drm_lock_flags_t flags);
+extern int drm_notifier(void *priv);
/* Context Bitmap support (ctxbitmap.c) */
extern int drm_ctxbitmap_init(drm_device_t *dev);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
index a99f24cae..4ab67281c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
@@ -542,10 +542,9 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
if (d->flags & _DRM_DMA_BLOCK) {
DRM_DEBUG("%d waiting\n", current->pid);
- current->state = TASK_INTERRUPTIBLE;
for (;;) {
- if (!last_buf->waiting
- && !last_buf->pending)
+ current->state = TASK_INTERRUPTIBLE;
+ if (!last_buf->waiting && !last_buf->pending)
break; /* finished */
schedule();
if (signal_pending(current)) {
@@ -586,7 +585,8 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd,
int retcode = 0;
drm_dma_t d;
- copy_from_user_ret(&d, (drm_dma_t *)arg, sizeof(d), -EFAULT);
+ if (copy_from_user(&d, (drm_dma_t *)arg, sizeof(d)))
+ return -EFAULT;
DRM_DEBUG("%d %d: %d send, %d req\n",
current->pid, d.context, d.send_count, d.request_count);
@@ -621,7 +621,8 @@ int gamma_dma(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_DEBUG("%d returning, granted = %d\n",
current->pid, d.granted_count);
- copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT);
+ if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d)))
+ return -EFAULT;
return retcode;
}
@@ -710,7 +711,8 @@ int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd,
drm_control_t ctl;
int retcode;
- copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT);
+ if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl)))
+ return -EFAULT;
switch (ctl.func) {
case DRM_INST_HANDLER:
@@ -742,7 +744,8 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lck_start = start = get_cycles();
#endif
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -774,6 +777,7 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd,
}
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -790,7 +794,6 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
schedule();
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -804,6 +807,15 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */
if (!ret) {
+ sigemptyset(&dev->sigmask);
+ sigaddset(&dev->sigmask, SIGSTOP);
+ sigaddset(&dev->sigmask, SIGTSTP);
+ sigaddset(&dev->sigmask, SIGTTIN);
+ sigaddset(&dev->sigmask, SIGTTOU);
+ dev->sigdata.context = lock.context;
+ dev->sigdata.lock = dev->lock.hw_lock;
+ block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
+
if (lock.flags & _DRM_LOCK_READY)
gamma_dma_ready(dev);
if (lock.flags & _DRM_LOCK_QUIESCENT) {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
index 12945310e..26fe0c1c1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
@@ -29,7 +29,6 @@
* Keith Whitwell <keithw@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c,v 1.6 2000/08/28 02:43:15 tsi Exp $ */
#define __NO_VERSION__
#include "drmP.h"
@@ -253,16 +252,15 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
buf = i810_freelist_get(dev);
if (!buf) {
retcode = -ENOMEM;
- DRM_DEBUG("%s retcode %d\n", __FUNCTION__, retcode);
- goto out_get_buf;
+ DRM_DEBUG("retcode=%d\n", retcode);
+ return retcode;
}
retcode = i810_map_buffer(buf, filp);
if(retcode) {
i810_freelist_put(dev, buf);
- DRM_DEBUG("mapbuf failed in %s retcode %d\n",
- __FUNCTION__, retcode);
- goto out_get_buf;
+ DRM_DEBUG("mapbuf failed, retcode %d\n", retcode);
+ return retcode;
}
buf->pid = priv->pid;
buf_priv = buf->dev_private;
@@ -271,7 +269,6 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
d->request_size = buf->total;
d->virtual = buf_priv->virtual;
-out_get_buf:
return retcode;
}
@@ -491,8 +488,8 @@ int i810_dma_init(struct inode *inode, struct file *filp,
drm_i810_init_t init;
int retcode = 0;
- copy_from_user_ret(&init, (drm_i810_init_t *)arg,
- sizeof(init), -EFAULT);
+ if (copy_from_user(&init, (drm_i810_init_t *)arg, sizeof(init)))
+ return -EFAULT;
switch(init.func) {
case I810_INIT_DMA:
@@ -1006,7 +1003,8 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_DEBUG( "i810_control\n");
- copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT);
+ if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl)))
+ return -EFAULT;
switch (ctl.func) {
case DRM_INST_HANDLER:
@@ -1069,11 +1067,11 @@ static void i810_dma_quiescent(drm_device_t *dev)
return;
}
atomic_set(&dev_priv->flush_done, 0);
- current->state = TASK_INTERRUPTIBLE;
add_wait_queue(&dev_priv->flush_queue, &entry);
end = jiffies + (HZ*3);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
i810_dma_quiescent_emit(dev);
if (atomic_read(&dev_priv->flush_done) == 1) break;
if((signed)(end - jiffies) <= 0) {
@@ -1104,10 +1102,10 @@ static int i810_flush_queue(drm_device_t *dev)
return 0;
}
atomic_set(&dev_priv->flush_done, 0);
- current->state = TASK_INTERRUPTIBLE;
add_wait_queue(&dev_priv->flush_queue, &entry);
end = jiffies + (HZ*3);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
i810_dma_emit_flush(dev);
if (atomic_read(&dev_priv->flush_done) == 1) break;
if((signed)(end - jiffies) <= 0) {
@@ -1179,7 +1177,8 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
int ret = 0;
drm_lock_t lock;
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -1200,6 +1199,7 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
if (!ret) {
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -1215,7 +1215,6 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
DRM_DEBUG("Calling lock schedule\n");
schedule();
if (signal_pending(current)) {
@@ -1228,6 +1227,15 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
}
if (!ret) {
+ sigemptyset(&dev->sigmask);
+ sigaddset(&dev->sigmask, SIGSTOP);
+ sigaddset(&dev->sigmask, SIGTSTP);
+ sigaddset(&dev->sigmask, SIGTTIN);
+ sigaddset(&dev->sigmask, SIGTTOU);
+ dev->sigdata.context = lock.context;
+ dev->sigdata.lock = dev->lock.hw_lock;
+ block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
+
if (lock.flags & _DRM_LOCK_QUIESCENT) {
DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
DRM_DEBUG("fred\n");
@@ -1267,8 +1275,8 @@ int i810_dma_vertex(struct inode *inode, struct file *filp,
dev_priv->sarea_priv;
drm_i810_vertex_t vertex;
- copy_from_user_ret(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex),
- -EFAULT);
+ if (copy_from_user(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex)))
+ return -EFAULT;
if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("i810_dma_vertex called without lock held\n");
@@ -1299,8 +1307,8 @@ int i810_clear_bufs(struct inode *inode, struct file *filp,
drm_device_t *dev = priv->dev;
drm_i810_clear_t clear;
- copy_from_user_ret(&clear, (drm_i810_clear_t *)arg, sizeof(clear),
- -EFAULT);
+ if (copy_from_user(&clear, (drm_i810_clear_t *)arg, sizeof(clear)))
+ return -EFAULT;
if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("i810_clear_bufs called without lock held\n");
@@ -1357,7 +1365,8 @@ int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
dev_priv->sarea_priv;
DRM_DEBUG("getbuf\n");
- copy_from_user_ret(&d, (drm_i810_dma_t *)arg, sizeof(d), -EFAULT);
+ if (copy_from_user(&d, (drm_i810_dma_t *)arg, sizeof(d)))
+ return -EFAULT;
if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("i810_dma called without lock held\n");
@@ -1371,7 +1380,8 @@ int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
current->pid, retcode, d.granted);
- copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT);
+ if (copy_to_user((drm_dma_t *)arg, &d, sizeof(d)))
+ return -EFAULT;
sarea_priv->last_dispatch = (int) hw_status[5];
return retcode;
@@ -1396,14 +1406,16 @@ int i810_copybuf(struct inode *inode, struct file *filp, unsigned int cmd,
return -EINVAL;
}
- copy_from_user_ret(&d, (drm_i810_copy_t *)arg, sizeof(d), -EFAULT);
+ if (copy_from_user(&d, (drm_i810_copy_t *)arg, sizeof(d)))
+ return -EFAULT;
if(d.idx > dma->buf_count) return -EINVAL;
buf = dma->buflist[ d.idx ];
buf_priv = buf->dev_private;
if (buf_priv->currently_mapped != I810_BUF_MAPPED) return -EPERM;
- copy_from_user_ret(buf_priv->virtual, d.address, d.used, -EFAULT);
+ if (copy_from_user(buf_priv->virtual, d.address, d.used))
+ return -EFAULT;
sarea_priv->last_dispatch = (int) hw_status[5];
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
index 5e86ea49d..ed880c41a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
@@ -1,6 +1,6 @@
/* i810_drv.c -- I810 driver -*- linux-c -*-
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
- *
+ *
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
@@ -11,11 +11,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -28,7 +28,6 @@
* Jeff Hartmann <jhartmann@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c,v 1.5 2000/08/28 02:43:15 tsi Exp $ */
#include <linux/config.h>
#include "drmP.h"
@@ -36,7 +35,7 @@
#define I810_NAME "i810"
#define I810_DESC "Intel I810"
-#define I810_DATE "20000719"
+#define I810_DATE "20000928"
#define I810_MAJOR 1
#define I810_MINOR 1
#define I810_PATCHLEVEL 0
@@ -144,7 +143,7 @@ __setup("i810=", i810_options);
static int i810_setup(drm_device_t *dev)
{
int i;
-
+
atomic_set(&dev->ioctl_count, 0);
atomic_set(&dev->vma_count, 0);
dev->buf_use = 0;
@@ -189,22 +188,22 @@ static int i810_setup(drm_device_t *dev)
#endif
dev->ctx_start = 0;
dev->lck_start = 0;
-
+
dev->buf_rp = dev->buf;
dev->buf_wp = dev->buf;
dev->buf_end = dev->buf + DRM_BSZ;
dev->buf_async = NULL;
init_waitqueue_head(&dev->buf_readers);
init_waitqueue_head(&dev->buf_writers);
-
+
DRM_DEBUG("\n");
-
+
/* The kernel's context could be created here, but is now created
in drm_dma_enqueue. This is more resource-efficient for
hardware that does not do DMA, but may mean that
drm_select_queue fails between the time the interrupt is
initialized and the time the queues are initialized. */
-
+
return 0;
}
@@ -219,15 +218,15 @@ static int i810_takedown(drm_device_t *dev)
DRM_DEBUG("\n");
if (dev->irq) i810_irq_uninstall(dev);
-
+
down(&dev->struct_sem);
del_timer(&dev->timer);
-
+
if (dev->devname) {
drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
dev->devname = NULL;
}
-
+
if (dev->unique) {
drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
dev->unique = NULL;
@@ -245,7 +244,7 @@ static int i810_takedown(drm_device_t *dev)
if (dev->agp) {
drm_agp_mem_t *entry;
drm_agp_mem_t *nexte;
-
+
/* Remove AGP resources, but leave dev->agp
intact until r128_cleanup is called. */
for (entry = dev->agp->memory; entry; entry = nexte) {
@@ -255,10 +254,10 @@ static int i810_takedown(drm_device_t *dev)
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
}
dev->agp->memory = NULL;
-
+
if (dev->agp->acquired && drm_agp.release)
(*drm_agp.release)();
-
+
dev->agp->acquired = 0;
dev->agp->enabled = 0;
}
@@ -270,7 +269,7 @@ static int i810_takedown(drm_device_t *dev)
}
dev->vmalist = NULL;
}
-
+
/* Clear map area and mtrr information */
if (dev->maplist) {
for (i = 0; i < dev->map_count; i++) {
@@ -306,7 +305,7 @@ static int i810_takedown(drm_device_t *dev)
dev->maplist = NULL;
dev->map_count = 0;
}
-
+
if (dev->queuelist) {
for (i = 0; i < dev->queue_count; i++) {
drm_waitlist_destroy(&dev->queuelist[i]->waitlist);
@@ -332,7 +331,7 @@ static int i810_takedown(drm_device_t *dev)
wake_up_interruptible(&dev->lock.lock_queue);
}
up(&dev->struct_sem);
-
+
return 0;
}
@@ -349,7 +348,7 @@ static int i810_init(void)
memset((void *)dev, 0, sizeof(*dev));
dev->count_lock = SPIN_LOCK_UNLOCKED;
sema_init(&dev->struct_sem, 1);
-
+
#ifdef MODULE
drm_parse_options(i810);
#endif
@@ -403,7 +402,7 @@ static void i810_cleanup(void)
drm_device_t *dev = &i810_device;
DRM_DEBUG("\n");
-
+
drm_proc_cleanup();
if (misc_deregister(&i810_misc)) {
DRM_ERROR("Cannot unload module\n");
@@ -429,17 +428,18 @@ int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version;
int len;
- copy_from_user_ret(&version,
+ if (copy_from_user(&version,
(drm_version_t *)arg,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
#define DRM_COPY(name,value) \
len = strlen(value); \
if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \
if (len && name) { \
- copy_to_user_ret(name, value, len, -EFAULT); \
+ if (copy_to_user(name, value, len)) \
+ return -EFAULT; \
}
version.version_major = I810_MAJOR;
@@ -450,10 +450,10 @@ int i810_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, I810_DATE);
DRM_COPY(version.desc, I810_DESC);
- copy_to_user_ret((drm_version_t *)arg,
+ if (copy_to_user((drm_version_t *)arg,
&version,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
return 0;
}
@@ -461,7 +461,7 @@ int i810_open(struct inode *inode, struct file *filp)
{
drm_device_t *dev = &i810_device;
int retcode = 0;
-
+
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
#if LINUX_VERSION_CODE < 0x020333
@@ -498,7 +498,7 @@ int i810_release(struct inode *inode, struct file *filp)
drm_lock_free(dev,
&dev->lock.hw_lock->lock,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-
+
/* FIXME: may require heavy-handed reset of
hardware at this point, possibly
processed via a callback to the X
@@ -508,6 +508,7 @@ int i810_release(struct inode *inode, struct file *filp)
DECLARE_WAITQUEUE(entry, current);
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
retcode = -EINTR;
@@ -519,10 +520,9 @@ int i810_release(struct inode *inode, struct file *filp)
dev->lock.lock_time = jiffies;
atomic_inc(&dev->total_locks);
break; /* Got lock */
- }
+ }
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
schedule();
if (signal_pending(current)) {
retcode = -ERESTARTSYS;
@@ -545,7 +545,7 @@ int i810_release(struct inode *inode, struct file *filp)
if (priv->next) priv->next->prev = priv->prev;
else dev->file_last = priv->prev;
up(&dev->struct_sem);
-
+
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
#if LINUX_VERSION_CODE < 0x020333
MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
@@ -585,7 +585,7 @@ int i810_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->ioctl_count);
atomic_inc(&dev->total_ioctl);
++priv->ioctl_count;
-
+
DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n",
current->pid, cmd, nr, dev->device, priv->authenticated);
@@ -605,7 +605,7 @@ int i810_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
retcode = (func)(inode, filp, cmd, arg);
}
}
-
+
atomic_dec(&dev->ioctl_count);
return retcode;
}
@@ -617,8 +617,9 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_lock_t lock;
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
-
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
+
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
current->pid, lock.context);
@@ -642,6 +643,7 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles()
- dev->lck_start)]);
#endif
-
+
+ unblock_all_signals();
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
index 0a21a9106..60e66b8fb 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
@@ -28,14 +28,12 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c,v 1.9 2000/08/28 02:43:15 tsi Exp $ */
#define __NO_VERSION__
#include "drmP.h"
int drm_waitlist_create(drm_waitlist_t *bl, int count)
{
- DRM_DEBUG("%d\n", count);
if (bl->count) return -EINVAL;
bl->count = count;
@@ -51,7 +49,6 @@ int drm_waitlist_create(drm_waitlist_t *bl, int count)
int drm_waitlist_destroy(drm_waitlist_t *bl)
{
- DRM_DEBUG("\n");
if (bl->rp != bl->wp) return -EINVAL;
if (bl->bufs) drm_free(bl->bufs,
(bl->count + 2) * sizeof(*bl->bufs),
@@ -70,8 +67,6 @@ int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf)
unsigned long flags;
left = DRM_LEFTCOUNT(bl);
- DRM_DEBUG("put %d (%d left, rp = %p, wp = %p)\n",
- buf->idx, left, bl->rp, bl->wp);
if (!left) {
DRM_ERROR("Overflow while adding buffer %d from pid %d\n",
buf->idx, buf->pid);
@@ -104,13 +99,11 @@ drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl)
if (++bl->rp >= bl->end) bl->rp = bl->bufs;
spin_unlock_irqrestore(&bl->read_lock, flags);
- DRM_DEBUG("get %d\n", buf->idx);
return buf;
}
int drm_freelist_create(drm_freelist_t *bl, int count)
{
- DRM_DEBUG("\n");
atomic_set(&bl->count, 0);
bl->next = NULL;
init_waitqueue_head(&bl->waiting);
@@ -124,7 +117,6 @@ int drm_freelist_create(drm_freelist_t *bl, int count)
int drm_freelist_destroy(drm_freelist_t *bl)
{
- DRM_DEBUG("\n");
atomic_set(&bl->count, 0);
bl->next = NULL;
return 0;
@@ -143,9 +135,6 @@ int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf)
DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n",
buf->idx, buf->waiting, buf->pending, buf->list);
}
- DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n",
- buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh),
- buf->waiting, buf->pending);
if (!bl) return 1;
#if DRM_DMA_HISTOGRAM
buf->time_freed = get_cycles();
@@ -191,9 +180,6 @@ static drm_buf_t *drm_freelist_try(drm_freelist_t *bl)
atomic_dec(&bl->count);
buf->next = NULL;
buf->list = DRM_LIST_NONE;
- DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n",
- buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh),
- buf->waiting, buf->pending);
if (buf->waiting || buf->pending) {
DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n",
buf->idx, buf->waiting, buf->pending, buf->list);
@@ -213,13 +199,10 @@ drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block)
if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */
atomic_set(&bl->wfh, 1);
if (atomic_read(&bl->wfh)) {
- DRM_DEBUG("Block = %d, count = %d, wfh = %d\n",
- block, atomic_read(&bl->count),
- atomic_read(&bl->wfh));
if (block) {
add_wait_queue(&bl->waiting, &entry);
- current->state = TASK_INTERRUPTIBLE;
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!atomic_read(&bl->wfh)
&& (buf = drm_freelist_try(bl))) break;
schedule();
@@ -231,7 +214,5 @@ drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block)
return buf;
}
- DRM_DEBUG("Count = %d, wfh = %d\n",
- atomic_read(&bl->count), atomic_read(&bl->wfh));
return drm_freelist_try(bl);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
index 550827278..90d2f1300 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
@@ -50,7 +50,6 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new, prev;
- DRM_DEBUG("%d attempts\n", context);
do {
old = *lock;
if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
@@ -68,11 +67,8 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
}
if (new == (context | _DRM_LOCK_HELD)) {
/* Have lock */
- DRM_DEBUG("%d\n", context);
return 1;
}
- DRM_DEBUG("%d unable to get lock held by %d\n",
- context, _DRM_LOCKING_CONTEXT(old));
return 0;
}
@@ -89,7 +85,6 @@ int drm_lock_transfer(drm_device_t *dev,
new = context | _DRM_LOCK_HELD;
prev = cmpxchg(lock, old, new);
} while (prev != old);
- DRM_DEBUG("%d => %d\n", _DRM_LOCKING_CONTEXT(old), context);
return 1;
}
@@ -99,7 +94,6 @@ int drm_lock_free(drm_device_t *dev,
unsigned int old, new, prev;
pid_t pid = dev->lock.pid;
- DRM_DEBUG("%d\n", context);
dev->lock.pid = 0;
do {
old = *lock;
@@ -128,10 +122,10 @@ static int drm_flush_queue(drm_device_t *dev, int context)
atomic_inc(&q->use_count);
if (atomic_read(&q->use_count) > 1) {
atomic_inc(&q->block_write);
- current->state = TASK_INTERRUPTIBLE;
add_wait_queue(&q->flush_queue, &entry);
atomic_inc(&q->block_count);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!DRM_BUFCOUNT(&q->waitlist)) break;
schedule();
if (signal_pending(current)) {
@@ -218,8 +212,41 @@ int drm_finish(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_DEBUG("\n");
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
ret = drm_flush_block_and_flush(dev, lock.context, lock.flags);
drm_flush_unblock(dev, lock.context, lock.flags);
return ret;
}
+
+/* If we get here, it means that the process has called DRM_IOCTL_LOCK
+ without calling DRM_IOCTL_UNLOCK.
+
+ If the lock is not held, then let the signal proceed as usual.
+
+ If the lock is held, then set the contended flag and keep the signal
+ blocked.
+
+
+ Return 1 if the signal should be delivered normally.
+ Return 0 if the signal should be blocked. */
+
+int drm_notifier(void *priv)
+{
+ drm_sigdata_t *s = (drm_sigdata_t *)priv;
+ unsigned int old, new, prev;
+
+
+ /* Allow signal delivery if lock isn't held */
+ if (!_DRM_LOCK_IS_HELD(s->lock->lock)
+ || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) return 1;
+
+ /* Otherwise, set flag to force call to
+ drmUnlock */
+ do {
+ old = s->lock->lock;
+ new = old | _DRM_LOCK_CONT;
+ prev = cmpxchg(&s->lock->lock, old, new);
+ } while (prev != old);
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
index b97eb4959..05d941b4c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
@@ -57,16 +57,16 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
if (!dma) return -EINVAL;
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
count = request.count;
order = drm_order(request.size);
size = 1 << order;
agp_offset = request.agp_start;
- alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size;
page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
total = PAGE_SIZE << page_order;
byte_count = 0;
@@ -119,8 +119,6 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
buf->order = order;
buf->used = 0;
- DRM_DEBUG("offset : %ld\n", offset);
-
buf->offset = offset; /* Hrm */
buf->bus_address = dev->agp->base + agp_offset + offset;
buf->address = (void *)(agp_offset + offset + dev->agp->base);
@@ -130,7 +128,8 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
init_waitqueue_head(&buf->dma_wait);
buf->pid = 0;
- buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS);
+ buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t),
+ DRM_MEM_BUFS);
buf->dev_priv_size = sizeof(drm_mga_buf_priv_t);
#if DRM_DMA_HISTOGRAM
@@ -142,9 +141,6 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
offset = offset + alignment;
entry->buf_count++;
byte_count += PAGE_SIZE << page_order;
-
- DRM_DEBUG("buffer %d @ %p\n",
- entry->buf_count, buf->address);
}
dma->buflist = drm_realloc(dma->buflist,
@@ -173,10 +169,10 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
request.count = entry->buf_count;
request.size = size;
- copy_to_user_ret((drm_buf_desc_t *)arg,
+ if (copy_to_user((drm_buf_desc_t *)arg,
&request,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
atomic_dec(&dev->buf_alloc);
@@ -219,10 +215,10 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
if (!dma) return -EINVAL;
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
count = request.count;
order = drm_order(request.size);
@@ -234,7 +230,7 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
if (dev->queue_count) return -EBUSY; /* Not while in use */
- alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size;
page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
total = PAGE_SIZE << page_order;
@@ -348,10 +344,10 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
request.count = entry->buf_count;
request.size = size;
- copy_to_user_ret((drm_buf_desc_t *)arg,
+ if (copy_to_user((drm_buf_desc_t *)arg,
&request,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
atomic_dec(&dev->buf_alloc);
return 0;
@@ -362,10 +358,10 @@ int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
{
drm_buf_desc_t request;
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
if(request.flags & _DRM_AGP_BUFFER)
return mga_addbufs_agp(inode, filp, cmd, arg);
@@ -393,58 +389,47 @@ int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd,
++dev->buf_use; /* Can't allocate more after this call */
spin_unlock(&dev->count_lock);
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_info_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
if (dma->bufs[i].buf_count) ++count;
}
- DRM_DEBUG("count = %d\n", count);
-
if (request.count >= count) {
for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
if (dma->bufs[i].buf_count) {
- copy_to_user_ret(&request.list[count].count,
+ if (copy_to_user(&request.list[count].count,
&dma->bufs[i].buf_count,
sizeof(dma->bufs[0]
- .buf_count),
- -EFAULT);
- copy_to_user_ret(&request.list[count].size,
+ .buf_count)) ||
+ copy_to_user(&request.list[count].size,
&dma->bufs[i].buf_size,
- sizeof(dma->bufs[0].buf_size),
- -EFAULT);
- copy_to_user_ret(&request.list[count].low_mark,
+ sizeof(dma->bufs[0].buf_size)) ||
+ copy_to_user(&request.list[count].low_mark,
&dma->bufs[i]
.freelist.low_mark,
sizeof(dma->bufs[0]
- .freelist.low_mark),
- -EFAULT);
- copy_to_user_ret(&request.list[count]
+ .freelist.low_mark)) ||
+ copy_to_user(&request.list[count]
.high_mark,
&dma->bufs[i]
.freelist.high_mark,
sizeof(dma->bufs[0]
- .freelist.high_mark),
- -EFAULT);
- DRM_DEBUG("%d %d %d %d %d\n",
- i,
- dma->bufs[i].buf_count,
- dma->bufs[i].buf_size,
- dma->bufs[i].freelist.low_mark,
- dma->bufs[i].freelist.high_mark);
+ .freelist.high_mark)))
+ return -EFAULT;
++count;
}
}
}
request.count = count;
- copy_to_user_ret((drm_buf_info_t *)arg,
+ if (copy_to_user((drm_buf_info_t *)arg,
&request,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
return 0;
}
@@ -461,13 +446,9 @@ int mga_markbufs(struct inode *inode, struct file *filp, unsigned int cmd,
if (!dma) return -EINVAL;
- copy_from_user_ret(&request,
- (drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ if (copy_from_user(&request, (drm_buf_desc_t *)arg, sizeof(request)))
+ return -EFAULT;
- DRM_DEBUG("%d, %d, %d\n",
- request.size, request.low_mark, request.high_mark);
order = drm_order(request.size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
entry = &dma->bufs[order];
@@ -496,17 +477,16 @@ int mga_freebufs(struct inode *inode, struct file *filp, unsigned int cmd,
if (!dma) return -EINVAL;
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_free_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
- DRM_DEBUG("%d\n", request.count);
for (i = 0; i < request.count; i++) {
- copy_from_user_ret(&idx,
+ if (copy_from_user(&idx,
&request.list[i],
- sizeof(idx),
- -EFAULT);
+ sizeof(idx)))
+ return -EFAULT;
if (idx < 0 || idx >= dma->buf_count) {
DRM_ERROR("Index %d (of %d max)\n",
idx, dma->buf_count - 1);
@@ -539,25 +519,19 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
if (!dma) return -EINVAL;
- DRM_DEBUG("\n");
-
spin_lock(&dev->count_lock);
if (atomic_read(&dev->buf_alloc)) {
spin_unlock(&dev->count_lock);
- DRM_DEBUG("Busy\n");
return -EBUSY;
}
++dev->buf_use; /* Can't allocate more after this call */
spin_unlock(&dev->count_lock);
- copy_from_user_ret(&request,
+ if (copy_from_user(&request,
(drm_buf_map_t *)arg,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
- DRM_DEBUG("mga_mapbufs\n");
- DRM_DEBUG("dma->flags : %x\n", dma->flags);
-
if (request.count >= dma->buf_count) {
if(dma->flags & _DRM_DMA_USE_AGP) {
drm_mga_private_t *dev_priv = dev->dev_private;
@@ -565,7 +539,6 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
map = dev->maplist[dev_priv->buffer_map_idx];
if (!map) {
- DRM_DEBUG("map is null\n");
retcode = -EINVAL;
goto done;
}
@@ -628,10 +601,10 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
request.count = dma->buf_count;
DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
- copy_to_user_ret((drm_buf_map_t *)arg,
+ if (copy_to_user((drm_buf_map_t *)arg,
&request,
- sizeof(request),
- -EFAULT);
+ sizeof(request)))
+ return -EFAULT;
DRM_DEBUG("retcode : %d\n", retcode);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
index 546aac165..b26c7c98e 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
@@ -28,7 +28,6 @@
* Jeff Hartmann <jhartmann@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c,v 1.4 2000/08/28 02:43:15 tsi Exp $ */
#define __NO_VERSION__
#include "drmP.h"
@@ -36,9 +35,7 @@
static int mga_alloc_queue(drm_device_t *dev)
{
- int temp = drm_ctxbitmap_next(dev);
- DRM_DEBUG("mga_alloc_queue: %d\n", temp);
- return temp;
+ return drm_ctxbitmap_next(dev);
}
int mga_context_switch(drm_device_t *dev, int old, int new)
@@ -103,20 +100,21 @@ int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_ctx_t ctx;
int i;
- DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
- copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT);
+ if (copy_from_user(&res, (drm_ctx_res_t *)arg, sizeof(res)))
+ return -EFAULT;
if (res.count >= DRM_RESERVED_CONTEXTS) {
memset(&ctx, 0, sizeof(ctx));
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
ctx.handle = i;
- copy_to_user_ret(&res.contexts[i],
+ if (copy_to_user(&res.contexts[i],
&i,
- sizeof(i),
- -EFAULT);
+ sizeof(i)))
+ return -EFAULT;
}
}
res.count = DRM_RESERVED_CONTEXTS;
- copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT);
+ if (copy_to_user((drm_ctx_res_t *)arg, &res, sizeof(res)))
+ return -EFAULT;
return 0;
}
@@ -127,18 +125,18 @@ int mga_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
+ return -EFAULT;
if ((ctx.handle = mga_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
/* Skip kernel's context and get a new one. */
ctx.handle = mga_alloc_queue(dev);
}
if (ctx.handle == -1) {
- DRM_DEBUG("Not enough free contexts.\n");
- /* Should this return -EBUSY instead? */
return -ENOMEM;
}
DRM_DEBUG("%d\n", ctx.handle);
- copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
+ if (copy_to_user((drm_ctx_t *)arg, &ctx, sizeof(ctx)))
+ return -EFAULT;
return 0;
}
@@ -154,10 +152,12 @@ int mga_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
{
drm_ctx_t ctx;
- copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ if (copy_from_user(&ctx, (drm_ctx_t*)arg, sizeof(ctx)))
+ return -EFAULT;
/* This is 0, because we don't hanlde any context flags */
ctx.flags = 0;
- copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT);
+ if (copy_to_user((drm_ctx_t*)arg, &ctx, sizeof(ctx)))
+ return -EFAULT;
return 0;
}
@@ -168,7 +168,8 @@ int mga_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
+ return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle);
return mga_context_switch(dev, dev->last_context, ctx.handle);
}
@@ -180,7 +181,8 @@ int mga_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
+ return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle);
mga_context_switch_complete(dev, ctx.handle);
@@ -194,8 +196,11 @@ int mga_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if (copy_from_user(&ctx, (drm_ctx_t *)arg, sizeof(ctx)))
+ return -EFAULT;
DRM_DEBUG("%d\n", ctx.handle);
+ if(ctx.handle == DRM_KERNEL_CONTEXT+1) priv->remove_auth_on_close = 1;
+
if(ctx.handle != DRM_KERNEL_CONTEXT) {
drm_ctxbitmap_free(dev, ctx.handle);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
index 4daa03acb..4e1871e28 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
@@ -52,34 +52,28 @@ static unsigned long mga_alloc_page(drm_device_t *dev)
{
unsigned long address;
- DRM_DEBUG("%s\n", __FUNCTION__);
address = __get_free_page(GFP_KERNEL);
if(address == 0UL) {
return 0;
}
atomic_inc(&virt_to_page(address)->count);
- set_bit(PG_locked, &virt_to_page(address)->flags);
+ set_bit(PG_reserved, &virt_to_page(address)->flags);
return address;
}
static void mga_free_page(drm_device_t *dev, unsigned long page)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- if(page == 0UL) {
- return;
- }
+ if(!page) return;
atomic_dec(&virt_to_page(page)->count);
- clear_bit(PG_locked, &virt_to_page(page)->flags);
- wake_up(&virt_to_page(page)->wait);
+ clear_bit(PG_reserved, &virt_to_page(page)->flags);
free_page(page);
return;
}
static void mga_delay(void)
{
- return;
+ return;
}
/* These are two age tags that will never be sent to
@@ -96,8 +90,6 @@ static int mga_freelist_init(drm_device_t *dev)
drm_mga_freelist_t *item;
int i;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
if(dev_priv->head == NULL) return -ENOMEM;
memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
@@ -132,8 +124,6 @@ static void mga_freelist_cleanup(drm_device_t *dev)
drm_mga_freelist_t *item;
drm_mga_freelist_t *prev;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
item = dev_priv->head;
while(item) {
prev = item;
@@ -153,7 +143,7 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
unsigned long end;
int i;
- DRM_DEBUG("%s\n", __FUNCTION__);
+ DRM_DEBUG("dispatch_status = 0x%02x\n", dev_priv->dispatch_status);
end = jiffies + (HZ*3);
while(1) {
if(!test_and_set_bit(MGA_IN_DISPATCH,
@@ -164,8 +154,10 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
DRM_ERROR("irqs: %d wanted %d\n",
atomic_read(&dev->total_irq),
atomic_read(&dma->total_lost));
- DRM_ERROR("lockup\n");
- goto out_nolock;
+ DRM_ERROR("lockup: dispatch_status = 0x%02x,"
+ " jiffies = %lu, end = %lu\n",
+ dev_priv->dispatch_status, jiffies, end);
+ return;
}
for (i = 0 ; i < 2000 ; i++) mga_delay();
}
@@ -177,15 +169,16 @@ static inline void mga_dma_quiescent(drm_device_t *dev)
atomic_read(&dev->total_irq),
atomic_read(&dma->total_lost));
DRM_ERROR("lockup\n");
- goto out_status;
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+ return;
}
for (i = 0 ; i < 2000 ; i++) mga_delay();
}
sarea_priv->dirty |= MGA_DMA_FLUSH;
-out_status:
clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
-out_nolock:
+ DRM_DEBUG("exit, dispatch_status = 0x%02x\n",
+ dev_priv->dispatch_status);
}
static void mga_reset_freelist(drm_device_t *dev)
@@ -216,29 +209,26 @@ drm_buf_t *mga_freelist_get(drm_device_t *dev)
static int failed = 0;
int return_null = 0;
- DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__,
- dev_priv->tail->age, dev_priv->last_prim_age);
-
if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) {
- DRM_DEBUG("I'm waiting on the freelist!!! %d\n",
- dev_priv->last_prim_age);
- set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
+ DRM_DEBUG("Waiting on freelist,"
+ " tail->age = %d, last_prim_age= %d\n",
+ dev_priv->tail->age,
+ dev_priv->last_prim_age);
add_wait_queue(&dev_priv->buf_queue, &entry);
+ set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
for (;;) {
- mga_dma_schedule(dev, 0);
current->state = TASK_INTERRUPTIBLE;
- if(!test_bit(MGA_IN_GETBUF,
- &dev_priv->dispatch_status))
+ mga_dma_schedule(dev, 0);
+ if(dev_priv->tail->age < dev_priv->last_prim_age)
break;
atomic_inc(&dev->total_sleeps);
schedule();
if (signal_pending(current)) {
++return_null;
- clear_bit(MGA_IN_GETBUF,
- &dev_priv->dispatch_status);
break;
}
}
+ clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
current->state = TASK_RUNNING;
remove_wait_queue(&dev_priv->buf_queue, &entry);
if (return_null) return NULL;
@@ -254,6 +244,7 @@ drm_buf_t *mga_freelist_get(drm_device_t *dev)
failed = 0;
return next->buf;
}
+
failed++;
return NULL;
}
@@ -267,8 +258,6 @@ int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf)
drm_mga_freelist_t *head;
drm_mga_freelist_t *next;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if(buf_priv->my_freelist->age == MGA_BUF_USED) {
/* Discarded buffer, put it on the tail */
next = buf_priv->my_freelist;
@@ -278,7 +267,6 @@ int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf)
next->prev = prev;
next->next = NULL;
dev_priv->tail = next;
- DRM_DEBUG("Discarded\n");
} else {
/* Normally aged buffer, put it on the head + 1,
* as the real head is a sentinal element
@@ -302,7 +290,6 @@ static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init)
int i, temp, size_of_buf;
int offset = init->reserved_map_agpstart;
- DRM_DEBUG("%s\n", __FUNCTION__);
dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) /
PAGE_SIZE) * PAGE_SIZE;
size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS;
@@ -323,7 +310,7 @@ static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init)
dev_priv->ioremap = drm_ioremap(dev->agp->base + offset,
temp);
if(dev_priv->ioremap == NULL) {
- DRM_DEBUG("Ioremap failed\n");
+ DRM_ERROR("Ioremap failed\n");
return -ENOMEM;
}
init_waitqueue_head(&dev_priv->wait_queue);
@@ -370,7 +357,6 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
int next_idx;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
dev_priv->last_prim = prim;
/* We never check for overflow, b/c there is always room */
@@ -387,14 +373,12 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
end = jiffies + (HZ*3);
if(sarea_priv->dirty & MGA_DMA_FLUSH) {
- DRM_DEBUG("Dma top flush\n");
while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
if((signed)(end - jiffies) <= 0) {
DRM_ERROR("irqs: %d wanted %d\n",
atomic_read(&dev->total_irq),
atomic_read(&dma->total_lost));
- DRM_ERROR("lockup in fire primary "
- "(Dma Top Flush)\n");
+ DRM_ERROR("lockup (flush)\n");
goto out_prim_wait;
}
@@ -402,14 +386,12 @@ void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
}
sarea_priv->dirty &= ~(MGA_DMA_FLUSH);
} else {
- DRM_DEBUG("Status wait\n");
while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) {
if((signed)(end - jiffies) <= 0) {
DRM_ERROR("irqs: %d wanted %d\n",
atomic_read(&dev->total_irq),
atomic_read(&dma->total_lost));
- DRM_ERROR("lockup in fire primary "
- "(Status Wait)\n");
+ DRM_ERROR("lockup (wait)\n");
goto out_prim_wait;
}
@@ -452,7 +434,6 @@ int mga_advance_primary(drm_device_t *dev)
/* This needs to reset the primary buffer if available,
* we should collect stats on how many times it bites
* it's tail */
- DRM_DEBUG("%s\n", __FUNCTION__);
next_prim_idx = dev_priv->current_prim_idx + 1;
if(next_prim_idx >= MGA_NUM_PRIM_BUFS)
@@ -464,9 +445,8 @@ int mga_advance_primary(drm_device_t *dev)
if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) {
add_wait_queue(&dev_priv->wait_queue, &entry);
- current->state = TASK_INTERRUPTIBLE;
-
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
mga_dma_schedule(dev, 0);
if(!test_and_set_bit(MGA_BUF_IN_USE,
&prim_buffer->buffer_status))
@@ -479,7 +459,7 @@ int mga_advance_primary(drm_device_t *dev)
break;
}
}
- current->state = TASK_RUNNING;
+ current->state = TASK_RUNNING;
remove_wait_queue(&dev_priv->wait_queue, &entry);
if(ret) return ret;
}
@@ -491,10 +471,10 @@ int mga_advance_primary(drm_device_t *dev)
prim_buffer->sec_used = 0;
prim_buffer->prim_age = dev_priv->next_prim_age++;
if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) {
- mga_flush_queue(dev);
- mga_dma_quiescent(dev);
- mga_reset_freelist(dev);
- prim_buffer->prim_age = (dev_priv->next_prim_age += 2);
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ mga_reset_freelist(dev);
+ prim_buffer->prim_age = (dev_priv->next_prim_age += 2);
}
/* Reset all buffer status stuff */
@@ -511,67 +491,55 @@ int mga_advance_primary(drm_device_t *dev)
static inline int mga_decide_to_fire(drm_device_t *dev)
{
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
- drm_device_dma_t *dma = dev->dma;
-
- DRM_DEBUG("%s\n", __FUNCTION__);
if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) {
- atomic_inc(&dma->total_prio);
return 1;
}
if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
dev_priv->next_prim->num_dwords) {
- atomic_inc(&dma->total_prio);
return 1;
}
if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
dev_priv->next_prim->num_dwords) {
- atomic_inc(&dma->total_prio);
return 1;
}
if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) {
if(test_bit(MGA_BUF_SWAP_PENDING,
&dev_priv->next_prim->buffer_status)) {
- atomic_inc(&dma->total_dmas);
return 1;
}
}
if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) {
if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) {
- atomic_inc(&dma->total_hit);
return 1;
}
}
if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) {
if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) {
- atomic_inc(&dma->total_missed_free);
return 1;
}
}
- atomic_inc(&dma->total_tried);
return 0;
}
int mga_dma_schedule(drm_device_t *dev, int locked)
{
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
- drm_device_dma_t *dma = dev->dma;
- int retval = 0;
+ int retval = 0;
- if (test_and_set_bit(0, &dev->dma_flag)) {
- atomic_inc(&dma->total_missed_dma);
+ if (!dev_priv) return -EBUSY;
+
+ if (test_and_set_bit(0, &dev->dma_flag)) {
retval = -EBUSY;
goto sch_out_wakeup;
}
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) ||
test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) ||
test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
@@ -580,18 +548,14 @@ int mga_dma_schedule(drm_device_t *dev, int locked)
if (!locked &&
!drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
- atomic_inc(&dma->total_missed_lock);
clear_bit(0, &dev->dma_flag);
- DRM_DEBUG("Not locked\n");
retval = -EBUSY;
goto sch_out_wakeup;
}
- DRM_DEBUG("I'm locked\n");
if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) {
/* Fire dma buffer */
if(mga_decide_to_fire(dev)) {
- DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx);
clear_bit(MGA_BUF_FORCE_FIRE,
&dev_priv->next_prim->buffer_status);
if(dev_priv->current_prim == dev_priv->next_prim) {
@@ -603,8 +567,6 @@ int mga_dma_schedule(drm_device_t *dev, int locked)
} else {
clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
}
- } else {
- DRM_DEBUG("I can't get the dispatch lock\n");
}
if (!locked) {
@@ -614,6 +576,8 @@ int mga_dma_schedule(drm_device_t *dev, int locked)
}
}
+ clear_bit(0, &dev->dma_flag);
+
sch_out_wakeup:
if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
atomic_read(&dev_priv->pending_bufs) == 0) {
@@ -622,18 +586,10 @@ sch_out_wakeup:
wake_up_interruptible(&dev_priv->flush_queue);
}
- if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
- dev_priv->tail->age < dev_priv->last_prim_age) {
- clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
- DRM_DEBUG("Waking up buf queue\n");
+ if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)
+ && dev_priv->tail->age < dev_priv->last_prim_age)
wake_up_interruptible(&dev_priv->buf_queue);
- } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
- DRM_DEBUG("Not waking buf_queue on %d %d\n",
- atomic_read(&dev->total_irq),
- dev_priv->last_prim_age);
- }
- clear_bit(0, &dev->dma_flag);
return retval;
}
@@ -643,7 +599,6 @@ static void mga_dma_service(int irq, void *device, struct pt_regs *regs)
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_mga_prim_buf_t *last_prim_buffer;
- DRM_DEBUG("%s\n", __FUNCTION__);
atomic_inc(&dev->total_irq);
if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return;
MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
@@ -653,28 +608,28 @@ static void mga_dma_service(int irq, void *device, struct pt_regs *regs)
dev_priv->sarea_priv->last_dispatch =
dev_priv->last_prim_age = last_prim_buffer->prim_age;
clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status);
- wake_up_interruptible(&dev_priv->wait_queue);
clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status);
clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
atomic_dec(&dev_priv->pending_bufs);
queue_task(&dev->tq, &tq_immediate);
mark_bh(IMMEDIATE_BH);
+ wake_up_interruptible(&dev_priv->wait_queue);
}
static void mga_dma_task_queue(void *device)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
mga_dma_schedule((drm_device_t *)device, 0);
}
int mga_dma_cleanup(drm_device_t *dev)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if(dev->dev_private) {
drm_mga_private_t *dev_priv =
(drm_mga_private_t *) dev->dev_private;
+ if (dev->irq) mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+
if(dev_priv->ioremap) {
int temp = (dev_priv->warp_ucode_size +
dev_priv->primary_size +
@@ -717,7 +672,6 @@ int mga_dma_cleanup(drm_device_t *dev)
static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
drm_mga_private_t *dev_priv;
drm_map_t *sarea_map = NULL;
- int i;
DRM_DEBUG("%s\n", __FUNCTION__);
@@ -730,7 +684,6 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
if((init->reserved_map_idx >= dev->map_count) ||
(init->buffer_map_idx >= dev->map_count)) {
mga_dma_cleanup(dev);
- DRM_DEBUG("reserved_map or buffer_map are invalid\n");
return -EINVAL;
}
@@ -758,7 +711,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
dev_priv->WarpPipe = 0xff000000;
dev_priv->vertexsize = 0;
- DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n",
+ DRM_DEBUG("chipset=%d ucode_size=%d backOffset=%x depthOffset=%x\n",
dev_priv->chipset, dev_priv->warp_ucode_size,
dev_priv->backOffset, dev_priv->depthOffset);
DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n",
@@ -768,13 +721,6 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
memcpy(&dev_priv->WarpIndex, &init->WarpIndex,
sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES);
- for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++)
- DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n",
- i,
- dev_priv->WarpIndex[i].installed,
- dev_priv->WarpIndex[i].phys_addr,
- dev_priv->WarpIndex[i].size);
-
if(mga_init_primary_bufs(dev, init) != 0) {
DRM_ERROR("Can not initialize primary buffers\n");
mga_dma_cleanup(dev);
@@ -839,8 +785,6 @@ int mga_dma_init(struct inode *inode, struct file *filp,
drm_device_t *dev = priv->dev;
drm_mga_init_t init;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if (copy_from_user(&init, (drm_mga_init_t *)arg, sizeof(init)))
return -EFAULT;
@@ -927,8 +871,6 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd,
if (copy_from_user(&ctl, (drm_control_t *)arg, sizeof(ctl)))
return -EFAULT;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
switch (ctl.func) {
case DRM_INST_HANDLER:
return mga_irq_install(dev, ctl.irq);
@@ -945,18 +887,16 @@ static int mga_flush_queue(drm_device_t *dev)
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
int ret = 0;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- if(dev_priv == NULL) {
- return 0;
- }
+ if(!dev_priv) return 0;
if(dev_priv->next_prim->num_dwords != 0) {
- current->state = TASK_INTERRUPTIBLE;
add_wait_queue(&dev_priv->flush_queue, &entry);
+ if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status))
+ DRM_ERROR("Incorrect mga_flush_queue logic\n");
set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
mga_dma_schedule(dev, 0);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!test_bit(MGA_IN_FLUSH,
&dev_priv->dispatch_status))
break;
@@ -969,7 +909,7 @@ static int mga_flush_queue(drm_device_t *dev)
break;
}
}
- current->state = TASK_RUNNING;
+ current->state = TASK_RUNNING;
remove_wait_queue(&dev_priv->flush_queue, &entry);
}
return ret;
@@ -985,7 +925,8 @@ void mga_reclaim_buffers(drm_device_t *dev, pid_t pid)
if(dev->dev_private == NULL) return;
if(dma->buflist == NULL) return;
- DRM_DEBUG("%s\n", __FUNCTION__);
+ DRM_DEBUG("buf_count=%d\n", dma->buf_count);
+
mga_flush_queue(dev);
for (i = 0; i < dma->buf_count; i++) {
@@ -1011,7 +952,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
int ret = 0;
drm_lock_t lock;
- DRM_DEBUG("%s\n", __FUNCTION__);
if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
@@ -1021,13 +961,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
return -EINVAL;
}
- DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock.context, current->pid, dev->lock.hw_lock->lock,
- lock.flags);
-
- if (lock.context < 0) {
- return -EINVAL;
- }
+ if (lock.context < 0) return -EINVAL;
/* Only one queue:
*/
@@ -1035,6 +969,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
if (!ret) {
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -1050,7 +985,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
schedule();
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -1078,7 +1012,8 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
}
}
- DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+ if (ret) DRM_DEBUG("%d %s\n", lock.context,
+ ret ? "interrupted" : "has lock");
return ret;
}
@@ -1090,12 +1025,11 @@ int mga_flush_ioctl(struct inode *inode, struct file *filp,
drm_lock_t lock;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
- DRM_DEBUG("%s\n", __FUNCTION__);
if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
return -EFAULT;
if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
- DRM_ERROR("mga_flush_ioctl called without lock held\n");
+ DRM_ERROR("lock not held\n");
return -EINVAL;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
index 38bc716b7..4aaac6254 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
@@ -1,6 +1,6 @@
/* mga_drv.c -- Matrox g200/g400 driver -*- linux-c -*-
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
- *
+ *
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
@@ -11,11 +11,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -29,18 +29,17 @@
*
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c,v 1.4 2000/08/28 02:43:15 tsi Exp $ */
#include <linux/config.h>
#include "drmP.h"
#include "mga_drv.h"
#define MGA_NAME "mga"
-#define MGA_DESC "Matrox g200/g400"
-#define MGA_DATE "20000719"
-#define MGA_MAJOR 1
+#define MGA_DESC "Matrox G200/G400"
+#define MGA_DATE "20000928"
+#define MGA_MAJOR 2
#define MGA_MINOR 0
-#define MGA_PATCHLEVEL 0
+#define MGA_PATCHLEVEL 1
static drm_device_t mga_device;
drm_ctx_t mga_res_ctx;
@@ -124,7 +123,7 @@ static char *mga = NULL;
#endif
MODULE_AUTHOR("VA Linux Systems, Inc.");
-MODULE_DESCRIPTION("Matrox g200/g400");
+MODULE_DESCRIPTION("Matrox G200/G400");
MODULE_PARM(mga, "s");
#ifndef MODULE
@@ -145,7 +144,7 @@ __setup("mga=", mga_options);
static int mga_setup(drm_device_t *dev)
{
int i;
-
+
atomic_set(&dev->ioctl_count, 0);
atomic_set(&dev->vma_count, 0);
dev->buf_use = 0;
@@ -188,22 +187,22 @@ static int mga_setup(drm_device_t *dev)
dev->ctx_start = 0;
dev->lck_start = 0;
-
+
dev->buf_rp = dev->buf;
dev->buf_wp = dev->buf;
dev->buf_end = dev->buf + DRM_BSZ;
dev->buf_async = NULL;
init_waitqueue_head(&dev->buf_readers);
init_waitqueue_head(&dev->buf_writers);
-
+
DRM_DEBUG("\n");
-
+
/* The kernel's context could be created here, but is now created
in drm_dma_enqueue. This is more resource-efficient for
hardware that does not do DMA, but may mean that
drm_select_queue fails between the time the interrupt is
initialized and the time the queues are initialized. */
-
+
return 0;
}
@@ -217,16 +216,17 @@ static int mga_takedown(drm_device_t *dev)
DRM_DEBUG("\n");
+ if (dev->dev_private) mga_dma_cleanup(dev);
if (dev->irq) mga_irq_uninstall(dev);
-
+
down(&dev->struct_sem);
del_timer(&dev->timer);
-
+
if (dev->devname) {
drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
dev->devname = NULL;
}
-
+
if (dev->unique) {
drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
dev->unique = NULL;
@@ -244,7 +244,7 @@ static int mga_takedown(drm_device_t *dev)
if (dev->agp) {
drm_agp_mem_t *entry;
drm_agp_mem_t *nexte;
-
+
/* Remove AGP resources, but leave dev->agp
intact until cleanup is called. */
for (entry = dev->agp->memory; entry; entry = nexte) {
@@ -254,10 +254,10 @@ static int mga_takedown(drm_device_t *dev)
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
}
dev->agp->memory = NULL;
-
+
if (dev->agp->acquired && drm_agp.release)
(*drm_agp.release)();
-
+
dev->agp->acquired = 0;
dev->agp->enabled = 0;
}
@@ -269,7 +269,7 @@ static int mga_takedown(drm_device_t *dev)
}
dev->vmalist = NULL;
}
-
+
/* Clear map area and mtrr information */
if (dev->maplist) {
for (i = 0; i < dev->map_count; i++) {
@@ -305,7 +305,7 @@ static int mga_takedown(drm_device_t *dev)
dev->maplist = NULL;
dev->map_count = 0;
}
-
+
if (dev->queuelist) {
for (i = 0; i < dev->queue_count; i++) {
drm_waitlist_destroy(&dev->queuelist[i]->waitlist);
@@ -331,7 +331,7 @@ static int mga_takedown(drm_device_t *dev)
wake_up_interruptible(&dev->lock.lock_queue);
}
up(&dev->struct_sem);
-
+
return 0;
}
@@ -348,11 +348,10 @@ static int mga_init(void)
memset((void *)dev, 0, sizeof(*dev));
dev->count_lock = SPIN_LOCK_UNLOCKED;
sema_init(&dev->struct_sem, 1);
-
+
#ifdef MODULE
drm_parse_options(mga);
#endif
- DRM_DEBUG("doing misc_register\n");
if ((retcode = misc_register(&mga_misc))) {
DRM_ERROR("Cannot register \"%s\"\n", MGA_NAME);
return retcode;
@@ -360,11 +359,8 @@ static int mga_init(void)
dev->device = MKDEV(MISC_MAJOR, mga_misc.minor);
dev->name = MGA_NAME;
- DRM_DEBUG("doing mem init\n");
drm_mem_init();
- DRM_DEBUG("doing proc init\n");
drm_proc_init(dev);
- DRM_DEBUG("doing agp init\n");
dev->agp = drm_agp_init();
if(dev->agp == NULL) {
DRM_INFO("The mga drm module requires the agpgart module"
@@ -381,7 +377,6 @@ static int mga_init(void)
MTRR_TYPE_WRCOMB,
1);
#endif
- DRM_DEBUG("doing ctxbitmap init\n");
if((retcode = drm_ctxbitmap_init(dev))) {
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
drm_proc_cleanup();
@@ -408,7 +403,7 @@ static void mga_cleanup(void)
drm_device_t *dev = &mga_device;
DRM_DEBUG("\n");
-
+
drm_proc_cleanup();
if (misc_deregister(&mga_misc)) {
DRM_ERROR("Cannot unload module\n");
@@ -416,11 +411,10 @@ static void mga_cleanup(void)
DRM_INFO("Module unloaded\n");
}
drm_ctxbitmap_cleanup(dev);
- mga_dma_cleanup(dev);
#ifdef CONFIG_MTRR
if(dev->agp && dev->agp->agp_mtrr) {
int retval;
- retval = mtrr_del(dev->agp->agp_mtrr,
+ retval = mtrr_del(dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size * 1024*1024);
DRM_DEBUG("mtrr_del = %d\n", retval);
@@ -445,17 +439,18 @@ int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version;
int len;
- copy_from_user_ret(&version,
+ if (copy_from_user(&version,
(drm_version_t *)arg,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
#define DRM_COPY(name,value) \
len = strlen(value); \
if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \
if (len && name) { \
- copy_to_user_ret(name, value, len, -EFAULT); \
+ if (copy_to_user(name, value, len)) \
+ return -EFAULT; \
}
version.version_major = MGA_MAJOR;
@@ -466,10 +461,10 @@ int mga_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, MGA_DATE);
DRM_COPY(version.desc, MGA_DESC);
- copy_to_user_ret((drm_version_t *)arg,
+ if (copy_to_user((drm_version_t *)arg,
&version,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
return 0;
}
@@ -477,7 +472,7 @@ int mga_open(struct inode *inode, struct file *filp)
{
drm_device_t *dev = &mga_device;
int retcode = 0;
-
+
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
#if LINUX_VERSION_CODE < 0x020333
@@ -508,22 +503,27 @@ int mga_release(struct inode *inode, struct file *filp)
if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
&& dev->lock.pid == current->pid) {
mga_reclaim_buffers(dev, priv->pid);
- DRM_ERROR("Process %d dead, freeing lock for context %d\n",
- current->pid,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ DRM_INFO("Process %d dead (ctx %d, d_s = 0x%02x)\n",
+ current->pid,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock),
+ dev->dev_private ?
+ ((drm_mga_private_t *)dev->dev_private)
+ ->dispatch_status
+ : 0);
+
+ if (dev->dev_private)
+ ((drm_mga_private_t *)dev->dev_private)
+ ->dispatch_status &= MGA_IN_DISPATCH;
+
drm_lock_free(dev,
&dev->lock.hw_lock->lock,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-
- /* FIXME: may require heavy-handed reset of
- hardware at this point, possibly
- processed via a callback to the X
- server. */
} else if (dev->lock.hw_lock) {
/* The lock is required to reclaim buffers */
DECLARE_WAITQUEUE(entry, current);
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
retcode = -EINTR;
@@ -535,10 +535,9 @@ int mga_release(struct inode *inode, struct file *filp)
dev->lock.lock_time = jiffies;
atomic_inc(&dev->total_locks);
break; /* Got lock */
- }
+ }
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
schedule();
if (signal_pending(current)) {
retcode = -ERESTARTSYS;
@@ -549,6 +548,9 @@ int mga_release(struct inode *inode, struct file *filp)
remove_wait_queue(&dev->lock.lock_queue, &entry);
if(!retcode) {
mga_reclaim_buffers(dev, priv->pid);
+ if (dev->dev_private)
+ ((drm_mga_private_t *)dev->dev_private)
+ ->dispatch_status &= MGA_IN_DISPATCH;
drm_lock_free(dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT);
}
@@ -556,12 +558,19 @@ int mga_release(struct inode *inode, struct file *filp)
drm_fasync(-1, filp, 0);
down(&dev->struct_sem);
+ if (priv->remove_auth_on_close == 1) {
+ drm_file_t *temp = dev->file_first;
+ while(temp) {
+ temp->authenticated = 0;
+ temp = temp->next;
+ }
+ }
if (priv->prev) priv->prev->next = priv->next;
else dev->file_first = priv->next;
if (priv->next) priv->next->prev = priv->prev;
else dev->file_last = priv->prev;
up(&dev->struct_sem);
-
+
drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
#if LINUX_VERSION_CODE < 0x020333
MOD_DEC_USE_COUNT; /* Needed before Linux 2.3.51 */
@@ -602,9 +611,6 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->ioctl_count);
atomic_inc(&dev->total_ioctl);
++priv->ioctl_count;
-
- DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n",
- current->pid, cmd, nr, dev->device, priv->authenticated);
if (nr >= MGA_IOCTL_COUNT) {
retcode = -EINVAL;
@@ -613,7 +619,10 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
func = ioctl->func;
if (!func) {
- DRM_DEBUG("no function\n");
+ DRM_DEBUG("no function: pid = %d, cmd = 0x%02x,"
+ " nr = 0x%02x, dev 0x%x, auth = %d\n",
+ current->pid, cmd, nr, dev->device,
+ priv->authenticated);
retcode = -EINVAL;
} else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN))
|| (ioctl->auth_needed && !priv->authenticated)) {
@@ -622,7 +631,7 @@ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
retcode = (func)(inode, filp, cmd, arg);
}
}
-
+
atomic_dec(&dev->ioctl_count);
return retcode;
}
@@ -634,17 +643,15 @@ int mga_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_lock_t lock;
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
-
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
+
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
current->pid, lock.context);
return -EINVAL;
}
- DRM_DEBUG("%d frees lock (%d holds)\n",
- lock.context,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
atomic_inc(&dev->total_unlocks);
if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
atomic_inc(&dev->total_contends);
@@ -652,9 +659,8 @@ int mga_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
mga_dma_schedule(dev, 1);
if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- DRM_ERROR("\n");
- }
+ DRM_KERNEL_CONTEXT)) DRM_ERROR("\n");
+ unblock_all_signals();
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
index 101409cb2..e37cc2ef4 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
@@ -11,11 +11,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -28,7 +28,6 @@
* Jeff Hartmann <jhartmann@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h,v 1.4 2000/08/28 02:43:15 tsi Exp $ */
#ifndef _MGA_DRV_H_
#define _MGA_DRV_H_
@@ -51,7 +50,7 @@ typedef struct {
} drm_mga_prim_buf_t;
typedef struct _drm_mga_freelist {
- unsigned int age;
+ __volatile__ unsigned int age;
drm_buf_t *buf;
struct _drm_mga_freelist *next;
struct _drm_mga_freelist *prev;
@@ -83,6 +82,7 @@ typedef struct _drm_mga_private {
int use_agp;
drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES];
unsigned int WarpPipe;
+ unsigned int vertexsize;
atomic_t pending_bufs;
void *status_page;
unsigned long real_status_page;
@@ -98,7 +98,7 @@ typedef struct _drm_mga_private {
wait_queue_head_t wait_queue; /* Processes waiting until interrupt */
wait_queue_head_t buf_queue; /* Processes waiting for a free buf */
/* Some validated register values:
- */
+ */
u32 mAccess;
} drm_mga_private_t;
@@ -129,7 +129,6 @@ extern int mga_dma_init(struct inode *inode, struct file *filp,
extern int mga_dma_cleanup(drm_device_t *dev);
extern int mga_flush_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern void mga_flush_write_combine(void);
extern unsigned int mga_create_sync_tag(drm_device_t *dev);
extern drm_buf_t *mga_freelist_get(drm_device_t *dev);
extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf);
@@ -138,9 +137,9 @@ extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid);
/* mga_bufs.c */
-extern int mga_addbufs(struct inode *inode, struct file *filp,
+extern int mga_addbufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern int mga_infobufs(struct inode *inode, struct file *filp,
+extern int mga_infobufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int mga_markbufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
@@ -180,6 +179,7 @@ extern int mga_rmctx(struct inode *inode, struct file *filp,
extern int mga_context_switch(drm_device_t *dev, int old, int new);
extern int mga_context_switch_complete(drm_device_t *dev, int new);
+#define mga_flush_write_combine() mb()
typedef enum {
TT_GENERAL,
@@ -202,7 +202,7 @@ typedef struct {
#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
#define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2)
#define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)
-#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))
+#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))
#define MGA_VERBOSE 0
#define MGA_NUM_PRIM_BUFS 8
@@ -213,13 +213,12 @@ typedef struct {
#define PRIM_OVERFLOW(dev, dev_priv, length) do { \
drm_mga_prim_buf_t *tmp_buf = \
dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
- if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \
- &tmp_buf->buffer_status)) { \
+ if( test_bit(MGA_BUF_NEEDS_OVERFLOW, &tmp_buf->buffer_status)) { \
mga_advance_primary(dev); \
mga_dma_schedule(dev, 1); \
tmp_buf = dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
} else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length || \
- tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \
+ tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \
set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \
mga_advance_primary(dev); \
mga_dma_schedule(dev, 1); \
@@ -296,7 +295,7 @@ drm_mga_prim_buf_t *tmp_buf = \
num_dwords + 1 + outcount, ADRINDEX(reg), val); \
if( ++outcount == 4) { \
outcount = 0; \
- dma_ptr[0] = *(u32 *)tempIndex; \
+ dma_ptr[0] = *(unsigned long *)tempIndex; \
dma_ptr+=5; \
num_dwords += 5; \
} \
@@ -378,6 +377,72 @@ drm_mga_prim_buf_t *tmp_buf = \
#define MGAREG_YTOP 0x1c98
#define MGAREG_ZORG 0x1c0c
+/* Warp registers */
+#define MGAREG_WR0 0x2d00
+#define MGAREG_WR1 0x2d04
+#define MGAREG_WR2 0x2d08
+#define MGAREG_WR3 0x2d0c
+#define MGAREG_WR4 0x2d10
+#define MGAREG_WR5 0x2d14
+#define MGAREG_WR6 0x2d18
+#define MGAREG_WR7 0x2d1c
+#define MGAREG_WR8 0x2d20
+#define MGAREG_WR9 0x2d24
+#define MGAREG_WR10 0x2d28
+#define MGAREG_WR11 0x2d2c
+#define MGAREG_WR12 0x2d30
+#define MGAREG_WR13 0x2d34
+#define MGAREG_WR14 0x2d38
+#define MGAREG_WR15 0x2d3c
+#define MGAREG_WR16 0x2d40
+#define MGAREG_WR17 0x2d44
+#define MGAREG_WR18 0x2d48
+#define MGAREG_WR19 0x2d4c
+#define MGAREG_WR20 0x2d50
+#define MGAREG_WR21 0x2d54
+#define MGAREG_WR22 0x2d58
+#define MGAREG_WR23 0x2d5c
+#define MGAREG_WR24 0x2d60
+#define MGAREG_WR25 0x2d64
+#define MGAREG_WR26 0x2d68
+#define MGAREG_WR27 0x2d6c
+#define MGAREG_WR28 0x2d70
+#define MGAREG_WR29 0x2d74
+#define MGAREG_WR30 0x2d78
+#define MGAREG_WR31 0x2d7c
+#define MGAREG_WR32 0x2d80
+#define MGAREG_WR33 0x2d84
+#define MGAREG_WR34 0x2d88
+#define MGAREG_WR35 0x2d8c
+#define MGAREG_WR36 0x2d90
+#define MGAREG_WR37 0x2d94
+#define MGAREG_WR38 0x2d98
+#define MGAREG_WR39 0x2d9c
+#define MGAREG_WR40 0x2da0
+#define MGAREG_WR41 0x2da4
+#define MGAREG_WR42 0x2da8
+#define MGAREG_WR43 0x2dac
+#define MGAREG_WR44 0x2db0
+#define MGAREG_WR45 0x2db4
+#define MGAREG_WR46 0x2db8
+#define MGAREG_WR47 0x2dbc
+#define MGAREG_WR48 0x2dc0
+#define MGAREG_WR49 0x2dc4
+#define MGAREG_WR50 0x2dc8
+#define MGAREG_WR51 0x2dcc
+#define MGAREG_WR52 0x2dd0
+#define MGAREG_WR53 0x2dd4
+#define MGAREG_WR54 0x2dd8
+#define MGAREG_WR55 0x2ddc
+#define MGAREG_WR56 0x2de0
+#define MGAREG_WR57 0x2de4
+#define MGAREG_WR58 0x2de8
+#define MGAREG_WR59 0x2dec
+#define MGAREG_WR60 0x2df0
+#define MGAREG_WR61 0x2df4
+#define MGAREG_WR62 0x2df8
+#define MGAREG_WR63 0x2dfc
+
#define PDEA_pagpxfer_enable 0x2
#define WIA_wmode_suspend 0x0
@@ -397,8 +462,8 @@ drm_mga_prim_buf_t *tmp_buf = \
#define DC_atype_zi 0x30
#define DC_atype_blk 0x40
#define DC_atype_i 0x70
-#define DC_linear_xy 0x0
-#define DC_linear_linear 0x80
+#define DC_linear_xy 0x0
+#define DC_linear_linear 0x80
#define DC_zmode_nozcmp 0x0
#define DC_zmode_ze 0x200
#define DC_zmode_zne 0x300
@@ -406,16 +471,16 @@ drm_mga_prim_buf_t *tmp_buf = \
#define DC_zmode_zlte 0x500
#define DC_zmode_zgt 0x600
#define DC_zmode_zgte 0x700
-#define DC_solid_disable 0x0
-#define DC_solid_enable 0x800
-#define DC_arzero_disable 0x0
-#define DC_arzero_enable 0x1000
-#define DC_sgnzero_disable 0x0
-#define DC_sgnzero_enable 0x2000
-#define DC_shftzero_disable 0x0
-#define DC_shftzero_enable 0x4000
-#define DC_bop_SHIFT 16
-#define DC_trans_SHIFT 20
+#define DC_solid_disable 0x0
+#define DC_solid_enable 0x800
+#define DC_arzero_disable 0x0
+#define DC_arzero_enable 0x1000
+#define DC_sgnzero_disable 0x0
+#define DC_sgnzero_enable 0x2000
+#define DC_shftzero_disable 0x0
+#define DC_shftzero_enable 0x4000
+#define DC_bop_SHIFT 16
+#define DC_trans_SHIFT 20
#define DC_bltmod_bmonolef 0x0
#define DC_bltmod_bmonowf 0x8000000
#define DC_bltmod_bplan 0x2000000
@@ -424,21 +489,22 @@ drm_mga_prim_buf_t *tmp_buf = \
#define DC_bltmod_bu32rgb 0xe000000
#define DC_bltmod_bu24bgr 0x16000000
#define DC_bltmod_bu24rgb 0x1e000000
-#define DC_pattern_disable 0x0
-#define DC_pattern_enable 0x20000000
-#define DC_transc_disable 0x0
-#define DC_transc_enable 0x40000000
-#define DC_clipdis_disable 0x0
-#define DC_clipdis_enable 0x80000000
+#define DC_pattern_disable 0x0
+#define DC_pattern_enable 0x20000000
+#define DC_transc_disable 0x0
+#define DC_transc_enable 0x40000000
+#define DC_clipdis_disable 0x0
+#define DC_clipdis_enable 0x80000000
-#define SETADD_mode_vertlist 0x0
+
+#define SETADD_mode_vertlist 0x0
#define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \
DC_sgnzero_enable | DC_shftzero_enable | \
(0xC << DC_bop_SHIFT) | DC_clipdis_enable | \
DC_solid_enable | DC_transc_enable)
-
+
#define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \
DC_solid_disable | DC_arzero_disable | \
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
index b4c164343..9bbd254c1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
@@ -11,11 +11,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -28,7 +28,6 @@
* Keith Whitwell <keithw@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c,v 1.5 2000/08/28 02:43:15 tsi Exp $ */
#define __NO_VERSION__
#include "drmP.h"
@@ -39,13 +38,13 @@
* change these values
*/
-#define MGAEMITCLIP_SIZE 10
-#define MGAEMITCTX_SIZE 15
-#define MGAG200EMITTEX_SIZE 20
-#define MGAG400EMITTEX0_SIZE 30
-#define MGAG400EMITTEX1_SIZE 25
-#define MGAG400EMITPIPE_SIZE 50
-#define MGAG200EMITPIPE_SIZE 15
+#define MGAEMITCLIP_SIZE 10
+#define MGAEMITCTX_SIZE 20
+#define MGAG200EMITTEX_SIZE 20
+#define MGAG400EMITTEX0_SIZE 30
+#define MGAG400EMITTEX1_SIZE 25
+#define MGAG400EMITPIPE_SIZE 50
+#define MGAG200EMITPIPE_SIZE 15
#define MAX_STATE_SIZE ((MGAEMITCLIP_SIZE * MGA_NR_SAREA_CLIPRECTS) + \
MGAEMITCTX_SIZE + MGAG400EMITTEX0_SIZE + \
@@ -57,24 +56,24 @@ static void mgaEmitClipRect(drm_mga_private_t * dev_priv,
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->ContextState;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
/* This takes 10 dwords */
PRIMGETPTR(dev_priv);
- /* Force reset of dwgctl (eliminates clip disable) */
+ /* Force reset of dwgctl on G400 (eliminates clip disable bit) */
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
#if 0
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DWGSYNC, 0);
- PRIMOUTREG(MGAREG_DWGSYNC, 0);
- PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
#else
- PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
- PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
- PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
- PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
#endif
-
+ }
PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1));
PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / dev_priv->cpp);
@@ -88,9 +87,8 @@ static void mgaEmitContext(drm_mga_private_t * dev_priv)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->ContextState;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
- /* This takes a max of 15 dwords */
+ /* This takes a max of 20 dwords */
PRIMGETPTR(dev_priv);
PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]);
@@ -108,6 +106,11 @@ static void mgaEmitContext(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]);
PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]);
PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
+
+ PRIMOUTREG(MGAREG_STENCIL, regs[MGA_CTXREG_STENCIL]);
+ PRIMOUTREG(MGAREG_STENCILCTL, regs[MGA_CTXREG_STENCILCTL]);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
} else {
PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
PRIMOUTREG(MGAREG_DMAPAD, 0);
@@ -123,7 +126,6 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->TexState[0];
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
@@ -142,9 +144,9 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
- PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_WR24, regs[MGA_TEXREG_WIDTH]);
- PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(MGAREG_WR34, regs[MGA_TEXREG_HEIGHT]);
PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
PRIMOUTREG(MGAREG_DMAPAD, 0);
@@ -152,17 +154,17 @@ static void mgaG200EmitTex(drm_mga_private_t * dev_priv)
PRIMADVANCE(dev_priv);
}
+#define TMC_dualtex_enable 0x80
+
static void mgaG400EmitTex0(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->TexState[0];
- int multitex = sarea_priv->WarpPipe & MGA_T2;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
- /* This takes a max of 30 dwords */
+ /* This takes 30 dwords */
PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
@@ -177,22 +179,20 @@ static void mgaG400EmitTex0(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
- PRIMOUTREG(0x2d00 + 49 * 4, 0);
+ PRIMOUTREG(MGAREG_WR49, 0);
- PRIMOUTREG(0x2d00 + 57 * 4, 0);
- PRIMOUTREG(0x2d00 + 53 * 4, 0);
- PRIMOUTREG(0x2d00 + 61 * 4, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_WR57, 0);
+ PRIMOUTREG(MGAREG_WR53, 0);
+ PRIMOUTREG(MGAREG_WR61, 0);
+ PRIMOUTREG(MGAREG_WR52, 0x40);
- if (!multitex) {
- PRIMOUTREG(0x2d00 + 52 * 4, 0x40);
- PRIMOUTREG(0x2d00 + 60 * 4, 0x40);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- }
+ PRIMOUTREG(MGAREG_WR60, 0x40);
+ PRIMOUTREG(MGAREG_WR54, regs[MGA_TEXREG_WIDTH] | 0x40);
+ PRIMOUTREG(MGAREG_WR62, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
- PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
@@ -206,7 +206,6 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->TexState[1];
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
@@ -226,14 +225,14 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
- PRIMOUTREG(0x2d00 + 49 * 4, 0);
+ PRIMOUTREG(MGAREG_WR49, 0);
- PRIMOUTREG(0x2d00 + 57 * 4, 0);
- PRIMOUTREG(0x2d00 + 53 * 4, 0);
- PRIMOUTREG(0x2d00 + 61 * 4, 0);
- PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
+ PRIMOUTREG(MGAREG_WR57, 0);
+ PRIMOUTREG(MGAREG_WR53, 0);
+ PRIMOUTREG(MGAREG_WR61, 0);
+ PRIMOUTREG(MGAREG_WR52, regs[MGA_TEXREG_WIDTH] | 0x40);
- PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_WR60, regs[MGA_TEXREG_HEIGHT] | 0x40);
PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
@@ -241,13 +240,16 @@ static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
PRIMADVANCE(dev_priv);
}
+#define MAGIC_FPARAM_HEX_VALUE 0x46480000
+/* This is the hex value of 12800.0f which is a magic value we must
+ * set in wr56.
+ */
+
static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int pipe = sarea_priv->WarpPipe;
- float fParam = 12800.0f;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
@@ -279,14 +281,14 @@ static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD);
PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_DWGSYNC, 0x7000);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
-
- PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000);
+ PRIMOUTREG(MGAREG_TEXCTL2, 0x00008000);
PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+
PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000);
PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
}
PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807);
@@ -302,18 +304,18 @@ static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_WFLAG, 0);
PRIMOUTREG(MGAREG_WFLAG1, 0);
- PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam)));
+ PRIMOUTREG(MGAREG_WR56, MAGIC_FPARAM_HEX_VALUE);
PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */
- PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */
- PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */
- PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */
+ PRIMOUTREG(MGAREG_WR49, 0); /* Tex stage 0 */
+ PRIMOUTREG(MGAREG_WR57, 0); /* Tex stage 0 */
+ PRIMOUTREG(MGAREG_WR53, 0); /* Tex stage 1 */
+ PRIMOUTREG(MGAREG_WR61, 0); /* Tex stage 1 */
- PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */
- PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */
- PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */
- PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */
+ PRIMOUTREG(MGAREG_WR54, 0x40); /* Tex stage 0 : w */
+ PRIMOUTREG(MGAREG_WR62, 0x40); /* Tex stage 0 : h */
+ PRIMOUTREG(MGAREG_WR52, 0x40); /* Tex stage 1 : w */
+ PRIMOUTREG(MGAREG_WR60, 0x40); /* Tex stage 1 : h */
/* Dma pading required due to hw bug */
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
@@ -330,7 +332,6 @@ static void mgaG200EmitPipe(drm_mga_private_t * dev_priv)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int pipe = sarea_priv->WarpPipe;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
@@ -339,12 +340,12 @@ static void mgaG200EmitPipe(drm_mga_private_t * dev_priv)
PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend);
PRIMOUTREG(MGAREG_WVRTXSZ, 7);
PRIMOUTREG(MGAREG_WFLAG, 0);
- PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */
+ PRIMOUTREG(MGAREG_WR24, 0); /* tex w/h */
- PRIMOUTREG(0x2d00 + 25 * 4, 0x100);
- PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */
- PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF);
- PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF);
+ PRIMOUTREG(MGAREG_WR25, 0x100);
+ PRIMOUTREG(MGAREG_WR34, 0); /* tex w/h */
+ PRIMOUTREG(MGAREG_WR42, 0xFFFF);
+ PRIMOUTREG(MGAREG_WR60, 0xFFFF);
/* Dma pading required due to hw bug */
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
@@ -361,7 +362,6 @@ static void mgaEmitState(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int dirty = sarea_priv->dirty;
- DRM_DEBUG("%s\n", __FUNCTION__);
if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
int multitex = sarea_priv->WarpPipe & MGA_T2;
@@ -403,7 +403,6 @@ static void mgaEmitState(drm_mga_private_t * dev_priv)
}
}
-
/* Disallow all write destinations except the front and backbuffer.
*/
static int mgaVerifyContext(drm_mga_private_t * dev_priv)
@@ -411,8 +410,6 @@ static int mgaVerifyContext(drm_mga_private_t * dev_priv)
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->ContextState;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset &&
regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) {
DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n",
@@ -431,8 +428,6 @@ static int mgaVerifyTex(drm_mga_private_t * dev_priv, int unit)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) {
DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n",
sarea_priv->TexState[unit][MGA_TEXREG_ORG],
@@ -450,8 +445,6 @@ static int mgaVerifyState(drm_mga_private_t * dev_priv)
unsigned int dirty = sarea_priv->dirty;
int rv = 0;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
@@ -479,8 +472,6 @@ static int mgaVerifyIload(drm_mga_private_t * dev_priv,
unsigned long bus_address,
unsigned int dstOrg, int length)
{
- DRM_DEBUG("%s\n", __FUNCTION__);
-
if (dstOrg < dev_priv->textureOffset ||
dstOrg + length >
(dev_priv->textureOffset + dev_priv->textureSize)) {
@@ -503,7 +494,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
int use_agp = PDEA_pagpxfer_enable | 0x00000001;
u16 y2;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
y2 = length / 64;
@@ -511,7 +501,6 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
PRIMOUTREG(MGAREG_DSTORG, destOrg);
PRIMOUTREG(MGAREG_MACCESS, 0x00000000);
- DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp);
PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp);
PRIMOUTREG(MGAREG_AR5, 64);
@@ -525,10 +514,10 @@ static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16));
PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_SRCORG, 0);
PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x7000);
PRIMADVANCE(dev_priv);
}
@@ -542,34 +531,22 @@ static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
int use_agp = PDEA_pagpxfer_enable;
int i = 0;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- DRM_DEBUG("dispatch vertex %d addr 0x%lx, "
- "length 0x%x nbox %d dirty %x\n",
- buf->idx, address, length,
- sarea_priv->nbox, sarea_priv->dirty);
-
- DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total);
if (buf->used) {
/* WARNING: if you change any of the state functions verify
- * these numbers (Overestimating this doesn't hurt).
+ * these numbers (Overestimating this doesn't hurt).
*/
buf_priv->dispatched = 1;
PRIM_OVERFLOW(dev, dev_priv,
(MAX_STATE_SIZE + (5 * MGA_NR_SAREA_CLIPRECTS)));
mgaEmitState(dev_priv);
+
+#if 0
+ length = dev_priv->vertexsize * 3 * 4;
+#endif
+
do {
if (i < sarea_priv->nbox) {
- DRM_DEBUG("idx %d Emit box %d/%d:"
- "%d,%d - %d,%d\n",
- buf->idx,
- i, sarea_priv->nbox,
- sarea_priv->boxes[i].x1,
- sarea_priv->boxes[i].y1,
- sarea_priv->boxes[i].x2,
- sarea_priv->boxes[i].y2);
-
mgaEmitClipRect(dev_priv,
&sarea_priv->boxes[i]);
}
@@ -606,16 +583,10 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
int use_agp = PDEA_pagpxfer_enable;
int i = 0;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
-
- DRM_DEBUG("dispatch indices %d addr 0x%x, "
- "start 0x%x end 0x%x nbox %d dirty %x\n",
- buf->idx, address, start, end,
- sarea_priv->nbox, sarea_priv->dirty);
if (start != end) {
/* WARNING: if you change any of the state functions verify
- * these numbers (Overestimating this doesn't hurt).
+ * these numbers (Overestimating this doesn't hurt).
*/
buf_priv->dispatched = 1;
PRIM_OVERFLOW(dev, dev_priv,
@@ -624,15 +595,6 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
do {
if (i < sarea_priv->nbox) {
- DRM_DEBUG("idx %d Emit box %d/%d:"
- "%d,%d - %d,%d\n",
- buf->idx,
- i, sarea_priv->nbox,
- sarea_priv->boxes[i].x1,
- sarea_priv->boxes[i].y1,
- sarea_priv->boxes[i].x2,
- sarea_priv->boxes[i].y2);
-
mgaEmitClipRect(dev_priv,
&sarea_priv->boxes[i]);
}
@@ -645,6 +607,7 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
SETADD_mode_vertlist));
PRIMOUTREG(MGAREG_SETUPEND,
((address + end) | use_agp));
+/* ((address + start + 12) | use_agp)); */
PRIMADVANCE(dev_priv);
} while (++i < sarea_priv->nbox);
}
@@ -659,7 +622,9 @@ static void mga_dma_dispatch_indices(drm_device_t * dev,
static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
unsigned int clear_color,
- unsigned int clear_zval)
+ unsigned int clear_zval,
+ unsigned int clear_colormask,
+ unsigned int clear_depthmask)
{
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -669,7 +634,6 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
unsigned int cmd;
int i;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
if (dev_priv->sgram)
cmd = MGA_CLEAR_CMD | DC_atype_blk;
@@ -681,14 +645,9 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
for (i = 0; i < nbox; i++) {
unsigned int height = pbox[i].y2 - pbox[i].y1;
- DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n",
- pbox[i].x1, pbox[i].y1, pbox[i].x2,
- pbox[i].y2, flags);
-
if (flags & MGA_FRONT) {
- DRM_DEBUG("clear front\n");
- PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_PLNWT, clear_colormask);
PRIMOUTREG(MGAREG_YDSTLEN,
(pbox[i].y1 << 16) | height);
PRIMOUTREG(MGAREG_FXBNDRY,
@@ -701,9 +660,8 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
}
if (flags & MGA_BACK) {
- DRM_DEBUG("clear back\n");
- PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_PLNWT, clear_colormask);
PRIMOUTREG(MGAREG_YDSTLEN,
(pbox[i].y1 << 16) | height);
PRIMOUTREG(MGAREG_FXBNDRY,
@@ -716,9 +674,8 @@ static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
}
if (flags & MGA_DEPTH) {
- DRM_DEBUG("clear depth\n");
- PRIMOUTREG(MGAREG_DMAPAD, 0);
PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_PLNWT, clear_depthmask);
PRIMOUTREG(MGAREG_YDSTLEN,
(pbox[i].y1 << 16) | height);
PRIMOUTREG(MGAREG_FXBNDRY,
@@ -750,7 +707,6 @@ static void mga_dma_dispatch_swap(drm_device_t * dev)
int pixel_stride = dev_priv->stride / dev_priv->cpp;
PRIMLOCALS;
- DRM_DEBUG("%s\n", __FUNCTION__);
PRIM_OVERFLOW(dev, dev_priv, (MGA_NR_SAREA_CLIPRECTS * 5) + 20);
@@ -773,9 +729,6 @@ static void mga_dma_dispatch_swap(drm_device_t * dev)
unsigned int h = pbox[i].y2 - pbox[i].y1;
unsigned int start = pbox[i].y1 * pixel_stride;
- DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
- pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2);
-
PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1);
PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1);
PRIMOUTREG(MGAREG_FXBNDRY,
@@ -803,9 +756,8 @@ int mga_clear_bufs(struct inode *inode, struct file *filp,
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_clear_t clear;
- copy_from_user_ret(&clear, (drm_mga_clear_t *) arg, sizeof(clear),
- -EFAULT);
- DRM_DEBUG("%s\n", __FUNCTION__);
+ if (copy_from_user(&clear, (drm_mga_clear_t *) arg, sizeof(clear)))
+ return -EFAULT;
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_clear_bufs called without lock held\n");
@@ -819,7 +771,10 @@ int mga_clear_bufs(struct inode *inode, struct file *filp,
*/
dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX;
mga_dma_dispatch_clear(dev, clear.flags,
- clear.clear_color, clear.clear_depth);
+ clear.clear_color,
+ clear.clear_depth,
+ clear.clear_color_mask,
+ clear.clear_depth_mask);
PRIMUPDATE(dev_priv);
mga_flush_write_combine();
mga_dma_schedule(dev, 1);
@@ -834,7 +789,6 @@ int mga_swap_bufs(struct inode *inode, struct file *filp,
drm_mga_private_t *dev_priv =
(drm_mga_private_t *) dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- DRM_DEBUG("%s\n", __FUNCTION__);
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_swap_bufs called without lock held\n");
@@ -869,11 +823,9 @@ int mga_iload(struct inode *inode, struct file *filp,
drm_mga_buf_priv_t *buf_priv;
drm_mga_iload_t iload;
unsigned long bus_address;
- DRM_DEBUG("%s\n", __FUNCTION__);
- DRM_DEBUG("Starting Iload\n");
- copy_from_user_ret(&iload, (drm_mga_iload_t *) arg, sizeof(iload),
- -EFAULT);
+ if (copy_from_user(&iload, (drm_mga_iload_t *) arg, sizeof(iload)))
+ return -EFAULT;
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_iload called without lock held\n");
@@ -883,8 +835,6 @@ int mga_iload(struct inode *inode, struct file *filp,
buf = dma->buflist[iload.idx];
buf_priv = buf->dev_private;
bus_address = buf->bus_address;
- DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n",
- bus_address, iload.length, iload.destOrg);
if (mgaVerifyIload(dev_priv,
bus_address, iload.destOrg, iload.length)) {
@@ -915,18 +865,15 @@ int mga_vertex(struct inode *inode, struct file *filp,
drm_buf_t *buf;
drm_mga_buf_priv_t *buf_priv;
drm_mga_vertex_t vertex;
- DRM_DEBUG("%s\n", __FUNCTION__);
- copy_from_user_ret(&vertex, (drm_mga_vertex_t *) arg,
- sizeof(vertex), -EFAULT);
+ if (copy_from_user(&vertex, (drm_mga_vertex_t *) arg, sizeof(vertex)))
+ return -EFAULT;
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_vertex called without lock held\n");
return -EINVAL;
}
- DRM_DEBUG("mga_vertex\n");
-
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
@@ -940,7 +887,6 @@ int mga_vertex(struct inode *inode, struct file *filp,
buf_priv->dispatched = 0;
mga_freelist_put(dev, buf);
}
- DRM_DEBUG("bad state\n");
return -EINVAL;
}
@@ -964,18 +910,16 @@ int mga_indices(struct inode *inode, struct file *filp,
drm_buf_t *buf;
drm_mga_buf_priv_t *buf_priv;
drm_mga_indices_t indices;
- DRM_DEBUG("%s\n", __FUNCTION__);
- copy_from_user_ret(&indices, (drm_mga_indices_t *) arg,
- sizeof(indices), -EFAULT);
+ if (copy_from_user(&indices,
+ (drm_mga_indices_t *)arg, sizeof(indices)))
+ return -EFAULT;
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_indices called without lock held\n");
return -EINVAL;
}
- DRM_DEBUG("mga_indices\n");
-
buf = dma->buflist[indices.idx];
buf_priv = buf->dev_private;
@@ -1005,17 +949,18 @@ static int mga_dma_get_buffers(drm_device_t * dev, drm_dma_t * d)
{
int i;
drm_buf_t *buf;
- DRM_DEBUG("%s\n", __FUNCTION__);
for (i = d->granted_count; i < d->request_count; i++) {
buf = mga_freelist_get(dev);
if (!buf)
break;
buf->pid = current->pid;
- copy_to_user_ret(&d->request_indices[i],
- &buf->idx, sizeof(buf->idx), -EFAULT);
- copy_to_user_ret(&d->request_sizes[i],
- &buf->total, sizeof(buf->total), -EFAULT);
+ if (copy_to_user(&d->request_indices[i],
+ &buf->idx, sizeof(buf->idx)))
+ return -EFAULT;
+ if (copy_to_user(&d->request_sizes[i],
+ &buf->total, sizeof(buf->total)))
+ return -EFAULT;
++d->granted_count;
}
return 0;
@@ -1029,11 +974,9 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_dma_t *dma = dev->dma;
int retcode = 0;
drm_dma_t d;
- DRM_DEBUG("%s\n", __FUNCTION__);
- copy_from_user_ret(&d, (drm_dma_t *) arg, sizeof(d), -EFAULT);
- DRM_DEBUG("%d %d: %d send, %d req\n",
- current->pid, d.context, d.send_count, d.request_count);
+ if (copy_from_user(&d, (drm_dma_t *) arg, sizeof(d)))
+ return -EFAULT;
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
DRM_ERROR("mga_dma called without lock held\n");
@@ -1064,8 +1007,7 @@ int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd,
retcode = mga_dma_get_buffers(dev, &d);
}
- DRM_DEBUG("%d returning, granted = %d\n",
- current->pid, d.granted_count);
- copy_to_user_ret((drm_dma_t *) arg, &d, sizeof(d), -EFAULT);
+ if (copy_to_user((drm_dma_t *) arg, &d, sizeof(d)))
+ return -EFAULT;
return retcode;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
index 6053a9477..77519a561 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
@@ -1,3 +1,5 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c,v 1.3 2000/09/01 02:31:40 tsi Exp $ */
+
#include <linux/config.h>
#include <linux/version.h>
@@ -5,6 +7,10 @@
#define CONFIG_SMP 0
#endif
+#ifndef CONFIG_MODULES
+#define CONFIG_MODULES 0
+#endif
+
#ifndef CONFIG_MODVERSIONS
#define CONFIG_MODVERSIONS 0
#endif
@@ -22,6 +28,7 @@
#endif
SMP = CONFIG_SMP
+MODULES = CONFIG_MODULES
MODVERSIONS = CONFIG_MODVERSIONS
AGP = CONFIG_AGP
AGP_MODULE = CONFIG_AGP_MODULE
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
index 94ee806ca..7ae498014 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
@@ -28,7 +28,6 @@
* Kevin E. Martin <martin@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c,v 1.3 2000/08/28 02:43:16 tsi Exp $ */
#include <linux/config.h>
#include "drmP.h"
@@ -36,7 +35,7 @@
#define R128_NAME "r128"
#define R128_DESC "ATI Rage 128"
-#define R128_DATE "20000719"
+#define R128_DATE "20000928"
#define R128_MAJOR 1
#define R128_MINOR 0
#define R128_PATCHLEVEL 0
@@ -421,17 +420,18 @@ int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version;
int len;
- copy_from_user_ret(&version,
+ if (copy_from_user(&version,
(drm_version_t *)arg,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
#define DRM_COPY(name,value) \
len = strlen(value); \
if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \
if (len && name) { \
- copy_to_user_ret(name, value, len, -EFAULT); \
+ if (copy_to_user(name, value, len)) \
+ return -EFAULT; \
}
version.version_major = R128_MAJOR;
@@ -442,10 +442,10 @@ int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, R128_DATE);
DRM_COPY(version.desc, R128_DESC);
- copy_to_user_ret((drm_version_t *)arg,
+ if (copy_to_user((drm_version_t *)arg,
&version,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
return 0;
}
@@ -467,7 +467,7 @@ int r128_open(struct inode *inode, struct file *filp)
}
spin_unlock(&dev->count_lock);
}
-
+
return retcode;
}
@@ -501,7 +501,7 @@ int r128_release(struct inode *inode, struct file *filp)
}
spin_unlock(&dev->count_lock);
}
-
+
unlock_kernel();
return retcode;
}
@@ -560,7 +560,8 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lck_start = start = get_cycles();
#endif
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -601,6 +602,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -616,7 +618,6 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
#if 1
current->policy |= SCHED_YIELD;
#endif
@@ -657,6 +658,14 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
if (!ret) {
+ sigemptyset(&dev->sigmask);
+ sigaddset(&dev->sigmask, SIGSTOP);
+ sigaddset(&dev->sigmask, SIGTSTP);
+ sigaddset(&dev->sigmask, SIGTTIN);
+ sigaddset(&dev->sigmask, SIGTTOU);
+ dev->sigdata.context = lock.context;
+ dev->sigdata.lock = dev->lock.hw_lock;
+ block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
if (lock.flags & _DRM_LOCK_READY) {
/* Wait for space in DMA/FIFO */
}
@@ -691,7 +700,8 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_lock_t lock;
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -720,6 +730,6 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
current->priority = DEF_PRIORITY;
}
#endif
-
+ unblock_all_signals();
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
index da2f676d3..63b98c727 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
@@ -197,7 +197,7 @@ extern int r128_context_switch_complete(drm_device_t *dev, int new);
#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
-#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
+#define R128_BASE(reg) ((u32)(dev_priv->mmio->handle))
#define R128_ADDR(reg) (R128_BASE(reg) + reg)
#define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c
index e13bd8531..f2fdf6dd3 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c
@@ -30,7 +30,6 @@
* Sung-Ching Lin <sclin@sis.com.tw>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_context.c,v 1.3 2000/09/22 11:35:47 alanh Exp $ */
#define __NO_VERSION__
#include "drmP.h"
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h
new file mode 100644
index 000000000..73807f317
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drm.h
@@ -0,0 +1,31 @@
+
+#ifndef _sis_drm_public_h_
+#define _sis_drm_public_h_
+
+typedef struct {
+ int context;
+ unsigned int offset;
+ unsigned int size;
+ unsigned int free;
+} drm_sis_mem_t;
+
+typedef struct {
+ unsigned int offset, size;
+} drm_sis_agp_t;
+
+typedef struct {
+ unsigned int left, right;
+} drm_sis_flip_t;
+
+#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t)
+#define SIS_IOCTL_FB_FREE DRM_IOW( 0x45, drm_sis_mem_t)
+
+#define SIS_IOCTL_AGP_INIT DRM_IOWR( 0x53, drm_sis_agp_t)
+#define SIS_IOCTL_AGP_ALLOC DRM_IOWR( 0x54, drm_sis_mem_t)
+#define SIS_IOCTL_AGP_FREE DRM_IOW( 0x55, drm_sis_mem_t)
+
+#define SIS_IOCTL_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
+#define SIS_IOCTL_FLIP_INIT DRM_IO( 0x49)
+#define SIS_IOCTL_FLIP_FINAL DRM_IO( 0x50)
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c
index c5103d583..2f98e3221 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c
@@ -1,5 +1,4 @@
-/* sis_drv.c -- sis driver -*- linux-c -*-
- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
+/* sis.c -- sis driver -*- linux-c -*-
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
@@ -23,18 +22,12 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Daryll Strauss <daryll@valinux.com>
- * Sung-Ching Lin <sclin@sis.com.tw>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.c,v 1.5 2000/09/22 11:35:47 alanh Exp $ */
#include <linux/config.h>
#include "drmP.h"
-#include "sis_drm_public.h"
+#include "sis_drm.h"
#include "sis_drv.h"
#define SIS_NAME "sis"
@@ -581,6 +574,7 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -596,7 +590,6 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
#if 1
current->policy |= SCHED_YIELD;
#endif
@@ -637,6 +630,15 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
if (!ret) {
+ sigemptyset(&dev->sigmask);
+ sigaddset(&dev->sigmask, SIGSTOP);
+ sigaddset(&dev->sigmask, SIGTSTP);
+ sigaddset(&dev->sigmask, SIGTTIN);
+ sigaddset(&dev->sigmask, SIGTTOU);
+ dev->sigdata.context = lock.context;
+ dev->sigdata.lock = dev->lock.hw_lock;
+ block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
+
if (lock.flags & _DRM_LOCK_READY) {
/* Wait for space in DMA/FIFO */
}
@@ -648,12 +650,6 @@ int sis_lock(struct inode *inode, struct file *filp, unsigned int cmd,
}
}
-#if LINUX_VERSION_CODE < 0x020400
- if (lock.context != sis_res_ctx.handle) {
- current->counter = 5;
- current->priority = DEF_PRIORITY/4;
- }
-#endif
DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
#if DRM_DMA_HISTOGRAM
@@ -694,12 +690,6 @@ int sis_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
}
}
-#if LINUX_VERSION_CODE < 0x020400
- if (lock.context != sis_res_ctx.handle) {
- current->counter = 5;
- current->priority = DEF_PRIORITY;
- }
-#endif
-
+ unblock_all_signals();
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h
index 496c5655d..8c4e29108 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h
@@ -1,5 +1,4 @@
/* sis_drv.h -- Private header for sis driver -*- linux-c -*-
- * Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
@@ -24,13 +23,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Daryll Strauss <daryll@valinux.com>
- * Sung-Ching Lin <sclin@sis.com.tw>
- *
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_drv.h,v 1.3 2000/09/22 11:35:47 alanh Exp $ */
#ifndef _SIS_DRV_H_
#define _SIS_DRV_H_
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c
index a946a41f1..6143ad83a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c
@@ -27,7 +27,6 @@
* Sung-Ching Lin <sclin@sis.com.tw>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c,v 1.2 2000/09/22 11:35:47 alanh Exp $ */
#define __NO_VERSION__
#include <linux/module.h>
@@ -163,7 +162,6 @@ int setDestroy(set_t *set)
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.c,v 1.2 2000/09/22 11:35:47 alanh Exp $ */
#define ISFREE(bptr) ((bptr)->free)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h
index 59d58b8c6..c3367dba7 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h
@@ -27,7 +27,6 @@
* Sung-Ching Lin <sclin@sis.com.tw>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_ds.h,v 1.3 2000/09/22 11:35:47 alanh Exp $ */
#ifndef _sis_ds_h_
#define _sis_ds_h_
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c
index 1d909785e..e6e8ed7dd 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c
@@ -27,11 +27,10 @@
* Sung-Ching Lin <sclin@sis.com.tw>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/sis_mm.c,v 1.4 2000/09/22 11:35:47 alanh Exp $ */
#define __NO_VERSION__
#include "drmP.h"
-#include "sis_drm_public.h"
+#include "sis_drm.h"
#include "sis_ds.h"
#include "sis_drv.h"
#include <linux/fb.h>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
index 0fef5f7e2..5f2c804af 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
@@ -1,4 +1,4 @@
-/* tdfx.c -- tdfx driver -*- linux-c -*-
+/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
* Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -11,11 +11,11 @@
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
@@ -23,13 +23,12 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
- *
+ *
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Daryll Strauss <daryll@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c,v 1.6 2000/08/28 02:43:16 tsi Exp $ */
#include <linux/config.h>
#include "drmP.h"
@@ -37,7 +36,7 @@
#define TDFX_NAME "tdfx"
#define TDFX_DESC "3dfx Banshee/Voodoo3+"
-#define TDFX_DATE "20000719"
+#define TDFX_DATE "20000928"
#define TDFX_MAJOR 1
#define TDFX_MINOR 0
#define TDFX_PATCHLEVEL 0
@@ -77,7 +76,7 @@ static drm_ioctl_desc_t tdfx_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
-
+
[DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { tdfx_addctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { tdfx_rmctx, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { tdfx_modctx, 1, 1 },
@@ -129,7 +128,7 @@ __setup("tdfx=", tdfx_options);
static int tdfx_setup(drm_device_t *dev)
{
int i;
-
+
atomic_set(&dev->ioctl_count, 0);
atomic_set(&dev->vma_count, 0);
dev->buf_use = 0;
@@ -171,7 +170,7 @@ static int tdfx_setup(drm_device_t *dev)
dev->ctx_start = 0;
dev->lck_start = 0;
-
+
dev->buf_rp = dev->buf;
dev->buf_wp = dev->buf;
dev->buf_end = dev->buf + DRM_BSZ;
@@ -180,15 +179,15 @@ static int tdfx_setup(drm_device_t *dev)
init_waitqueue_head(&dev->buf_writers);
tdfx_res_ctx.handle=-1;
-
+
DRM_DEBUG("\n");
-
+
/* The kernel's context could be created here, but is now created
in drm_dma_enqueue. This is more resource-efficient for
hardware that does not do DMA, but may mean that
drm_select_queue fails between the time the interrupt is
initialized and the time the queues are initialized. */
-
+
return 0;
}
@@ -204,12 +203,12 @@ static int tdfx_takedown(drm_device_t *dev)
down(&dev->struct_sem);
del_timer(&dev->timer);
-
+
if (dev->devname) {
drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
dev->devname = NULL;
}
-
+
if (dev->unique) {
drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
dev->unique = NULL;
@@ -228,7 +227,7 @@ static int tdfx_takedown(drm_device_t *dev)
if (dev->agp) {
drm_agp_mem_t *temp;
drm_agp_mem_t *temp_next;
-
+
temp = dev->agp->memory;
while(temp != NULL) {
temp_next = temp->next;
@@ -247,7 +246,7 @@ static int tdfx_takedown(drm_device_t *dev)
}
dev->vmalist = NULL;
}
-
+
/* Clear map area and mtrr information */
if (dev->maplist) {
for (i = 0; i < dev->map_count; i++) {
@@ -285,14 +284,14 @@ static int tdfx_takedown(drm_device_t *dev)
dev->maplist = NULL;
dev->map_count = 0;
}
-
+
if (dev->lock.hw_lock) {
dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.pid = 0;
wake_up_interruptible(&dev->lock.lock_queue);
}
up(&dev->struct_sem);
-
+
return 0;
}
@@ -309,7 +308,7 @@ static int tdfx_init(void)
memset((void *)dev, 0, sizeof(*dev));
dev->count_lock = SPIN_LOCK_UNLOCKED;
sema_init(&dev->struct_sem, 1);
-
+
#ifdef MODULE
drm_parse_options(tdfx);
#endif
@@ -341,7 +340,7 @@ static int tdfx_init(void)
TDFX_PATCHLEVEL,
TDFX_DATE,
tdfx_misc.minor);
-
+
return 0;
}
@@ -352,7 +351,7 @@ static void tdfx_cleanup(void)
drm_device_t *dev = &tdfx_device;
DRM_DEBUG("\n");
-
+
drm_proc_cleanup();
if (misc_deregister(&tdfx_misc)) {
DRM_ERROR("Cannot unload module\n");
@@ -380,17 +379,18 @@ int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
drm_version_t version;
int len;
- copy_from_user_ret(&version,
+ if (copy_from_user(&version,
(drm_version_t *)arg,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
#define DRM_COPY(name,value) \
len = strlen(value); \
if (len > name##_len) len = name##_len; \
name##_len = strlen(value); \
if (len && name) { \
- copy_to_user_ret(name, value, len, -EFAULT); \
+ if (copy_to_user(name, value, len)) \
+ return -EFAULT; \
}
version.version_major = TDFX_MAJOR;
@@ -401,10 +401,10 @@ int tdfx_version(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_COPY(version.date, TDFX_DATE);
DRM_COPY(version.desc, TDFX_DESC);
- copy_to_user_ret((drm_version_t *)arg,
+ if (copy_to_user((drm_version_t *)arg,
&version,
- sizeof(version),
- -EFAULT);
+ sizeof(version)))
+ return -EFAULT;
return 0;
}
@@ -412,7 +412,7 @@ int tdfx_open(struct inode *inode, struct file *filp)
{
drm_device_t *dev = &tdfx_device;
int retcode = 0;
-
+
DRM_DEBUG("open_count = %d\n", dev->open_count);
if (!(retcode = drm_open_helper(inode, filp, dev))) {
#if LINUX_VERSION_CODE < 0x020333
@@ -480,7 +480,7 @@ int tdfx_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->ioctl_count);
atomic_inc(&dev->total_ioctl);
++priv->ioctl_count;
-
+
DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n",
current->pid, cmd, nr, dev->device, priv->authenticated);
@@ -500,7 +500,7 @@ int tdfx_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
retcode = (func)(inode, filp, cmd, arg);
}
}
-
+
atomic_dec(&dev->ioctl_count);
return retcode;
}
@@ -519,7 +519,8 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lck_start = start = get_cycles();
#endif
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
@@ -537,7 +538,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
if (lock.context < 0 || lock.context >= dev->queue_count)
return -EINVAL;
#endif
-
+
if (!ret) {
#if 0
if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
@@ -549,7 +550,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Can't take lock if we just had it and
there is contention. */
DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n",
- lock.context, current->pid, j,
+ lock.context, current->pid, j,
dev->lock.lock_time, jiffies);
current->state = TASK_INTERRUPTIBLE;
current->policy |= SCHED_YIELD;
@@ -560,6 +561,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
+ current->state = TASK_INTERRUPTIBLE;
if (!dev->lock.hw_lock) {
/* Device has been unregistered */
ret = -EINTR;
@@ -572,10 +574,9 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->total_locks);
break; /* Got lock */
}
-
+
/* Contention */
atomic_inc(&dev->total_sleeps);
- current->state = TASK_INTERRUPTIBLE;
#if 1
current->policy |= SCHED_YIELD;
#endif
@@ -616,6 +617,15 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#endif
if (!ret) {
+ sigemptyset(&dev->sigmask);
+ sigaddset(&dev->sigmask, SIGSTOP);
+ sigaddset(&dev->sigmask, SIGTSTP);
+ sigaddset(&dev->sigmask, SIGTTIN);
+ sigaddset(&dev->sigmask, SIGTTOU);
+ dev->sigdata.context = lock.context;
+ dev->sigdata.lock = dev->lock.hw_lock;
+ block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
+
if (lock.flags & _DRM_LOCK_READY) {
/* Wait for space in DMA/FIFO */
}
@@ -638,7 +648,7 @@ int tdfx_lock(struct inode *inode, struct file *filp, unsigned int cmd,
#if DRM_DMA_HISTOGRAM
atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]);
#endif
-
+
return ret;
}
@@ -650,8 +660,9 @@ int tdfx_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
drm_device_t *dev = priv->dev;
drm_lock_t lock;
- copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
-
+ if (copy_from_user(&lock, (drm_lock_t *)arg, sizeof(lock)))
+ return -EFAULT;
+
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
current->pid, lock.context);
@@ -679,6 +690,7 @@ int tdfx_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
current->priority = DEF_PRIORITY;
}
#endif
-
+
+ unblock_all_signals();
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
index 074e75d94..964921b46 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
@@ -28,7 +28,6 @@
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c,v 1.8 2000/08/28 02:43:16 tsi Exp $ */
#define __NO_VERSION__
#include "drmP.h"
@@ -68,8 +67,6 @@ struct page *drm_vm_nopage(struct vm_area_struct *vma,
int write_access)
#endif
{
- DRM_DEBUG("0x%08lx, %d\n", address, write_access);
-
return NOPAGE_SIGBUS; /* Disallow mremap */
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
index b921db386..c933f5935 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
@@ -502,7 +502,8 @@ int drmAddMap(int fd,
map.offset = offset;
#ifdef __alpha__
- if (type != DRM_SHM)
+ /* Make sure we add the bus_base to all but shm */
+ if (type != DRM_SHM)
map.offset += BUS_BASE;
#endif
map.size = size;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile
deleted file mode 100644
index 6b12f3c9c..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile
+++ /dev/null
@@ -1,35 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile,v 3.3 2000/06/27 14:27:30 tsi Exp $
-
-
-
-
-XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:23:58 rws $
-
-#include <Server.tmpl>
-
-#if defined(OsfArchitecture)
-BIOS_MOD = bios_devmem
-#else
-BIOS_MOD = bios_mmap
-#endif
-
-SRCS = mach_init.c mach_video.c mach_io.c $(BIOS_MOD).c \
- VTsw_noop.c kmod_noop.c
-
-OBJS = mach_init.o mach_video.o mach_io.o $(BIOS_MOD).o \
- VTsw_noop.o kmod_noop.o
-
-INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
- -I$(XINCLUDESRC)
-
-SubdirLibraryRule($(OBJS))
-NormalLibraryObjectRule()
-
-#if defined(OsfArchitecture)
-ObjectFromSpecialSource(bios_devmem,../shared/bios_devmem,/**/)
-#endif
-ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
-ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
-
-DependTarget()
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile
deleted file mode 100644
index aca4c717c..000000000
--- a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile
+++ /dev/null
@@ -1,29 +0,0 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile,v 3.6 2000/06/27 14:27:30 tsi Exp $
-
-
-
-
-
-XCOMM $XConsortium: Imakefile /main/5 1996/09/28 17:24:04 rws $
-
-#include <Server.tmpl>
-
-SRCS = mnx_init.c mnx_video.c mnx_io.c bios_devmem.c \
- ioperm_noop.c VTsw_noop.c std_mouse.c posix_tty.c kmod_noop.c
-
-OBJS = mnx_init.o mnx_video.o mnx_io.o bios_devmem.o \
- ioperm_noop.o VTsw_noop.o posix_tty.o kmod_noop.o
-
-INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
- -I$(XINCLUDESRC)
-
-SubdirLibraryRule($(OBJS))
-NormalLibraryObjectRule()
-NormalAsmObjectRule()
-
-ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/)
-ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
-ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/)
-ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
-
-DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
index d5ad7f5fb..6cc9500f1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
@@ -35,7 +35,13 @@
#ifndef _DRM_H_
#define _DRM_H_
+#if defined(__linux__)
#include <asm/ioctl.h> /* For _IO* macros */
+#define DRM_IOCTL_NR(n) _IOC_NR(n)
+#elif defined(__FreeBSD__)
+#include <sys/ioccom.h>
+#define DRM_IOCTL_NR(n) ((n) & 0xff)
+#endif
#define DRM_PROC_DEVICES "/proc/devices"
#define DRM_PROC_MISC "/proc/misc"
@@ -290,7 +296,6 @@ typedef struct drm_agp_info {
} drm_agp_info_t;
#define DRM_IOCTL_BASE 'd'
-#define DRM_IOCTL_NR(n) _IOC_NR(n)
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
index 415434839..563daff13 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
@@ -203,6 +203,31 @@ typedef struct { unsigned int a[100]; } __drm_dummy_lock_t;
"r" (new)); \
} while (0)
+#elif defined(__alpha__)
+
+#define DRM_CAS(lock, old, new, ret) \
+ do { \
+ int old32; \
+ int cur32; \
+ __asm__ __volatile__( \
+ " mb\n" \
+ " zap %4, 0xF0, %0\n" \
+ " ldl_l %1, %2\n" \
+ " zap %1, 0xF0, %1\n" \
+ " cmpeq %0, %1, %1\n" \
+ " beq %1, 1f\n" \
+ " bis %5, %5, %1\n" \
+ " stl_c %1, %2\n" \
+ "1: xor %1, 1, %1\n" \
+ " stl %1, %3" \
+ : "+r" (old32), \
+ "+&r" (cur32), \
+ "=m" (__drm_dummy_lock(lock)),\
+ "=m" (ret) \
+ : "r" (old), \
+ "r" (new)); \
+ } while(0)
+
#elif defined(__sparc__)
#define DRM_CAS(lock,old,new,__ret) \
@@ -261,9 +286,15 @@ do { register unsigned int __old __asm("o0"); \
#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
+#ifdef __alpha__
+#define DRM_CAS_RESULT(_result) int _result
+#else
+#define DRM_CAS_RESULT(_result) char _result
+#endif
+
#define DRM_LIGHT_LOCK(fd,lock,context) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
} while(0)
@@ -272,7 +303,7 @@ do { register unsigned int __old __asm("o0"); \
benchmarking only. */
#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
if (__ret) drmGetLock(fd,context,0); \
else ++count; \
@@ -286,7 +317,7 @@ do { register unsigned int __old __asm("o0"); \
#define DRM_UNLOCK(fd,lock,context) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret); \
if (__ret) drmUnlock(fd,context); \
} while(0)
@@ -294,7 +325,7 @@ do { register unsigned int __old __asm("o0"); \
/* Simple spin locks */
#define DRM_SPINLOCK(spin,val) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
do { \
DRM_CAS(spin,0,val,__ret); \
if (__ret) while ((spin)->lock); \
@@ -303,7 +334,7 @@ do { register unsigned int __old __asm("o0"); \
#define DRM_SPINLOCK_TAKE(spin,val) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
int cur; \
do { \
cur = (*spin).lock; \
@@ -323,7 +354,7 @@ do { register unsigned int __old __asm("o0"); \
#define DRM_SPINUNLOCK(spin,val) \
do { \
- char __ret; \
+ DRM_CAS_RESULT(__ret); \
if ((*spin).lock == val) { /* else server stole lock */ \
do { \
DRM_CAS(spin,val,0,__ret); \
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
index 756a10c38..d5f4cd97a 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.29 2000/09/20 02:05:41 keithp Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.30 2000/09/24 18:28:56 keithp Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -450,6 +450,7 @@ XAAPixmapBPP (ScreenPtr pScreen, int depth)
{
PixmapPtr pPix;
int bpp;
+ DestroyPixmapProcPtr destroyPixmap;
XAA_SCREEN_PROLOGUE (pScreen, CreatePixmap);
pPix = (*pScreen->CreatePixmap) (pScreen, 1, 1, depth);
@@ -457,9 +458,10 @@ XAAPixmapBPP (ScreenPtr pScreen, int depth)
if (!pPix)
return 0;
bpp = pPix->drawable.bitsPerPixel;
+ destroyPixmap = pScreen->DestroyPixmap;
XAA_SCREEN_PROLOGUE (pScreen, DestroyPixmap);
(*pScreen->DestroyPixmap) (pPix);
- XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, XAADestroyPixmap);
+ XAA_SCREEN_EPILOGUE (pScreen, DestroyPixmap, destroyPixmap);
return bpp;
}