From 27f4b11a328477df142798fb881a37cbf7b30fa3 Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Mon, 23 Feb 2004 21:36:29 +0000 Subject: merge most of XFree86 RC3 (4.3.99.903) from vendor branch. bug #214 --- man/via.man | 6 +- src/via.h | 59 +++++++++- src/via_accel.c | 97 ++++++++++------ src/via_bandwidth.c | 4 +- src/via_bios.h | 128 +++++++++++---------- src/via_dri.c | 47 +++++--- src/via_driver.c | 90 +++++++++++---- src/via_driver.h | 129 ++++++++++++++------- src/via_i2c.c | 5 +- src/via_memory.c | 15 ++- src/via_mode.h | 8 +- src/via_swov.c | 26 ++--- src/via_video.c | 314 ++++++++++++++++++++++------------------------------ 13 files changed, 542 insertions(+), 386 deletions(-) diff --git a/man/via.man b/man/via.man index 8f38fa8..6741c98 100644 --- a/man/via.man +++ b/man/via.man @@ -1,4 +1,4 @@ -.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via.man,v 1.3 2003/08/04 10:32:26 eich Exp $ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via.man,v 1.4 2003/12/19 22:00:46 dawes Exp $ .\" shorthand for double quote that works everywhere. .ds q \N'34' .TH VIA __drivermansuffix__ __vendorversion__ @@ -22,8 +22,8 @@ driver supports the VIA CLE266 (CLE3122, CLE3022) chipset video and the VIA KM400/K8M800 VT3204/5/7204/5 video, including 2D acceleration and the Xv video overlay extensions. Flat panel, TV and VGA outputs are supported. .PP -Direct rendering 3D is available for this device only using XFree 4.2 -builds. If you are interested in porting the DRI support to current XFree +Direct rendering 3D is available for this device only using XFree86 4.2 +builds. If you are interested in porting the DRI support to current XFree86 then please see the DRI project on sourceforge.net. .PP .SH CONFIGURATION DETAILS diff --git a/src/via.h b/src/via.h index 9732461..15795f1 100644 --- a/src/via.h +++ b/src/via.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via.h,v 1.4 2003/08/27 15:16:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via.h,v 1.5 2004/01/05 00:34:17 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -575,4 +575,61 @@ #define GEOutW(port, data) *((volatile CARD16 *)(lpGEMMIO + (port))) = (data) #define GEOutD(port, data) *((volatile CARD32 *)(lpGEMMIO + (port))) = (data) +/* + * MPEG 1/2 Slice Engine (at 0xC00 relative to base) + */ + +#define MPG_CONTROL 0x00 +#define MPG_CONTROL_STRUCT 0x03 +#define MPG_CONTROL_STRUCT_TOP 0x01 +#define MPG_CONTROL_STRUCT_BOTTOM 0x02 +#define MPG_CONTROL_STRUCT_FRAME 0x03 + /* Use TOP if interlaced */ +#define MPG_CONTROL_TYPE 0x3C +#define MPG_CONTROL_TYPE_I (0x01 << 2) +#define MPG_CONTROL_TYPE_B (0x02 << 2) +#define MPG_CONTROL_TYPE_P (0x03 << 3) +#define MPG_CONTROL_ALTSCAN 0x40 +#define MPG_BLOCK 0x08 /* Unsure */ +#define MPG_COMMAND 0x0C +#define MPG_DATA1 0x10 +#define MPG_DATA2 0x14 +#define MPG_DATA3 0x18 +#define MPG_DATA4 0x1C + +#define MPG_YPHYSICAL(x) (0x20 + 12*(x)) +#define MPG_CbPHYSICAL(x) (0x24 + 12*(x)) +#define MPG_CrPHYSICAL(x) (0x28 + 12*(x)) + +#define MPG_PITCH 0x50 +#define MPG_STATUS 0x54 + +#define MPG_MATRIX_IDX 0x5C +#define MPG_MATRIX_IDX_INTRA 0x00 +#define MPG_MATRIX_IDX_NON 0x01 +#define MPG_MATRIX_DATA 0x60 + +#define MPG_SLICE_CTRL_1 0x90 +#define MPG_SLICE_MBAMAX 0x2FFF +#define MPG_SLICE_PREDICTIVE_DCT 0x4000 +#define MPG_SLICE_TOP_FIRST 0x8000 +#define MPG_SLICE_MACROBLOCK_WIDTH(x) ((x)<<18) /* in 64's */ +#define MPG_SLICE_CTRL_2 0x94 +#define MPG_SLICE_CONCEAL_MVEC 0x0000001 +#define MPG_SLICE_QSCALE_TYPE 0x0000002 +#define MPG_SLICE_DCPRECISION 0x000000C +#define MPG_SLICE_MACROBQUOT 0x0FFFFF0 +#define MPG_SLICE_INTRAVLC 0x1000000 +#define MPG_SLICE_CTRL_3 0x98 +#define MPG_SLICE_FHMVR 0x0000003 +#define MPG_SLICE_FVMVR 0x000000C +#define MPG_SLICE_BHMVR 0x0000030 +#define MPG_SLICE_BVMVR 0x00000C0 +#define MPG_SLICE_SECOND_FIELD 0x0100000 +#define MPG_SLICE_RESET 0x0400000 +#define MPG_SLICE_LENGTH 0x9C +#define MPG_SLICE_DATA 0xA0 + + + #endif /* _VIA_H_ */ diff --git a/src/via_accel.c b/src/via_accel.c index 0774465..e39f087 100644 --- a/src/via_accel.c +++ b/src/via_accel.c @@ -21,8 +21,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -/* $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 $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_accel.c,v 1.11 2004/01/29 03:13:24 dawes Exp $ */ /************************************************************************* * @@ -347,7 +346,9 @@ VIAInitAccel(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); XAAInfoRecPtr xaaptr; - BoxRec AvailFBArea; + BoxRec AvailFBArea; + unsigned long cacheEnd; + unsigned long cacheEndDRI; pVia->VQStart = 0; if (((pVia->FBFreeEnd - pVia->FBFreeStart) >= VIA_VQ_SIZE) && @@ -393,8 +394,8 @@ VIAInitAccel(ScreenPtr pScreen) xaaptr->SetClippingRectangle = VIASetClippingRectangle; xaaptr->DisableClipping = VIADisableClipping; xaaptr->ClippingFlags = HARDWARE_CLIP_SOLID_FILL | - /*HARDWARE_CLIP_SOLID_LINE |*/ - /*HARDWARE_CLIP_DASHED_LINE |*/ + HARDWARE_CLIP_SOLID_LINE | + HARDWARE_CLIP_DASHED_LINE | HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | HARDWARE_CLIP_MONO_8x8_FILL | HARDWARE_CLIP_COLOR_8x8_FILL | @@ -419,7 +420,6 @@ VIAInitAccel(ScreenPtr pScreen) VIASubsequentMono8x8PatternFillRect; xaaptr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | ROP_NEEDS_SOURCE | BIT_ORDER_IN_BYTE_MSBFIRST | 0; @@ -431,7 +431,6 @@ VIAInitAccel(ScreenPtr pScreen) xaaptr->Color8x8PatternFillFlags = NO_PLANEMASK | NO_TRANSPARENCY | HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | ROP_NEEDS_SOURCE | 0; @@ -498,49 +497,55 @@ VIAInitAccel(ScreenPtr pScreen) xaaptr->ImageWriteRange = VIA_MMIO_BLTSIZE; /* We reserve space for pixel cache */ - pVia->ScissB = (pVia->FBFreeStart + VIA_PIXMAP_CACHE_SIZE) / pVia->Bpl; - pVia->FBFreeStart += VIA_PIXMAP_CACHE_SIZE; + + cacheEnd = pVia->FBFreeEnd / pVia->Bpl; + cacheEndDRI = (pVia->FBFreeStart + VIA_PIXMAP_CACHE_SIZE + pVia->Bpl-1) / pVia->Bpl; + + /* + * Old DRI has some assumptions here that we need to work through + * and fix + * UPDATE: These assumptions are that pVia->FBFreestart should + * point to a free region in the framebuffer where it can place it's + * allocator. + */ + if(cacheEnd > cacheEndDRI) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Clipping pixmap cache for old DRI/DRM module.\n"); + cacheEnd = cacheEndDRI; + } + + /* + * Clip to the blitter limit + */ + pVia->ScissB = cacheEnd;; if (pVia->ScissB > 2047) pVia->ScissB = 2047; + /* + * The free start IS where the cache Ends. We should not add here. + */ + + pVia->FBFreeStart = (pVia->ScissB + 1) *pVia->Bpl; + /* * Finally, we set up the video memory space available to the pixmap - * cache. In this case, all memory from the end of the virtual screen - * to the end of the command overflow buffer can be used. If you haven't - * enabled the PIXMAP_CACHE flag, then these lines can be omitted. + * cache */ AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; - AvailFBArea.y2 = (pVia->FBFreeEnd) / pVia->Bpl; + AvailFBArea.y2 = pVia->ScissB; /* * The pixmap cache must stay within the lowest 2048 lines due * to hardware blitting limits. The rest is available for offscreen - * allocations + * allocations unless DRI stole it. */ - 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); - - + xf86InitFBManager(pScreen, &AvailFBArea); DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %d lines for offscreen memory.\n", AvailFBArea.y2 - pScrn->virtualY )); @@ -548,6 +553,32 @@ VIAInitAccel(ScreenPtr pScreen) return XAAInit(pScreen, xaaptr); } +void VIAInitLinear(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VIAPtr pVia = VIAPTR(pScrn); +#ifdef XFREE86_44 + /* + * In the 44 path we must take care not to truncate offset and size so + * that we get overlaps. If there is available memory below line 2048 + * we use it. + */ + unsigned long offset = (pVia->FBFreeStart + pVia->Bpp - 1 ) / pVia->Bpp; + unsigned long size = pVia->FBFreeEnd / pVia->Bpp - offset; + if (size > 0) xf86InitFBManagerLinear(pScreen, offset, size); +#else + /* + * In the 43 path we don't have to care about truncation. just use + * all available memory, also below line 2048. The drm module uses + * pVia->FBFreeStart as offscreen available start. We do it to. + */ + unsigned long offset = pVia->FBFreeStart; + unsigned long size = pVia->FBFreeEnd - offset; + if (size > 0 ) VIAInitPool(pVia, offset, size); +#endif +} + + /* The sync function for the GE */ void VIAAccelSync(ScrnInfoPtr pScrn) diff --git a/src/via_bandwidth.c b/src/via_bandwidth.c index 7720bdc..3bd24e4 100644 --- a/src/via_bandwidth.c +++ b/src/via_bandwidth.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_bandwidth.c,v 1.2 2003/08/27 15:16:06 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_bandwidth.c,v 1.3 2004/01/05 00:34:17 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -75,7 +75,7 @@ void VIAEnabledPrimaryExtendedFIFO(VIABIOSInfoPtr pBIOSInfo) VGAOUT8(0x3C5, bRegTemp); } } - else /* Single view or Simultaneoue case */ + else /* Single view or Simultaneous case */ { if (pBIOSInfo->HDisplay > 1024) { diff --git a/src/via_bios.h b/src/via_bios.h index deb10cb..ce62874 100644 --- a/src/via_bios.h +++ b/src/via_bios.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_bios.h,v 1.3 2003/08/27 15:16:07 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_bios.h,v 1.4 2003/12/31 05:42:04 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -26,18 +26,18 @@ #ifndef _VIA_BIOS_H_ #define _VIA_BIOS_H_ 1 -#define VIA_CRT_SUPPORT TRUE -#define VIA_LCD_SUPPORT TRUE -#define VIA_UNCOVERD_LCD_PANEL FALSE -#define VIA_NTSC_SUPPORT TRUE -#define VIA_PAL_SUPPORT TRUE -#define VIA_DVI_SUPPORT TRUE +#define VIA_CRT_SUPPORT TRUE +#define VIA_LCD_SUPPORT TRUE +#define VIA_UNCOVERD_LCD_PANEL FALSE +#define VIA_NTSC_SUPPORT TRUE +#define VIA_PAL_SUPPORT TRUE +#define VIA_DVI_SUPPORT TRUE -#define VIA_CRT_SUPPORT_BIT 0x01 -#define VIA_LCD_SUPPORT_BIT 0x02 -#define VIA_NTSC_SUPPORT_BIT 0x04 -#define VIA_PAL_SUPPORT_BIT 0x08 -#define VIA_DVI_SUPPORT_BIT 0x20 +#define VIA_CRT_SUPPORT_BIT 0x01 +#define VIA_LCD_SUPPORT_BIT 0x02 +#define VIA_NTSC_SUPPORT_BIT 0x04 +#define VIA_PAL_SUPPORT_BIT 0x08 +#define VIA_DVI_SUPPORT_BIT 0x20 #define VIA_BIOS_REG_TABLE_MAX_NUM 32 #define VIA_BIOS_REG_LCD_MAX_NUM 48 @@ -51,16 +51,16 @@ #define VIA_BIOS_MAX_NUM_CTREXP 5 #define VIA_BIOS_MAX_NUM_TV_REG 144 /* 00 - 8F, tv2,tv3,ch7019 are the same */ #define VIA_BIOS_MAX_NUM_SAA7108_TV_REG 176 /* 00 - AF */ -#define VIA_BIOS_NUM_FS454_TV_REG 32 /* Nums of TV Register in setmode needs */ +#define VIA_BIOS_NUM_FS454_TV_REG 32 /* Nums of TV Register in setmode needs */ #define VIA_BIOS_MAX_NUM_TV_CRTC 32 #define VIA_BIOS_NUM_TV_SPECIAL_REG 8 #define VIA_BIOS_MAX_NUM_TV_PATCH 8 #define VIA_BIOS_NUM_TV_OTHER 16 #define VIA_BIOS_NUM_TV2 2 #define VIA_BIOS_NUM_TV3 6 -#define VIA_BIOS_NUM_SAA7108 4 -#define VIA_BIOS_NUM_CH7019 3 -#define VIA_BIOS_NUM_FS454 5 +#define VIA_BIOS_NUM_SAA7108 4 +#define VIA_BIOS_NUM_CH7019 3 +#define VIA_BIOS_NUM_FS454 5 /* The position of some BIOS information from start of BIOS */ @@ -104,7 +104,7 @@ #define VIA_RES_720X576 13 #define VIA_RES_1024X512 14 #define VIA_RES_856X480 15 -#define VIA_RES_1024X576 16 +#define VIA_RES_1024X576 16 #define VIA_RES_INVALID 255 #define VIA_TVRES_640X480 0 @@ -168,24 +168,24 @@ #define VIA_TV_NUM_HSCALE_LEVEL 8 #define VIA_TV_NUM_HSCALE_REG 16 -#define VIA_DEVICE_CRT1 0x01 -#define VIA_DEVICE_LCD 0x02 -#define VIA_DEVICE_TV 0x04 -#define VIA_DEVICE_DFP 0x08 -#define VIA_DEVICE_CRT2 0x10 +#define VIA_DEVICE_CRT1 0x01 +#define VIA_DEVICE_LCD 0x02 +#define VIA_DEVICE_TV 0x04 +#define VIA_DEVICE_DFP 0x08 +#define VIA_DEVICE_CRT2 0x10 /* System Memory CLK */ -#define VIA_MEM_SDR66 0x00 -#define VIA_MEM_SDR100 0x01 -#define VIA_MEM_SDR133 0x02 -#define VIA_MEM_DDR200 0x03 -#define VIA_MEM_DDR266 0x04 -#define VIA_MEM_DDR333 0x05 -#define VIA_MEM_DDR400 0x06 +#define VIA_MEM_SDR66 0x00 +#define VIA_MEM_SDR100 0x01 +#define VIA_MEM_SDR133 0x02 +#define VIA_MEM_DDR200 0x03 +#define VIA_MEM_DDR266 0x04 +#define VIA_MEM_DDR333 0x05 +#define VIA_MEM_DDR400 0x06 /* Digital Output Bus Width */ -#define VIA_DI_12BIT 0x00 -#define VIA_DI_24BIT 0x01 +#define VIA_DI_12BIT 0x00 +#define VIA_DI_24BIT 0x01 #define CAP_WEAVE 0x0 #define CAP_BOB 0x1 @@ -473,36 +473,35 @@ typedef struct _VIAVMODETABLE { VIABIOSTV3TableRec tv3OverTable[VIA_BIOS_NUM_TV3]; VIABIOSTV3TableRec vt1622aTable[VIA_BIOS_NUM_TV3]; VIABIOSTV3TableRec vt1622aOverTable[VIA_BIOS_NUM_TV3]; - VIABIOSSAA7108TableRec saa7108Table[VIA_BIOS_NUM_SAA7108]; - VIABIOSSAA7108TableRec saa7108OverTable[VIA_BIOS_NUM_SAA7108]; - VIABIOSCH7019TableRec ch7019Table[VIA_BIOS_NUM_CH7019]; - VIABIOSCH7019TableRec ch7019OverTable[VIA_BIOS_NUM_CH7019]; - VIABIOSFS454TableRec fs454Table[VIA_BIOS_NUM_FS454]; - VIABIOSFS454TableRec fs454OverTable[VIA_BIOS_NUM_FS454]; + VIABIOSSAA7108TableRec saa7108Table[VIA_BIOS_NUM_SAA7108]; + VIABIOSSAA7108TableRec saa7108OverTable[VIA_BIOS_NUM_SAA7108]; + VIABIOSCH7019TableRec ch7019Table[VIA_BIOS_NUM_CH7019]; + VIABIOSCH7019TableRec ch7019OverTable[VIA_BIOS_NUM_CH7019]; + VIABIOSFS454TableRec fs454Table[VIA_BIOS_NUM_FS454]; + VIABIOSFS454TableRec fs454OverTable[VIA_BIOS_NUM_FS454]; } VIAModeTableRec, *VIAModeTablePtr; -typedef struct _UTUSERSETTING +typedef struct _VIAUserSettingRec { Bool DefaultSetting; - Bool ADAPTIVE_FFILTER_ON; - unsigned long UT_TV_VPOSITION; - unsigned long UT_TV_HPOSITION; - unsigned long UT_TV_FFILTER; - unsigned long UT_TV_ADAPTIVE_FFILTER; - unsigned long UT_TV_BRIGHTNESS; - unsigned long UT_TV_CONTRAST; - unsigned long UT_TV_SATURATION; - unsigned long UT_TV_TINT; -} UTUSERSETTING, *UTUSERSETTINGptr; + Bool AdaptiveFilterOn; + unsigned long tvVPosition; + unsigned long tvHPosition; + unsigned long tvFFilter; + unsigned long tvAdaptiveFFilter; + unsigned long tvBrightness; + unsigned long tvContrast; + unsigned long tvSaturation; + unsigned long tvTint; +} VIAUserSettingRec, *VIAUserSettingPtr; typedef struct _VIABIOSINFO { - VIAModeTablePtr pModeTable; int Chipset; int ChipRev; - unsigned char TMDS; - unsigned char LVDS; + unsigned char TMDS; + unsigned char LVDS; /*int DVIEncoder;*/ int TVEncoder; int BIOSTVTabVer; @@ -511,32 +510,32 @@ typedef struct _VIABIOSINFO { Bool FirstInit; unsigned char* FBBase; unsigned long videoRambytes; - unsigned char MemClk; + unsigned char MemClk; int scrnIndex; unsigned int mode, refresh, resMode; int countWidthByQWord; int offsetWidthByQWord; - unsigned char ConnectedDevice; - unsigned char ActiveDevice; - unsigned char DefaultActiveDevice; + unsigned char ConnectedDevice; + unsigned char ActiveDevice; + unsigned char DefaultActiveDevice; /* Here are all the BIOS Relative Options */ int BIOSMajorVersion; int BIOSMinorVersion; - unsigned char BIOSDateYear; - unsigned char BIOSDateMonth; - unsigned char BIOSDateDay; + unsigned char BIOSDateYear; + unsigned char BIOSDateMonth; + unsigned char BIOSDateDay; Bool A2; Bool UseBIOS; - Bool LCDDualEdge; /* mean add-on card is 2CH or Dual or DDR */ + Bool LCDDualEdge; /* mean add-on card is 2CH or Dual or DDR */ Bool DVIAttach; Bool LCDAttach; Bool Center; Bool TVAttach; Bool TVDotCrawl; - unsigned char BusWidth; /* Digital Output Bus Width */ + unsigned char BusWidth; /* Digital Output Bus Width */ int PanelSize; int TVType; int TVOutput; @@ -581,21 +580,20 @@ typedef struct _VIABIOSINFO { xf86MonPtr DDC2; I2CDevPtr dev; - unsigned int resTVMode; - unsigned char TVI2CAdd; + unsigned int resTVMode; + unsigned char TVI2CAdd; unsigned char TVRegs[0xFF]; /* MHS */ - Bool SAMM; /* SAMM success or not? */ + Bool SAMM; /* SAMM success or not? */ Bool IsSecondary; Bool HasSecondary; Bool SetTV; Bool SetDVI; /* Utility User Setting */ - UTUSERSETTINGptr pUTUSERSETTING; + VIAUserSettingPtr UserSetting; LOCO colors[256]; /* Gamma value. LOCO typedef in colormapst.h */ - } VIABIOSInfoRec, *VIABIOSInfoPtr; /* Functions protype */ diff --git a/src/via_dri.c b/src/via_dri.c index ce5dade..0ea0eb7 100644 --- a/src/via_dri.c +++ b/src/via_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_dri.c,v 1.4 2003/09/24 02:43:30 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_dri.c,v 1.9 2004/02/08 17:57:10 tsi Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -82,7 +82,7 @@ static void VIADRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, static Bool VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia) { unsigned long agp_phys; - unsigned int agpaddr; + drmAddress agpaddr; VIADRIPtr pVIADRI; DRIInfoPtr pDRIInfo; pDRIInfo = pVia->pDRIInfo; @@ -129,11 +129,14 @@ static Bool VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia) xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] Failed to map public agp area\n"); pVIADRI->agp.size = 0; - return FALSE; + drmAgpUnbind(pVia->drmFD, pVia->agpHandle); + drmAgpFree(pVia->drmFD, pVia->agpHandle); + drmAgpRelease(pVia->drmFD); + return FALSE; } /* Map AGP from kernel to Xserver - Not really needed */ - drmMap(pVia->drmFD, pVIADRI->agp.handle,pVIADRI->agp.size, - (drmAddressPtr)&agpaddr); + drmMap(pVia->drmFD, pVIADRI->agp.handle, pVIADRI->agp.size, &agpaddr); + pVia->agpMappedAddr = agpaddr; xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] agpBase = %p\n", pVia->agpBase); @@ -149,8 +152,14 @@ static Bool VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia) agp.offset = 0; agp.size = AGP_SIZE; if (drmCommandWrite(pVia->drmFD, DRM_VIA_AGP_INIT, &agp, - sizeof(drmViaAgp)) < 0) + sizeof(drmViaAgp)) < 0) { + drmUnmap(agpaddr,pVia->agpSize); + drmRmMap(pVia->drmFD,pVIADRI->agp.handle); + drmAgpUnbind(pVia->drmFD, pVia->agpHandle); + drmAgpFree(pVia->drmFD, pVia->agpHandle); + drmAgpRelease(pVia->drmFD); return FALSE; + } } return TRUE; @@ -462,8 +471,18 @@ VIADRICloseScreen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; VIAPtr pVia = VIAPTR(pScrn); - DRICloseScreen(pScreen); + if (pVia->agpSize) { + drmUnmap(pVia->agpMappedAddr,pVia->agpSize); + drmRmMap(pVia->drmFD,pVia->agpHandle); + drmAgpUnbind(pVia->drmFD, pVia->agpHandle); + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing agp memory\n"); + drmAgpFree(pVia->drmFD, pVia->agpHandle); + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing agp module\n"); + drmAgpRelease(pVia->drmFD); + } + DRICloseScreen(pScreen); + if (pVia->pDRIInfo) { if (pVia->pDRIInfo->devPrivate) { xfree(pVia->pDRIInfo->devPrivate); @@ -473,13 +492,13 @@ VIADRICloseScreen(ScreenPtr pScreen) pVia->pDRIInfo=0; } - if (pVia->pVisualConfigs) xfree(pVia->pVisualConfigs); - if (pVia->pVisualConfigsPriv) xfree(pVia->pVisualConfigsPriv); - if (pVia->agpSize) { - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing agp memory\n"); - drmAgpFree(pVia->drmFD, pVia->agpHandle); - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing agp module\n"); - drmAgpRelease(pVia->drmFD); + if (pVia->pVisualConfigs) { + xfree(pVia->pVisualConfigs); + pVia->pVisualConfigs = NULL; + } + if (pVia->pVisualConfigsPriv) { + xfree(pVia->pVisualConfigsPriv); + pVia->pVisualConfigsPriv = NULL; } } diff --git a/src/via_driver.c b/src/via_driver.c index 6575034..ef4557c 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -1,5 +1,4 @@ -/* $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 $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.c,v 1.28 2004/02/08 17:57:10 tsi Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -82,7 +81,6 @@ static void VIADisableMMIO(ScrnInfoPtr pScrn); static Bool VIAMapMMIO(ScrnInfoPtr pScrn); static Bool VIAMapFB(ScrnInfoPtr pScrn); static void VIAUnmapMem(ScrnInfoPtr pScrn); -static int VIAGetMemSize(void); Bool VIADeviceSelection(ScrnInfoPtr pScrn); Bool VIADeviceDispatch(ScrnInfoPtr pScrn); @@ -448,6 +446,8 @@ static Bool VIAGetRec(ScrnInfoPtr pScrn) pScrn->driverPrivate = xnfcalloc(sizeof(VIARec), 1); ((VIARec *)(pScrn->driverPrivate))->pBIOSInfo = xnfcalloc(sizeof(VIABIOSInfoRec), 1); + ((VIARec *)(pScrn->driverPrivate))->pBIOSInfo->UserSetting = + xnfcalloc(sizeof(VIAUserSettingRec), 1); ((VIARec *)(pScrn->driverPrivate))->pBIOSInfo->pModeTable = xnfcalloc(sizeof(VIAModeTableRec), 1); @@ -469,7 +469,9 @@ static void VIAFreeRec(ScrnInfoPtr pScrn) return; xfree(((VIARec *)(pScrn->driverPrivate))->pBIOSInfo->pModeTable); + xfree(((VIARec *)(pScrn->driverPrivate))->pBIOSInfo->UserSetting); xfree(((VIARec *)(pScrn->driverPrivate))->pBIOSInfo); + ViaTunerDestroy(pScrn); xfree(pScrn->driverPrivate); pScrn->driverPrivate = NULL; @@ -535,7 +537,7 @@ static Bool VIAProbe(DriverPtr drv, int flags) { pScrn->driverVersion = VIA_VERSION; pScrn->driverName = DRIVER_NAME; - pScrn->name = DRIVER_NAME; + pScrn->name = "VIA"; pScrn->Probe = VIAProbe; pScrn->PreInit = VIAPreInit; pScrn->ScreenInit = VIAScreenInit; @@ -1359,7 +1361,10 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) pScrn->videoRam = bMemSize << 6; } else { - VGAOUT8(0x3C4, 0x34); /* Was 0x39 */ + if(pVia->Chipset == VIA_CLE266) + VGAOUT8(0x3C4, 0x34); + else + VGAOUT8(0x3C4, 0x39); bMemSize = VGAIN8(0x3c5); if (bMemSize > 16 && bMemSize <= 128) { pScrn->videoRam = (bMemSize + 1) << 9; @@ -1370,7 +1375,7 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags) else { DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "bMemSize = %d\nGet Video Memory Size by default.\n", bMemSize)); - pScrn->videoRam = VIAGetMemSize(); + pScrn->videoRam = 16 << 10; /* Assume the base 16Mb */ } } } @@ -2204,6 +2209,24 @@ static Bool VIAMapFB(ScrnInfoPtr pScrn) pVia->FrameBufferBase, pVia->videoRambytes); if (pVia->videoRambytes) { + + /* + * FIXME: This is a hack to get rid of offending wrongly sized + * MTRR regions set up by the VIA BIOS. Should be taken care of + * in the OS support layer. + */ + + unsigned char *tmp; + tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, + pVia->PciTag, pVia->FrameBufferBase, + pVia->videoRambytes); + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp, + pVia->videoRambytes); + + /* + * End of hack. + */ + pVia->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, pVia->PciTag, pVia->FrameBufferBase, pVia->videoRambytes); @@ -2344,8 +2367,33 @@ static Bool VIAScreenInit(int scrnIndex, ScreenPtr pScreen, fbPictureInit(pScreen, 0, 0); #endif - if (!pVia->NoAccel) + if (!pVia->NoAccel) { VIAInitAccel(pScreen); + } +#ifdef XFREE86_44 + else { + /* + * This is needed because xf86InitFBManagerLinear in VIAInitLinear + * needs xf86InitFBManager to have been initialized, and + * xf86InitFBManager needs at least one line of free memory to + * work. This is only for Xv in Noaccel part, and since Xv is in some + * sense accelerated, it might be a better idea to disable it + * altogether. + */ + BoxRec AvailFBArea; + + AvailFBArea.x1 = 0; + AvailFBArea.y1 = 0; + AvailFBArea.x2 = pScrn->displayWidth; + AvailFBArea.y2 = pScrn->virtualY + 1; + /* + * Update FBFreeStart also for other memory managers, since + * we steal one line to make xf86InitFBManager work. + */ + pVia->FBFreeStart = (AvailFBArea.y2 + 1) * pVia->Bpl; + xf86InitFBManager(pScreen, &AvailFBArea); + } +#endif miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); @@ -2424,16 +2472,17 @@ static Bool VIAScreenInit(int scrnIndex, ScreenPtr pScreen, else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } + if (!pVia->directRenderingEnabled) + VIAInitLinear(pScreen); +#else + VIAInitLinear(pScreen); #endif - if (VIA_SERIES(pVia->Chipset) && !pVia->IsSecondary) { + + if (!pVia->IsSecondary) { + /* The chipset is checked in viaInitVideo */ viaFillGraphicInfo(pScrn); - /* There is alas not enough bandwidth to do 1600x1200x16 with video overlay */ -/* if(pScrn->bitsPerPixel * pScrn->virtualX *pScrn->virtualY <= 1400 * 1050 * 16) */ - viaInitVideo(pScreen); -/* else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "video overlay disabled (%dx%d@%d exceeds bandwidth)\n", - pScrn->virtualX, pScrn->virtualY, pScrn->bitsPerPixel);*/ + viaInitVideo(pScreen); } if (serverGeneration == 1) @@ -2663,6 +2712,11 @@ static Bool VIACloseScreen(int scrnIndex, ScreenPtr pScreen) VIASETREG(0x440, 0x00000004); } } +#ifdef XF86DRI + if (pVia->directRenderingEnabled) { + VIADRICloseScreen(pScreen); + } +#endif if (pVia->AccelInfoRec) { XAADestroyInfoRec(pVia->AccelInfoRec); pVia->AccelInfoRec = NULL; @@ -3086,14 +3140,6 @@ static void VIADPMS(ScrnInfoPtr pScrn, int mode, int flags) } -int VIAGetMemSize() -{ - /* TODO: Do memory sizing */ - - /* Default 16MB */ - return (16 << 10); -} - /* Active Device according connected status */ Bool VIADeviceSelection(ScrnInfoPtr pScrn) { diff --git a/src/via_driver.h b/src/via_driver.h index 54cf348..929ca35 100644 --- a/src/via_driver.h +++ b/src/via_driver.h @@ -1,5 +1,4 @@ -/* $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 $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.13 2004/02/08 17:57:10 tsi Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -80,6 +79,12 @@ #define PATCHLEVEL 30 #define VIA_VERSION ((VERSION_MAJOR<<24) | (VERSION_MINOR<<16) | PATCHLEVEL) +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,14,0) +#undef XFREE86_44 +#else +#define XFREE86_44 1 +#endif + #define VGAIN8(addr) MMIO_IN8(pVia->MapBase+0x8000, addr) #define VGAIN16(addr) MMIO_IN16(pVia->MapBase+0x8000, addr) #define VGAIN(addr) MMIO_IN32(pVia->MapBase+0x8000, addr) @@ -156,36 +161,51 @@ typedef struct __viaVideoControl { typedef struct __VIAHWRec { - unsigned long dwThreeHQVBuffer; /*Use Three HQV Buffers*/ - unsigned long dwV3SrcHeightSetting; /*Set Video Source Width and Height*/ - unsigned long dwSupportExtendFIFO; /*Support Extand FIFO*/ - unsigned long dwHQVFetchByteUnit; /*HQV Fetch Count unit is byte*/ - unsigned long dwHQVInitPatch; /*Initialize HQV Engine 2 times*/ - unsigned long dwSupportV3Gamma; /*Support V3 Gamma */ - unsigned long dwUpdFlip; /*Set HQV3D0[15] to flip video*/ - unsigned long dwHQVDisablePatch; /*Change Video Engine Clock setting for HQV disable bug*/ - unsigned long dwSUBFlip; /*Set HQV3D0[15] to flip video for sub-picture blending*/ - unsigned long dwNeedV3Prefetch; /*V3 pre-fetch function for K8*/ - unsigned long dwNeedV4Prefetch; /*V4 pre-fetch function for K8*/ - unsigned long dwUseSystemMemory; /*Use system memory for DXVA compressed data buffers*/ - unsigned long dwExpandVerPatch; /*Patch video HW bug in expand SIM mode or same display path*/ - unsigned long dwExpandVerHorPatch; /*Patch video HW bug in expand SAMM mode or same display path*/ - unsigned long dwV3ExpireNumTune; /*Change V3 expire number setting for V3 bandwidth issue*/ - unsigned long dwV3FIFOThresholdTune; /*Change V3 FIFO, Threshold and Pre-threshold setting for V3 bandwidth issue*/ - unsigned long dwCheckHQVFIFOEmpty; /*HW Flip path, need to check HQV FIFO status */ - unsigned long dwUseMPEGAGP; /*Use MPEG AGP function*/ - unsigned long dwV3FIFOPatch; /*For CLE V3 FIFO Bug (srcWidth <= 8)*/ - unsigned long dwSupportTwoColorKey; /*Support two color key*/ - unsigned long dwCxColorSpace; /*CLE_Cx ColorSpace*/ + unsigned long dwThreeHQVBuffer; /* Use Three HQV Buffers*/ + unsigned long dwV3SrcHeightSetting; /* Set Video Source Width and Height*/ + unsigned long dwSupportExtendFIFO; /* Support Extand FIFO*/ + unsigned long dwHQVFetchByteUnit; /* HQV Fetch Count unit is byte*/ + unsigned long dwHQVInitPatch; /* Initialize HQV Engine 2 times*/ + unsigned long dwSupportV3Gamma; /* Support V3 Gamma */ + unsigned long dwUpdFlip; /* Set HQV3D0[15] to flip video*/ + unsigned long dwHQVDisablePatch; /* Change Video Engine Clock setting for HQV disable bug*/ + unsigned long dwSUBFlip; /* Set HQV3D0[15] to flip video for sub-picture blending*/ + unsigned long dwNeedV3Prefetch; /* V3 pre-fetch function for K8*/ + unsigned long dwNeedV4Prefetch; /* V4 pre-fetch function for K8*/ + unsigned long dwUseSystemMemory; /* Use system memory for DXVA compressed data buffers*/ + unsigned long dwExpandVerPatch; /* Patch video HW bug in expand SIM mode or same display path*/ + unsigned long dwExpandVerHorPatch; /* Patch video HW bug in expand SAMM mode or same display path*/ + unsigned long dwV3ExpireNumTune; /* Change V3 expire number setting for V3 bandwidth issue*/ + unsigned long dwV3FIFOThresholdTune; /* Change V3 FIFO, Threshold and Pre-threshold setting for V3 bandwidth issue*/ + unsigned long dwCheckHQVFIFOEmpty; /* HW Flip path, need to check HQV FIFO status */ + unsigned long dwUseMPEGAGP; /* Use MPEG AGP function*/ + unsigned long dwV3FIFOPatch; /* For CLE V3 FIFO Bug (srcWidth <= 8)*/ + unsigned long dwSupportTwoColorKey; /* Support two color key*/ + unsigned long dwCxColorSpace; /* CLE_Cx ColorSpace*/ } VIAHWRec; /*Wait Function Structure and Flag*/ typedef struct _WaitHWINFO { - unsigned char* pjVideo; /*MMIO Address Info*/ - unsigned long dwVideoFlag; /*Video Flag*/ + unsigned char * pjVideo; /* MMIO Address Info*/ + unsigned long dwVideoFlag; /* Video Flag*/ }WaitHWINFO, * LPWaitHWINFO; +/* VIA Tuners */ +typedef struct +{ + int decoderType; /* Decoder I2C Type */ +#define SAA7108H 0 +#define SAA7113H 1 +#define SAA7114H 2 + I2CDevPtr I2C; /* Decoder I2C */ + I2CDevPtr FMI2C; /* FM Tuner I2C */ + + /* Not yet used */ + int autoDetect; /* Autodetect mode */ + int tunerMode; /* Fixed mode */ +} ViaTunerRec, *ViaTunerPtr; + /* * varables that need to be shared among different screens. */ @@ -301,21 +321,22 @@ typedef struct _VIA { Bool Cap0_FieldSwap; #ifdef XF86DRI - Bool directRenderingEnabled; - DRIInfoPtr pDRIInfo; - int drmFD; - int numVisualConfigs; - __GLXvisualConfig* pVisualConfigs; - VIAConfigPrivPtr pVisualConfigsPriv; - unsigned long agpHandle; - unsigned long registerHandle; - unsigned long agpAddr; - unsigned char *agpBase; - unsigned int agpSize; - Bool IsPCI; - Bool drixinerama; + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig* pVisualConfigs; + VIAConfigPrivPtr pVisualConfigsPriv; + unsigned long agpHandle; + unsigned long registerHandle; + unsigned long agpAddr; + drmAddress agpMappedAddr; + unsigned char *agpBase; + unsigned int agpSize; + Bool IsPCI; + Bool drixinerama; #endif - unsigned char ActiveDevice; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */ + unsigned char ActiveDevice; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */ unsigned char *CursorImage; CARD32 CursorFG; CARD32 CursorBG; @@ -331,7 +352,13 @@ typedef struct _VIA { pointer VidReg; unsigned long gdwVidRegCounter; - unsigned long old_dwUseExtendedFIFO; + unsigned long old_dwUseExtendedFIFO; + + /* Overlay TV Tuners */ + ViaTunerPtr Tuner[2]; + I2CDevPtr CXA2104S; + int AudioMode; + int AudioMute; /* Global 2D state block - needs to slowly die */ ViaGraphicRec graphicInfo; @@ -378,6 +405,7 @@ void VIAHideCursor(ScrnInfoPtr); Bool VIAInitAccel(ScreenPtr); void VIAInitialize2DEngine(ScrnInfoPtr); void VIAAccelSync(ScrnInfoPtr); +void VIAInitLinear(ScreenPtr pScreen); /* In via_shadow.c */ @@ -435,4 +463,25 @@ void VIAFreeLinear(VIAMemPtr); unsigned long VIAAllocLinear(VIAMemPtr, ScrnInfoPtr, unsigned long); void VIAInitPool(VIAPtr, unsigned long, unsigned long); +/* In via_tuner.c */ +void ViaTunerStandard(ViaTunerPtr, int); +void ViaTunerBrightness(ViaTunerPtr, int); +void ViaTunerContrast(ViaTunerPtr, int); +void ViaTunerHue(ViaTunerPtr, int); +void ViaTunerLuminance(ViaTunerPtr, int); +void ViaTunerSaturation(ViaTunerPtr, int); +void ViaTunerInput(ViaTunerPtr, int); +#define MODE_TV 0 +#define MODE_SVIDEO 1 +#define MODE_COMPOSITE 2 + +void ViaTunerChannel(ViaTunerPtr, int, int); +void ViaAudioSelect(VIAPtr pVia, int tuner); +void ViaAudioInit(VIAPtr pVia); +void ViaAudioMode(VIAPtr pVia, int mode); +void ViaAudioMute(VIAPtr pVia, int mute); +void ViaTunerProbe(ScrnInfoPtr pScrn); +void ViaTunerDestroy(ScrnInfoPtr pScrn); + + #endif /* _VIA_DRIVER_H_ */ diff --git a/src/via_i2c.c b/src/via_i2c.c index 94fa7c6..e873810 100644 --- a/src/via_i2c.c +++ b/src/via_i2c.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_i2c.c,v 1.3 2003/08/27 15:16:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_i2c.c,v 1.4 2003/12/31 05:42:05 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -81,7 +81,8 @@ VIAI2C1GetBits(I2CBusPtr b, int *clock, int *data) *data = (reg & DDC_SDA_READ_MASK) != 0; } -/* Function for DVI DDC2 */ +/* Function for DVI DDC2. Also used for the tuner and TV IC's */ + static void VIAI2C2PutBits(I2CBusPtr b, int clock, int data) { diff --git a/src/via_memory.c b/src/via_memory.c index 48ac245..7150c2e 100644 --- a/src/via_memory.c +++ b/src/via_memory.c @@ -20,7 +20,7 @@ * 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_memory.c,v 1.2 2003/12/18 04:05:58 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_memory.c,v 1.5 2004/01/29 03:13:25 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -66,10 +66,13 @@ void VIAFreeLinear(VIAMemPtr mem) mem->pool = 0; return; case 2: +#ifdef XF86DRI if(drmCommandWrite(mem->drm_fd, DRM_VIA_FREEMEM, &mem->drm, sizeof(drmViaMem)) < 0) ErrorF("DRM module failed free.\n"); - drmClose(mem->drm_fd); + /* Don't close the global drmFD on each memory free! */ + /* drmClose(mem->drm_fd); */ +#endif mem->pool = 0; return; case 3: @@ -82,7 +85,7 @@ void VIAFreeLinear(VIAMemPtr mem) unsigned long VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long size) { -#if defined(XF86DRI) || !defined(XFREE_44) +#if defined(XF86DRI) || !defined(XFREE86_44) VIAPtr pVia = VIAPTR(pScrn); #endif @@ -111,10 +114,12 @@ unsigned long VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long siz } #endif -#ifdef XFREE_44 +#ifdef XFREE86_44 { int depth = (pScrn->bitsPerPixel + 7) >> 3; - mem->linear = xf86AllocateOffscreenLinear(pScrn->pScreen, size/depth, + /* Make sure we don't truncate requested size */ + mem->linear = xf86AllocateOffscreenLinear(pScrn->pScreen, + ( size + depth - 1 ) / depth, 32, NULL, NULL, NULL); if(mem->linear == NULL) { diff --git a/src/via_mode.h b/src/via_mode.h index 323c9d0..4897a4d 100644 --- a/src/via_mode.h +++ b/src/via_mode.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_mode.h,v 1.3 2003/08/27 15:16:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_mode.h,v 1.4 2004/02/09 01:45:23 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -132,9 +132,9 @@ static VIAModeEntry Modes[] = { { 512, 384, 8, 0X25, 3, 0X432E, 0XC53F, { 64, 47, 8, 0XFFFF, { 0, 0X1, 0XF, 0, 0XE }, 0X4F, { 0X4D, 0X3F, 0X3F, 0X91, 0X42, 0X9, 0X92, 0X1F, 0, 0X40, 0X1E, 0, 0, 0, 0, 0, 0X80, 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0X432E, 0XC4E9, { 128, 35, 16, 0X8000, { 0, 0X1, 0XF, 0X3, 0XE }, 0X4F, { 0X9F, 0X7F, 0X7F, 0X83, 0X85, 0X92, 0X53, 0XF0, 0, 0X60, 0X1E, 0, 0, 0, 0, 0, 0X40, 0X3, 0X3F, 0, 0, 0X3F, 0X54, 0XE3, 0XFF }, { 0, 0X1, 0X2, 0X3, 0X4, 0X5, 0X6, 0X7, 0X8, 0X9, 0XA, 0XB, 0XC, 0XD, 0XE, 0XF, 0X41, 0, 0XF, 0 }, { 0, 0, 0, 0, 0, 0X40, 0X5, 0XF, 0XFF } }, { { 0XC4, 0XC4, 0XC4, 0XC4, 0XD4, 0XD4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0X15, 0X16, 0X17, 0X18, 0X33, 0X35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0XFE, 0XBF, 0XFF, 0XFF, 0X7, 0XFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0XAE, 0XC, 0X1F, 0X4C, 0X6, 0X40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 6 } } }; static const VIABIOSRegTableRec commExtTable = { diff --git a/src/via_swov.c b/src/via_swov.c index 1600549..6d8be58 100644 --- a/src/via_swov.c +++ b/src/via_swov.c @@ -1,5 +1,4 @@ -/* $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 $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_swov.c,v 1.11 2004/02/04 04:15:09 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -66,19 +65,18 @@ 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; int iCount; /* iCount for clean HQV FB use */ unsigned char *lpTmpAddr; /* for clean HQV FB use */ VIAHWRec *hwDiff = &pVia->ViaHW; - + unsigned long retCode; DBG_DD(ErrorF("//VIAVidCreateSurface: \n")); if ( lpDDSurfaceDesc == NULL ) - return PI_ERR; + return BadAccess; ErrorF("Creating %lu surface\n", lpDDSurfaceDesc->dwFourCC); @@ -121,8 +119,8 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface SWFBSIZE = dwPitch*dwHeight; /*YUYV*/ VIAFreeLinear(&pVia->swov.SWOVMem); - if(VIAAllocLinear(&pVia->swov.SWOVMem, pScrn, SWFBSIZE * 2)) - return BadAccess; + if(Success != (retCode = VIAAllocLinear(&pVia->swov.SWOVMem, pScrn, SWFBSIZE * 2))) + return retCode; dwAddr = pVia->swov.SWOVMem.base; /* fill in the SW buffer with 0x8000 (YUY2-black color) to clear FB buffer*/ @@ -170,8 +168,8 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface size = HQVFBSIZE*2; VIAFreeLinear(&pVia->swov.HQVMem); - if(VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size)) - return BadAccess; + if(Success != (retCode = VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size))) + return retCode; dwAddr = pVia->swov.HQVMem.base; /* dwAddr = pVia->swov.SWOVlinear->offset * depth + SWOVFBSIZE; */ @@ -253,8 +251,8 @@ unsigned long VIAVidCreateSurface(ScrnInfoPtr pScrn, LPDDSURFACEDESC lpDDSurface SWFBSIZE = dwPitch * dwHeight * 1.5; /* 1.5 bytes per pixel */ VIAFreeLinear(&pVia->swov.SWfbMem); - if(VIAAllocLinear(&pVia->swov.SWfbMem, pScrn, 2 * SWFBSIZE)) - return BadAccess; + if(Success != (retCode = VIAAllocLinear(&pVia->swov.SWfbMem, pScrn, 2 * SWFBSIZE))) + return retCode; dwAddr = pVia->swov.SWfbMem.base; DEBUG(ErrorF("dwAddr for SWfbMem is %lu\n", dwAddr)); @@ -316,8 +314,8 @@ if (!(pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) size = HQVFBSIZE * 2; VIAFreeLinear(&pVia->swov.HQVMem); - if(VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size)) - return BadAccess; + if(Success != (retCode = VIAAllocLinear(&pVia->swov.HQVMem, pScrn, size))) + return retCode; dwAddr = pVia->swov.HQVMem.base; DEBUG(ErrorF("dwAddr for HQV is %lu\n", dwAddr)); @@ -359,7 +357,7 @@ if (!(pVia->swov.gdwVideoFlagSW & SW_USE_HQV)) break; } - return dwRet; + return Success; } /*VIAVidCreateSurface*/ diff --git a/src/via_video.c b/src/via_video.c index badc20f..040c85d 100644 --- a/src/via_video.c +++ b/src/via_video.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_video.c,v 1.12 2003/11/10 18:22:35 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_video.c,v 1.17 2004/02/04 04:15:09 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -223,28 +223,10 @@ static char * XVPORTNAME[5] = "XV_SWOV", "XV_TV0" , "XV_TV1" , - /*"XV_TV2" ,*/ "XV_UTCTRL", "XV_DUMMY" }; - -#define DDR100SUPPORTMODECOUNT 24 -#define DDR133UNSUPPORTMODECOUNT 19 -static const MODEINFO SupportDDR100[DDR100SUPPORTMODECOUNT]= - {{640,480,8,60}, {640,480,8,75}, {640,480,8,85}, {640,480,8,100}, {640,480,8,120}, - {640,480,16,60}, {640,480,16,75}, {640,480,16,85}, {640,480,16,100}, {640,480,16,120}, - {640,480,32,60}, {640,480,32,75}, {640,480,32,85}, {640,480,16,100}, {640,480,32,120}, - {800,600,8,60}, {800,600,8,75}, {800,600,8,85}, {800,600,8,100}, {800,600,16,60}, - {800,600,16,75}, {800,600,16,85}, {800,600,32,60}, {1024,768,8,60}}; - -static const MODEINFO UnSupportDDR133[DDR133UNSUPPORTMODECOUNT]= - {{1152,864,32,75}, {1280,768,32,75}, {1280,768,32,85}, {1280,960,32,60}, {1280,960,32,75}, - {1280,960,32,85}, {1280,1024,16,85}, {1280,1024,32,60}, {1280,1024,32,75}, {1280,1024,32,85}, - {1400,1050,16,85}, {1400,1050,32,60}, {1400,1050,32,75}, {1400,1050,32,85}, {1600,1200,8,75}, - {1600,1200,8,85}, {1600,1200,16,75}, {1600,1200,16,85}, {1600,1200,32,60}}; - - /* * F U N C T I O N */ @@ -264,54 +246,46 @@ static __inline void waitDISPLAYBEGIN(vmmtr viaVidEng) while (IN_VBLANK); } -/* Decide if the mode support video overlay */ +/* + * Decide if the mode support video overlay. This depends on the bandwidth + * of the mode and the type of RAM available. + */ + static Bool DecideOverlaySupport(VIAPtr pVia) { - unsigned long iCount; + /* Small trick here. We keep the height in 16's of lines and width in 32's + to avoid numeric overflow */ + unsigned long bandwidth = (pVia->graphicInfo.dwHeight >> 4) * (pVia->graphicInfo.dwWidth >> 5) * + pVia->graphicInfo.dwBPP * pVia->graphicInfo.dwRefreshRate; VGAOUT8(0x3D4, 0x3D); switch ((VGAIN8(0x3D5) & 0x70) >> 4) { - case 0: + case 0: /* No overlay without DDR */ case SDR100: - break; - case SDR133: - break; - + return FALSE; case DDR100: - for (iCount=0; iCount < DDR100SUPPORTMODECOUNT; iCount++) + /* Basic limit for DDR100 is about this */ + if(bandwidth > 1800000) + return FALSE; + /* But we have constraints at higher than 800x600 */ + if (pVia->graphicInfo.dwWidth > 800) { - if ( (pVia->graphicInfo.dwWidth == SupportDDR100[iCount].dwWidth) && - (pVia->graphicInfo.dwHeight == SupportDDR100[iCount].dwHeight) && - (pVia->graphicInfo.dwBPP == SupportDDR100[iCount].dwBPP) && - (pVia->graphicInfo.dwRefreshRate == SupportDDR100[iCount].dwRefreshRate) ) - { - return TRUE; - break; - } + if(pVia->graphicInfo.dwBPP != 8) + return FALSE; + if(pVia->graphicInfo.dwHeight > 768) + return FALSE; + if(pVia->graphicInfo.dwRefreshRate > 60) + return FALSE; } - - return FALSE; - break; + return TRUE; case DDR133: - for (iCount=0; iCount < DDR133UNSUPPORTMODECOUNT; iCount++) - { - if ( (pVia->graphicInfo.dwWidth == UnSupportDDR133[iCount].dwWidth) && - (pVia->graphicInfo.dwHeight == UnSupportDDR133[iCount].dwHeight) && - (pVia->graphicInfo.dwBPP == UnSupportDDR133[iCount].dwBPP) && - (pVia->graphicInfo.dwRefreshRate == UnSupportDDR133[iCount].dwRefreshRate) ) - { - return FALSE; - break; - } - } - + if(bandwidth > 7901250) + return FALSE; return TRUE; - break; } - return FALSE; } @@ -377,7 +351,10 @@ void viaInitVideo(ScreenPtr pScreen) DBG_DD(ErrorF(" via_video.c : viaInitVideo : \n")); - if((pVia->Chipset == VIA_CLE266)) + /* + * We have no KM400 information.. + */ + if(pVia->Chipset == VIA_CLE266) { newAdaptor = viaSetupImageVideoG(pScreen); } @@ -408,17 +385,6 @@ void viaInitVideo(ScreenPtr pScreen) if(newAdaptors) xfree(newAdaptors); - - - /* Driver init */ - /* DriverProc(CREATEDRIVER,NULL); */ - - /* 3rd party Device Init */ - /* - InitializeVDEC(); - InitializeTUNER(); - InitializeAudio(); - */ } @@ -433,6 +399,8 @@ viaSetupImageVideoG(ScreenPtr pScreen) DBG_DD(ErrorF(" via_video.c : viaSetupImageVideoG: \n")); + /* Look for available devices */ + ViaTunerProbe(pScrn); xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); xvContrast = MAKE_ATOM("XV_CONTRAST"); @@ -455,25 +423,19 @@ viaSetupImageVideoG(ScreenPtr pScreen) if(!(adaptPtr[i] = xf86XVAllocateVideoAdaptorRec(pScrn))) return NULL; - gviaPortPriv[i] = (viaPortPrivPtr)xcalloc(1, sizeof(viaPortPrivRec) ); - if ( ! gviaPortPriv[i] ){ - DBG_DD(ErrorF(" via_xvpriv.c : Fail to allocate gviaPortPriv: \n")); - } - else{ - DBG_DD(ErrorF(" via_xvpriv.c : gviaPortPriv[%d] = 0x%08x \n", i,gviaPortPriv[i])); - } - /* - if(!(pPriv[i] = xcalloc(1, sizeof(viaPortPrivPtr)))) + gviaPortPriv[i] = (viaPortPrivPtr)xnfcalloc(1, sizeof(viaPortPrivRec) ); + pdevUnion[i] = (DevUnion *)xnfcalloc(1, sizeof(DevUnion)); + + if(i == 0) /* Overlay engine */ { - xfree(adaptPtr[i]); - return NULL; + adaptPtr[i]->type = XvInputMask | XvWindowMask | XvImageMask | XvVideoMask | XvStillMask; + adaptPtr[i]->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; + } + else + { + adaptPtr[i]->type = XvInputMask | XvWindowMask | XvVideoMask; + adaptPtr[i]->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; } - */ - - pdevUnion[i] = (DevUnion *)xcalloc(1, sizeof(DevUnion) ); - - adaptPtr[i]->type = XvInputMask | XvWindowMask | XvImageMask | XvVideoMask | XvStillMask; - adaptPtr[i]->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; adaptPtr[i]->name = XVPORTNAME[i]; adaptPtr[i]->nEncodings = 8; adaptPtr[i]->pEncodings = DummyEncoding; @@ -484,10 +446,6 @@ viaSetupImageVideoG(ScreenPtr pScreen) adaptPtr[i]->nPorts = 1; adaptPtr[i]->pPortPrivates = pdevUnion[i]; adaptPtr[i]->pPortPrivates->ptr = (pointer) gviaPortPriv[i]; -/* - adaptPtr[i]->pPortPrivates = (DevUnion*)(&pPriv[1]); - adaptPtr[i]->pPortPrivates[0].ptr = (pointer)pPriv; -*/ if (i == 3) /* Utility port doesn't need attribute */ { adaptPtr[i]->nAttributes = 0; @@ -506,7 +464,6 @@ viaSetupImageVideoG(ScreenPtr pScreen) adaptPtr[i]->GetPortAttribute = viaGetPortAttributeG; adaptPtr[i]->QueryBestSize = viaQueryBestSizeG; adaptPtr[i]->PutImage = viaPutImageG; -/* adaptPtr[i]->ReputImage= viaReputImageG; */ adaptPtr[i]->QueryImageAttributes = viaQueryImageAttributesG; #ifdef COLOR_KEY @@ -519,14 +476,14 @@ viaSetupImageVideoG(ScreenPtr pScreen) gviaPortPriv[i]->xv_portnum = i; /* gotta uninit this someplace */ +#ifdef XFREE86_44 REGION_NULL(pScreen, &gviaPortPriv[i]->clip); +#else + REGION_INIT(pScreen, &gviaPortPriv[i]->clip, NullBox, 1); +#endif } /* End of for */ - - viaResetVideo(pScrn); - return adaptPtr[0]; - } @@ -560,13 +517,14 @@ RegionsEqual(RegionPtr A, RegionPtr B) } -static unsigned long CreateSWOVSurface(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, int fourcc, short width, short height) +static int CreateSWOVSurface(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, int fourcc, short width, short height) { VIAPtr pVia = VIAPTR(pScrn); LPDDSURFACEDESC lpSurfaceDesc = &pPriv->SurfaceDesc; + unsigned long retCode; if (pVia->Video.VideoStatus & SWOV_SURFACE_CREATED) - return TRUE; + return Success; lpSurfaceDesc->dwWidth = (unsigned long)width; lpSurfaceDesc->dwHeight = (unsigned long)height; @@ -574,7 +532,8 @@ static unsigned long CreateSWOVSurface(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, lpSurfaceDesc->dwFourCC = (unsigned long)fourcc; - VIAVidCreateSurface(pScrn, lpSurfaceDesc); + if (Success != (retCode = VIAVidCreateSurface(pScrn, lpSurfaceDesc))) + return retCode; pPriv->ddLock.dwFourCC = (unsigned long)fourcc; @@ -588,7 +547,7 @@ static unsigned long CreateSWOVSurface(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv, pVia->Video.VideoStatus |= SWOV_SURFACE_CREATED|SW_VIDEO_ON; pVia->Video.dwAction = ACTION_SET_VIDEOSTATUS; - return TRUE; + return Success; } @@ -665,7 +624,7 @@ viaStopVideoG(ScrnInfoPtr pScrn, pointer data, Bool exit) * Inputs: CARD16 channel - the tuner channel to be set. * * Outputs: NONE * ****************************************************************************/ -static void SetTunerChannel (viaPortPrivPtr pChanPriv, INT32 frequency) +static void SetTunerChannel (ViaTunerPtr pTuner, viaPortPrivPtr pChanPriv, INT32 frequency) { int control; short divider = 0; @@ -675,36 +634,30 @@ static void SetTunerChannel (viaPortPrivPtr pChanPriv, INT32 frequency) case PAL_60_COMPOSITE : case PAL_60_TUNER : case PAL_60_SVIDEO : - divider=633+(short)frequency; + divider = 633 + (short)frequency; break; case NTSC_COMPOSITE : case NTSC_TUNER : case NTSC_SVIDEO : - divider=733+(short)frequency; + divider = 733 + (short)frequency; break; default: - divider=frequency; + divider = frequency; } control = 0x8E00; if ( divider <= LOW_BAND ) - { - control |= 0xA0; - } - else{ - if ( divider <= MID_BAND ) - control |= 0x90; - else - control |= 0x30; - } - - + control |= 0xA0; + else if ( divider <= MID_BAND ) + control |= 0x90; + else + control |= 0x30; - DBG_DD(ErrorF(" via_video.c : SetTunerChannel : Divider = 0x%08x, Control= 0x%08x, \n", - divider,control)); + DBG_DD(ErrorF(" via_video.c : SetTunerChannel : Divider = 0x%08x, Control= 0x%08x, \n", divider,control)); - /* Tuner chip interfacing goes here */ + if(pTuner) + ViaTunerChannel(pTuner, divider, control); } /* SetTunerChannel ()... */ @@ -736,7 +689,13 @@ viaSetPortAttributeG( vmmtr viaVidEng = (vmmtr) pVia->VidMapBase; viaPortPrivPtr pPriv = (viaPortPrivPtr)data; int attr, avalue; - + ViaTunerPtr pTuner = NULL; + + if(pPriv->xv_portnum == COMMAND_FOR_TV0) + pTuner = pVia->Tuner[0]; + else if(pPriv->xv_portnum == COMMAND_FOR_TV1) + pTuner = pVia->Tuner[1]; + ; DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : \n")); pVia->OverlaySupported = DecideOverlaySupport(pVia); @@ -763,53 +722,53 @@ viaSetPortAttributeG( { DBG_DD(ErrorF(" xvBrightness = %08d\n",value)); pPriv->pict.brightness = xv_to_v4l(value); + if(pTuner) + ViaTunerBrightness(pTuner, value); } if (attribute == xvContrast) { DBG_DD(ErrorF(" xvContrast = %08d\n",value)); pPriv->pict.contrast = xv_to_v4l(value); + if(pTuner) + ViaTunerContrast(pTuner, value); } if (attribute == xvSaturation) { DBG_DD(ErrorF(" xvSaturation = %08d\n",value)); pPriv->pict.colour = xv_to_v4l(value); + if(pTuner) + ViaTunerSaturation(pTuner, value); } if (attribute == xvHue) { DBG_DD(ErrorF(" xvHue = %08d\n",value)); pPriv->pict.hue = xv_to_v4l(value); + if(pTuner) + ViaTunerHue(pTuner, value); } /* Audio control */ } else if (attribute == xvMute){ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : xvMute = %08d\n",value)); - if ( value ) - { - pPriv->AudioMode = ATTR_MUTE_ON; - attr = ATTR_MUTE_ON; - } - else{ - pPriv->AudioMode = ATTR_MUTE_OFF; - attr = ATTR_STEREO; - } - + if(value) + value = 1; + ViaAudioMute(pVia, value); } else if (attribute == xvVolume){ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : xvVolume = %08d\n",value)); pPriv->Volume = value; attr = ATTR_VOLUME; avalue = value; - + /* FIXME */ /* Tuner control. Channel switch */ } else if (attribute == xvFreq){ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : xvFreq = %08x\n",value)); - SetTunerChannel(pPriv, value ); - + SetTunerChannel(pTuner, pPriv, value ); /* Video decoder control. NTSC/PAL, SVIDEO/COMPOSITIVE/TV */ } else if (attribute == xvEncoding){ DBG_DD(ErrorF(" xvEncoding = %d. \n",value)); - pPriv->dwEncoding = value; - + if(pTuner) + ViaTunerStandard(pTuner, value); /* VIA Proprietary Attribute for Video control */ } else if (attribute == xvPort ){ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : xvPort=%d\n", value)); @@ -829,9 +788,14 @@ viaSetPortAttributeG( /* VIA Proprietary Attribute for AUDIO control */ } else if (attribute == xvAudioCtrl ){ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : xvAudioSwitch=%d\n", value)); - - attr = ATTR_AUDIO_CONTROLByAP; - avalue = value; + if(pTuner) + { + ViaAudioMode(pVia, value); + if(pPriv->xv_portnum == COMMAND_FOR_TV0) + ViaAudioSelect(pVia,0); + else + ViaAudioSelect(pVia, 1); + } }else{ DBG_DD(ErrorF(" via_video.c : viaSetPortAttributeG : is not supported the attribute")); return BadMatch; @@ -946,17 +910,21 @@ static void CopyDataYUV422( int h, int w ) { - int count; + int count; /* copy YUY2 data to video memory, * do 32 bits alignment. */ - count = h; - while(count--) { - memcpy(dst, src, w); - src += srcPitch; - dst += dstPitch; - } + + w <<= 1; /* Each pixel is YU or YV - 16 bits */ + srcPitch <<= 1; + + count = h; + while(count--) { + memcpy(dst, src, w); + src += srcPitch; + dst += dstPitch; + } } @@ -975,38 +943,37 @@ CopyDataYUV420( int h, int w ){ - int count; + int count; /* copy Y component to video memory */ - count = h; - while(count--) { - memcpy(dst1, src1, w); - src1 += srcPitch; - dst1 += dstPitch; - } + count = h; + while(count--) { + memcpy(dst1, src1, w); + src1 += srcPitch; + dst1 += dstPitch; + } /* UV component is 1/4 of Y */ - w >>= 1; - h >>= 1; - srcPitch >>= 1; - dstPitch >>= 1; + w >>= 1; + h >>= 1; + srcPitch >>= 1; + dstPitch >>= 1; /* copy V(Cr) component to video memory */ - count = h; - while(count--) { - memcpy(dst2, src2, w); - src2 += srcPitch; - dst2 += dstPitch; - } + count = h; + while(count--) { + memcpy(dst2, src2, w); + src2 += srcPitch; + dst2 += dstPitch; + } /* copy U(Cb) component to video memory */ - count = h; - while(count--) { - memcpy(dst3, src3, w); - src3 += srcPitch; - dst3 += dstPitch; - } - + count = h; + while(count--) { + memcpy(dst3, src3, w); + src3 += srcPitch; + dst3 += dstPitch; + } } @@ -1025,6 +992,7 @@ viaPutImageG( VIAPtr pVia = VIAPTR(pScrn); viaPortPrivPtr pPriv = (viaPortPrivPtr)data; vmmtr viaVidEng = (vmmtr) pVia->VidMapBase; + unsigned long retCode; /* int i; BoxPtr pbox; */ @@ -1061,9 +1029,10 @@ viaPutImageG( if ( (pPriv->old_src_w != src_w) || (pPriv->old_src_h != src_h) ) DestroySWOVSurface(pScrn, pPriv); - if ( !CreateSWOVSurface(pScrn, pPriv, id, width, height) ) + if (Success != ( retCode = CreateSWOVSurface(pScrn, pPriv, id, width, height) )) { DBG_DD(ErrorF(" : Fail to Create SW Video Surface\n")); + return retCode; } @@ -1108,12 +1077,7 @@ viaPutImageG( lpUpdateOverlay->rSrc.right = src_x + width; lpUpdateOverlay->rSrc.bottom = src_y + height; - /* temp solve LinDVD AP bug */ - /* When y<0, lindvd will send wrong x */ - if (drw_y<0) - lpUpdateOverlay->rDest.left = drw_x/2; - else - lpUpdateOverlay->rDest.left = drw_x; + lpUpdateOverlay->rDest.left = drw_x; lpUpdateOverlay->rDest.top = drw_y; lpUpdateOverlay->rDest.right = lpUpdateOverlay->rDest.left + drw_w; lpUpdateOverlay->rDest.bottom = drw_y + drw_h; @@ -1169,18 +1133,6 @@ viaPutImageG( REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes); xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); -#if 0 - /* draw these */ - /* FillSolidRects function cause segment fail in SAMM mode - * So I change to use SetupForSolidFill - * Changed to XAAFillSolidRects by Alan - */ - - XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, - (CARD32)~0, - REGION_NUM_RECTS(clipBoxes), - REGION_RECTS(clipBoxes)); -#endif } /* -- cgit v1.2.3