[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-openchrome: Changes to 'upstream-experimental'



 ChangeLog                |  111 ++++++
 configure.ac             |    3 
 libxvmc/Makefile.am      |    8 
 libxvmc/viaLowLevelPro.c |    6 
 libxvmc/viaXvMC.c        |   62 +--
 src/via.h                |   16 
 src/via_accel.c          |   13 
 src/via_bios.h           |    1 
 src/via_crtc.c           |   37 +-
 src/via_cursor.c         |  773 ++++++++++++++++++++---------------------------
 src/via_dga.c            |    8 
 src/via_driver.c         |   71 ++--
 src/via_driver.h         |   61 ++-
 src/via_id.c             |    4 
 src/via_mode.c           |   51 +++
 src/via_mode.h           |   24 -
 src/via_panel.c          |    2 
 src/via_regs.h           |   79 ++++
 src/via_swov.c           |   12 
 src/via_video.c          |    5 
 20 files changed, 772 insertions(+), 575 deletions(-)

New commits:
commit 9d6131f9306af528e6e19d7b14649c13651e7115
Author: schlobinux <schlobinux@e8d65cb0-85f4-0310-8831-c60e2a5ce829>
Date:   Thu Jan 8 20:42:27 2009 +0000

    Twinhead M6 (reported by Bradon Kanyid)
    
    git-svn-id: http://svn.openchrome.org/svn/trunk@713 e8d65cb0-85f4-0310-8831-c60e2a5ce829

diff --git a/src/via_id.c b/src/via_id.c
index a344e84..a840a90 100644
--- a/src/via_id.c
+++ b/src/via_id.c
@@ -147,6 +147,7 @@ static struct ViaCardIdStruct ViaCardId[] = {
     {"MSI Fuzzy CN700/CN700T/CN700G",         VIA_VM800,   0x1462, 0x7199, VIA_DEVICE_CRT | VIA_DEVICE_TV},
     {"MSI PM8M3-V",                           VIA_VM800,   0x1462, 0x7211, VIA_DEVICE_CRT},
     {"MSI PM8PM",                             VIA_VM800,   0x1462, 0x7222, VIA_DEVICE_CRT},
+    {"Twinhead M6",                           VIA_VM800,   0x14FF, 0xA007, VIA_DEVICE_CRT | VIA_DEVICE_LCD},
     {"RoverBook Partner W500",                VIA_VM800,   0x1509, 0x4330, VIA_DEVICE_CRT | VIA_DEVICE_LCD},
     {"Clevo/RoverBook Voyager V511L",         VIA_VM800,   0x1558, 0x0662, VIA_DEVICE_CRT | VIA_DEVICE_LCD},
     {"Clevo M5xxS",                           VIA_VM800,   0x1558, 0x5406, VIA_DEVICE_CRT | VIA_DEVICE_LCD},

commit 0d093a6fa106b75b895719cce86280e2668759de
Author: jnettlet <jnettlet@e8d65cb0-85f4-0310-8831-c60e2a5ce829>
Date:   Wed Jan 7 05:23:26 2009 +0000

    Temporary workaround for freedesktop bug 21563
    
    git-svn-id: http://svn.openchrome.org/svn/trunk@712 e8d65cb0-85f4-0310-8831-c60e2a5ce829

diff --git a/ChangeLog b/ChangeLog
index de96e87..4840652 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-01-07  Jon Nettleton <jon.nettleton@gmail.com>
+
+	* src/via_bios.h:
+	* src/via_crtc.c: (via_xf86crtc_resize), (ViaPreInitCRTCConfig):
+	* src/via_driver.c: (VIAPreInit):
+
+	Temporary hack to fix a bug with newer Xorg and DRI
+	that crashes if CRTC is not setup.  I am adding this
+	because I am working on this part of the code anyways
+	so it won't get lost in bit rot.
+
 2009-01-06  Jon Nettleton  <jon.nettleton@gmail.com>
 
 	* src/via_mode.c: (ViaModesMonitorFixup), (ViaModesAttachHelper):
diff --git a/src/via_bios.h b/src/via_bios.h
index 04e84be..dfff60a 100644
--- a/src/via_bios.h
+++ b/src/via_bios.h
@@ -227,6 +227,7 @@ void ViaModeFirstCRTC(ScrnInfoPtr pScrn, DisplayModePtr mode);
 void ViaModeSet(ScrnInfoPtr pScrn, DisplayModePtr mode);
 
 /* via_crtc.c */
+void ViaPreInitCRTCConfig(ScrnInfoPtr pScrn);
 void ViaCRTCInit(ScrnInfoPtr pScrn);
 void ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pSCrn, int x, int y);
 void ViaFirstCRTCSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
diff --git a/src/via_crtc.c b/src/via_crtc.c
index 653c26a..d0f19e5 100644
--- a/src/via_crtc.c
+++ b/src/via_crtc.c
@@ -35,6 +35,8 @@
 
 #include "via_mode.h"
 
+#include <xorg/xf86Crtc.h>
+
 static void
 ViaCRTCSetGraphicsRegisters(ScrnInfoPtr pScrn)
 {
@@ -73,6 +75,26 @@ ViaCRTCSetAttributeRegisters(ScrnInfoPtr pScrn)
     hwp->writeAttr(hwp, 0x14, 0x00);
 }
 
+static Bool
+via_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
+{
+    scrn->virtualX = width;
+    scrn->virtualY = height;
+    return TRUE;
+}
+
+static const
+xf86CrtcConfigFuncsRec via_xf86crtc_config_funcs = {
+    via_xf86crtc_resize
+};
+
+void 
+ViaPreInitCRTCConfig(ScrnInfoPtr pScrn)
+{
+     xf86CrtcConfigInit (pScrn, &via_xf86crtc_config_funcs);
+}
+
+
 void
 ViaCRTCInit(ScrnInfoPtr pScrn)
 {
diff --git a/src/via_driver.c b/src/via_driver.c
index 405a8af..2005b73 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1665,6 +1665,9 @@ VIAPreInit(ScrnInfoPtr pScrn, int flags)
         return FALSE;
     }
 
+	/* Might not belong here temporary fix for bug fix */
+    ViaPreInitCRTCConfig(pScrn);
+
     if (!pVia->UseLegacyModeSwitch) {
         if (pBIOSInfo->Panel->IsActive)
             ViaPanelPreInit(pScrn);

commit 442f2af8810ffa19ad278668064e41576150877e
Author: jnettlet <jnettlet@e8d65cb0-85f4-0310-8831-c60e2a5ce829>
Date:   Mon Jan 5 13:40:36 2009 +0000

    adjust monitor values to handle preset LCD panel and TV modes
    
    git-svn-id: http://svn.openchrome.org/svn/trunk@711 e8d65cb0-85f4-0310-8831-c60e2a5ce829

diff --git a/ChangeLog b/ChangeLog
index f7e8126..de96e87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-01-06  Jon Nettleton  <jon.nettleton@gmail.com>
+
+	* src/via_mode.c: (ViaModesMonitorFixup), (ViaModesAttachHelper):
+
+	Make sure that the monitor settings will handle our
+	internal Modes set for TV out and LCD Panels.
+
 2009-01-05  Jon Nettleton  <jon.nettleton@gmail.com>
 
 	* src/via_cursor.c: (viaHWCursorInit), (viaLoadCursorImage):
diff --git a/src/via_mode.c b/src/via_mode.c
index f06e659..c19b42d 100644
--- a/src/via_mode.c
+++ b/src/via_mode.c
@@ -676,6 +676,53 @@ ViaPanelGetIndex(ScrnInfoPtr pScrn, DisplayModePtr mode)
 }
 
 /*
+ * adapted from nv and savage 
+ */
+static void
+ViaModesMonitorFixup(ScrnInfoPtr pScrn, MonPtr monitorp, DisplayModePtr mode)
+{
+	/* These are all modes that the driver sets up
+	 * so we can comfortably update the monitor
+	 * configuration to work with them.
+	 */
+
+	if (monitorp->hsync[0].lo == 0)
+		monitorp->hsync[0].lo = 31.50;
+	if (monitorp->hsync[0].hi == 0)
+		monitorp->hsync[0].hi = 37.90;
+	if (monitorp->vrefresh[0].lo == 0)
+		monitorp->vrefresh[0].lo = 50.00;
+	if (monitorp->vrefresh[0].hi == 0)
+		monitorp->vrefresh[0].hi = 70.00;
+
+	if (!mode->HSync)
+		mode->HSync = ((float) mode->Clock ) / ((float) mode->HTotal);
+	if (!mode->VRefresh)
+		mode->VRefresh = (1000.0 * ((float) mode->Clock)) /
+		   ((float) (mode->HTotal * mode->VTotal));
+
+	if (mode->HSync < monitorp->hsync[0].lo) {
+		monitorp->hsync[0].lo = mode->HSync;
+		DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModesMonitorFixup - Adjusted HSync.lo to %f\n", monitorp->hsync[0].lo));
+	}
+	if (mode->HSync > monitorp->hsync[0].hi) {
+		monitorp->hsync[0].hi = mode->HSync;
+		DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModesMonitorFixup - Adjusted HSync.hi to %f\n", monitorp->hsync[0].hi));
+	}
+	if (mode->VRefresh < monitorp->vrefresh[0].lo) {
+		monitorp->vrefresh[0].lo = mode->VRefresh;
+		DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModesMonitorFixup - Adjusted VRefresh.lo to %f\n", monitorp->vrefresh[0].lo));
+	}
+	if (mode->VRefresh > monitorp->vrefresh[0].hi) {
+		monitorp->vrefresh[0].hi = mode->VRefresh;
+		DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaModesMonitorFixup - Adjusted VRefresh.hi to %f\n", monitorp->vrefresh[0].hi));
+	}
+
+	monitorp->nHsync = 1;
+	monitorp->nVrefresh = 1;
+}
+
+/*
  * Stolen from xf86Config.c's addDefaultModes
  */
 static void
@@ -697,6 +744,7 @@ ViaModesAttachHelper(ScrnInfoPtr pScrn, MonPtr monitorp, DisplayModePtr Modes)
             mode->prev = NULL;
         }
         last = mode;
