rpms/xorg-x11-drv-openchrome/F-12 openchrome-0.2.904-I420_Xv_surface_for_CME.patch, NONE, 1.1 openchrome-0.2.904-latest_trunk.patch, 1.1, 1.2 xorg-x11-drv-openchrome.spec, 1.54, 1.55 openchrome-0.2.904-2d_perf_tweaks.patch, 1.1, NONE openchrome-0.2.904-add_I2CDevices_option.patch, 1.1, NONE openchrome-0.2.904-disable_AGP_and_DMA_by_default_for_VX8xx.patch, 1.1, NONE openchrome-0.2.904-fix_xv_on_vx800.patch, 1.1, NONE openchrome-0.2.904-put_50ms_timeout_on_HQV.patch, 1.1, NONE openchrome-0.2.904-sanitize_SaveVideoRegister.patch, 1.1, NONE openchrome-0.2.904-set_colorkey_for_2nd_monitor.patch, 1.1, NONE openchrome-0.2.904-setup_HWDiff_HQVCmeRegs_for_all_chipsets.patch, 1.1, NONE openchrome-0.2.904-vx855_xv.patch, 1.1, NONE

Xavier Bachelot xavierb at fedoraproject.org
Mon May 24 19:52:51 UTC 2010


Author: xavierb

Update of /cvs/pkgs/rpms/xorg-x11-drv-openchrome/F-12
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv32436

Modified Files:
	openchrome-0.2.904-latest_trunk.patch 
	xorg-x11-drv-openchrome.spec 
Added Files:
	openchrome-0.2.904-I420_Xv_surface_for_CME.patch 
Removed Files:
	openchrome-0.2.904-2d_perf_tweaks.patch 
	openchrome-0.2.904-add_I2CDevices_option.patch 
	openchrome-0.2.904-disable_AGP_and_DMA_by_default_for_VX8xx.patch 
	openchrome-0.2.904-fix_xv_on_vx800.patch 
	openchrome-0.2.904-put_50ms_timeout_on_HQV.patch 
	openchrome-0.2.904-sanitize_SaveVideoRegister.patch 
	openchrome-0.2.904-set_colorkey_for_2nd_monitor.patch 
	openchrome-0.2.904-setup_HWDiff_HQVCmeRegs_for_all_chipsets.patch 
	openchrome-0.2.904-vx855_xv.patch 
Log Message:
0.2.904 + svn853 + TVout fix + I420 CME

openchrome-0.2.904-I420_Xv_surface_for_CME.patch:
 via_swov.c  |   19 ++++++++++--
 via_video.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 104 insertions(+), 10 deletions(-)

--- NEW FILE openchrome-0.2.904-I420_Xv_surface_for_CME.patch ---
>From fa325c183bd66b2b20e8f22c74d87fa01a831ab0 Mon Sep 17 00:00:00 2001
From: root <root at localhost.localdomain>
Date: Thu, 8 Apr 2010 20:39:37 +0000
Subject: [PATCH 6/8] Add I420 Xvideo Surface for CME_Engine

This patch is not finished, it only implements the I420 support
for the CME Engine chipsets.  I need to finish legacy support of this format.
---
 src/via_swov.c  |   19 ++++++++++-
 src/via_video.c |   94 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 104 insertions(+), 9 deletions(-)

