diff options
author | Egbert Eich <eich@suse.de> | 2004-01-29 08:08:41 +0000 |
---|---|---|
committer | Egbert Eich <eich@suse.de> | 2004-01-29 08:08:41 +0000 |
commit | d4caf3cf47fff18c45123b46ec60f96d4d9629b1 (patch) | |
tree | a58eaec19c9d676b3fc310bba6d10fcf4354e8cc | |
parent | 2b0c6360cf48ae1163f047e2bb50109b92432204 (diff) |
Importing vendor version xf86-012804-2330 on Thu Jan 29 00:06:33 PST 2004xf86-012804-2330
-rw-r--r-- | man/via.man | 6 | ||||
-rw-r--r-- | src/via.h | 59 | ||||
-rw-r--r-- | src/via_accel.c | 96 | ||||
-rw-r--r-- | src/via_bandwidth.c | 4 | ||||
-rw-r--r-- | src/via_bios.h | 128 | ||||
-rw-r--r-- | src/via_dri.c | 2 | ||||
-rw-r--r-- | src/via_driver.c | 82 | ||||
-rw-r--r-- | src/via_driver.h | 121 | ||||
-rw-r--r-- | src/via_i2c.c | 5 | ||||
-rw-r--r-- | src/via_memory.c | 11 | ||||
-rw-r--r-- | src/via_video.c | 296 |
11 files changed, 466 insertions, 344 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 @@ -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 b5d5542..9d6a6e4 100644 --- a/src/via_accel.c +++ b/src/via_accel.c @@ -21,7 +21,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_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.10 2004/01/27 02:38:15 dawes Exp $ */ /************************************************************************* * @@ -346,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) && @@ -392,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 | @@ -418,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; @@ -430,7 +431,6 @@ VIAInitAccel(ScreenPtr pScreen) xaaptr->Color8x8PatternFillFlags = NO_PLANEMASK | NO_TRANSPARENCY | HARDWARE_PATTERN_PROGRAMMED_BITS | - HARDWARE_PATTERN_PROGRAMMED_ORIGIN | ROP_NEEDS_SOURCE | 0; @@ -497,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 )); @@ -547,6 +553,32 @@ VIAInitAccel(ScreenPtr pScreen) return XAAInit(pScreen, xaaptr); } +void VIAInitLinear(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + VIAPtr pVia = VIAPTR(pScrn); +#ifdef XFREE_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..08ff891 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.6 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. diff --git a/src/via_driver.c b/src/via_driver.c index c30ece0..7ec6627 100644 --- a/src/via_driver.c +++ b/src/via_driver.c @@ -1,4 +1,4 @@ -/* $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.25 2004/01/27 17:01:20 dawes Exp $ */ /* * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. @@ -81,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); @@ -447,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); @@ -468,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; @@ -1358,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; @@ -1369,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 */ } } } @@ -2203,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); @@ -2343,8 +2367,33 @@ static Bool VIAScreenInit(int scrnIndex, ScreenPtr pScreen, fbPictureInit(pScreen, 0, 0); #endif - if (!pVia->NoAccel) + if (!pVia->NoAccel) { VIAInitAccel(pScreen); + } +#ifdef XFREE_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); @@ -2423,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) @@ -3085,14 +3135,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 426efab..4284963 100644 --- a/src/via_driver.h +++ b/src/via_driver.h @@ -1,4 +1,4 @@ -/* $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.10 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. @@ -155,36 +155,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. */ @@ -300,21 +315,21 @@ 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; + 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; @@ -330,7 +345,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; @@ -377,6 +398,7 @@ void VIAHideCursor(ScrnInfoPtr); Bool VIAInitAccel(ScreenPtr); void VIAInitialize2DEngine(ScrnInfoPtr); void VIAAccelSync(ScrnInfoPtr); +void VIAInitLinear(ScreenPtr pScreen); /* In via_shadow.c */ @@ -434,4 +456,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..508b142 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.4 2004/01/27 02:25:07 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: @@ -114,7 +117,9 @@ unsigned long VIAAllocLinear(VIAMemPtr mem, ScrnInfoPtr pScrn, unsigned long siz #ifdef XFREE_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_video.c b/src/via_video.c index badc20f..9253594 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.15 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. @@ -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 @@ -521,12 +478,8 @@ viaSetupImageVideoG(ScreenPtr pScreen) /* gotta uninit this someplace */ REGION_NULL(pScreen, &gviaPortPriv[i]->clip); } /* End of for */ - - viaResetVideo(pScrn); - return adaptPtr[0]; - } @@ -665,7 +618,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 +628,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 +683,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 +716,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 +782,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 +904,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 +937,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; + } } @@ -1108,12 +1069,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 +1125,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 } /* |