+        ViaModesMonitorFixup(pScrn, monitorp, mode);
     }
     monitorp->Last = last;
 }

commit 578449b7c51c1f43f6d6b2fd50c82a402205ccc4
Author: jnettlet <jnettlet@e8d65cb0-85f4-0310-8831-c60e2a5ce829>
Date:   Mon Jan 5 02:12:08 2009 +0000

    Merge work done in hwcursor_branch back to trunk
    
    git-svn-id: http://svn.openchrome.org/svn/trunk@709 e8d65cb0-85f4-0310-8831-c60e2a5ce829

diff --git a/ChangeLog b/ChangeLog
index 7143e6a..f7e8126 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-01-05  Jon Nettleton  <jon.nettleton@gmail.com>
+
+	* src/via_cursor.c: (viaHWCursorInit), (viaLoadCursorImage):
+
+	A couple more tweaks to fix mono hardware cursor on older
+	chipsets.
+
+2009-01-05  Jon Nettleton  <jon.nettleton@gmail.com>
+
+	* src/via_cursor.c: (viaHWCursorInit), (viaUseHWCursorARGB),
+	(viaUseHWCursor):
+	* src/via_driver.c: (VIAScreenInit):
+
+	Missed a couple of changes for the chipset specific
+	cursors.  Moved chipset detection to HWInit.  Removed
+	some extraneous debugging.
+
 2009-01-04  Gabriel Mansi  <gabriel-dot-mansi-at-gmail-dot-com>
 
 	* src/via.h:
@@ -12,6 +29,37 @@
 
 2009-01-04  Jon Nettleton  <jon.nettleton@gmail.com>
 
+	* src/via_cursor.c: (viaHWCursorInit), (viaCursorSetFB),
+	(viaUseHWCursorARGB), (viaUseHWCursor), (viaLoadCursorImage),
+	(viaSetCursorColors), (viaLoadCursorARGB):
+	* src/via_driver.h:
+
+	Okay I tried to cheat.  We need to have some chipset
+	specific intelligence.  I have added this back into
+	the initial test to check for HWCursor support.
+
+2009-01-04  Jon Nettleton <jon.nettleton@gmail.com>
+
+	* src/via_accel.c: (viaInitXAA), (viaInitAccel):
+	* src/via_crtc.c: (ViaSecondCRTCSetStartingAddress):
+	* src/via_cursor.c: (viaHWCursorInit), (viaCursorSetFB),
+	(viaCursorStore), (viaCursorRestore), (viaShowCursor),
+	(viaHideCursor), (viaSetCursorPosition), (viaUseHWCursorARGB),
+	(viaUseHWCursor), (viaLoadCursorImage), (viaSetCursorColors),
+	(viaLoadCursorARGB):
+	* src/via_dga.c: (VIADGASetMode):
+	* src/via_driver.c: (VIAFreeRec), (VIASetupDefaultOptions),
+	(VIAPreInit), (VIAEnterVT), (VIALeaveVT), (VIAScreenInit),
+	(VIACloseScreen):
+	* src/via_driver.h:
+	* src/via_regs.h:
+
+	This is a take at reworking HWCursor.  It works off the
+	ttm_branch and the work done in the randr_branch.  It only needs
+	marginal testing as HWCursor was already very broken.
+
+2009-01-04  Jon Nettleton  <jon.nettleton@gmail.com>
+
 	* src/via_driver.c: (VIAMapMMIO), (VIAMapFB):
 
 	Moved pVia->FrameBufferBase setting to within
diff --git a/src/via_accel.c b/src/via_accel.c
index 3267a8e..125cc07 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -1278,7 +1278,8 @@ viaInitXAA(ScreenPtr pScreen)
 
     if (pVia->Chipset != VIA_K8M800 &&
         pVia->Chipset != VIA_K8M890 &&
-        pVia->Chipset != VIA_P4M900)
+        pVia->Chipset != VIA_P4M900 &&
+        pVia->Chipset != VIA_VX800)
         xaaptr->ImageWriteFlags |= NO_GXCOPY;
 
     xaaptr->SetupForImageWrite = viaSetupForImageWrite;
@@ -2421,7 +2422,7 @@ viaInitAccel(ScreenPtr pScreen)
 	pVia->FBFreeEnd -= VIA_VQ_SIZE;
     }
 
-    if (pVia->cursor->isHWCursorEnabled)
+    if (pVia->hwcursor)
         viaCursorSetFB(pScrn);
 
     viaInitialize2DEngine(pScrn);
diff --git a/src/via_crtc.c b/src/via_crtc.c
index ed0b90c..653c26a 100644
--- a/src/via_crtc.c
+++ b/src/via_crtc.c
@@ -305,11 +305,9 @@ ViaFirstCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
     CARD32 Base;
     CARD32 tmp;
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                     "ViaFirstCRTCSetStartingAddress\n"));
-
     Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8);
     Base = Base >> 1;
+
     hwp->writeCrtc(hwp, 0x0C, (Base & 0xFF00) >> 8);
     hwp->writeCrtc(hwp, 0x0D, Base & 0xFF);
     hwp->writeCrtc(hwp, 0x34, (Base & 0xFF0000) >> 16);
@@ -325,9 +323,6 @@ ViaSecondCRTCSetStartingAddress(ScrnInfoPtr pScrn, int x, int y)
     CARD32 Base;
     CARD32 tmp;
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                     "ViaSecondCRTCSetStartingAddress\n"));
-
     Base = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel / 8);
     Base = (Base + pScrn->fbOffset) >> 3;
 