diff --git a/src/via_swov.c b/src/via_swov.c
index 8b68498..5be2d6a 100644
--- a/src/via_swov.c
+++ b/src/via_swov.c
@@ -392,6 +392,7 @@ viaOverlayGetV1V3Format(VIAPtr pVia, int vport, /* 1 or 3, as in V1 or V3 */
     if (videoFlag & VIDEO_HQV_INUSE) {
         switch (pVia->swov.SrcFourCC) {
             case FOURCC_YV12:
+            case FOURCC_I420:
             case FOURCC_XVMC:
                 *pHQVCtl |= HQV_YUV420;
                 break;
@@ -421,6 +422,7 @@ viaOverlayGetV1V3Format(VIAPtr pVia, int vport, /* 1 or 3, as in V1 or V3 */
     } else {
         switch (pVia->swov.SrcFourCC) {
             case FOURCC_YV12:
+            case FOURCC_I420:
             case FOURCC_XVMC:
                 if (vport == 1) {
                     *pVidCtl |= V1_YCbCr420;
@@ -503,6 +505,7 @@ viaOverlayGetSrcStartAddress(VIAPtr pVia,
                 break;
 
             case FOURCC_YV12:
+            case FOURCC_I420:
             case FOURCC_XVMC:
 
                 if (videoFlag & VIDEO_HQV_INUSE)
@@ -763,6 +766,7 @@ viaOverlayGetFetch(VIAPtr pVia, unsigned long videoFlag,
 
     switch (pVia->swov.SrcFourCC) {
         case FOURCC_YV12:
+        case FOURCC_I420:
         case FOURCC_XVMC:
             n = 0; /* 2^n = 1 byte per pixel (Y channel in planar YUV) */
             break;
@@ -1146,7 +1150,8 @@ AddHQVSurface(ScrnInfoPtr pScrn, unsigned int numbuf, CARD32 fourcc)
         !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE))
         proReg = PRO_HQV1_OFFSET;
 
-    isplanar = ((fourcc == FOURCC_YV12) || (fourcc == FOURCC_XVMC));
+    isplanar = ((fourcc == FOURCC_YV12) || (fourcc == FOURCC_I420) ||
+				(fourcc == FOURCC_XVMC));
 
     width = pVia->swov.SWDevice.gdwSWSrcWidth;
     height = pVia->swov.SWDevice.gdwSWSrcHeight;
@@ -1189,6 +1194,7 @@ CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width,
     isplanar = FALSE;
     switch (FourCC) {
         case FOURCC_YV12:
+        case FOURCC_I420:
         case FOURCC_XVMC:
             isplanar = TRUE;
             pitch = ALIGN_TO(Width, 32);
@@ -1281,9 +1287,10 @@ ViaSwovSurfaceCreate(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv,
             break;
 
         case FOURCC_YV12:
+        case FOURCC_I420:
             retCode = CreateSurface(pScrn, FourCC, Width, Height, TRUE);
             if (retCode == Success)
-                retCode = AddHQVSurface(pScrn, numbuf, FOURCC_YV12);
+                retCode = AddHQVSurface(pScrn, numbuf, FourCC);
             break;
 
         case FOURCC_XVMC:
@@ -1345,6 +1352,7 @@ ViaSwovSurfaceDestroy(ScrnInfoPtr pScrn, viaPortPrivPtr pPriv)
                 break;
 
             case FOURCC_YV12:
+            case FOURCC_I420:
                 VIAFreeLinear(&pVia->swov.SWfbMem);
             case FOURCC_XVMC:
                 pVia->swov.SrcFourCC = 0;
@@ -1509,6 +1517,7 @@ SetupFIFOs(VIAPtr pVia, unsigned long videoFlag,
 {
     if (miniCtl & V1_Y_INTERPOLY) {
         if (pVia->swov.SrcFourCC == FOURCC_YV12
+			|| pVia->swov.SrcFourCC == FOURCC_I420
             || pVia->swov.SrcFourCC == FOURCC_XVMC) {
             if (videoFlag & VIDEO_HQV_INUSE) {
                 if (videoFlag & VIDEO_1_INUSE)
@@ -1542,6 +1551,7 @@ SetupFIFOs(VIAPtr pVia, unsigned long videoFlag,
         }
     } else {
         if (pVia->swov.SrcFourCC == FOURCC_YV12
+			|| pVia->swov.SrcFourCC == FOURCC_I420
             || pVia->swov.SrcFourCC == FOURCC_XVMC) {
             if (videoFlag & VIDEO_HQV_INUSE) {
                 if (videoFlag & VIDEO_1_INUSE)
@@ -1893,6 +1903,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag,
     pVia->swov.overlayRecordV1.dwOffset = dwOffset;
 
     if (pVia->swov.SrcFourCC == FOURCC_YV12
+		|| pVia->swov.SrcFourCC == FOURCC_I420
         || pVia->swov.SrcFourCC == FOURCC_XVMC) {
 
         YCBCRREC YCbCr;
@@ -1985,6 +1996,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFlag,
             SetHQVFetch(pVia, hqvSrcFetch, oriSrcHeight);
 
         if (pVia->swov.SrcFourCC == FOURCC_YV12
+            || pVia->swov.SrcFourCC == FOURCC_I420
             || pVia->swov.SrcFourCC == FOURCC_XVMC) {
             if (videoFlag & VIDEO_1_INUSE)
                 SaveVideoRegister(pVia, V1_STRIDE, srcPitch << 1);
@@ -2294,6 +2306,7 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate)
         (pVia->swov.SrcFourCC == FOURCC_RV16) ||
         (pVia->swov.SrcFourCC == FOURCC_RV32) ||
         (pVia->swov.SrcFourCC == FOURCC_YV12) ||
+        (pVia->swov.SrcFourCC == FOURCC_I420) ||
         (pVia->swov.SrcFourCC == FOURCC_XVMC)) {
         videoFlag = pVia->swov.gdwVideoFlagSW;
     }
@@ -2368,6 +2381,7 @@ VIAVidUpdateOverlay(ScrnInfoPtr pScrn, LPDDUPDATEOVERLAY pUpdate)
         (pVia->swov.SrcFourCC == FOURCC_RV16) ||
         (pVia->swov.SrcFourCC == FOURCC_RV32) ||
         (pVia->swov.SrcFourCC == FOURCC_YV12) ||
+        (pVia->swov.SrcFourCC == FOURCC_I420) ||
         (pVia->swov.SrcFourCC == FOURCC_XVMC)) {
         pVia->swov.SWDevice.gdwSWDstLeft = pUpdate->DstLeft + panDX;
         pVia->swov.SWDevice.gdwSWDstTop = pUpdate->DstTop + panDY;
@@ -2427,6 +2441,7 @@ ViaOverlayHide(ScrnInfoPtr pScrn)
         (pVia->swov.SrcFourCC == FOURCC_RV16) ||
         (pVia->swov.SrcFourCC == FOURCC_RV32) ||
         (pVia->swov.SrcFourCC == FOURCC_YV12) ||
+        (pVia->swov.SrcFourCC == FOURCC_I420) ||
         (pVia->swov.SrcFourCC == FOURCC_XVMC))
         videoFlag = pVia->swov.gdwVideoFlagSW;
 
diff --git a/src/via_video.c b/src/via_video.c
index 4c3f2d9..5924556 100644
--- a/src/via_video.c
+++ b/src/via_video.c
@@ -117,6 +117,10 @@ static int viaSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer);
 static int viaPutImage(ScrnInfoPtr, short, short, short, short, short, short,
     short, short, int, unsigned char *, short, short, Bool,
     RegionPtr, pointer, DrawablePtr);
+static void UVBlit(unsigned char *dest,
+    const unsigned char *uBuffer,
+    const unsigned char *vBuffer,
+    unsigned width, unsigned srcPitch, unsigned dstPitch, unsigned lines);
 static void nv12Blit(unsigned char *nv12Chroma,
     const unsigned char *uBuffer,
     const unsigned char *vBuffer,
@@ -158,11 +162,12 @@ static XF86AttributeRec AttributesG[NUM_ATTRIBUTES_G] = {
     {XvSettable | XvGettable, 0, 1, "XV_AUTOPAINT_COLORKEY"}
 };
 
-#define NUM_IMAGES_G 6
+#define NUM_IMAGES_G 7
 
 static XF86ImageRec ImagesG[NUM_IMAGES_G] = {
     XVIMAGE_YUY2,
     XVIMAGE_YV12,
+    XVIMAGE_I420,
     {
         /*
          * Below, a dummy picture type that is used in XvPutImage only to do
@@ -1048,6 +1053,7 @@ Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc,
                 proReg) & ~HQV_FLIP_ODD) | HQV_SW_FLIP | HQV_FLIP_STATUS);
             break;
         case FOURCC_YV12:
+        case FOURCC_I420:
         default:
             while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)
                     && --count);
@@ -1074,16 +1080,49 @@ Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc,
  */
 
 static void
+planar420cp(unsigned char *dst,
+    const unsigned char *src, int dstPitch, int w, int h, int i420)
+{
+    /* 
+     * Blit luma component as a fake YUY2 assembler blit. 
+     */
+	unsigned long srcUOffset, srcVOffset;
+    if (i420) {
+	    srcVOffset  = w * h + (w >> 1) * (h >> 1);
+	    srcUOffset = w * h;
+    } else {
+	    srcUOffset  = w * h + (w >> 1) * (h >> 1);
+	    srcVOffset = w * h;
+	}
+
+    (*viaFastVidCpy) (dst, src, dstPitch, w >> 1, h, 1);
+    UVBlit(dst + dstPitch * h, src + srcUOffset,
+           src + srcVOffset, w >> 1, w >> 1, dstPitch, h >> 1);
+}
+
+/*
+ * Slow and dirty. NV12 blit.
+ */
+
+static void
 nv12cp(unsigned char *dst,
-    const unsigned char *src, int dstPitch, int w, int h, int yuv422)
+    const unsigned char *src, int dstPitch, int w, int h, int i420)
 {
     /* 
      * Blit luma component as a fake YUY2 assembler blit. 
      */
+	unsigned long srcUOffset, srcVOffset;
+    if (i420) {
+	    srcVOffset  = w * h + (w >> 1) * (h >> 1);
+	    srcUOffset = w * h;
+    } else {
+	    srcUOffset  = w * h + (w >> 1) * (h >> 1);
+	    srcVOffset = w * h;
+	}
 
     (*viaFastVidCpy) (dst, src, dstPitch, w >> 1, h, TRUE);
-    nv12Blit(dst + dstPitch * h, src + w * h + (w >> 1) * (h >> 1),
-            src + w * h, w >> 1, w >> 1, dstPitch, h >> 1);
+    nv12Blit(dst + dstPitch * h, src + srcUOffset,
+            src + srcVOffset, w >> 1, w >>1, dstPitch, h >> 1);
 }
 
 #ifdef XF86DRI
@@ -1108,7 +1147,7 @@ viaDmaBlitImage(VIAPtr pVia,
 
     bounceBuffer = ((unsigned long)src & 15);
     nv12Conversion = (pVia->VideoEngine == VIDEO_ENGINE_CME && 
-        id == FOURCC_YV12);
+        (id == FOURCC_YV12 || id == FOURCC_I420));
 
     switch (id) {
         case FOURCC_YUY2:
@@ -1123,6 +1162,7 @@ viaDmaBlitImage(VIAPtr pVia,
             break;
 
         case FOURCC_YV12:
+        case FOURCC_I420:
         default:
             bounceStride = ALIGN_TO(width, 16);
             bounceLines = height;
@@ -1138,7 +1178,7 @@ viaDmaBlitImage(VIAPtr pVia,
                 pPort->dmaBounceBuffer = 0;
             }
             size = bounceStride * bounceLines + 16;
-            if (FOURCC_YV12 == id)
+            if (id == FOURCC_YV12 || id == FOURCC_I420)
                 size += ALIGN_TO(bounceStride >> 1, 16) * bounceLines;
             pPort->dmaBounceBuffer = (unsigned char *)malloc(size);
             pPort->dmaBounceLines = bounceLines;
@@ -1178,7 +1218,7 @@ viaDmaBlitImage(VIAPtr pVia,
 
     lumaSync = blit.sync;
 
-    if (id == FOURCC_YV12) {
+    if (id == FOURCC_YV12 || id == FOURCC_I420) {
         unsigned tmp = ALIGN_TO(width >> 1, 16);
 
         if (nv12Conversion) {
@@ -1310,6 +1350,17 @@ viaPutImage(ScrnInfoPtr pScrn,
 #endif
                 } else {
                     switch (id) {
+                        case FOURCC_I420:
+                            if (pVia->VideoEngine == VIDEO_ENGINE_CME) {
+                                nv12cp(pVia->swov.SWDevice.
+                                    lpSWOverlaySurface[pVia->dwFrameNum & 1],
+                                    buf, dstPitch, width, height, 1);
+                            } else {
+                                (*viaFastVidCpy)(pVia->swov.SWDevice.
+                                    lpSWOverlaySurface[pVia->dwFrameNum & 1],
+                                    buf, dstPitch, width, height, 0);
+                            }
+                            break;
                         case FOURCC_YV12:
                             if (pVia->VideoEngine == VIDEO_ENGINE_CME) {
                                 nv12cp(pVia->swov.SWDevice.
@@ -1566,6 +1617,35 @@ VIAVidAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
 }
 
 /*
+ * Blit the U and V Fields. Used to Flip the U V for I420.
+ */
+
+static void
+UVBlit(unsigned char *dst,
+        const unsigned char *uBuffer,
+        const unsigned char *vBuffer,
+        unsigned width, unsigned srcPitch, unsigned dstPitch, unsigned lines)
+{
+    int i, j;
+
+    dstPitch >>= 1;
+
+    for(j = 0; j < lines; j++)
+    {
+        for(i = 0; i < width; i++)
+        {
+            dst[i] = (uBuffer[i] << 8) | (vBuffer[i] << 16);
+        }
+
+        dst += dstPitch;
+        uBuffer += srcPitch;
+        vBuffer += srcPitch;
+    }
+
+}
+
+
+/*
  * Blit the chroma field from one buffer to another while at the same time converting from
  * YV12 to NV12.
  */
-- 
1.6.2.5


openchrome-0.2.904-latest_trunk.patch:
 ChangeLog           |  130 +++++++++++++++++++++++
 man/openchrome.man  |   29 +++--
 src/via.h           |   39 ++++++
 src/via_accel.c     |   78 ++++++++-----
 src/via_bandwidth.c |  103 ++++++++++++++----
 src/via_bios.h      |    5 
 src/via_crtc.c      |   11 +
 src/via_cursor.c    |   56 +++++++--
 src/via_dri.c       |    5 
 src/via_driver.c    |  166 ++++++++++++++++++++++-------
 src/via_driver.h    |    6 -
 src/via_i2c.c       |   15 ++
 src/via_id.c        |    5 
 src/via_mode.h      |   88 +++++++--------
 src/via_panel.c     |   83 +++++++++-----
 src/via_swov.c      |  293 ++++++++++++++++++++++++++++++++++++----------------
 src/via_swov.h      |    2 
 src/via_video.c     |  253 ++++++++++++++++----------------------------
 src/via_video.h     |    6 -
 19 files changed, 932 insertions(+), 441 deletions(-)

Index: openchrome-0.2.904-latest_trunk.patch
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-drv-openchrome/F-12/openchrome-0.2.904-latest_trunk.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- openchrome-0.2.904-latest_trunk.patch	20 Mar 2010 12:21:09 -0000	1.1
+++ openchrome-0.2.904-latest_trunk.patch	24 May 2010 19:52:50 -0000	1.2
@@ -1,8 +1,82 @@
 Index: ChangeLog
 ===================================================================
---- ChangeLog	(.../tags/release_0_2_904)	(revision 841)
-+++ ChangeLog	(.../trunk)	(revision 841)
-@@ -1,3 +1,59 @@
+--- ChangeLog	(.../tags/release_0_2_904)	(revision 853)
++++ ChangeLog	(.../trunk)	(revision 853)
+@@ -1,3 +1,133 @@
++2010-05-04  Jon Nettleton <jon.nettleton at gmail.com>
++
++	Re-enable the Virtual Queue for the VX800/VX855 chipsets.
++
++	* src/via_accel.c: (viaDisableVQ), (viaInitialize2DEngine):
++
++2010-05-04  Jon Nettleton  <jon.nettleton at gmail.com>
++
++	Disable certain hardware clipping options for the VX855.
++	These cause the 2d engine to become unstable when in
++	16-bit mode.
++
++	* src/via_accel.c: (viaInitXAA):
++
++2010-05-04  Jon Nettleton <jon.nettleton at gmail.com>
++
++	Add an undocumented option which allows certain I2C buses
++	to be probed at startup.  This allows workarounds for custom
++	chipset makers that have used the VX855 I2C buses for other
++	purposes.
++
++	* src/via_bios.h:
++	* src/via_driver.c: (VIASetupDefaultOptions), (VIAPreInit):
++	* src/via_driver.h:
++	* src/via_i2c.c:
++
++2010-05-04  Jon Nettleton  <jon.nettleton at gmail.com>
++
++	Improve 2d performance on chipsets that don't have
++	AGP/PCIe support yet.
++
++	* src/via_accel.c: (viaSetupForScreenToScreenCopy),
++	(viaSetupForSolidFill), (viaSetupForMono8x8PatternFill),
++	(viaSetupForColor8x8PatternFill),
++	(viaSetupForCPUToScreenColorExpandFill),
++	(viaSubsequentScanlineCPUToScreenColorExpandFill),
++	(viaSetupForImageWrite), (viaSubsequentImageWriteRect),
++	(viaSetupForSolidLine), (viaSetupForDashedLine), (viaInitXAA):
++
++2010-05-04  Jon Nettleton <jon.nettleton at gmail.com>
++
++	Put timeouts on our while statements.  These codepaths
++	should be interrupted by a hardware state change, but
++	if something goes wrong they loop forevere.  Let's try
++	and behave a little by putting a timeout on these loops.
++
++	* src/via_swov.c: (viaWaitHQVFlip), (viaWaitHQVFlipClear),
++	(viaWaitHQVDone):
++	* src/via_video.c: (Flip):
++
++2010-05-04  Jon Nettleton <jon.nettleton at gmail.com>
++
++	Add XVideo support for the VX855 Chipset.
++	To support this chipset I have added HWDiff->HQVCmeRegs
++	that allows handling differing register values, and
++	HWDiff->dwNewScaleCtl which allows selection of a
++	new Video scaling engine needed for the VX800/VX855
++	chipsets.
++
++	* src/via.h:
++	* src/via_bandwidth.c: (ViaSetSecondaryFIFO):
++	* src/via_driver.h:
++	* src/via_swov.c: (SaveVideoRegister), (VIAVidHWDiffInit),
++	(viaOverlayHQVCalcZoomWidth), (viaOverlayHQVCalcZoomHeight),
++	(ViaSwovSurfaceCreate), (SetHQVFetch), (Upd_Video):
++	* src/via_swov.h:
++
++2010-04-21  Bartosz Kosiorek  <gang65 at poczta.onet.pl>
++
++	Replace RegionsEqual with REGION_EQUAL and use 
++        the xf86XVFillKeyHelperDrawable instead of xf86XVFillKeyHelper
++
++	* src/via_video.c: (viaReputImage), (viaPutImage):
++
 +2010-03-07  Bartosz Kosiorek  <gang65 at poczta.onet.pl>
 +
 +	Fix segfaults with EXA and XV (Ticket #359)
@@ -64,8 +138,8 @@ Index: ChangeLog
  	Save/restore ECK Clock Synthesizer
 Index: src/via_panel.c
 ===================================================================
---- src/via_panel.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_panel.c	(.../trunk)	(revision 841)
+--- src/via_panel.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_panel.c	(.../trunk)	(revision 853)
 @@ -171,12 +171,18 @@ ViaPanelScale(ScrnInfoPtr pScrn, int resWidth, int
                       resWidth, resHeight, panelWidth, panelHeight));
  
@@ -223,8 +297,8 @@ Index: src/via_panel.c
      }
 Index: src/via_video.c
 ===================================================================
---- src/via_video.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_video.c	(.../trunk)	(revision 841)
+--- src/via_video.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_video.c	(.../trunk)	(revision 853)
 @@ -466,8 +466,8 @@ viaResetVideo(ScrnInfoPtr pScrn)
  
      viaVidEng->video1_ctl = 0;
@@ -347,10 +421,38 @@ Index: src/via_video.c
  
      allAdaptors = NULL;
      newAdaptors = NULL;
-@@ -664,106 +713,7 @@ RegionsEqual(RegionPtr A, RegionPtr B)
-     return TRUE;
+@@ -636,134 +685,7 @@ viaInitVideo(ScreenPtr pScreen)
+     }
  }
  
+-static Bool
+-RegionsEqual(RegionPtr A, RegionPtr B)
+-{
+-    int *dataA, *dataB;
+-    int num;
+ 
+-    num = REGION_NUM_RECTS(A);
+-    if (num != REGION_NUM_RECTS(B))
+-        return FALSE;
+-
+-    if ((A->extents.x1 != B->extents.x1) ||
+-        (A->extents.x2 != B->extents.x2) ||
+-        (A->extents.y1 != B->extents.y1) || (A->extents.y2 != B->extents.y2))
+-    return FALSE;
+-
+-    dataA = (int *)REGION_RECTS(A);
+-    dataB = (int *)REGION_RECTS(B);
+-
+-    while (num--) {
+-        if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
+-            return FALSE;
+-        dataA += 2;
+-        dataB += 2;
+-    }
+-
+-    return TRUE;
+-}
+-
 -static void
 -viaVideoFillPixmap(ScrnInfoPtr pScrn,
 -        char *base,
@@ -360,7 +462,7 @@ Index: src/via_video.c
 -        unsigned long color)
 -{
 -    int i;
- 
+-
 -    ErrorF("pitch %lu, depth %d, x %d, y %d, w %d, h %d, color 0x%08lx\n",
 -            pitch, depth, x, y, w, h, color);
 -
@@ -454,7 +556,12 @@ Index: src/via_video.c
  /*
   * This one gets called, for example, on panning.
   */
-@@ -783,10 +733,15 @@ viaReputImage(ScrnInfoPtr pScrn,
+@@ -779,14 +701,19 @@ viaReputImage(ScrnInfoPtr pScrn,
+     viaPortPrivPtr pPriv = (viaPortPrivPtr) data;
+     VIAPtr pVia = VIAPTR(pScrn);
+ 
+-    if (!RegionsEqual(&pPriv->clip, clipBoxes)) {
++    if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
          REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);
          if (pPriv->autoPaint) {
              if (pDraw->type == DRAWABLE_WINDOW) {
@@ -473,7 +580,7 @@ Index: src/via_video.c
              }
          }
      }
-@@ -832,7 +787,7 @@ viaSetupAdaptors(ScreenPtr pScreen, XF86VideoAdapt
+@@ -832,7 +759,7 @@ viaSetupAdaptors(ScreenPtr pScreen, XF86VideoAdapt
      DevUnion *pdevUnion;
      int i, j, usedPorts, numPorts;
  
@@ -482,7 +589,7 @@ Index: src/via_video.c
  
      xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
      xvContrast = MAKE_ATOM("XV_CONTRAST");
-@@ -1042,6 +997,8 @@ viaGetPortAttribute(ScrnInfoPtr pScrn,
+@@ -1042,6 +969,8 @@ viaGetPortAttribute(ScrnInfoPtr pScrn,
          }
  
      } else {
@@ -491,7 +598,35 @@ Index: src/via_video.c
          /*return BadMatch */;
      }
      return Success;
-@@ -1296,7 +1253,7 @@ viaPutImage(ScrnInfoPtr pScrn,
+@@ -1070,6 +999,7 @@ Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc
+         unsigned long DisplayBufferIndex)
+ {
+     unsigned long proReg = 0;
++    unsigned count = 50000;
+ 
+     if (pVia->ChipId == PCI_CHIP_VT3259
+         && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE))
+@@ -1081,7 +1011,8 @@ Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc
+         case FOURCC_RV15:
+         case FOURCC_RV16:
+         case FOURCC_RV32:
+-            while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP));
++            while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)
++                    && --count);
+             VIDOutD(HQV_SRC_STARTADDR_Y + proReg,
+                 pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]);
+             VIDOutD(HQV_CONTROL + proReg,
+@@ -1090,7 +1021,8 @@ Flip(VIAPtr pVia, viaPortPrivPtr pPriv, int fourcc
+             break;
+         case FOURCC_YV12:
+         default:
+-            while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP));
++            while ((VIDInD(HQV_CONTROL + proReg) & HQV_SW_FLIP)
++                    && --count);
+             VIDOutD(HQV_SRC_STARTADDR_Y + proReg,
+                 pVia->swov.SWDevice.dwSWPhysicalAddr[DisplayBufferIndex]);
+             if (pVia->VideoEngine == VIDEO_ENGINE_CME) {
+@@ -1296,7 +1228,7 @@ viaPutImage(ScrnInfoPtr pScrn,
      unsigned long retCode;
  
  # ifdef XV_DEBUG
@@ -500,7 +635,7 @@ Index: src/via_video.c
      ErrorF(" via_video.c : FourCC=0x%x width=%d height=%d sync=%d\n", id,
              width, height, sync);
      ErrorF
-@@ -1405,12 +1362,11 @@ viaPutImage(ScrnInfoPtr pScrn,
+@@ -1405,12 +1337,11 @@ viaPutImage(ScrnInfoPtr pScrn,
  
              lpUpdateOverlay->dwFlags = DDOVER_KEYDEST;
  
@@ -518,18 +653,28 @@ Index: src/via_video.c
              /* If use extend FIFO mode */
              if (pScrn->currentMode->HDisplay > 1024) {
                  dwUseExtendedFIFO = 1;
-@@ -1458,12 +1414,19 @@ viaPutImage(ScrnInfoPtr pScrn,
+@@ -1436,7 +1367,8 @@ viaPutImage(ScrnInfoPtr pScrn,
+                     && (pPriv->old_src_w == src_w) && (pPriv->old_src_h == src_h)
+                     && (pVia->old_dwUseExtendedFIFO == dwUseExtendedFIFO)
+                     && (pVia->VideoStatus & VIDEO_SWOV_ON) &&
+-                    RegionsEqual(&pPriv->clip, clipBoxes)) {
++                    REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
++                DBG_DD(ErrorF(" via_video.c : don't do UpdateOverlay! \n"));
+                 viaXvError(pScrn, pPriv, xve_none);
+                 return Success;
+             }
+@@ -1454,16 +1386,18 @@ viaPutImage(ScrnInfoPtr pScrn,
+             pVia->VideoStatus |= VIDEO_SWOV_ON;
+ 
+             /*  BitBlt: Draw the colorkey rectangle */
+-            if (!RegionsEqual(&pPriv->clip, clipBoxes)) {
++            if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
                  REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);
                  if (pPriv->autoPaint) {
                      if (pDraw->type == DRAWABLE_WINDOW) {
 -                        viaPaintColorkey(pScrn, pPriv, clipBoxes, pDraw);
-+                        /* TODO Replace xf86XVFillKeyHelper with xf86XVFillKeyHelperDrawable
-+                           Currently resizing problem exists in VLC Media Player
-+                           Example of implementation:
 +                        xf86XVFillKeyHelperDrawable(pDraw, pPriv->colorKey, clipBoxes);
 +                        DamageDamageRegion(pDraw, clipBoxes);
-+                        */
-+                        xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes);
                      } else {
 -                        xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey,
 -                            clipBoxes);
@@ -541,7 +686,7 @@ Index: src/via_video.c
              }
              /*
               *  Update video overlay
-@@ -1498,6 +1461,7 @@ viaQueryImageAttributes(ScrnInfoPtr pScrn,
+@@ -1498,6 +1432,7 @@ viaQueryImageAttributes(ScrnInfoPtr pScrn,
  
      DBG_DD(ErrorF(" via_video.c : viaQueryImageAttributes : FourCC=0x%x, ",
              id));
@@ -549,18 +694,10 @@ Index: src/via_video.c
  
      if ((!w) || (!h))
          return 0;
-@@ -1513,6 +1477,7 @@ viaQueryImageAttributes(ScrnInfoPtr pScrn,
- 
-     switch (id) {
-         case FOURCC_YV12: /*Planar format : YV12 -4:2:0 */
-+        case FOURCC_I420:
-             *h = (*h + 1) & ~1;
-             size = *w;
-             if (pVia->useDmaBlit)
 Index: src/via_video.h
 ===================================================================
---- src/via_video.h	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_video.h	(.../trunk)	(revision 841)
+--- src/via_video.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_video.h	(.../trunk)	(revision 853)
 @@ -44,6 +44,10 @@
  
  #define VIDEO_BPP 2
@@ -583,8 +720,8 @@ Index: src/via_video.h
      CARD32 v3alpha_fetch;	       /* 2b8 */
 Index: src/via_mode.h
 ===================================================================
---- src/via_mode.h	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_mode.h	(.../trunk)	(revision 841)
+--- src/via_mode.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_mode.h	(.../trunk)	(revision 853)
 @@ -54,50 +54,50 @@ static struct ViaDotClock {
      CARD16 UniChrome;
      union pllparams UniChromePro;
@@ -682,8 +819,8 @@ Index: src/via_mode.h
  /*
 Index: src/via_driver.c
 ===================================================================
---- src/via_driver.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_driver.c	(.../trunk)	(revision 841)
+--- src/via_driver.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_driver.c	(.../trunk)	(revision 853)
 @@ -178,8 +178,8 @@ static SymTabRec VIAChipsets[] = {
      {VIA_P4M900,   "P4M900/VN896/CN896"},
      {VIA_CX700,    "CX700/VX700"},
@@ -695,7 +832,7 @@ Index: src/via_driver.c
      {-1,            NULL }
  };
  
-@@ -215,6 +215,7 @@ typedef enum
+@@ -215,9 +215,11 @@ typedef enum
      OPTION_EXA_SCRATCH_SIZE,
      OPTION_SWCURSOR,
      OPTION_SHADOW_FB,
@@ -703,7 +840,11 @@ Index: src/via_driver.c
      OPTION_ROTATE,
      OPTION_VIDEORAM,
      OPTION_ACTIVEDEVICE,
-@@ -253,6 +254,7 @@ static OptionInfoRec VIAOptions[] = {
++    OPTION_I2CDEVICES,
+     OPTION_BUSWIDTH,
+     OPTION_CENTER,
+     OPTION_PANELSIZE,
+@@ -253,6 +255,7 @@ static OptionInfoRec VIAOptions[] = {
      {OPTION_EXA_SCRATCH_SIZE,    "ExaScratchSize",   OPTV_INTEGER, {0}, FALSE},
      {OPTION_SWCURSOR,            "SWCursor",         OPTV_BOOLEAN, {0}, FALSE},
      {OPTION_SHADOW_FB,           "ShadowFB",         OPTV_BOOLEAN, {0}, FALSE},
@@ -711,7 +852,15 @@ Index: src/via_driver.c
      {OPTION_ROTATE,              "Rotate",           OPTV_ANYSTR,  {0}, FALSE},
      {OPTION_VIDEORAM,            "VideoRAM",         OPTV_INTEGER, {0}, FALSE},
      {OPTION_ACTIVEDEVICE,        "ActiveDevice",     OPTV_ANYSTR,  {0}, FALSE},
-@@ -307,6 +309,7 @@ VIASetup(pointer module, pointer opts, int *errmaj
+@@ -276,6 +279,7 @@ static OptionInfoRec VIAOptions[] = {
+     {OPTION_MODE_SWITCH_METHOD,  "ModeSwitchMethod", OPTV_ANYSTR,  {0}, FALSE},
+     {OPTION_MAX_DRIMEM,          "MaxDRIMem",        OPTV_INTEGER, {0}, FALSE},
+     {OPTION_AGPMEM,              "AGPMem",           OPTV_INTEGER, {0}, FALSE},
++    {OPTION_I2CDEVICES,          "I2CDevices",       OPTV_ANYSTR,  {0}, FALSE},
+     {-1,                         NULL,               OPTV_NONE,    {0}, FALSE}
+ };
+ 
+@@ -307,6 +311,7 @@ VIASetup(pointer module, pointer opts, int *errmaj
  {
      static Bool setupDone = FALSE;
  
@@ -719,7 +868,7 @@ Index: src/via_driver.c
      if (!setupDone) {
          setupDone = TRUE;
          xf86AddDriver(&VIA, module,
-@@ -339,6 +342,7 @@ VIAGetRec(ScrnInfoPtr pScrn)
+@@ -339,6 +344,7 @@ VIAGetRec(ScrnInfoPtr pScrn)
      if (pScrn->driverPrivate)
          return TRUE;
  
@@ -727,7 +876,7 @@ Index: src/via_driver.c
      pScrn->driverPrivate = xnfcalloc(sizeof(VIARec), 1);
      VIAPtr pVia = ((VIARec *) (pScrn->driverPrivate));
  
-@@ -455,7 +459,6 @@ via_pci_probe(DriverPtr driver, int entity_num,
+@@ -455,7 +461,6 @@ via_pci_probe(DriverPtr driver, int entity_num,
  {
      ScrnInfoPtr scrn = NULL;
      EntityInfoPtr entity;
@@ -735,7 +884,7 @@ Index: src/via_driver.c
  
      scrn = xf86ConfigPciEntity(scrn, 0, entity_num, VIAPciChipsets,
                                 NULL, NULL, NULL, NULL, NULL);
-@@ -652,6 +655,12 @@ VIAProbeDDC(ScrnInfoPtr pScrn, int index)
+@@ -652,6 +657,12 @@ VIAProbeDDC(ScrnInfoPtr pScrn, int index)
      vbeInfoPtr pVbe;
  
      if (xf86LoadSubModule(pScrn, "vbe")) {
@@ -748,7 +897,7 @@ Index: src/via_driver.c
          pVbe = VBEInit(NULL, index);
          ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
          vbeFree(pVbe);
-@@ -664,7 +673,7 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
+@@ -664,7 +675,7 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
      VIAPtr pVia = VIAPTR(pScrn);
      VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
  
@@ -757,7 +906,12 @@ Index: src/via_driver.c
  
      pVia->shadowFB = FALSE;
      pVia->NoAccel = FALSE;
-@@ -688,6 +697,9 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
+@@ -684,10 +695,14 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
+     pVia->maxDriSize = 0;
+     pVia->agpMem = AGP_SIZE / 1024;
+     pVia->ActiveDevice = 0x00;
++    pVia->I2CDevices = 0x00;
+     pVia->VideoEngine = VIDEO_ENGINE_CLE;
  #ifdef HAVE_DEBUG
      pVia->PrintVGARegs = FALSE;
  #endif
@@ -767,7 +921,7 @@ Index: src/via_driver.c
      pVia->swov.maxWInterp = 800;
      pVia->swov.maxHInterp = 600;
      pVia->useLegacyVBE = TRUE;
-@@ -713,11 +725,14 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
+@@ -713,11 +728,14 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
              pVia->UseLegacyModeSwitch = TRUE;
              break;
          case VIA_PM800:
@@ -784,7 +938,18 @@ Index: src/via_driver.c
              break;
          case VIA_K8M890:
              pVia->VideoEngine = VIDEO_ENGINE_CME;
-@@ -1050,19 +1065,13 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -744,8 +762,8 @@ VIASetupDefaultOptions(ScrnInfoPtr pScrn)
+         case VIA_VX800:
+         case VIA_VX855:
+             pVia->VideoEngine = VIDEO_ENGINE_CME;
+-            /* pVia->agpEnable = FALSE;
+-            pVia->dmaXV = FALSE;*/
++            pVia->agpEnable = FALSE;
++            pVia->dmaXV = FALSE;
+             break;
+     }
+ 
+@@ -1050,19 +1068,13 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
          xf86DrvMsg(pScrn->scrnIndex, from,
                     "Probed amount of VideoRAM = %d kB\n", pScrn->videoRam);
  
@@ -804,7 +969,7 @@ Index: src/via_driver.c
      if (xf86GetOptValInteger(VIAOptions, OPTION_VIDEORAM, &pScrn->videoRam))
          xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
                     "Setting amount of VideoRAM to %d kB\n", pScrn->videoRam);
-@@ -1100,6 +1109,31 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1100,6 +1112,31 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
      }
  
      /* When rotating, switch shadow framebuffer on and acceleration off. */
@@ -836,7 +1001,7 @@ Index: src/via_driver.c
      if ((s = xf86GetOptValString(VIAOptions, OPTION_ROTATE))) {
          if (!xf86NameCmp(s, "CW")) {
              pVia->shadowFB = TRUE;
-@@ -1498,6 +1532,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1498,6 +1535,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
          }
      }
  
@@ -844,7 +1009,25 @@ Index: src/via_driver.c
      Gamma zeros = { 0.0, 0.0, 0.0 };
      if (!xf86SetGamma(pScrn, zeros)) {
          VIAFreeRec(pScrn);
-@@ -1561,9 +1596,8 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1523,6 +1561,17 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+ 
+     pVia->videoRambytes = pScrn->videoRam << 10;
+ 
++    /* I2CDevices Option for I2C Initialization */
++    //pVia->I2CDevices = 0x00;
++    if ((s = xf86GetOptValString(VIAOptions, OPTION_I2CDEVICES))) {
++        if (strstr(s, "Bus1"))
++            pVia->I2CDevices |= VIA_I2C_BUS1;
++        if (strstr(s, "Bus2"))
++            pVia->I2CDevices |= VIA_I2C_BUS2;
++        if (strstr(s, "Bus3"))  
++            pVia->I2CDevices |= VIA_I2C_BUS3;
++    }
++
+     if (!xf86LoadSubModule(pScrn, "i2c")) {
+         VIAFreeRec(pScrn);
+         return FALSE;
+@@ -1561,9 +1610,8 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
  
      if (pBIOSInfo->Panel->IsActive &&
          ((pVia->Chipset == VIA_K8M800) ||
@@ -855,7 +1038,7 @@ Index: src/via_driver.c
                     "VM800 is currently not supported.\n");
          xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                     "Using VBE to set modes to work around this.\n");
-@@ -1621,7 +1655,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1621,7 +1669,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
           *
           * CLE266A: primary AdjustFrame can use only 24 bits, so we are limited
           * to 12x11 bits; 4080x2048 (~2:1), 3344x2508 (4:3), or 2896x2896 (1:1).
@@ -864,7 +1047,7 @@ Index: src/via_driver.c
           *
           * We should be able to limit the memory available for a mode to 32 MB,
           * but xf86ValidateModes (or miScanLineWidth) fails to catch this
-@@ -1629,13 +1663,14 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1629,13 +1677,14 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
           */
  
          /* Select valid modes from those available. */
@@ -883,7 +1066,7 @@ Index: src/via_driver.c
                                128,      /* min height */
                                2508,     /* max height */
                                pScrn->display->virtualX, /* virtual width */
-@@ -1650,6 +1685,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1650,6 +1699,7 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
              return FALSE;
          }
  
@@ -891,7 +1074,7 @@ Index: src/via_driver.c
          xf86PruneDriverModes(pScrn);
  
          if (i == 0 || pScrn->modes == NULL) {
-@@ -1662,9 +1698,17 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
+@@ -1662,9 +1712,17 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
      /* Set up screen parameters. */
      pVia->Bpp = pScrn->bitsPerPixel >> 3;
      pVia->Bpl = pScrn->displayWidth * pVia->Bpp;
@@ -909,7 +1092,7 @@ Index: src/via_driver.c
      xf86SetDpi(pScrn, 0, 0);
  
  #ifdef USE_FB
-@@ -1935,7 +1979,9 @@ VIASave(ScrnInfoPtr pScrn)
+@@ -1935,7 +1993,9 @@ VIASave(ScrnInfoPtr pScrn)
          Regs->SR17 = hwp->readSeq(hwp, 0x17);
          Regs->SR18 = hwp->readSeq(hwp, 0x18);
          Regs->SR19 = hwp->readSeq(hwp, 0x19);
@@ -919,7 +1102,7 @@ Index: src/via_driver.c
          Regs->SR1B = hwp->readSeq(hwp, 0x1B);
          Regs->SR1C = hwp->readSeq(hwp, 0x1C);
          Regs->SR1D = hwp->readSeq(hwp, 0x1D);
-@@ -1977,40 +2023,56 @@ VIASave(ScrnInfoPtr pScrn)
+@@ -1977,40 +2037,56 @@ VIASave(ScrnInfoPtr pScrn)
                  Regs->SR4C = hwp->readSeq(hwp, 0x4C);
                  break;
          }
@@ -985,7 +1168,7 @@ Index: src/via_driver.c
          }
  
          /* Save TMDS status */
-@@ -2098,11 +2160,19 @@ VIARestore(ScrnInfoPtr pScrn)
+@@ -2098,11 +2174,19 @@ VIARestore(ScrnInfoPtr pScrn)
      hwp->writeSeq(hwp, 0x45, Regs->SR45);
      hwp->writeSeq(hwp, 0x46, Regs->SR46);
  
@@ -1005,7 +1188,7 @@ Index: src/via_driver.c
      switch (pVia->Chipset) {
          case VIA_CLE266:
          case VIA_KM400:
-@@ -2112,6 +2182,10 @@ VIARestore(ScrnInfoPtr pScrn)
+@@ -2112,6 +2196,10 @@ VIARestore(ScrnInfoPtr pScrn)
              hwp->writeSeq(hwp, 0x4A, Regs->SR4A);
              hwp->writeSeq(hwp, 0x4B, Regs->SR4B);
              hwp->writeSeq(hwp, 0x4C, Regs->SR4C);
@@ -1016,7 +1199,7 @@ Index: src/via_driver.c
              break;
      }
  
-@@ -2127,14 +2201,23 @@ VIARestore(ScrnInfoPtr pScrn)
+@@ -2127,14 +2215,23 @@ VIARestore(ScrnInfoPtr pScrn)
      hwp->writeCrtc(hwp, 0x32, Regs->CR32);
      /* HSYNCH Adjuster */
      hwp->writeCrtc(hwp, 0x33, Regs->CR33);
@@ -1042,7 +1225,7 @@ Index: src/via_driver.c
      hwp->writeCrtc(hwp, 0x49, Regs->CR49);
  
      /* Restore LCD control registers. */
-@@ -2453,7 +2536,6 @@ static void
+@@ -2453,7 +2550,6 @@ static void
  VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
                VisualPtr pVisual)
  {
@@ -1050,7 +1233,7 @@ Index: src/via_driver.c
      vgaHWPtr hwp = VGAHWPTR(pScrn);
  
      int i, j, index;
-@@ -2880,7 +2962,6 @@ static Bool
+@@ -2880,7 +2976,6 @@ static Bool
  VIAWriteMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
  {
      VIAPtr pVia = VIAPTR(pScrn);
@@ -1058,7 +1241,7 @@ Index: src/via_driver.c
  
      DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAWriteMode\n"));
  
-@@ -3033,9 +3114,7 @@ static void
+@@ -3033,9 +3128,7 @@ static void
  VIAAdjustFrame(int scrnIndex, int x, int y, int flags)
  {
      ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -1068,7 +1251,7 @@ Index: src/via_driver.c
  
      DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIAAdjustFrame %dx%d\n", x, y));
  
-@@ -3173,7 +3252,6 @@ VIASwitchMode(int scrnIndex, DisplayModePtr mode,
+@@ -3173,7 +3266,6 @@ VIASwitchMode(int scrnIndex, DisplayModePtr mode,
  static void
  VIADPMS(ScrnInfoPtr pScrn, int mode, int flags)
  {
@@ -1078,8 +1261,8 @@ Index: src/via_driver.c
  
 Index: src/via_crtc.c
 ===================================================================
---- src/via_crtc.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_crtc.c	(.../trunk)	(revision 841)
+--- src/via_crtc.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_crtc.c	(.../trunk)	(revision 853)
 @@ -234,8 +234,8 @@ ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayMode
      /* Primary starting address -> 0x00, adjustframe does the rest */
      hwp->writeCrtc(hwp, 0x0C, 0x00);
@@ -1113,10 +1296,556 @@ Index: src/via_crtc.c
  }
  
  void
+Index: src/via_swov.c
+===================================================================
+--- src/via_swov.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_swov.c	(.../trunk)	(revision 853)
+@@ -65,6 +65,31 @@
+ #define IN_VIDEO_DISPLAY     (*((unsigned long volatile *)(pVia->VidMapBase+V_FLAGS))&VBI_STATUS)
+ #define VIA_FIRETIMEOUT 40000
+ 
++enum HQV_CME_Regs {
++        HQV_SDO_CTRL1,
++        HQV_SDO_CTRL2,
++        HQV_SDO_CTRL3,
++        HQV_SDO_CTRL4
++};
++
++/* register offsets for VT3553/VX800 */
++static const unsigned hqv_cme_regs[] = {
++    [HQV_SDO_CTRL1]  = HQV_SRC_DATA_OFFSET_CONTROL1,
++    [HQV_SDO_CTRL2]  = HQV_SRC_DATA_OFFSET_CONTROL2,
++    [HQV_SDO_CTRL3]  = HQV_SRC_DATA_OFFSET_CONTROL3,
++    [HQV_SDO_CTRL4]  = HQV_SRC_DATA_OFFSET_CONTROL4
++};
++
++/* register hqv offsets for new VT3409/VX855 */
++static const unsigned hqv_cme_regs_409[] = {
++    [HQV_SDO_CTRL1]  = HQV_SRC_DATA_OFFSET_CTRL1_409,
++    [HQV_SDO_CTRL2]  = HQV_SRC_DATA_OFFSET_CTRL2_409,
++    [HQV_SDO_CTRL3]  = HQV_SRC_DATA_OFFSET_CTRL3_409,
++    [HQV_SDO_CTRL4]  = HQV_SRC_DATA_OFFSET_CTRL4_409
++};
++
++#define HQV_CME_REG(HWDiff, name) (HWDiff)->HQVCmeRegs[name]
++
+ static void
+ viaWaitVideoCommandFire(VIAPtr pVia)
+ {
+@@ -88,6 +113,7 @@ viaWaitHQVFlip(VIAPtr pVia)
+ {
+     unsigned long proReg = 0;
+     CARD32 volatile *pdwState;
++    unsigned count = 50000;
+ 
+     if (pVia->ChipId == PCI_CHIP_VT3259
+         && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE))
+@@ -96,10 +122,9 @@ viaWaitHQVFlip(VIAPtr pVia)
+     pdwState = (CARD32 volatile *)(pVia->VidMapBase + (HQV_CONTROL + proReg));
+ 
+     if (pVia->VideoEngine == VIDEO_ENGINE_CME) {
+-        // while (*pdwState & (HQV_SUBPIC_FLIP | HQV_SW_FLIP)) ;
+-	while (*pdwState & HQV_SUBPIC_FLIP);
++		while (--count && (*pdwState & HQV_SUBPIC_FLIP));
+     } else {
+-        while (!(*pdwState & HQV_FLIP_STATUS)) ;
++        while (--count && !(*pdwState & HQV_FLIP_STATUS)) ;
+     }
+ }
+ 
+@@ -109,8 +134,9 @@ viaWaitHQVFlipClear(VIAPtr pVia, unsigned long dwD
+     CARD32 volatile *pdwState =
+             (CARD32 volatile *)(pVia->VidMapBase + HQV_CONTROL);
+     *pdwState = dwData;
++    unsigned count = 50000;
+ 
+-    while ((*pdwState & HQV_FLIP_STATUS)) {
++    while (--count && (*pdwState & HQV_FLIP_STATUS)) {
+         VIDOutD(HQV_CONTROL, *pdwState | HQV_FLIP_STATUS);
+     }
+ }
+@@ -126,6 +152,7 @@ viaWaitHQVDone(VIAPtr pVia)
+ {
+     CARD32 volatile *pdwState;
+     unsigned long proReg = 0;
++    unsigned count = 50000;
+ 
+     if (pVia->ChipId == PCI_CHIP_VT3259
+         && !(pVia->swov.gdwVideoFlagSW & VIDEO_1_INUSE))
+@@ -133,7 +160,7 @@ viaWaitHQVDone(VIAPtr pVia)
+ 
+     pdwState = (CARD32 volatile *)(pVia->VidMapBase + (HQV_CONTROL + proReg));
+     if (pVia->swov.MPEG_ON) {
+-        while ((*pdwState & HQV_SW_FLIP)) ;
++        while (--count && (*pdwState & HQV_SW_FLIP)) ;
+     }
+ }
+ 
+@@ -179,12 +206,14 @@ ResetVidRegBuffer(VIAPtr pVia)
+ static void
+ SaveVideoRegister(VIAPtr pVia, CARD32 index, CARD32 data)
+ {
++    if (pVia->VidRegCursor >= VIDREG_BUFFER_SIZE) {
++        DBG_DD(ErrorF("SaveVideoRegister: Out of video register space flushing"));
++        FlushVidRegBuffer(pVia);
++        ResetVidRegBuffer(pVia);
++    }
++
+     pVia->VidRegBuffer[pVia->VidRegCursor++] = index;
+     pVia->VidRegBuffer[pVia->VidRegCursor++] = data;
+-
+-    if (pVia->VidRegCursor > VIDREG_BUFFER_SIZE) {
+-        DBG_DD(ErrorF("SaveVideoRegister: Out of video register space"));
+-    }
+ }
+ 
+ /*
+@@ -224,6 +253,7 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+                 HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+                 HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
+             }
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
+             break;
+         case VIA_KM400:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -232,6 +262,7 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
+             break;
+         case VIA_K8M800:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -240,6 +271,7 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
+             break;
+         case VIA_PM800:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -248,6 +280,7 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
+             break;
+         case VIA_VM800:
+         case VIA_P4M900:
+@@ -257,6 +290,8 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs;
+             break;
+         case VIA_K8M890:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -265,6 +300,8 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_TRUE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs;
+             break;
+         case VIA_P4M890:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -273,6 +310,8 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_TRUE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs;
+             break;
+         case VIA_CX700:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+@@ -281,8 +320,19 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_FALSE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs;
+             break;
+         case VIA_VX800:
++            HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
++            HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE;
++            HWDiff->dwSupportTwoColorKey = VID_HWDIFF_TRUE;
++            HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
++            HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE;
++            HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_TRUE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs;
++            break;
+         case VIA_VX855:
+             HWDiff->dwThreeHQVBuffer = VID_HWDIFF_TRUE;
+             HWDiff->dwHQVFetchByteUnit = VID_HWDIFF_TRUE;
+@@ -290,6 +340,8 @@ VIAVidHWDiffInit(ScrnInfoPtr pScrn)
+             HWDiff->dwHQVInitPatch = VID_HWDIFF_FALSE;
+             HWDiff->dwHQVDisablePatch = VID_HWDIFF_FALSE;
+             HWDiff->dwNeedV1Prefetch = VID_HWDIFF_FALSE;
++            HWDiff->dwNewScaleCtl = VID_HWDIFF_TRUE;
++            HWDiff->HQVCmeRegs = hqv_cme_regs_409;
+             break;
+         default:
+             xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+@@ -509,10 +561,12 @@ viaOverlayHQVCalcZoomWidth(VIAPtr pVia,
+                            unsigned long *pMiniCtl,
+                            unsigned long *pHQVfilterCtl,
+                            unsigned long *pHQVminiCtl,
++                           unsigned long *pHQVscaleCtlH,
+                            unsigned long *pHQVzoomflag)
+ {
+     unsigned long tmp, sw1, d, falign, mdiv;
+     Bool zoom_ok = TRUE;
++    VIAHWDiff *hwDiff = &pVia->HWDiff;
+ 
+     CARD32 HQVfilter[5] = { HQV_H_FILTER_DEFAULT, HQV_H_TAP4_121,
+         HQV_H_TAP4_121, HQV_H_TAP8_12221, HQV_H_TAP8_12221
+@@ -525,24 +579,57 @@ viaOverlayHQVCalcZoomWidth(VIAPtr pVia,
+     if (srcWidth == dstWidth) { /* No zoom */
+         *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT;
+     } else if (srcWidth < dstWidth) { /* Zoom in */
++			*pZoomCtl &= 0x0000FFFF;
++	        tmp = srcWidth * 0x800 / dstWidth;
++	        *pZoomCtl |= ((tmp & 0x7ff) << 16) | V1_X_ZOOM_ENABLE;
++	        *pMiniCtl |= V1_X_INTERPOLY;
++	        zoom_ok = !(tmp > 0x7ff);
+ 
+-        tmp = srcWidth * 0x800 / dstWidth;
+-        *pZoomCtl = ((tmp & 0x7ff) << 16) | V1_X_ZOOM_ENABLE;
+-        *pMiniCtl |= V1_X_INTERPOLY;
+-        zoom_ok = !(tmp > 0x7ff);
++	        *pHQVzoomflag = 1;
++	        *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT;
++    } else { /* srcWidth > dstWidth - Zoom out */
++		if (hwDiff->dwNewScaleCtl) {
++            if (srcWidth > (dstWidth << 3)) {
++                /*<1/8*/
++                /*FIXME!*/
++                if (dstWidth <= 32) {
++                    dstWidth = 33;
++                }
++                if (srcWidth > (dstWidth << 5)) {
++                    tmp = 1 * 0x1000 / 31;
++                } else {
++                    tmp = (dstWidth * 0x1000) / srcWidth;
++                }
+ 
+-        *pHQVzoomflag = 1;
+-        *pHQVfilterCtl |= HQV_H_FILTER_DEFAULT;
++                *pHQVscaleCtlH = HQV_H_SCALE_DOWN_UNDER_EIGHTH;
++            } else if (srcWidth == (dstWidth << 3)) {
++                /*1/8*/
++                tmp = ((dstWidth - 1) * 0x1000) / srcWidth;
++                *pHQVscaleCtlH = HQV_H_SCALE_DOWN_UNDER_EIGHTH;
++            } else if (srcWidth > (dstWidth << 2)) {
++                /*1/4 -1/8 zoom-out*/
++                tmp = (srcWidth * 0x1000) / dstWidth;
++                *pHQVscaleCtlH = HQV_H_SCALE_DOWN_FOURTH_TO_EIGHTH;
++            } else {
++                /*1-1/4 zoom-out*/
++                /*setting :src/(destination+0.5)*/
++                tmp = (srcWidth * 0x2000) / ((dstWidth << 1) + 1);
++                *pHQVscaleCtlH = HQV_H_SCALE_DOWN_FOURTH_TO_1;
++            }
+ 
+-    } else { /* srcWidth > dstWidth - Zoom out */
++            /*rounding to nearest interger*/
++            tmp += (((tmp * 0x1000) & 0xfff) > 1) ? 1 : 0;
++            *pHQVscaleCtlH |= (tmp & 0x7fff) | HQV_H_SCALE_ENABLE;
++		} else {
++	        /* HQV rounding patch, instead of:
++	         * //tmp = dstWidth*0x0800 / srcWidth; */
++	        tmp = dstWidth * 0x800 * 0x400 / srcWidth;
++	        tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0);
+ 
+-        /* HQV rounding patch, instead of:
+-         * //tmp = dstWidth*0x0800 / srcWidth; */
+-        tmp = dstWidth * 0x800 * 0x400 / srcWidth;
+-        tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0);
++	        *pHQVminiCtl = (tmp & 0x7ff) | HQV_H_MINIFY_ENABLE | HQV_H_MINIFY_DOWN;
+ 
+-        *pHQVminiCtl = (tmp & 0x7ff) | HQV_H_MINIFY_ENABLE | HQV_H_MINIFY_DOWN;
+-
++	        *pHQVminiCtl |= HQV_HDEBLOCK_FILTER;
++		}
+         /* Scale down the picture by a factor mdiv = (1 << d) = {2, 4, 8 or 16} */
+ 
+         sw1 = srcWidth;
+@@ -561,27 +648,25 @@ viaOverlayHQVCalcZoomWidth(VIAPtr pVia,
+         *pMiniCtl |= ((d << 1) - 1) << 24; /* <= {1,3,5,7} << 24 */
+ 
+         *pHQVfilterCtl |= HQVfilter[d];
+-        /* *pHQVminiCtl = HQVmini[d]; */
+-        *pHQVminiCtl |= HQV_HDEBLOCK_FILTER;
+ 
+-        /* Scale to arbitrary size, on top of previous scaling by (1 << d). */
++       	/* Scale to arbitrary size, on top of previous scaling by (1 << d). */
+ 
+-        if (sw1 < dstWidth) {
+-            /* CLE bug
+-             *pZoomCtl = sw1 * 0x0800 / dstWidth;*/
+-            *pZoomCtl = (sw1 - 2) * 0x0800 / dstWidth;
+-            *pZoomCtl = ((*pZoomCtl & 0x7ff) << 16) | V1_X_ZOOM_ENABLE;
+-        }
+-    }
++       	if (sw1 < dstWidth) {
++            	/* CLE bug
++           	*pZoomCtl = sw1 * 0x0800 / dstWidth;*/
++           	*pZoomCtl = (sw1 - 2) * 0x0800 / dstWidth;
++           	*pZoomCtl = ((*pZoomCtl & 0x7ff) << 16) | V1_X_ZOOM_ENABLE;
++   		}
+ 
+-    if (videoFlag & VIDEO_1_INUSE) {
+-        pVia->swov.overlayRecordV1.dwFetchAlignment = falign;
+-        pVia->swov.overlayRecordV1.dwminifyH = mdiv;
+-    } else {
+-        pVia->swov.overlayRecordV3.dwFetchAlignment = falign;
+-        pVia->swov.overlayRecordV3.dwminifyH = mdiv;
+-    }
++    	if (videoFlag & VIDEO_1_INUSE) {
++        	pVia->swov.overlayRecordV1.dwFetchAlignment = falign;
++        	pVia->swov.overlayRecordV1.dwminifyH = mdiv;
++    	} else {
++        	pVia->swov.overlayRecordV3.dwFetchAlignment = falign;
++        	pVia->swov.overlayRecordV3.dwminifyH = mdiv;
++    	}
+ 
++	}
+     return zoom_ok;
+ }
+ 
+@@ -591,10 +676,12 @@ viaOverlayHQVCalcZoomHeight(VIAPtr pVia,
+                             unsigned long *pZoomCtl, unsigned long *pMiniCtl,
+                             unsigned long *pHQVfilterCtl,
+                             unsigned long *pHQVminiCtl,
++                            unsigned long *pHQVscaleCtlV,
+                             unsigned long *pHQVzoomflag)
+ {
+     unsigned long tmp, sh1, d;
+     Bool zoom_ok = TRUE;
++    VIAHWDiff *hwDiff = &pVia->HWDiff;
+ 
+     CARD32 HQVfilter[5] = { HQV_V_TAP4_121, HQV_V_TAP4_121, HQV_V_TAP4_121,
+                             HQV_V_TAP8_12221, HQV_V_TAP8_12221 };
+@@ -608,48 +695,58 @@ viaOverlayHQVCalcZoomHeight(VIAPtr pVia,
+     if (srcHeight == dstHeight) { /* No zoom */
+         *pHQVfilterCtl |= HQV_V_TAP4_121;
+     } else if (srcHeight < dstHeight) { /* Zoom in */
++		*pZoomCtl &= 0xFFFF0000;
++	    tmp = srcHeight * 0x400 / dstHeight - 1;
++	    *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE);
++	    *pMiniCtl |= (V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY);
+ 
+-        tmp = srcHeight * 0x0400 / dstHeight;
+-        *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE);
+-        *pMiniCtl |= (V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY);
+-
+-        *pHQVzoomflag = 1;
+-        *pHQVfilterCtl |= HQV_V_TAP4_121;
++	    *pHQVzoomflag = 1;
++	    *pHQVfilterCtl |= HQV_V_TAP4_121;
+     } else { /* srcHeight > dstHeight - Zoom out */
++		if (hwDiff->dwNewScaleCtl) {
++            /*setting :src/(destination+0.5)*/
++            tmp = srcHeight * 0x2000 / ((dstHeight << 1) + 1);
++            tmp += (((tmp * 0x1000) & 0xfff) > 1) ? 1 : 0;
++            if ((tmp & 0x1ffff) == 0) {
++                tmp = 0x1ffff;
++            }
+ 
+-        /* HQV rounding patch, instead of:
+-         * //tmp = dstHeight*0x0800 / srcHeight; */
+-        tmp = dstHeight * 0x0800 * 0x400 / srcHeight;
+-        tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0);
+-        *pHQVminiCtl |= (((tmp & 0x7ff) << 16) | HQV_V_MINIFY_ENABLE
+-                         | HQV_V_MINIFY_DOWN);
++            *pHQVscaleCtlV = (tmp & 0x1ffff) | HQV_V_SCALE_ENABLE| HQV_V_SCALE_DOWN;
++		} else {
++	        /* HQV rounding patch, instead of:
++	         * //tmp = dstHeight*0x0800 / srcHeight; */
++	        tmp = dstHeight * 0x0800 * 0x400 / srcHeight;
++	        tmp = tmp / 0x400 + ((tmp & 0x3ff) ? 1 : 0);
++	        *pHQVminiCtl |= (((tmp & 0x7ff) << 16) | HQV_V_MINIFY_ENABLE
++	                         | HQV_V_MINIFY_DOWN);
+ 
+-        /* Scale down the picture by a factor (1 << d) = {2, 4, 8 or 16} */
++	        /* Scale down the picture by a factor (1 << d) = {2, 4, 8 or 16} */
++	
++	        sh1 = srcHeight;
++	        for (d = 1; d < 5; d++) {
++	            sh1 >>= 1;
++	            if (sh1 <= dstHeight)
++	                break;
++	        }
++	        if (d == 5) { /* Too small. */
++	            d = 4;
++	            zoom_ok = FALSE;
++	        }
+ 
+-        sh1 = srcHeight;
+-        for (d = 1; d < 5; d++) {
+-            sh1 >>= 1;
+-            if (sh1 <= dstHeight)
+-                break;
+-        }
+-        if (d == 5) { /* Too small. */
+-            d = 4;
+-            zoom_ok = FALSE;
+-        }
++	        *pMiniCtl |= ((d << 1) - 1) << 16; /* <= {1,3,5,7} << 16 */
+ 
+-        *pMiniCtl |= ((d << 1) - 1) << 16; /* <= {1,3,5,7} << 16 */
++	        *pHQVfilterCtl |= HQVfilter[d];
++	        /* *pHQVminiCtl |= HQVmini[d]; */
++	        *pHQVminiCtl |= HQV_VDEBLOCK_FILTER;
+ 
+-        *pHQVfilterCtl |= HQVfilter[d];
+-        /* *pHQVminiCtl |= HQVmini[d]; */
+-        *pHQVminiCtl |= HQV_VDEBLOCK_FILTER;
++	        /* Scale to arbitrary size, on top of previous scaling by (1 << d). */
+ 
+-        /* Scale to arbitrary size, on top of previous scaling by (1 << d). */
+-
+-        if (sh1 < dstHeight) {
+-            tmp = sh1 * 0x0400 / dstHeight;
+-            *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE);
+-            *pMiniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY;
+-        }
++	        if (sh1 < dstHeight) {
++	            tmp = sh1 * 0x0400 / dstHeight;
++	            *pZoomCtl |= ((tmp & 0x3ff) | V1_Y_ZOOM_ENABLE);
++	            *pMiniCtl |= V1_Y_INTERPOLY | V1_YCBCR_INTERPOLY;
++	        }
++		}
+     }
+ 
+     return zoom_ok;
+@@ -1488,6 +1585,7 @@ SetColorKey(VIAPtr pVia, unsigned long videoFlag,
+ 
+     if (videoFlag & VIDEO_1_INUSE) {
+         SaveVideoRegister(pVia, V_COLOR_KEY, keyLow);
++        SaveVideoRegister(pVia, SND_COLOR_KEY, keyLow);
+     } else {
+         if (pVia->HWDiff.dwSupportTwoColorKey)    /*CLE_C0 */
+             SaveVideoRegister(pVia, V3_COLOR_KEY, keyLow);
+@@ -1561,8 +1659,9 @@ SetHQVFetch(VIAPtr pVia, CARD32 srcFetch, unsigned
+         srcFetch >>= 3;  /* fetch unit is 8 bytes */
+     }
+ 
+-    SaveVideoRegister(pVia, HQV_SRC_FETCH_LINE + proReg,
+-                      ((srcFetch - 1) << 16) | (srcHeight - 1));
++    if (pVia->ChipId != PCI_CHIP_VT3409)
++        SaveVideoRegister(pVia, HQV_SRC_FETCH_LINE + proReg,
++                          ((srcFetch - 1) << 16) | (srcHeight - 1));
+ }
+ 
+ static void
+@@ -1713,6 +1812,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+     unsigned long zoomCtl = 0, miniCtl = 0;
+     unsigned long hqvCtl = 0;
+     unsigned long hqvFilterCtl = 0, hqvMiniCtl = 0;
++    unsigned long hqvScaleCtlH = 0, hqvScaleCtlV = 0;
+     unsigned long haveHQVzoomH = 0, haveHQVzoomV = 0;
+     unsigned long hqvSrcWidth = 0, hqvDstWidth = 0;
+     unsigned long hqvSrcFetch = 0, hqvOffset = 0;
+@@ -1762,16 +1862,16 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+ 
+     /* 
+      * FIXME:
+-     * Enable video on secondary 
++     * Enable video on secondary (change Panel to SecondCRTC?)
+      */
+     if ((pVia->VideoEngine == VIDEO_ENGINE_CME
+          || pVia->Chipset == VIA_VM800)
+         && pVia->pBIOSInfo->Panel->IsActive) {
+ 
+         /* V1_ON_SND_DISPLAY */
+-        vidCtl |= 0x80000000;
++        vidCtl |= V1_ON_SND_DISPLAY;
+         /* SECOND_DISPLAY_COLOR_KEY_ENABLE */
+-        compose |= 0x00010000 | 0x1;
++        compose |= SECOND_DISPLAY_COLOR_KEY_ENABLE | 0x1;
+     }
+ 
+     viaOverlayGetV1V3Format(pVia, (videoFlag & VIDEO_1_INUSE) ? 1 : 3,
+@@ -1925,7 +2025,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+ 
+     if (!viaOverlayHQVCalcZoomWidth(pVia, videoFlag, srcWidth, dstWidth,
+                                     &zoomCtl, &miniCtl, &hqvFilterCtl,
+-                                    &hqvMiniCtl, &haveHQVzoomH)) {
++                                    &hqvMiniCtl, &hqvScaleCtlH, &haveHQVzoomH)) {
+         /* Need to scale (minify) too much - can't handle it. */
+         SetFetch(pVia, videoFlag, fetch);
+         FireVideoCommand(pVia, videoFlag, compose);
+@@ -1964,7 +2064,7 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+ 
+     if (!viaOverlayHQVCalcZoomHeight(pVia, srcHeight, dstHeight, &zoomCtl,
+                                      &miniCtl, &hqvFilterCtl, &hqvMiniCtl,
+-                                     &haveHQVzoomV)) {
++                                     &hqvScaleCtlV, &haveHQVzoomV)) {
+         /* Need to scale (minify) too much - can't handle it. */
+         FireVideoCommand(pVia, videoFlag, compose);
+         FlushVidRegBuffer(pVia);
+@@ -2008,8 +2108,13 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+                 hqvFilterCtl &= 0xfffdffff;
+             SetMiniAndZoom(pVia, videoFlag, 0, 0);
+         }
+-        SaveVideoRegister(pVia, HQV_MINIFY_CONTROL + proReg, hqvMiniCtl);
+-        SaveVideoRegister(pVia, HQV_FILTER_CONTROL + proReg, hqvFilterCtl);
++		if (hwDiff->dwNewScaleCtl) {
++        	SaveVideoRegister(pVia, HQV_H_SCALE_CONTROL + proReg, hqvScaleCtlH);
++        	SaveVideoRegister(pVia, HQV_V_SCALE_CONTROL + proReg, hqvScaleCtlV);
++		} else {
++        	SaveVideoRegister(pVia, HQV_MINIFY_CONTROL + proReg, hqvMiniCtl);
++		}
++       	SaveVideoRegister(pVia, HQV_FILTER_CONTROL + proReg, hqvFilterCtl);
+     } else
+         SetMiniAndZoom(pVia, videoFlag, miniCtl, zoomCtl);
+ 
+@@ -2022,11 +2127,24 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+                                miniCtl, compose);
+ 
+     if (pVia->VideoEngine == VIDEO_ENGINE_CME) {
+-        VIDOutD(HQV_SRC_DATA_OFFSET_CONTROL1,0);
+-        VIDOutD(HQV_SRC_DATA_OFFSET_CONTROL3,((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++        SaveVideoRegister(pVia, HQV_CME_REG(hwDiff, HQV_SDO_CTRL1),0);
++        SaveVideoRegister(pVia, HQV_CME_REG(hwDiff, HQV_SDO_CTRL3),((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
+         if (pVia->Chipset == VIA_VX800 || pVia->Chipset == VIA_VX855) {
+-            VIDOutD(HQV_SRC_DATA_OFFSET_CONTROL2,0);
+-            VIDOutD(HQV_SRC_DATA_OFFSET_CONTROL4,((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++            SaveVideoRegister(pVia, HQV_CME_REG(hwDiff, HQV_SDO_CTRL2),0);
++            SaveVideoRegister(pVia, HQV_CME_REG(hwDiff, HQV_SDO_CTRL4),((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++            if (pVia->Chipset == VIA_VX855) {
++                SaveVideoRegister(pVia, HQV_DST_DATA_OFFSET_CTRL1,0);
++                SaveVideoRegister(pVia, HQV_DST_DATA_OFFSET_CTRL3,((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++                SaveVideoRegister(pVia, HQV_DST_DATA_OFFSET_CTRL2,0);
++                SaveVideoRegister(pVia, HQV_DST_DATA_OFFSET_CTRL4,((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++                SaveVideoRegister(pVia, HQV_BACKGROUND_DATA_OFFSET,((pUpdate->SrcRight - 1 ) << 16) | (pUpdate->SrcBottom - 1));
++                SaveVideoRegister(pVia, HQV_EXTENDED_CONTROL,0);
++                /*0x3e0*/
++                SaveVideoRegister(pVia, HQV_SUBP_HSCALE_CTRL,0);
++                /*0x3e8*/
++                SaveVideoRegister(pVia, HQV_SUBP_VSCALE_CTRL,0);
++                SaveVideoRegister(pVia, HQV_DEFAULT_VIDEO_COLOR, HQV_FIX_COLOR);
++            }
+         }
+     }
+ 
+@@ -2062,9 +2180,6 @@ Upd_Video(ScrnInfoPtr pScrn, unsigned long videoFl
+                     usleep(1);
+                 }
+ 
+-                if (pVia->VideoEngine == VIDEO_ENGINE_CME)
+-                    hqvCtl |= HQV_GEN_IRQ;
+-
+                 VIDOutD(HQV_CONTROL + proReg, hqvCtl & ~HQV_SW_FLIP);
+                 VIDOutD(HQV_CONTROL + proReg, hqvCtl | HQV_SW_FLIP);
+ 
 Index: src/via_driver.h
 ===================================================================
---- src/via_driver.h	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_driver.h	(.../trunk)	(revision 841)
+--- src/via_driver.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_driver.h	(.../trunk)	(revision 853)
 @@ -130,6 +130,7 @@ typedef struct {
      CARD8   SR4A, SR4B, SR4C;
  
@@ -1125,7 +1854,23 @@ Index: src/via_driver.h
      CARD8   CR13, CR30, CR31, CR32, CR33, CR34, CR35, CR36;
      CARD8   CR37, CR38, CR39, CR3A, CR40, CR41, CR42, CR43;
      CARD8   CR44, CR45, CR46, CR47, CR48, CR49, CR4A;
-@@ -418,10 +419,10 @@ typedef struct _VIA {
+@@ -285,6 +286,7 @@ typedef struct _VIA {
+     Bool                agpDMA;
+     Bool                nPOT[VIA_NUM_TEXUNITS];
+     const unsigned     *TwodRegs;
++    const unsigned     *HqvCmeRegs;
+     ExaDriverPtr        exaDriverPtr;
+     ExaOffscreenArea   *exa_scratch;
+     unsigned int        exa_scratch_next;
+@@ -412,16 +414,18 @@ typedef struct _VIA {
+     void                *cursorMap;
+     CARD32              cursorOffset;
+ 
++    CARD8               I2CDevices;	/* Option */
++
+ #ifdef HAVE_DEBUG
+     Bool                disableXvBWCheck;
+     Bool                DumpVGAROM;
      Bool                PrintVGARegs;
      Bool                PrintTVRegs;
      Bool                I2CScan;
@@ -1137,10 +1882,39 @@ Index: src/via_driver.h
  } VIARec, *VIAPtr;
  
  #define VIAPTR(p) ((VIAPtr)((p)->driverPrivate))
+Index: src/via_bios.h
+===================================================================
+--- src/via_bios.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_bios.h	(.../trunk)	(revision 853)
+@@ -82,6 +82,11 @@
+ #define	    VIA_DEVICE_TV		    0x04
+ #define	    VIA_DEVICE_DFP		    0x08
+ 
++#define     VIA_I2C_NONE                    0x00
++#define     VIA_I2C_BUS1                    0x01
++#define     VIA_I2C_BUS2                    0x02
++#define     VIA_I2C_BUS3                    0x04
++
+ /* System Memory CLK */
+ #define VIA_MEM_SDR66   0x00
+ #define VIA_MEM_SDR100  0x01
+Index: src/via_swov.h
+===================================================================
+--- src/via_swov.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_swov.h	(.../trunk)	(revision 853)
+@@ -73,6 +73,8 @@ typedef struct __VIAHWDiff
+     /*unsigned long dwV3FIFOPatch; *//* For CLE V3 FIFO Bug (srcWidth <= 8) */
+     unsigned long dwSupportTwoColorKey;	/* Support two color key */
+     /* unsigned long dwCxColorSpace; *//* CLE_Cx ColorSpace */
++    unsigned dwNewScaleCtl; /* Use new HQV scale engine code */
++    const unsigned *HQVCmeRegs; /* Which set of CME regs to use for newer chipsets */
+ } VIAHWDiff;
+ 
+ void VIAVidHWDiffInit(ScrnInfoPtr pScrn);
 Index: src/via_bandwidth.c
 ===================================================================
---- src/via_bandwidth.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_bandwidth.c	(.../trunk)	(revision 841)
+--- src/via_bandwidth.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_bandwidth.c	(.../trunk)	(revision 853)
 @@ -194,6 +194,7 @@ ViaSetPrimaryFIFO(ScrnInfoPtr pScrn, DisplayModePt
              else
                  ViaSeqMask(hwp, 0x22, 0x00, 0x1F);  /* 128/4 = overflow = 0 */
@@ -1273,11 +2047,149 @@ Index: src/via_bandwidth.c
              break;
          case VIA_P4M900:
              ViaCrtcMask(hwp, 0x68, 0xB0, 0xF0);
+@@ -418,6 +462,21 @@ ViaSetSecondaryFIFO(ScrnInfoPtr pScrn, DisplayMode
+                 ViaCrtcMask(hwp, 0x94, 0x20, 0x7F);
+             break;
+         case VIA_VX855:
++            /* {CR68,4,7},{CR94,7,7},{CR95,7,7} : 200/8-1 = 0x7c */
++            ViaCrtcMask(hwp, 0x68, 0xF0, 0xF0); 
++            ViaCrtcMask(hwp, 0x94, 0x00, 0x80);
++            ViaCrtcMask(hwp, 0x95, 0x00, 0x80);
++            /* {CR68,0,3},{CR95,4,6} : 160/4 = 0x28 */
++            ViaCrtcMask(hwp, 0x68, 0x00, 0x0F);
++            ViaCrtcMask(hwp, 0x95, 0x10, 0x70);
++            /* {CR92,0,3},{CR95,0,2} : 160/4 = 0x28 */
++            ViaCrtcMask(hwp, 0x92, 0x00, 0x08);
++            ViaCrtcMask(hwp, 0x95, 0x01, 0x07);
++            /* {CR94,0,6} : 320/4 = 0x50 */
++            if ((mode->HDisplay >= 1400) && (pScrn->bitsPerPixel == 32))
++                ViaCrtcMask(hwp, 0x94, 0x08, 0x7F);
++            else
++                ViaCrtcMask(hwp, 0x94, 0x08, 0x7F);
+             break;
+         default:
+             xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ViaSetSecondaryFIFO: "
 Index: src/via_accel.c
 ===================================================================
---- src/via_accel.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_accel.c	(.../trunk)	(revision 841)
-@@ -1210,7 +1210,8 @@ viaInitXAA(ScreenPtr pScreen)
+--- src/via_accel.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_accel.c	(.../trunk)	(revision 853)
+@@ -417,6 +417,8 @@ viaDisableVQ(ScrnInfoPtr pScrn)
+     switch (pVia->Chipset) {
+         case VIA_K8M890:
+         case VIA_P4M900:
++        case VIA_VX800:
++        case VIA_VX855:
+             VIASETREG(0x41c, 0x00100000);
+             VIASETREG(0x420, 0x74301000);
+             break;
+@@ -492,6 +494,8 @@ viaInitialize2DEngine(ScrnInfoPtr pScrn)
+     switch (pVia->Chipset) {
+         case VIA_K8M890:
+         case VIA_P4M900:
++        case VIA_VX800:
++        case VIA_VX855:
+             viaInitPCIe(pVia);
+             break;
+         default:
+@@ -503,6 +507,8 @@ viaInitialize2DEngine(ScrnInfoPtr pScrn)
+         switch (pVia->Chipset) {
+             case VIA_K8M890:
+             case VIA_P4M900:
++            case VIA_VX800:
++            case VIA_VX855:
+                 viaEnablePCIeVQ(pVia);
+                 break;
+             default:
+@@ -759,6 +765,7 @@ viaSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, i
+     tdc->cmd = cmd;
+     viaAccelTransparentHelper(pVia, (trans_color != -1) ? 0x4000 : 0x0000,
+                               trans_color, FALSE);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -796,6 +803,7 @@ viaSetupForSolidFill(ScrnInfoPtr pScrn, int color,
+     tdc->cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | VIAACCELPATTERNROP(rop);
+     tdc->fgColor = color;
+     viaAccelTransparentHelper(pVia, 0x00, 0x00, FALSE);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -852,6 +860,7 @@ viaSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, i
+     tdc->pattern0 = pattern0;
+     tdc->pattern1 = pattern1;
+     viaAccelTransparentHelper(pVia, 0x00, 0x00, FALSE);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -901,6 +910,7 @@ viaSetupForColor8x8PatternFill(ScrnInfoPtr pScrn,
+     tdc->patternAddr = (patternx * pVia->Bpp + patterny * pVia->Bpl);
+     viaAccelTransparentHelper(pVia, (trans_color != -1) ? 0x4000 : 0x0000,
+                               trans_color, FALSE);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -962,9 +972,9 @@ viaSetupForCPUToScreenColorExpandFill(ScrnInfoPtr
+     tdc->fgColor = fg;
+     tdc->bgColor = bg;
+ 
++    viaAccelTransparentHelper(pVia, 0x0, 0x0, FALSE);
++
+     ADVANCE_RING;
+-
+-    viaAccelTransparentHelper(pVia, 0x0, 0x0, FALSE);
+ }
+ 
+ static void
+@@ -991,7 +1001,7 @@ viaSubsequentScanlineCPUToScreenColorExpandFill(Sc
+                        pScrn->fbOffset + sub * pVia->Bpl, tdc->mode,
+                        pVia->Bpl, pVia->Bpl, tdc->cmd);
+ 
+-    viaFlushPCI(cb);
++    ADVANCE_RING;
+     viaDisableClipping(pScrn);
+ }
+ 
+@@ -1005,9 +1015,9 @@ viaSetupForImageWrite(ScrnInfoPtr pScrn, int rop,
+     RING_VARS;
+ 
+     tdc->cmd = VIA_GEC_BLT | VIA_GEC_SRC_SYS | VIAACCELCOPYROP(rop);
+-    ADVANCE_RING;
+     viaAccelTransparentHelper(pVia, (trans_color != -1) ? 0x4000 : 0x0000,
+                               trans_color, FALSE);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -1030,7 +1040,7 @@ viaSubsequentImageWriteRect(ScrnInfoPtr pScrn, int
+                        pScrn->fbOffset + pVia->Bpl * sub, tdc->mode,
+                        pVia->Bpl, pVia->Bpl, tdc->cmd);
+ 
+-    viaFlushPCI(cb);
++    ADVANCE_RING;
+     viaDisableClipping(pScrn);
+ }
+ 
+@@ -1052,6 +1062,7 @@ viaSetupForSolidLine(ScrnInfoPtr pScrn, int color,
+     OUT_RING_H1(VIA_REG(pVia, GEMODE), tdc->mode);
+     OUT_RING_H1(VIA_REG(pVia, MONOPAT0), 0xFF);
+     OUT_RING_H1(VIA_REG(pVia, MONOPATFGC), tdc->fgColor);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -1189,6 +1200,7 @@ viaSetupForDashedLine(ScrnInfoPtr pScrn, int fg, i
+     OUT_RING_H1(VIA_REG(pVia, MONOPATFGC), tdc->fgColor);
+     OUT_RING_H1(VIA_REG(pVia, MONOPATBGC), tdc->bgColor);
+     OUT_RING_H1(VIA_REG(pVia, MONOPAT0), tdc->pattern0);
++    ADVANCE_RING;
+ }
+ 
+ static void
+@@ -1210,7 +1222,8 @@ viaInitXAA(ScreenPtr pScreen)
  
      /* General acceleration flags. */
      xaaptr->Flags = (PIXMAP_CACHE |
@@ -1287,8 +2199,24 @@ Index: src/via_accel.c
                       MICROSOFT_ZERO_LINE_BIAS | 0);
  
      if (pScrn->bitsPerPixel == 8)
-@@ -1228,14 +1229,17 @@ viaInitXAA(ScreenPtr pScreen)
+@@ -1218,24 +1231,29 @@ viaInitXAA(ScreenPtr pScreen)
  
+     xaaptr->SetClippingRectangle = viaSetClippingRectangle;
+     xaaptr->DisableClipping = viaDisableClipping;
+-    xaaptr->ClippingFlags = (HARDWARE_CLIP_SOLID_FILL |
+-                             HARDWARE_CLIP_SOLID_LINE |
+-                             HARDWARE_CLIP_DASHED_LINE |
+-                             HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
++    xaaptr->ClippingFlags = (HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
+                              HARDWARE_CLIP_MONO_8x8_FILL |
+                              HARDWARE_CLIP_COLOR_8x8_FILL |
+                              HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND | 0);
+ 
++    if (pVia->Chipset != VIA_VX855)
++    	xaaptr->ClippingFlags |= (HARDWARE_CLIP_SOLID_FILL |
++                                  HARDWARE_CLIP_SOLID_LINE |
++                                  HARDWARE_CLIP_DASHED_LINE);
++
      xaaptr->Sync = viaAccelSync;
  
 +    /* ScreenToScreen copies */
@@ -1305,7 +2233,7 @@ Index: src/via_accel.c
      xaaptr->SetupForMono8x8PatternFill = viaSetupForMono8x8PatternFill;
      xaaptr->SubsequentMono8x8PatternFillRect =
              viaSubsequentMono8x8PatternFillRect;
-@@ -1244,6 +1248,7 @@ viaInitXAA(ScreenPtr pScreen)
+@@ -1244,6 +1262,7 @@ viaInitXAA(ScreenPtr pScreen)
                                         HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
                                         BIT_ORDER_IN_BYTE_MSBFIRST | 0);
  
@@ -1313,7 +2241,7 @@ Index: src/via_accel.c
      xaaptr->SetupForColor8x8PatternFill = viaSetupForColor8x8PatternFill;
      xaaptr->SubsequentColor8x8PatternFillRect =
              viaSubsequentColor8x8PatternFillRect;
-@@ -1252,12 +1257,14 @@ viaInitXAA(ScreenPtr pScreen)
+@@ -1252,12 +1271,14 @@ viaInitXAA(ScreenPtr pScreen)
                                          HARDWARE_PATTERN_PROGRAMMED_BITS |
                                          HARDWARE_PATTERN_PROGRAMMED_ORIGIN | 0);
  
@@ -1328,7 +2256,7 @@ Index: src/via_accel.c
      xaaptr->SetupForDashedLine = viaSetupForDashedLine;
      xaaptr->SubsequentDashedTwoPointLine = viaSubsequentDashedTwoPointLine;
      xaaptr->DashPatternMaxLength = 8;
-@@ -1266,35 +1273,42 @@ viaInitXAA(ScreenPtr pScreen)
+@@ -1266,44 +1287,41 @@ viaInitXAA(ScreenPtr pScreen)
                                 LINE_PATTERN_POWER_OF_2_ONLY |
                                 LINE_PATTERN_MSBFIRST_LSBJUSTIFIED | 0);
  
@@ -1361,9 +2289,10 @@ Index: src/via_accel.c
                                 SCANLINE_PAD_DWORD |
                                 BIT_ORDER_IN_BYTE_MSBFIRST |
 -                               LEFT_EDGE_CLIPPING | ROP_NEEDS_SOURCE | 0);
+-                               // SYNC_AFTER_IMAGE_WRITE | 0);
 +                               LEFT_EDGE_CLIPPING | 
-+			       ROP_NEEDS_SOURCE | 0);
-                                // SYNC_AFTER_IMAGE_WRITE | 0);
++			       ROP_NEEDS_SOURCE |
++                               NO_GXCOPY | 0);
  
      /*
       * Most Unichromes are much faster using processor-to-framebuffer writes
@@ -1374,16 +2303,51 @@ Index: src/via_accel.c
 +     * TODO Check speed for other chipsets
       */
  
-     switch (pVia->Chipset) {
+-    switch (pVia->Chipset) {
 -        case VIA_K8M800:
 -        case VIA_K8M890:
-         case VIA_P4M900:
-         case VIA_VX800:
-         case VIA_VX855:
+-        case VIA_P4M900:
+-        case VIA_VX800:
+-        case VIA_VX855:
+-            break;
+-        default:
+-            xaaptr->ImageWriteFlags |= NO_GXCOPY;
+-            break;
+-    }
+-
+     xaaptr->SetupForImageWrite = viaSetupForImageWrite;
+     xaaptr->SubsequentImageWriteRect = viaSubsequentImageWriteRect;
+     xaaptr->ImageWriteBase = pVia->BltBase;
+Index: src/via_i2c.c
+===================================================================
+--- src/via_i2c.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_i2c.c	(.../trunk)	(revision 853)
+@@ -365,9 +365,18 @@ ViaI2CInit(ScrnInfoPtr pScrn)
+ 
+     DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaI2CInit\n"));
+ 
+-    pVia->pI2CBus1 = ViaI2CBus1Init(pScrn->scrnIndex);
+-    pVia->pI2CBus2 = ViaI2CBus2Init(pScrn->scrnIndex);
+-    pVia->pI2CBus3 = ViaI2CBus3Init(pScrn->scrnIndex);
++    if (!pVia->I2CDevices) {
++        pVia->pI2CBus1 = ViaI2CBus1Init(pScrn->scrnIndex);
++        pVia->pI2CBus2 = ViaI2CBus2Init(pScrn->scrnIndex);
++        pVia->pI2CBus3 = ViaI2CBus3Init(pScrn->scrnIndex);
++    } else {
++        if (pVia->I2CDevices & VIA_I2C_BUS1)
++            pVia->pI2CBus1 = ViaI2CBus1Init(pScrn->scrnIndex);
++        if (pVia->I2CDevices & VIA_I2C_BUS2)
++            pVia->pI2CBus2 = ViaI2CBus2Init(pScrn->scrnIndex);
++        if (pVia->I2CDevices & VIA_I2C_BUS3)
++            pVia->pI2CBus3 = ViaI2CBus3Init(pScrn->scrnIndex);
++    }
+ 
+ #ifdef HAVE_DEBUG
+     if (pVia->I2CScan) {
 Index: src/via_cursor.c
 ===================================================================
---- src/via_cursor.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_cursor.c	(.../trunk)	(revision 841)
+--- src/via_cursor.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_cursor.c	(.../trunk)	(revision 853)
 @@ -145,9 +145,12 @@ viaHWCursorInit(ScreenPtr pScreen)
      infoPtr->ShowCursor = viaShowCursor;
      infoPtr->UseHWCursor = viaUseHWCursor;
@@ -1538,8 +2502,8 @@ Index: src/via_cursor.c
  
 Index: src/via_dri.c
 ===================================================================
---- src/via_dri.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_dri.c	(.../trunk)	(revision 841)
+--- src/via_dri.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_dri.c	(.../trunk)	(revision 853)
 @@ -267,6 +267,11 @@ VIADRIAgpInit(ScreenPtr pScreen, VIAPtr pVia)
      pVIADRI = pDRIInfo->devPrivate;
      pVia->agpSize = 0;
@@ -1552,10 +2516,158 @@ Index: src/via_dri.c
      if (drmAgpAcquire(pVia->drmFD) < 0) {
          xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed %d\n",
                     errno);
+Index: src/via.h
+===================================================================
+--- src/via.h	(.../tags/release_0_2_904)	(revision 853)
++++ src/via.h	(.../trunk)	(revision 853)
+@@ -215,6 +215,9 @@
+ #define HQV_DST_STRIDE          0x1F4
+ #define HQV_SRC_STRIDE          0x1F8
+ 
++#define HQV_H_SCALE_CONTROL     0x1B0
++#define HQV_V_SCALE_CONTROL     0x1B4
++
+ #define PRO_HQV1_OFFSET         0x1000
+ /*
+  *  Video command definition
+@@ -515,7 +518,23 @@
+ #define HQV_FIFO_STATUS     0x00001000  
+ #define HQV_GEN_IRQ         0x00000080
+ #define HQV_FIFO_DEPTH_1    0x00010000
++/* for CME engine */
++#define HQV_SW_FLIP_QUEUE_ENABLE    0x00100000
+ 
++/* for hwDiff->dwNewScaleCtl */
++#define HQV_H_SCALE_ENABLE                 0x80000000
++#define HQV_H_SCALE_UP                     0x00000000  
++#define HQV_H_SCALE_DOWN_FOURTH_TO_1       0x10000000 
++#define HQV_H_SCALE_DOWN_FOURTH_TO_EIGHTH  0x20000000 
++#define HQV_H_SCALE_DOWN_UNDER_EIGHTH      0x30000000 
++
++#define HQV_V_SCALE_ENABLE 0x80000000
++#define HQV_V_SCALE_UP     0x00000000
++#define HQV_V_SCALE_DOWN   0x10000000
++
++/* HQV Default Vodeo Color 0x3B8 */
++#define HQV_FIX_COLOR           0x0643212c
++
+ /* HQV_FILTER_CONTROL      0x3E4 */
+ #define HQV_H_LOWPASS_2TAP  0x00000001
+ #define HQV_H_LOWPASS_4TAP  0x00000002
+@@ -575,6 +594,25 @@
+ #define HQV_VDEBLOCK_FILTER 0x80000000
+ #define HQV_HDEBLOCK_FILTER 0x00008000
+ 
++/* new added registers for VT3409.For some registers have different meanings 
++ * but the same address,we add postfix _409 to distinguish */
++#define HQV_COLOR_ADJUSTMENT_PRE_CTRL1      0x160
++#define HQV_COLOR_ADJUSTMENT_PRE_CTRL2      0x164
++#define HQV_COLOR_ADJUSTMENT_PRE_CTRL3      0x168
++#define HQV_COLOR_ADJUSTMENT_PRE_CTRL4      0x16C
++#define HQV_SRC_DATA_OFFSET_CTRL1_409       0x170 
++#define HQV_SRC_DATA_OFFSET_CTRL2_409       0x174  
++#define HQV_SRC_DATA_OFFSET_CTRL3_409       0x178  
++#define HQV_SRC_DATA_OFFSET_CTRL4_409       0x17C  
++#define HQV_DST_DATA_OFFSET_CTRL1           0x180
++#define HQV_DST_DATA_OFFSET_CTRL2           0x184  
++#define HQV_DST_DATA_OFFSET_CTRL3           0x188  
++#define HQV_DST_DATA_OFFSET_CTRL4           0x18C 
++#define HQV_RESIDUE_PIXEL_FRAME_STARTADDR   0x1BC
++#define HQV_BACKGROUND_DATA_OFFSET          0x1CC
++#define HQV_SUBP_HSCALE_CTRL                0x1E0
++#define HQV_SUBP_VSCALE_CTRL                0x1E8
++
+ /* Add new HQV Registers for VT3353: */
+ #define HQV_SRC_DATA_OFFSET_CONTROL1        0x180
+ #define HQV_SRC_DATA_OFFSET_CONTROL2        0x184
+@@ -588,6 +626,7 @@
+ #define HQV_COLOR_ADJUSTMENT_CONTROL2       0x1A4
+ #define HQV_COLOR_ADJUSTMENT_CONTROL3       0x1A8
+ #define HQV_COLOR_ADJUSTMENT_CONTROL5       0x1AC
++#define HQV_DEFAULT_VIDEO_COLOR             0x1B8
+ 
+ #define CHROMA_KEY_LOW          0x00FFFFFF
+ #define CHROMA_KEY_HIGH         0x00FFFFFF
+Index: man/openchrome.man
+===================================================================
+--- man/openchrome.man	(.../tags/release_0_2_904)	(revision 853)
++++ man/openchrome.man	(.../trunk)	(revision 853)
+@@ -59,16 +59,18 @@ are supported:
+ .BI "Option \*qAccelMethod\*q  \*q" string \*q
+ The driver supports "XAA" and "EXA" acceleration methods.  The default
+ method is XAA, since EXA is still experimental.  Contrary to XAA, EXA
+-implements acceleration for screen uploads and downlads (if DRI is
++implements acceleration for screen uploads and downloads (if DRI is
+ enabled) and for the Render/Composite extension.
+ .TP
+ .BI "Option \*qActiveDevice\*q  \*q" string \*q
+ Specifies the active device combination.  Any string containing "CRT",
+ "LCD", "DFP", "TV" should be possible. "CRT" represents anything that
+-is connected to the VGA port, "LCD" and "DFP" are for laptop panels
+-(not TFT screens attached to the VGA port), "TV" is self-explanatory.
++is connected to the VGA port, "LCD" is for laptop panels (not TFT screens
++attached to the VGA port), "DFP" is for screens connected to the DVI port,
++"TV" is self-explanatory.
+ The default is to use what is detected.  The driver is currently unable
+-to use LCD and TV simultaneously, and will favour the LCD.
++to use LCD and TV simultaneously, and will favour the LCD.  The DVI port is
++not properly probed and needs to be enabled with this option.
+ .TP
+ .BI "Option \*qAGPMem\*q  \*q" integer \*q
+ Sets the amount of AGP memory that is allocated at X server startup.
+@@ -81,7 +83,7 @@ EXA scratch area in AGP space, it will be allocate
+ no room for DRI textures, they will be allocated from the DRI part of
+ VRAM (see the option "MaxDRIMem").  The default amount of AGP is
+ 32768 kB.  Note that the AGP aperture set in the BIOS must be able
+-to accomodate the amount of AGP memory specified here.  Otherwise no
++to accommodate the amount of AGP memory specified here.  Otherwise no
+ AGP memory will be available.  It is safe to set a very large AGP
+ aperture in the BIOS.
+ .TP
+@@ -131,10 +133,10 @@ as possible to the EXA pixmap storage area.
+ .TP
+ .BI "Option \*qMigrationHeuristic\*q  \*q" string \*q
+ Sets the heuristic for EXA pixmap migration.  This is an EXA core
+-option, and on Xorg server versions after 1.1.0 this defaults to
+-"smart".  The openchrome driver performs best with "greedy", so you
++option, and starting from __xservername__ server version 1.3.0 this defaults to
++"always".  The openchrome driver performs best with "greedy", so you
+ should really add this option to your configuration file.  The third
+-possibility is "always", which might become more useful in the future.
++possibility is "smart".
+ .TP
+ .BI "Option \*qNoAccel\*q  \*q" boolean \*q
+ Disables the use of hardware acceleration.  Acceleration is enabled
+@@ -159,9 +161,16 @@ Specifies the size (width x height) of the LCD pan
+ system.  The sizes 640x480, 800x600, 1024x768, 1280x1024, and 1400x1050
+ are supported.
+ .TP
++.BI "Option \*qRotationType\*q  \*q" string \*q
++Enabled rotation by using RandR. The driver only support unaccelerated
++RandR rotations "SWRandR". Hardware rotations "HWRandR" is currently 
++unimplemented.
++.TP
+ .BI "Option \*qRotate\*q  \*q" string \*q
+ Rotates the display either clockwise ("CW"), counterclockwise ("CCW") and
+-upside-down ("UD"). Rotation is only supported unaccelerated.
++upside-down ("UD"). Rotation is only supported unaccelerated.  Adding 
++option "Rotate", enables RandR rotation feature.  The RandR allows 
++clients to dynamically change X screens.
+ .TP
+ .BI "Option \*qShadowFB\*q  \*q" boolean \*q
+ Enables the use of a shadow frame buffer.  This is required when
+@@ -234,6 +243,6 @@ overscan).  These modes are made available by the
+ provided in __xconfigfile__ will be ignored.
+ 
+ .SH "SEE ALSO"
+-__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
++__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__), EXA(__filemansuffix__), Xv(__filemansuffix__)
+ .SH AUTHORS
+ Authors include: ...
 Index: src/via_id.c
 ===================================================================
---- src/via_id.c	(.../tags/release_0_2_904)	(revision 841)
-+++ src/via_id.c	(.../trunk)	(revision 841)
+--- src/via_id.c	(.../tags/release_0_2_904)	(revision 853)
++++ src/via_id.c	(.../trunk)	(revision 853)
 @@ -152,6 +152,7 @@ static struct ViaCardIdStruct ViaCardId[] = {
      {"MSI PM8PM",                             VIA_VM800,   0x1462, 0x7222, VIA_DEVICE_CRT},
      {"Twinhead M6",                           VIA_VM800,   0x14FF, 0xA007, VIA_DEVICE_CRT | VIA_DEVICE_LCD},


Index: xorg-x11-drv-openchrome.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-drv-openchrome/F-12/xorg-x11-drv-openchrome.spec,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -p -r1.54 -r1.55
--- xorg-x11-drv-openchrome.spec	31 Mar 2010 17:16:20 -0000	1.54
+++ xorg-x11-drv-openchrome.spec	24 May 2010 19:52:50 -0000	1.55
@@ -1,55 +1,48 @@
 %define tarball xf86-video-openchrome
 %define moduledir %(pkg-config xorg-server --variable=moduledir )
-%define driverdir	%{moduledir}/drivers
+%define driverdir %{moduledir}/drivers
 
 %define cvsdate xxxxxxx
 
 %define with_xvmc 1
 %define with_debug 0
 
-Summary:	Xorg X11 openchrome video driver
-Name:		xorg-x11-drv-openchrome
-Version:	0.2.904
-Release:	5%{?dist}
-URL:		http://www.openchrome.org
-License:	MIT
-Group:		User Interface/X Hardware Support
-BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Summary:        Xorg X11 openchrome video driver
+Name:           xorg-x11-drv-openchrome
+Version:        0.2.904
+Release:        6%{?dist}
+URL:            http://www.openchrome.org
+License:        MIT
+Group:          User Interface/X Hardware Support
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
-Source0:	http://www.openchrome.org/releases/%{tarball}-%{version}.tar.bz2
-Source1:	openchrome.xinf
+Source0:        http://www.openchrome.org/releases/%{tarball}-%{version}.tar.bz2
+Source1:        openchrome.xinf
 
 # Patches from upstream trunk :
+# svn diff -x -p http://svn.openchrome.org/svn/tags/release_0_2_904 http://svn.openchrome.org/svn/trunk
 Patch0:         openchrome-0.2.904-latest_trunk.patch
 
 # Fedora specific patches :
 
 # Experimental patches (branch backport, etc...): 
-Patch10:         openchrome-0.2.904-disable_AGP_and_DMA_by_default_for_VX8xx.patch
-Patch11:         openchrome-0.2.904-set_colorkey_for_2nd_monitor.patch
-Patch12:         openchrome-0.2.904-vx855_xv.patch
-Patch13:         openchrome-0.2.904-fix_tvout_flickering.patch
-Patch14:         openchrome-0.2.904-add_I2CDevices_option.patch
-Patch15:         openchrome-0.2.904-2d_perf_tweaks.patch
-Patch16:         openchrome-0.2.904-put_50ms_timeout_on_HQV.patch
-Patch17:         openchrome-0.2.904-fix_xv_on_vx800.patch
-Patch18:         openchrome-0.2.904-sanitize_SaveVideoRegister.patch
-Patch19:         openchrome-0.2.904-setup_HWDiff_HQVCmeRegs_for_all_chipsets.patch
-
-ExclusiveArch:	%{ix86} x86_64
-
-BuildRequires:	xorg-x11-server-devel
-BuildRequires:	libX11-devel
-BuildRequires:	libXext-devel
-BuildRequires:	mesa-libGL-devel
+Patch13:        openchrome-0.2.904-fix_tvout_flickering.patch
+Patch20:        openchrome-0.2.904-I420_Xv_surface_for_CME.patch
+
+ExclusiveArch:  %{ix86} x86_64
+
+BuildRequires:  xorg-x11-server-devel
+BuildRequires:  libX11-devel
+BuildRequires:  libXext-devel
+BuildRequires:  mesa-libGL-devel
 %if %{with_xvmc}
-BuildRequires:	libXvMC-devel
+BuildRequires:  libXvMC-devel
 %endif
-BuildRequires:	libdrm-devel >= 2.0-1
-Requires:	xorg-x11-server-Xorg
+BuildRequires:  libdrm-devel >= 2.0-1
+Requires:       xorg-x11-server-Xorg
 
-Obsoletes:  xorg-x11-drv-via <= 0.2.2-4
-Provides:   xorg-x11-drv-via = 0.2.2-5
+Obsoletes:      xorg-x11-drv-via <= 0.2.2-4
+Provides:       xorg-x11-drv-via = 0.2.2-5
 
 
 %description 
@@ -58,11 +51,11 @@ X.Org X11 openchrome video driver.
 
 %if %{with_xvmc}
 %package devel
-Summary:	Xorg X11 openchrome video driver XvMC development package
-Group:		Development/System
-Requires:	%{name} = %{version}-%{release}
-Obsoletes:	xorg-x11-drv-via-devel <= 0.2.2-4
-Provides:	xorg-x11-drv-via-devel = 0.2.2-5
+Summary:        Xorg X11 openchrome video driver XvMC development package
+Group:          Development/System
+Requires:       %{name} = %{version}-%{release}
+Obsoletes:      xorg-x11-drv-via-devel <= 0.2.2-4
+Provides:       xorg-x11-drv-via-devel = 0.2.2-5
 
 %description devel
 X.Org X11 openchrome video driver XvMC development package.
@@ -72,16 +65,8 @@ X.Org X11 openchrome video driver XvMC d
 %prep
 %setup -q -n %{tarball}-%{version}
 %patch0 -p0
-%patch10 -p0
-%patch11 -p0
-%patch12 -p0
 %patch13 -p0
-%patch14 -p0
-%patch15 -p0
-%patch16 -p0
-%patch17 -p0
-%patch18 -p0
-%patch19 -p0
+%patch20 -p1
 
 
 %build
@@ -138,6 +123,11 @@ fi
 
 
 %changelog
+* Sat May 08 2010 Xavier Bachelot <xavier at bachelot.org> - 0.2.904-6
+- Sync with trunk (r853) and drop patches accordingly.
+- Add Xv acceleration for I420 on CME engine.
+- Clean up spec indentation.
+
 * Wed Mar 31 2010 Xavier Bachelot <xavier at bachelot.org> - 0.2.904-5
 - Sanitize SaveVideoRegister function.
 - Fix an Xv regression on CME chipsets introduced by the VX855 Xv patch.


--- openchrome-0.2.904-2d_perf_tweaks.patch DELETED ---


--- openchrome-0.2.904-add_I2CDevices_option.patch DELETED ---


--- openchrome-0.2.904-disable_AGP_and_DMA_by_default_for_VX8xx.patch DELETED ---


--- openchrome-0.2.904-fix_xv_on_vx800.patch DELETED ---


--- openchrome-0.2.904-put_50ms_timeout_on_HQV.patch DELETED ---


--- openchrome-0.2.904-sanitize_SaveVideoRegister.patch DELETED ---


--- openchrome-0.2.904-set_colorkey_for_2nd_monitor.patch DELETED ---


--- openchrome-0.2.904-setup_HWDiff_HQVCmeRegs_for_all_chipsets.patch DELETED ---


--- openchrome-0.2.904-vx855_xv.patch DELETED ---



More information about the scm-commits mailing list