summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-12-20 00:28:29 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-12-20 00:28:29 +0000
commita76d8cacebc98a4a0ce8a449c25e01c9c0cd735e (patch)
tree45e84e3b221fc09307c93c50953386322985214b
parentb17551a24da71942e290e5811e44c8b4ee9679c9 (diff)
merge XFree86 RC2 (4.3.99.902) from vendor branchXEVIE-BASE
-rw-r--r--src/via_accel.c31
-rw-r--r--src/via_driver.c37
-rw-r--r--src/via_driver.h15
-rw-r--r--src/via_priv.h44
-rw-r--r--src/via_swov.c382
5 files changed, 125 insertions, 384 deletions
diff --git a/src/via_accel.c b/src/via_accel.c
index e083a66..0774465 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -21,7 +21,8 @@
* 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/drivers/via/via_accel.c,v 1.4 2003/08/04 10:32:27 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/via/via_accel.c,v 1.6 2003/12/17 19:01:59 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_accel.c,v 1.6 2003/12/17 19:01:59 dawes Exp $ */
/*************************************************************************
*
@@ -514,7 +515,32 @@ VIAInitAccel(ScreenPtr pScreen)
AvailFBArea.y1 = 0;
AvailFBArea.x2 = pScrn->displayWidth;
AvailFBArea.y2 = (pVia->FBFreeEnd) / pVia->Bpl;
- xf86InitFBManager(pScreen, &AvailFBArea);
+
+ /*
+ * The pixmap cache must stay within the lowest 2048 lines due
+ * to hardware blitting limits. The rest is available for offscreen
+ * allocations
+ */
+
+ if(AvailFBArea.y2 > 2047)
+ {
+ unsigned long offset = 2048 * pVia->Bpl;
+ unsigned long size = (pVia->FBFreeEnd - offset);
+#ifdef XFREE_44
+ int bpp = (pScrn->bitsPerPixel + 7) / 8;
+#endif
+ AvailFBArea.y2 = 2047;
+ xf86InitFBManager(pScreen, &AvailFBArea);
+#ifdef XFREE_44
+ xf86InitFBManagerLinear(pScreen, offset/bpp, size/bpp);
+#else
+ VIAInitPool(pVia, offset, size);
+#endif
+ }
+ else
+ xf86InitFBManager(pScreen, &AvailFBArea);
+
+
DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Using %d lines for offscreen memory.\n",
AvailFBArea.y2 - pScrn->virtualY ));
@@ -1208,4 +1234,3 @@ static void VIADisableClipping(ScrnInfoPtr pScrn)
pVia->SavedCmd &= ~VIA_GEC_CLIP_ENABLE;
}
-
diff --git a/src/via_driver.c b/src/via_driver.c
index c442134..6575034 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1,4 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.c,v 1.16 2003/10/31 17:19:35 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.c,v 1.17 2003/12/17 18:57:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.c,v 1.17 2003/12/17 18:57:18 dawes Exp $ */
/*
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
@@ -238,6 +239,7 @@ static const char *i2cSymbols[] = {
"xf86CreateI2CDevRec",
"xf86I2CDevInit",
"xf86I2CWriteRead",
+ "xf86I2CProbeAddress",
"xf86DestroyI2CDevRec",
NULL
};
@@ -2173,10 +2175,7 @@ static Bool VIAMapMMIO(ScrnInfoPtr pScrn)
pVia->BltBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
pVia->MmioBase + VIA_MMIO_BLTBASE,
VIA_MMIO_BLTSIZE);
-/*
- pVia->FBFreeStart += 0x300000;
- ErrorF("After 3M FBFreeStart = 0x%x\n",pVia->FBFreeStart);
-*/
+
if (!pVia->MapBase || !pVia->BltBase) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Internal error: cound not map registers\n");
@@ -3192,19 +3191,19 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn)
int i;
if (!pVia->sharedData->b3DRegsInitialized)
- {
+ {
- VIASETREG(0x43C, 0x00010000);
+ VIASETREG(0x43C, 0x00010000);
- for (i = 0; i <= 0x7D; i++)
- {
+ for (i = 0; i <= 0x7D; i++)
+ {
VIASETREG(0x440, (CARD32) i << 24);
}
- VIASETREG(0x43C, 0x00020000);
+ VIASETREG(0x43C, 0x00020000);
- for (i = 0; i <= 0x94; i++)
- {
+ for (i = 0; i <= 0x94; i++)
+ {
VIASETREG(0x440, (CARD32) i << 24);
}
@@ -3213,22 +3212,22 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn)
VIASETREG(0x43C, 0x01020000);
- for (i = 0; i <= 0x94; i++)
- {
+ for (i = 0; i <= 0x94; i++)
+ {
VIASETREG(0x440, (CARD32) i << 24);
}
- VIASETREG(0x440, 0x82400000);
+ VIASETREG(0x440, 0x82400000);
VIASETREG(0x43C, 0xfe020000);
- for (i = 0; i <= 0x03; i++)
- {
+ for (i = 0; i <= 0x03; i++)
+ {
VIASETREG(0x440, (CARD32) i << 24);
}
VIASETREG(0x43C, 0x00030000);
- for (i = 0; i <= 0xff; i++)
+ for (i = 0; i <= 0xff; i++)
{
VIASETREG(0x440, 0);
}
@@ -3258,7 +3257,7 @@ VIAInitialize3DEngine(ScrnInfoPtr pScrn)
pVia->sharedData->b3DRegsInitialized = 1;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "3D Register has been initilized !\n");
+ "3D Engine has been initialized.\n");
}
VIASETREG(0x43C,0x00fe0000);
diff --git a/src/via_driver.h b/src/via_driver.h
index 9bb1a71..54cf348 100644
--- a/src/via_driver.h
+++ b/src/via_driver.h
@@ -1,4 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.7 2003/11/06 18:38:11 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.8 2003/12/17 18:57:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.8 2003/12/17 18:57:18 dawes Exp $ */
/*
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
@@ -26,7 +27,7 @@
#ifndef _VIA_DRIVER_H_
#define _VIA_DRIVER_H_ 1
-/*#define DEBUG_PRINT*/
+/* #define DEBUG_PRINT */
#ifdef DEBUG_PRINT
#define DEBUG(x) x
#else
@@ -220,6 +221,11 @@ typedef struct _VIA {
unsigned char* MapBaseDense;
unsigned char* FBBase;
unsigned char* FBStart;
+
+ /* Private memory pool management */
+ int SWOVUsed[MEM_BLOCKS]; /* Free map for SWOV pool */
+ unsigned long SWOVPool; /* Base of SWOV pool */
+ unsigned long SWOVSize; /* Size of SWOV blocks */
Bool PrimaryVidMapped;
int dacSpeedBpp;
@@ -424,4 +430,9 @@ unsigned long viaOverlayHQVCalcZoomWidth(VIAPtr pVia, unsigned long dwVideoFlag,
void viaOverlayGetV1Format(VIAPtr pVia, unsigned long dwVideoFlag,LPDDPIXELFORMAT lpDPF, unsigned long * lpdwVidCtl,unsigned long * lpdwHQVCtl );
void viaOverlayGetV3Format(VIAPtr pVia, unsigned long dwVideoFlag,LPDDPIXELFORMAT lpDPF, unsigned long * lpdwVidCtl,unsigned long * lpdwHQVCtl );
+/* In via_memory.c */
+void VIAFreeLinear(VIAMemPtr);
+unsigned long VIAAllocLinear(VIAMemPtr, ScrnInfoPtr, unsigned long);
+void VIAInitPool(VIAPtr, unsigned long, unsigned long);
+
#endif /* _VIA_DRIVER_H_ */
diff --git a/src/via_priv.h b/src/via_priv.h
index ee5dfd0..1e8a726 100644
--- a/src/via_priv.h
+++ b/src/via_priv.h
@@ -1,4 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_priv.h,v 1.3 2003/08/27 15:16:12 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/via/via_priv.h,v 1.4 2003/12/17 18:57:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_priv.h,v 1.4 2003/12/17 18:57:18 dawes Exp $ */
#ifndef _VIA_PRIV_H_
#define _VIA_PRIV_H_ 1
@@ -6,34 +7,31 @@
#include "ddmpeg.h"
#include "via_common.h"
+#define MEM_BLOCKS 4
+
+typedef struct {
+ unsigned long base; /* Offset into fb */
+ int pool; /* Pool we drew from */
+ int drm_fd; /* Fd in DRM mode */
+ drmViaMem drm; /* DRM management object */
+ int slot; /* Pool 3 slot */
+ void *pVia; /* VIA driver pointer */
+ FBLinearPtr linear; /* X linear pool info ptr */
+} VIAMem;
+
+typedef VIAMem *VIAMemPtr;
+
+
+
typedef struct {
unsigned long gdwVideoFlagTV1;
unsigned long gdwVideoFlagSW;
unsigned long gdwVideoFlagMPEG;
unsigned long gdwAlphaEnabled; /* For Alpha blending use*/
-#if 0
-/* memory management */
- ViaMMReq SWMemRequest;
- ViaMMReq HQVMemRequest;
-/*ViaMMReq MPEGMemRequest;
- ViaMMReq SUBPMemRequest;*/
-#endif
-
-/* for DRM memory management */
-#ifdef XF86DRI
- drmViaMem MPEGfbRequest;
- drmViaMem SUBPfbRequest;
- drmViaMem HQVfbRequest;
- drmViaMem TV0fbRequest;
- drmViaMem TV1fbRequest;
- drmViaMem ALPHAfbRequest;
- drmViaMem SWfbRequest;
- drmViaMem drm_SWOV_fb;
- drmViaMem drm_HQV_fb;
- int drm_SWOV_fd;
- int drm_HQV_fd;
-#endif
+ VIAMem SWOVMem;
+ VIAMem HQVMem;
+ VIAMem SWfbMem;
DDPIXELFORMAT DPFsrc;
DDUPDATEOVERLAY UpdateOverlayBackup; /* For HQVcontrol func use
diff --git a/src/via_swov.c b/src/via_swov.c
index 30e0c75..1600549 100644
--- a/src/via_swov.c
+++ b/src/via_swov.c
@@ -1,4 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.7 2003/11/06 18:38:11 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.10 2003/12/17 19:01:59 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.10 2003/12/17 19:01:59 dawes Exp $ */
/*
* Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
@@ -23,10 +24,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
@@ -70,12 +67,11 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface
VIAPtr pVia = VIAPTR(pScrn);
unsigned long dwWidth, dwHeight, dwPitch=0;
unsigned long dwRet=PI_OK;
+ unsigned long size;
unsigned long dwAddr;
- unsigned long HQVFBSIZE = 0, SWFBSIZE = 0, SWOVFBSIZE = 0;
+ unsigned long HQVFBSIZE = 0, SWFBSIZE = 0;
int iCount; /* iCount for clean HQV FB use */
unsigned char *lpTmpAddr; /* for clean HQV FB use */
-/* int dwNewHight = 0;*/
- int depth = 0;/*, DisplayWidth32 = 0; */
VIAHWRec *hwDiff = &pVia->ViaHW;
@@ -83,6 +79,8 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface
if ( lpDDSurfaceDesc == NULL )
return PI_ERR;
+
+ ErrorF("Creating %lu surface\n", lpDDSurfaceDesc->dwFourCC);
switch (lpDDSurfaceDesc->dwFourCC)
{
@@ -122,54 +120,11 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface
SWFBSIZE = dwPitch*dwHeight; /*YUYV*/
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Allocate SWOV memory!!\n"));
-
- if((pVia->swov.drm_SWOV_fd = drmOpen("via",NULL)) < 0)
- {
- ErrorF("DRM Device for via could not be opened.\n");
- return BadAccess;
- }
-
- pVia->swov.SWfbRequest.context=1;
- pVia->swov.SWfbRequest.size=SWFBSIZE*2;
- pVia->swov.SWfbRequest.type= VIDEO;
-
- if ( drmCommandWrite( pVia->swov.drm_SWOV_fd, DRM_VIA_ALLOCMEM,
- &pVia->swov.SWfbRequest, sizeof(drmViaMem)) < 0 )
- {
- ErrorF("\n//Cannot allocate SWOV memory use DRM module!\n");
- return -errno;
- }
- dwAddr = pVia->swov.SWfbRequest.offset;
- }
- else
-#endif
- {
-/* dwNewHight = dwHeight<<1;*/
- depth = (pScrn->bitsPerPixel + 7 ) >> 3;
-/* DisplayWidth32 = ALIGN_TO_32_BYTES(pScrn->displayWidth);*/
- SWOVFBSIZE = SWFBSIZE << 1;
-
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- DBG_DD(ErrorF("xfree86 Manager Free Init_SWOVLinear Offscreen Memory Success!!!! \n"));
- }
-
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, SWOVFBSIZE,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
+ VIAFreeLinear(&pVia->swov.SWOVMem);
+ if(VIAAllocLinear(&pVia->swov.SWOVMem, pScrn, SWFBSIZE * 2))
+ return BadAccess;
- dwAddr = pVia->swov.SWOVlinear->offset * depth;
- DBG_DD(ErrorF("SWOV dwAddr = 0x%x!!!! \n",dwAddr));
- }
-
+ dwAddr = pVia->swov.SWOVMem.base;
/* fill in the SW buffer with 0x8000 (YUY2-black color) to clear FB buffer*/
lpTmpAddr = pVia->FBBase + dwAddr;
@@ -208,90 +163,24 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface
dwPitch = pVia->swov.SWDevice.dwPitch;
HQVFBSIZE = dwPitch * dwHeight;
-
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Allocate HQV memory!!\n"));
-
- if((pVia->swov.drm_HQV_fd = drmOpen("via",NULL)) < 0)
- {
- ErrorF("DRM Device for via could not be opened.\n");
- return BadAccess;
- }
- pVia->swov.HQVfbRequest.context=1;
-
- if ( hwDiff->dwThreeHQVBuffer ) /* CLE_C0 */
- pVia->swov.HQVfbRequest.size=HQVFBSIZE*3;
- else
- pVia->swov.HQVfbRequest.size=HQVFBSIZE*2;
-
- pVia->swov.HQVfbRequest.type= VIDEO;
-
- if ( drmCommandWrite( pVia->swov.drm_HQV_fd,
- DRM_VIA_ALLOCMEM,
- &pVia->swov.HQVfbRequest, sizeof(drmViaMem)) < 0 )
- {
- ErrorF("\n//Cannot allocate HQV memory use DRM module!\n");
- return -errno;
- }
- dwAddr = pVia->swov.HQVfbRequest.offset;
- }
+ if(hwDiff->dwThreeHQVBuffer) /* CLE_C0 */
+ size = HQVFBSIZE*3;
else
-#endif
- {
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- DBG_DD(ErrorF("xfree86 Manager Free Init_SWOVLinear Offscreen Memory Success!!!! \n"));
- }
-
- if ( hwDiff->dwThreeHQVBuffer ) /* CLE_C0 */
- {
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, HQVFBSIZE*3,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
- }
- else
- {
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, HQVFBSIZE*2,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
- }
- dwAddr = pVia->swov.SWOVlinear->offset * depth + SWOVFBSIZE;
- DBG_DD(ErrorF("HQV dwAddr = 0x%x!!!! \n",dwAddr));
- }
+ size = HQVFBSIZE*2;
+
+ VIAFreeLinear(&pVia->swov.HQVMem);
+ if(VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size))
+ return BadAccess;
+ dwAddr = pVia->swov.HQVMem.base;
+/* dwAddr = pVia->swov.SWOVlinear->offset * depth + SWOVFBSIZE; */
pVia->swov.overlayRecordV1.dwHQVAddr[0] = dwAddr;
pVia->swov.overlayRecordV1.dwHQVAddr[1] = dwAddr + HQVFBSIZE;
if ( hwDiff->dwThreeHQVBuffer ) /*CLE_C0*/
- {
- pVia->swov.overlayRecordV1.dwHQVAddr[2] = pVia->swov.overlayRecordV1.dwHQVAddr[1] + HQVFBSIZE;
-
- if (pVia->swov.overlayRecordV1.dwHQVAddr[2] + HQVFBSIZE >=
- (unsigned long)pVia->graphicInfo.VideoHeapEnd)
- {
- ErrorF("// :Memory not enough for MPEG with HQV\n");
- return PI_ERR_CANNOT_CREATE_SURFACE;
- }
- }
- else
- {
- if (pVia->swov.overlayRecordV1.dwHQVAddr[1] + HQVFBSIZE >=
- (unsigned long)pVia->graphicInfo.VideoHeapEnd)
- {
- DBG_DD(ErrorF("// :Memory not enough for MPEG with HQV\n"));
- return PI_ERR_CANNOT_CREATE_SURFACE;
- }
- }
-
+ pVia->swov.overlayRecordV1.dwHQVAddr[2] = dwAddr + 2 * HQVFBSIZE;
+
/* fill in the HQV buffer with 0x8000 (YUY2-black color) to clear HQV buffers*/
for(iCount=0;iCount<HQVFBSIZE*2;iCount++)
@@ -363,52 +252,12 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface
SWFBSIZE = dwPitch * dwHeight * 1.5; /* 1.5 bytes per pixel */
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Allocate SWOV memory!!\n"));
- if((pVia->swov.drm_SWOV_fd = drmOpen("via",NULL)) < 0)
- {
- ErrorF("DRM Device for via could not be opened.\n");
- return BadAccess;
- }
-
- pVia->swov.SWfbRequest.context=1;
- pVia->swov.SWfbRequest.size=SWFBSIZE*2;
- pVia->swov.SWfbRequest.type= VIDEO;
-
- if ( drmCommandWrite( pVia->swov.drm_SWOV_fd, DRM_VIA_ALLOCMEM,
- &pVia->swov.SWfbRequest, sizeof(drmViaMem)) <0 )
- {
- ErrorF("\n//Cannot allocate SWOV memory use DRM module!\n");
- return -errno;
- }
-
- dwAddr = pVia->swov.SWfbRequest.offset;
- }
- else
-#endif
- {
- depth = (pScrn->bitsPerPixel + 7 ) >> 3;
- SWOVFBSIZE = SWFBSIZE << 1; /* ( SWOVFBSIZE = SWFBSIZE*2 )*/
-
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- DBG_DD(ErrorF("xfree86 Manager Free Init_SWOVLinear Offscreen Memory Success!!!! \n"));
- }
-
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, SWOVFBSIZE,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
-
- dwAddr = pVia->swov.SWOVlinear->offset * depth;
- DBG_DD(ErrorF("SWOV dwAddr = 0x%x!!!! \n",dwAddr));
- }
-
+ VIAFreeLinear(&pVia->swov.SWfbMem);
+ if(VIAAllocLinear(&pVia->swov.SWfbMem, pScrn, 2 * SWFBSIZE))
+ return BadAccess;
+ dwAddr = pVia->swov.SWfbMem.base;
+
+ DEBUG(ErrorF("dwAddr for SWfbMem is %lu\n", dwAddr));
/* fill in the SW buffer with 0x8000 (YUY2-black color) to clear FB buffer
*/
lpTmpAddr = pVia->FBBase + dwAddr;
@@ -461,90 +310,27 @@ if (!(pVia->swov.gdwVideoFlagSW & SW_USE_HQV))
HQVFBSIZE = dwPitch * dwHeight * 2;
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Allocate HQV memory!!\n"));
-
- if((pVia->swov.drm_HQV_fd = drmOpen("via",NULL)) < 0)
- {
- ErrorF("DRM Device for via could not be opened.\n");
- return BadAccess;
- }
-
- pVia->swov.HQVfbRequest.context=1;
-
- if ( hwDiff->dwThreeHQVBuffer ) /* CLE_C0 */
- pVia->swov.HQVfbRequest.size=HQVFBSIZE*3;
- else
- pVia->swov.HQVfbRequest.size=HQVFBSIZE*2;
-
- pVia->swov.HQVfbRequest.type= VIDEO;
-
- if ( drmCommandWrite( pVia->swov.drm_HQV_fd, DRM_VIA_ALLOCMEM,
- &pVia->swov.HQVfbRequest, sizeof(drmViaMem)) < 0 )
- {
- ErrorF("\n//Cannot allocate HQV memory use DRM module!\n");
- return -errno;
- }
- dwAddr = pVia->swov.HQVfbRequest.offset;
- }
+ if ( hwDiff->dwThreeHQVBuffer ) /* CLE_C0 */
+ size = HQVFBSIZE * 3;
else
-#endif
- {
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- DBG_DD(ErrorF("xfree86 Manager Free Init_SWOVLinear Offscreen Memory Success!!!! \n"));
- }
+ size = HQVFBSIZE * 2;
- if ( hwDiff->dwThreeHQVBuffer ) /* CLE_C0 */
- {
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, HQVFBSIZE*3,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
- }
- else
- {
- if(!(pVia->swov.SWOVlinear = xf86AllocateOffscreenLinear(pScrn->pScreen, HQVFBSIZE*2,
- 32, NULL, NULL, NULL)))
- {
- return BadAlloc;
- }
- }
-
- dwAddr = pVia->swov.SWOVlinear->offset * depth + SWOVFBSIZE;
- DBG_DD(ErrorF("HQV dwAddr = 0x%x!!!! \n",dwAddr));
- }
+ VIAFreeLinear(&pVia->swov.HQVMem);
+ if(VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size))
+ return BadAccess;
+
+ dwAddr = pVia->swov.HQVMem.base;
+ DEBUG(ErrorF("dwAddr for HQV is %lu\n", dwAddr));
+ DBG_DD(ErrorF("HQV dwAddr = 0x%x!!!! \n",dwAddr));
pVia->swov.overlayRecordV1.dwHQVAddr[0] = dwAddr;
pVia->swov.overlayRecordV1.dwHQVAddr[1] = dwAddr + HQVFBSIZE;
if ( hwDiff->dwThreeHQVBuffer ) /*CLE_C0*/
- {
- pVia->swov.overlayRecordV1.dwHQVAddr[2] = pVia->swov.overlayRecordV1.dwHQVAddr[1] + HQVFBSIZE;
-
- if (pVia->swov.overlayRecordV1.dwHQVAddr[2] + HQVFBSIZE >=
- (unsigned long)pVia->graphicInfo.VideoHeapEnd)
- {
- ErrorF("// :Memory not enough for MPEG with HQV\n");
- return PI_ERR_CANNOT_CREATE_SURFACE;
- }
- }
- else
- {
- if (pVia->swov.overlayRecordV1.dwHQVAddr[1] + HQVFBSIZE >=
- (unsigned long)pVia->graphicInfo.VideoHeapEnd)
- {
- DBG_DD(ErrorF("// :Memory not enough for MPEG with HQV\n"));
- return PI_ERR_CANNOT_CREATE_SURFACE;
- }
- }
+ pVia->swov.overlayRecordV1.dwHQVAddr[2] = dwAddr + 2 * HQVFBSIZE;
/* fill in the HQV buffer with 0x8000 (YUY2-black color) to clear HQV buffers
+ * FIXME: Check if should fill 3 on C0
*/
for(iCount=0 ; iCount< HQVFBSIZE*2; iCount++)
{
@@ -612,31 +398,8 @@ unsigned long VIAVidDestroySurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurfa
case FOURCC_YUY2 :
pVia->swov.DPFsrc.dwFlags = 0;
pVia->swov.DPFsrc.dwFourCC = 0;
-
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Free SWOV memory!!\n"));
-
- if ( drmCommandWrite( pVia->swov.drm_SWOV_fd, DRM_VIA_FREEMEM,
- &pVia->swov.SWfbRequest, sizeof(drmViaMem) ) < 0 )
- {
- ErrorF("\n//Cannot free SWOV memory use DRM module!\n");
- return -errno;
- }
- drmClose(pVia->swov.drm_SWOV_fd);
- }
- else
-#endif
- {
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- }
-
- }
-
+
+ VIAFreeLinear(&pVia->swov.SWOVMem);
if (!(pVia->swov.gdwVideoFlagSW & SW_USE_HQV))
{
pVia->swov.gdwVideoFlagSW = 0;
@@ -644,30 +407,7 @@ unsigned long VIAVidDestroySurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurfa
}
case FOURCC_HQVSW :
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Free HQV memory!!\n"));
-
- if ( drmCommandWrite( pVia->swov.drm_HQV_fd, DRM_VIA_FREEMEM,
- &pVia->swov.HQVfbRequest, sizeof(drmViaMem)) <0 )
- {
- ErrorF("\n//Cannot free HQV memory use DRM module!\n");
- return -errno;
- }
- drmClose(pVia->swov.drm_HQV_fd);
- }
- else
-#endif
- {
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- }
-
- }
-
+ VIAFreeLinear(&pVia->swov.HQVMem);
pVia->swov.gdwVideoFlagSW = 0;
/* if (pVia->swov.gdwVideoFlagTV1 != 0)
{
@@ -681,41 +421,9 @@ unsigned long VIAVidDestroySurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurfa
case FOURCC_YV12 :
pVia->swov.DPFsrc.dwFlags = 0;
pVia->swov.DPFsrc.dwFourCC = 0;
-
-#ifdef XF86DRI
- if (pVia->graphicInfo.DRMEnabled)
- {
- DBG_DD(ErrorF("\n//DRM Device : Free SWOV memory!!\n"));
-
- if ( drmCommandWrite( pVia->swov.drm_SWOV_fd, DRM_VIA_FREEMEM,
- &pVia->swov.SWfbRequest, sizeof(drmViaMem)) <0 )
- {
- ErrorF("\n//Cannot free SWOV memory use DRM module!\n");
- return -errno;
- }
- drmClose(pVia->swov.drm_SWOV_fd);
-
- DBG_DD(ErrorF("\n//DRM Device : Free HQV memory!!\n"));
-
- if ( drmCommandWrite( pVia->swov.drm_HQV_fd, DRM_VIA_FREEMEM,
- &pVia->swov.HQVfbRequest, sizeof(drmViaMem)) <0 )
- {
- ErrorF("\n//Cannot free HQV memory use DRM module!\n");
- return -errno;
- }
- drmClose(pVia->swov.drm_HQV_fd);
- }
- else
-#endif
- {
- if(pVia->swov.SWOVlinear)
- {
- xf86FreeOffscreenLinear(pVia->swov.SWOVlinear);
- pVia->swov.SWOVlinear = NULL;
- }
-
- }
-
+
+ VIAFreeLinear(&pVia->swov.SWfbMem);
+ VIAFreeLinear(&pVia->swov.HQVMem);
pVia->swov.gdwVideoFlagSW = 0;
break;
}