@@ -369,7 +364,8 @@ ViaSecondCRTCHorizontalOffset(ScrnInfoPtr pScrn)
     if (temp & 0x03) {
         temp += 0x03;
         temp &= ~0x03;
-    }
+	}
+    
     hwp->writeCrtc(hwp, 0x66, temp & 0xFF);
     ViaCrtcMask(hwp, 0x67, temp >> 8, 0x03);
 }
diff --git a/src/via_cursor.c b/src/via_cursor.c
index 5424284..83ba655 100644
--- a/src/via_cursor.c
+++ b/src/via_cursor.c
@@ -36,37 +36,60 @@
 
 #include "via.h"
 #include "via_driver.h"
-#include "via_regs.h"
 #include "via_id.h"
-
-#ifdef ARGB_CURSOR
 #include "cursorstr.h"
-#endif
 
-static void viaCursorLoadImage(ScrnInfoPtr pScrn, unsigned char *src);
-static void viaCursorSetPosition(ScrnInfoPtr pScrn, int x, int y);
-static void viaCursorSetColors(ScrnInfoPtr pScrn, int bg, int fg);
-static Bool viaCursorHWUse(ScreenPtr screen, CursorPtr cursor);
-static void viaCursorHWHide(ScrnInfoPtr pScrn);
-
-#ifdef ARGB_CURSOR
-static void viaCursorARGBShow(ScrnInfoPtr pScrn);
-static void viaCursorARGBHide(ScrnInfoPtr pScrn);
-static void viaCursorARGBSetPosition(ScrnInfoPtr pScrn, int x, int y);
-static Bool viaCursorARGBUse(ScreenPtr pScreen, CursorPtr pCurs);
-static void viaCursorARGBLoad(ScrnInfoPtr pScrn, CursorPtr pCurs);
-#endif
+void viaShowCursor(ScrnInfoPtr pScrn);
+void viaHideCursor(ScrnInfoPtr pScrn);
+static void viaSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static Bool viaUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs);
+static Bool viaUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs);
+static void viaLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void viaSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+static void viaLoadCursorARGB(ScrnInfoPtr pScrn, CursorPtr pCurs);
+
+static CARD32 mono_cursor_color[] = {
+	0x00000000,
+	0x00000000,
+	0xffffffff,
+	0xff000000,
+};
 
-#ifdef ARGB_CURSOR
-static void
-viaCursorARGBInit(ScrnInfoPtr pScrn)
+Bool
+viaHWCursorInit(ScreenPtr pScreen)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     VIAPtr pVia = VIAPTR(pScrn);
-    VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
+    xf86CursorInfoPtr infoPtr;
+
+	switch (pVia->Chipset) {
+		case VIA_CLE266:
+		case VIA_KM400:
+			/* FIXME Mono HW Cursors not working */
+			pVia->hwcursor = FALSE;
+			pVia->CursorARGBSupported = FALSE;
+			pVia->CursorMaxWidth = 32;
+			pVia->CursorMaxHeight = 32;
+			pVia->CursorSize = ((pVia->CursorMaxWidth * pVia->CursorMaxHeight) / 8) * 2;
+			break;
+		default:
+			pVia->CursorARGBSupported = TRUE;
+			pVia->CursorMaxWidth = 64;
+			pVia->CursorMaxHeight = 64;
+			pVia->CursorSize = pVia->CursorMaxWidth * (pVia->CursorMaxHeight + 1) * 4;
+			break;
+    }
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "viaCursorARGBInit\n"));
+    if (pVia->NoAccel) 
+    	viaCursorSetFB(pScrn);
 
-    unsigned long fbOffset = pScrn->fbOffset + pVia->cursor->fbCursorStart;
+    pVia->cursorMap = pVia->FBBase + pVia->CursorStart;
+
+    if (pVia->cursorMap == NULL)
+		return FALSE;
+
+    pVia->cursorOffset = pScrn->fbOffset + pVia->CursorStart;
+    memset(pVia->cursorMap, 0x00, pVia->CursorSize);
 
     switch (pVia->Chipset) {
         case VIA_CX700:
@@ -74,535 +97,394 @@ viaCursorARGBInit(ScrnInfoPtr pScrn)
         case VIA_P4M890:
         case VIA_P4M900:
         case VIA_VX800:
-            if (pBIOSInfo->FirstCRTC->IsActive) {
-                VIASETREG(VIA_REG_PRIM_HI_FBOFFSET, fbOffset);
-                /* Set 0 as transparent color key. */
-                VIASETREG(VIA_REG_PRIM_HI_TRANSCOLOR, 0);
-                VIASETREG(VIA_REG_PRIM_HI_FIFO, 0x0D000D0F);
-                VIASETREG(VIA_REG_PRIM_HI_INVTCOLOR, 0X00FFFFFF);
-                VIASETREG(VIA_REG_V327_HI_INVTCOLOR, 0X00FFFFFF);
-            }
-            if (pBIOSInfo->SecondCRTC->IsActive) {
-                VIASETREG(VIA_REG_HI_FBOFFSET, fbOffset);
-                /* Set 0 as transparent color key. */
-                VIASETREG(VIA_REG_HI_TRANSPARENT_COLOR, 0);
-                VIASETREG(VIA_REG_HI_INVTCOLOR, 0X00FFFFFF);
-                VIASETREG(ALPHA_V3_PREFIFO_CONTROL, 0xE0000);
-                VIASETREG(ALPHA_V3_FIFO_CONTROL, 0xE0F0000);
-            }
-            break;
-        default:
-            VIASETREG(VIA_REG_HI_FBOFFSET, fbOffset);
-            VIASETREG(VIA_REG_HI_TRANSPARENT_COLOR, 0);
-            VIASETREG(VIA_REG_HI_INVTCOLOR, 0X00FFFFFF);
-            VIASETREG(ALPHA_V3_PREFIFO_CONTROL, 0xE0000);
-            VIASETREG(ALPHA_V3_FIFO_CONTROL, 0xE0F0000);
-            break;
+			if (pVia->pBIOSInfo->FirstCRTC->IsActive) {
+				pVia->CursorRegControl  = VIA_REG_HI_CONTROL0;
+				pVia->CursorRegBase     = VIA_REG_HI_BASE0;
+				pVia->CursorRegPos      = VIA_REG_HI_POS0;
+				pVia->CursorRegOffset   = VIA_REG_HI_OFFSET0;
+				pVia->CursorRegFifo     = VIA_REG_HI_FIFO0;
+				pVia->CursorRegTransKey = VIA_REG_HI_TRANSKEY0;
+			}
+			if (pVia->pBIOSInfo->SecondCRTC->IsActive) {
+				pVia->CursorRegControl  = VIA_REG_HI_CONTROL1;
+				pVia->CursorRegBase     = VIA_REG_HI_BASE1;
+				pVia->CursorRegPos      = VIA_REG_HI_POS1;
+				pVia->CursorRegOffset   = VIA_REG_HI_OFFSET1;
+				pVia->CursorRegFifo     = VIA_REG_HI_FIFO1;
+				pVia->CursorRegTransKey = VIA_REG_HI_TRANSKEY1;
+			}
+			break;
+		default:
+			pVia->CursorRegControl = VIA_REG_ALPHA_CONTROL;
+			pVia->CursorRegBase = VIA_REG_ALPHA_BASE;
+			pVia->CursorRegPos = VIA_REG_ALPHA_POS;
+			pVia->CursorRegOffset = VIA_REG_ALPHA_OFFSET;
+			pVia->CursorRegFifo = VIA_REG_ALPHA_FIFO;
+			pVia->CursorRegTransKey = VIA_REG_ALPHA_TRANSKEY;
     }
-}
-#endif
-
-void
-viaCursorSetFB(ScrnInfoPtr pScrn)
-{
-    VIAPtr pVia = VIAPTR(pScrn);
-
-    if (!pVia->cursor->fbCursorStart
-        && ((pVia->FBFreeEnd - pVia->FBFreeStart) > pVia->cursor->size)) {
-        pVia->cursor->fbCursorStart = pVia->FBFreeEnd - pVia->cursor->size;
-        pVia->FBFreeEnd -= pVia->cursor->size;
-    }
-}
-
-Bool
-viaCursorHWInit(ScreenPtr pScreen)
-{
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    VIAPtr pVia = VIAPTR(pScrn);
-    xf86CursorInfoPtr infoPtr;
-
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIACursorHWInit\n"));
 
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAHWCursorInit\n"));
     infoPtr = xf86CreateCursorInfoRec();
     if (!infoPtr)
         return FALSE;
 
-    pVia->cursor->info = infoPtr;
+    pVia->CursorInfoRec = infoPtr;
 
-    infoPtr->MaxWidth = pVia->cursor->maxWidth;
-    infoPtr->MaxHeight = pVia->cursor->maxHeight;
-    infoPtr->Flags = (HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
-                      /*HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK | */
+    infoPtr->MaxWidth = pVia->CursorMaxWidth;
+    infoPtr->MaxHeight = pVia->CursorMaxHeight;
+    infoPtr->Flags = (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
+                      HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
                       HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
-                      HARDWARE_CURSOR_INVERT_MASK |
-                      HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
                       0);
 
-    if (pVia->cursor->maxWidth == 64)
-        infoPtr->Flags |= HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64;
-    else if (pVia->cursor->maxWidth == 32)
-        infoPtr->Flags |= HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32;
-    else {
-        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                   "VIACursorHWInit: unhandled width\n");
-        return FALSE;
-    }
-/*
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        infoPtr->Flags |= HARDWARE_CURSOR_ARGB;
-*/
-    infoPtr->SetCursorColors = viaCursorSetColors;
-    infoPtr->SetCursorPosition = viaCursorSetPosition;
-    infoPtr->LoadCursorImage = viaCursorLoadImage;
-    infoPtr->HideCursor = viaCursorHide;
-    infoPtr->ShowCursor = viaCursorShow;
-    infoPtr->UseHWCursor = viaCursorHWUse;
-
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled) {
-        infoPtr->UseHWCursorARGB = viaCursorARGBUse;
-        infoPtr->LoadCursorARGB = viaCursorARGBLoad;
-    }
-#endif
-
-    viaCursorSetFB(pScrn);
+    infoPtr->SetCursorColors = viaSetCursorColors;
+    infoPtr->SetCursorPosition = viaSetCursorPosition;
+    infoPtr->LoadCursorImage = viaLoadCursorImage;
+    infoPtr->HideCursor = viaHideCursor;
+    infoPtr->ShowCursor = viaShowCursor;
+    infoPtr->UseHWCursor = viaUseHWCursor;
 
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        viaCursorARGBInit(pScrn);
-#endif
+    infoPtr->UseHWCursorARGB = viaUseHWCursorARGB;
+	if (pVia->CursorARGBSupported)
+    	infoPtr->LoadCursorARGB = viaLoadCursorARGB;
 
     /* Set cursor location in frame buffer. */
-    VIASETREG(VIA_REG_CURSOR_MODE, pVia->cursor->fbCursorStart);
-    viaCursorHWHide(pScrn);
+    VIASETREG(VIA_REG_CURSOR_MODE, pVia->cursorOffset);
 
-    return xf86InitCursor(pScreen, infoPtr);
-}
+    pVia->CursorPipe = (pVia->pBIOSInfo->Panel->IsActive) ? 1 : 0;
 
-static void
-viaCursorHWShow(ScrnInfoPtr pScrn)
-{
-    VIAPtr pVia = VIAPTR(pScrn);
-    CARD32 mode;
-
-    mode = VIAGETREG(VIA_REG_CURSOR_MODE);
-    mode &= ~0x80000003;
-
-    /* Hardware cursor size */
-    if (pVia->cursor->maxWidth == 32)
-        mode |= 0x00000002 ;
-    
-    /* Enable cursor */
-    mode |= 0x00000001 ;
-    
-    if (pVia->pBIOSInfo->SecondCRTC->IsActive)
-        mode |= 0x80000000 ;
-    
-    /* Turn on hardware cursor. */
-    VIASETREG(VIA_REG_CURSOR_MODE, mode);
-    
+    /* Init HI_X0 */
+    VIASETREG(pVia->CursorRegControl, 0);
+    VIASETREG(pVia->CursorRegBase, pVia->cursorOffset);
+    VIASETREG(pVia->CursorRegTransKey, 0);
+
+    switch (pVia->Chipset) {
+        case VIA_CX700:
+        /* case VIA_CN750: */
+        case VIA_P4M890:
+        case VIA_P4M900:
+        case VIA_VX800:
+			if (pVia->pBIOSInfo->FirstCRTC->IsActive) {
+				VIASETREG(VIA_REG_PRIM_HI_INVTCOLOR, 0x00FFFFFF);
+				VIASETREG(VIA_REG_V327_HI_INVTCOLOR, 0x00FFFFFF);
+				VIASETREG(pVia->CursorRegFifo, 0x0D000D0F);
+			}
+			if (pVia->pBIOSInfo->SecondCRTC->IsActive) {
+				VIASETREG(VIA_REG_HI_INVTCOLOR, 0X00FFFFFF);
+				VIASETREG(VIA_REG_ALPHA_PREFIFO, 0xE0000);
+				VIASETREG(pVia->CursorRegFifo, 0xE0F0000);
+
+				/* Just in case */
+				VIASETREG(VIA_REG_HI_BASE0, pVia->cursorOffset);
+			}
+			break;
+    	default:
+			VIASETREG(VIA_REG_HI_INVTCOLOR, 0X00FFFFFF);
+			VIASETREG(VIA_REG_ALPHA_PREFIFO, 0xE0000);
+			VIASETREG(pVia->CursorRegFifo, 0xE0F0000);
+	}
+
+    return xf86InitCursor(pScreen, infoPtr);
 }
 
-static void
-viaCursorHWHide(ScrnInfoPtr pScrn)
+void
+viaCursorSetFB(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
-    CARD32 mode = VIAGETREG(VIA_REG_CURSOR_MODE);
 
-    /* Turn hardware cursor off. */
-    VIASETREG(VIA_REG_CURSOR_MODE, mode & 0xFFFFFFFE);
+    if ((pVia->FBFreeEnd - pVia->FBFreeStart) > pVia->CursorSize) {
+        pVia->CursorStart = pVia->FBFreeEnd - pVia->CursorSize;
+        pVia->FBFreeEnd = pVia->CursorStart;
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CursorStart: 0x%x\n", pVia->CursorStart);
+    }
 }
 
 
 void
-viaCursorShow(ScrnInfoPtr pScrn)
+viaCursorStore(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
 
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        viaCursorARGBShow(pScrn);
-    else
-#endif
-        viaCursorHWShow(pScrn);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaCursorStore\n"));
+
+    if (pVia->CursorPipe) {
+		pVia->CursorControl1 = VIAGETREG(pVia->CursorRegControl);
+    } else {
+		pVia->CursorControl0 = VIAGETREG(pVia->CursorRegControl);
+    }
+
+    pVia->CursorTransparentKey = VIAGETREG(pVia->CursorRegTransKey);
+
+
+    switch (pVia->Chipset) {
+        case VIA_CX700:
+        /* case VIA_CN750: */
+        case VIA_P4M890:
+        case VIA_P4M900:
+        case VIA_VX800:
+			if (pVia->pBIOSInfo->FirstCRTC->IsActive) {
+	    		pVia->CursorPrimHiInvtColor = VIAGETREG(VIA_REG_PRIM_HI_INVTCOLOR);
+	    		pVia->CursorV327HiInvtColor = VIAGETREG(VIA_REG_V327_HI_INVTCOLOR);
+			} 
+			if (pVia->pBIOSInfo->SecondCRTC->IsActive) {
+	    	/* TODO add saves here */
+			}
+			pVia->CursorFifo = VIAGETREG(pVia->CursorRegFifo);
+			break;
+		default:
+			/* TODO add saves here */
+			break;
+    }
 }
 
 void
-viaCursorHide(ScrnInfoPtr pScrn)
+viaCursorRestore(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
 
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        viaCursorARGBHide(pScrn);
-    else
-#endif
-        viaCursorHWHide(pScrn);
+    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ViaCursorRestore\n"));
+
+    if (pVia->CursorPipe) {
+		VIASETREG(pVia->CursorRegControl, pVia->CursorControl1);
+    } else {
+		VIASETREG(pVia->CursorRegControl, pVia->CursorControl0);
+    }
+
+    VIASETREG(pVia->CursorRegBase, pVia->cursorOffset);
+
+    VIASETREG(pVia->CursorRegTransKey, pVia->CursorTransparentKey);
+
+
+    switch (pVia->Chipset) {
+        case VIA_CX700:
+        /* case VIA_CN750: */
+        case VIA_P4M890:
+        case VIA_P4M900:
+        case VIA_VX800:
+			if (pVia->pBIOSInfo->FirstCRTC->IsActive) {
+	    		VIASETREG(VIA_REG_PRIM_HI_INVTCOLOR, pVia->CursorPrimHiInvtColor);
+	    		VIASETREG(VIA_REG_V327_HI_INVTCOLOR, pVia->CursorV327HiInvtColor);
+			}
+			if (pVia->pBIOSInfo->SecondCRTC->IsActive) {
+	    		/* TODO add real restores here */
+	    		VIASETREG(VIA_REG_HI_INVTCOLOR, 0X00FFFFFF);
+	    		VIASETREG(VIA_REG_ALPHA_PREFIFO, 0xE0000);
+			}
+			VIASETREG(pVia->CursorRegFifo, pVia->CursorFifo);
+			break;
+		default:
+			/* TODO add real restores here */
+			VIASETREG(VIA_REG_ALPHA_PREFIFO, 0xE0000);
+			VIASETREG(pVia->CursorRegFifo, 0xE0F0000);
+    }
 }
 
-static void
-viaCursorLoadImage(ScrnInfoPtr pScrn, unsigned char *src)
+/*
+ * ARGB Cursor
+ */
+
+void
+viaShowCursor(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
-    int x, y, i;
-
-    viaAccelSync(pScrn);
-    CARD32 *dst = (CARD32 *) (pVia->FBBase + pVia->cursor->fbCursorStart);
-
-    memset(dst, 0x00, pVia->cursor->size);
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled) {
-        viaCursorARGBHide(pScrn);
-        /* Convert monochrome to ARGB. */
-        int width = pVia->cursor->maxWidth / 8;
-
-        for (y = 0; y < (pVia->cursor->maxHeight / 8) * 2; y++) {
-            for (x = 0; x < width; x++) {
-                char t = *(src + width); /* is transparent? */
-                char fb = *src++; /* foreground or background ? */
-
-                for (i = 7; i >= 0; i--) {
-                    if (t & (1 << i))
-                        *dst++ = 0x00000000; /* transparent */
-                    else
-                        *dst++ = fb & (1 << i) ?
-                                0xFF000000 | pVia->cursor->foreground :
-                                0xFF000000 | pVia->cursor->background;
-                }
-            }
-            src += width;
-        }
-    } else
-#endif
-    {
-        viaCursorHWHide(pScrn);
-        /* Upload the cursor image to the frame buffer. */
-        memcpy(dst, src, pVia->cursor->size);
-    }
-    viaCursorShow(pScrn);
+    CARD32 temp;
+    CARD32 control = pVia->CursorRegControl;
+
+    temp =
+	(1 << 30) |
+	(1 << 29) |
+	(1 << 28) |
+	(1 << 26) |
+	(1 << 25) |
+	(1 <<  2) |
+	(1 <<  0);
+
+    if (pVia->CursorPipe)
+	temp |= (1 << 31);
+
+    VIASETREG(control, temp);
 }
 
-static void
-viaCursorHWSetPosition(ScrnInfoPtr pScrn, int x, int y, int xoff, int yoff)
+void
+viaHideCursor(ScrnInfoPtr pScrn)
 {
     VIAPtr pVia = VIAPTR(pScrn);
+    CARD32 temp;
+    CARD32 control = pVia->CursorRegControl;
 
-    /* viaCursorHWHide(pScrn); */
-    VIASETREG(VIA_REG_CURSOR_ORG, ((xoff << 16) | (yoff & 0x003f)));
-    VIASETREG(VIA_REG_CURSOR_POS, ((x << 16) | (y & 0x07ff)));
-    /* viaCursorHWShow(pScrn); */
+    temp = VIAGETREG(control);
+    VIASETREG(control, temp & 0xFFFFFFFE);
 }
 
 static void
-viaCursorSetPosition(ScrnInfoPtr pScrn, int x, int y)
+viaSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
 {
     VIAPtr pVia = VIAPTR(pScrn);
-    VIABIOSInfoPtr pBIOSInfo = pVia->pBIOSInfo;
-    unsigned char xoff, yoff;
+    CARD32 temp;
+    CARD32 control = pVia->CursorRegControl;
+    CARD32 offset = pVia->CursorRegOffset;
+    CARD32 pos = pVia->CursorRegPos;
+    unsigned xoff, yoff;
 
     if (x < 0) {
-        xoff = ((-x) & 0xFE);
-        x = 0;
+	xoff = ((-x) & 0xFE);
+	x = 0;
     } else {
-        xoff = 0;
+	xoff = 0;
     }
 
     if (y < 0) {
-        yoff = ((-y) & 0xFE);
-        y = 0;
+	yoff = ((-y) & 0xFE);
+	y = 0;
     } else {
-        yoff = 0;
-        /* LCD Expand Mode Cursor Y Position Re-Calculated */
-        if (pBIOSInfo->scaleY) {
-            y = (int)(((pBIOSInfo->panelY * y) + (pBIOSInfo->resY >> 1))
-                      / pBIOSInfo->resY);
-        }
+	yoff = 0;
     }
 
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        viaCursorARGBSetPosition(pScrn, x, y);
-    else
-#endif
-        viaCursorHWSetPosition(pScrn, x, y, xoff, yoff);
-}
-
-
-static void
-viaCursorSetColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
-    VIAPtr pVia = VIAPTR(pScrn);
-
-    pVia->cursor->foreground = fg;
-    pVia->cursor->background = bg;
+    temp = VIAGETREG(control);
+    VIASETREG(control, temp & 0xFFFFFFFE);
 
-#ifdef ARGB_CURSOR
-    if (pVia->cursor->isARGBSupported && pVia->cursor->isARGBEnabled)
-        return;
-#endif
+    VIASETREG(pos,    ((x    << 16) | (y    & 0x07ff)));
+    VIASETREG(offset, ((xoff << 16) | (yoff & 0x07ff)));
 
-    VIASETREG(VIA_REG_CURSOR_FG, fg);
-    VIASETREG(VIA_REG_CURSOR_BG, bg);
+    VIASETREG(control, temp);
 }
 
-void
-viaCursorStore(ScrnInfoPtr pScrn)
+static Bool
+viaUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     VIAPtr pVia = VIAPTR(pScrn);
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "viaCursorStore\n"));
-
-    if (pVia->cursor->image) {
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                   "viaCursorStore: stale image left.\n");
-        xfree(pVia->cursor->image);
-    }
-
-    pVia->cursor->image = xcalloc(1, pVia->cursor->size);
-    if (pVia->cursor->image)
-        memcpy(pVia->cursor->image, pVia->FBBase + pVia->cursor->fbCursorStart,
-               pVia->cursor->size);
-
-    pVia->cursor->foreground = (CARD32) VIAGETREG(VIA_REG_CURSOR_FG);
-    pVia->cursor->background = (CARD32) VIAGETREG(VIA_REG_CURSOR_BG);
-    pVia->cursor->mode = (CARD32) VIAGETREG(VIA_REG_CURSOR_MODE);
+    return (pVia->hwcursor
+            && pVia->CursorARGBSupported
+            && pCurs->bits->width <= pVia->CursorMaxWidth
+            && pCurs->bits->height <= pVia->CursorMaxHeight);
 }
 
-void
-viaCursorRestore(ScrnInfoPtr pScrn)
+static Bool
+viaUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
 {
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     VIAPtr pVia = VIAPTR(pScrn);
 
-    DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "viaCursorRestore\n"));
-
-    if (pVia->cursor->image) {
-        memcpy(pVia->FBBase + pVia->cursor->fbCursorStart, pVia->cursor->image,
-               pVia->cursor->size);
-        VIASETREG(VIA_REG_CURSOR_FG, pVia->cursor->foreground);
-        VIASETREG(VIA_REG_CURSOR_BG, pVia->cursor->background);
-        VIASETREG(VIA_REG_CURSOR_MODE, pVia->cursor->mode);
-        xfree(pVia->cursor->image);
-        pVia->cursor->image = NULL;
-    } else
-        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                   "viaCursorRestore: No cursor image stored.\n");
+    return (pVia->hwcursor
+            /* Can't enable HW cursor on both CRTCs at the same time. */
+            && !(pVia->pBIOSInfo->FirstCRTC->IsActive
+                 && pVia->pBIOSInfo->SecondCRTC->IsActive)
+            && pCurs->bits->width <= pVia->CursorMaxWidth
+            && pCurs->bits->height <= pVia->CursorMaxHeight);
 }
 
-#ifdef ARGB_CURSOR
-
 static void
-viaCursorARGBShow(ScrnInfoPtr pScrn)
+viaLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *s)
 {
     VIAPtr pVia = VIAPTR(pScrn);
-
-    switch (pVia->Chipset) {
-        case VIA_CX700:
-        /* case VIA_CN750: */
-        case VIA_P4M890:
-        case VIA_P4M900:
-	case VIA_VX800:
-            /* Turn on hardware icon cursor. */
-            if (pVia->pBIOSInfo->FirstCRTC->IsActive)
-                VIASETREG(VIA_REG_PRIM_HI_CTRL, 0x36000005);
-            if (pVia->pBIOSInfo->SecondCRTC->IsActive)
-                VIASETREG(VIA_REG_HI_CONTROL, 0xb6000005);
-            break;
-        default:
-            if (pVia->pBIOSInfo->FirstCRTC->IsActive)
-                VIASETREG(VIA_REG_PRIM_HI_CTRL, 0x76000005);
-            if (pVia->pBIOSInfo->SecondCRTC->IsActive)
-                VIASETREG(VIA_REG_HI_CONTROL, 0xf6000005);
-            break;
-    }


Reply to: