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

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



 configure.ac     |    2 
 src/Makefile.am  |    1 
 src/rhd.h        |    1 
 src/rhd_driver.c |   14 -
 src/rhd_id.c     |   26 +-
 src/rhd_lvtma.c  |  560 ++++++++++++++++++++++---------------------------------
 src/rhd_mc.c     |  135 +++++++++++++
 src/rhd_mc.h     |   34 +++
 src/rhd_pll.c    |    3 
 src/rhd_regs.h   |    3 
 10 files changed, 424 insertions(+), 355 deletions(-)

New commits:
commit 3b93b437e10e30ede927078c5546add1df7c501d
Author: Egbert Eich <eich@freedesktop.org>
Date:   Sat Nov 24 17:00:02 2007 +0100

    Fix memory offset for R6xx.
    
    Some 512Meg VBIOSes map the upper portion of the
    memory to the memory aperture exposed to the PCI
    BAR.
    This makes sure we always map the lower portion
    on R6xx.

diff --git a/src/Makefile.am b/src/Makefile.am
index 8eb8afb..45c4dde 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,6 +29,7 @@ radeonhd_drv_la_SOURCES = \
 	rhd_pll.c \
 	rhd_tmds.c \
 	rhd_vga.c \
+	rhd_mc.c \
 	rhd_shadow.c \
 	rhd_randr.c \
 	rhd_atombios.h \
diff --git a/src/rhd.h b/src/rhd.h
index 6931421..6a6493c 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -164,6 +164,7 @@ typedef struct RHDRec {
      */
     unsigned char*	BIOSCopy;
 
+    struct rhdMC       *MC;  /* Memory Controller */
     struct rhdVGA      *VGA; /* VGA compatibility HW */
     struct rhdCrtc     *Crtc[2];
     struct rhdPLL      *PLLs[2]; /* Pixelclock PLLs */
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index de917f2..3c4033a 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -94,6 +94,7 @@
 #include "rhd_output.h"
 #include "rhd_pll.h"
 #include "rhd_vga.h"
+#include "rhd_mc.h"
 #include "rhd_monitor.h"
 #include "rhd_crtc.h"
 #include "rhd_modes.h"
@@ -272,6 +273,7 @@ RHDFreeRec(ScrnInfoPtr pScrn)
 
     xfree(rhdPtr->Options);
 
+    RHDMCDestroy(rhdPtr);
     RHDVGADestroy(rhdPtr);
     RHDPLLsDestroy(rhdPtr);
     RHDLUTsDestroy(rhdPtr);
@@ -623,7 +625,7 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Init modesetting structures */
     RHDVGAInit(rhdPtr);
-
+    RHDMCInit(rhdPtr);
     RHDCrtcsInit(rhdPtr);
     RHDPLLsInit(rhdPtr);
     RHDLUTsInit(rhdPtr);
@@ -1229,9 +1231,6 @@ rhdMapFB(RHDPtr rhdPtr)
 		       "0x%08X while card Internal Address is 0x%08X\n",
 		       (unsigned int) membase,
 		       rhdPtr->FbIntAddress);
-    if (rhdPtr->ChipSet >= RHD_R600)
-	xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "VM_FB_LOCATION: 0x%08X\n",
-		   (unsigned int) RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION));
     xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Mapped FB at %p (size 0x%08X)\n",
 	       rhdPtr->FbBase, rhdPtr->FbMapSize);
     return TRUE;
@@ -1516,6 +1515,9 @@ rhdModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
     /* now disable our VGA Mode */
     RHDVGADisable(rhdPtr);
 
+    /* now set up the MC */
+    RHDMCSetup(rhdPtr);
+
     /* Set up D1 and appendages */
     Crtc = rhdPtr->Crtc[0];
     if (Crtc->Active) {
@@ -1567,6 +1569,8 @@ rhdSave(RHDPtr rhdPtr)
 
     RHDFUNC(rhdPtr);
 
+    RHDSaveMC(rhdPtr);
+
     RHDVGASave(rhdPtr);
 
     RHDOutputsSave(rhdPtr);
@@ -1597,6 +1601,8 @@ rhdRestore(RHDPtr rhdPtr)
     if (rhdPtr->CursorInfo)
 	rhdRestoreCursor(pScrn);
 
+    RHDRestoreMC(rhdPtr);
+
     RHDVGARestore(rhdPtr);
 
     RHDOutputsRestore(rhdPtr);
diff --git a/src/rhd_mc.c b/src/rhd_mc.c
new file mode 100644
index 0000000..6977e17
--- /dev/null
+++ b/src/rhd_mc.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2007  Luc Verhaegen <lverhaegen@novell.com>
+ * Copyright 2007  Matthias Hopf <mhopf@novell.com>
+ * Copyright 2007  Egbert Eich   <eich@novell.com>
+ * Copyright 2007  Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+
+#include "rhd.h"
+#include "rhd_regs.h"
+
+#ifndef _XF86_ANSIC_H
+#include <string.h>
+#endif
+
+struct rhdMC {
+    CARD32 VM_FbLocation;
+    CARD32 VM_MiscOffset;
+    Bool Stored;
+};
+
+
+/*
+ *
+ */
+void
+RHDMCInit(RHDPtr rhdPtr)
+{
+    struct rhdMC *MC;
+
+    RHDFUNC(rhdPtr);
+
+    if (rhdPtr->ChipSet < RHD_R600)
+	return;
+
+    MC = xnfcalloc(1, sizeof(struct rhdMC));
+    MC->Stored = FALSE;
+
+    rhdPtr->MC = MC;
+}
+
+/*
+ * Free structure.
+ */
+void
+RHDMCDestroy(RHDPtr rhdPtr)
+{
+    RHDFUNC(rhdPtr);
+
+    xfree(rhdPtr->MC);
+}
+
+/*
+ * Save MC_VM state.
+ */
+void
+RHDSaveMC(RHDPtr rhdPtr)
+{
+    struct rhdMC *MC = rhdPtr->MC;
+
+    RHDFUNC(rhdPtr);
+
+    if (!MC)
+	return;
+
+    MC->VM_FbLocation = RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION);
+    MC->VM_MiscOffset = RHDRegRead(rhdPtr, R6XX_MC_VM_MISC_OFFSET);
+    MC->Stored = TRUE;
+}
+
+/*
+ * Restore MC VM state.
+ */
+void
+RHDRestoreMC(RHDPtr rhdPtr)
+{
+    struct rhdMC *MC = rhdPtr->MC;
+
+    RHDFUNC(rhdPtr);
+
+    if (!MC)
+	return;
+
+    if (!MC->Stored) {
+	xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR,
+		   "%s: trying to restore uninitialized values.\n",__func__);
+	return;
+    }
+    RHDRegWrite(rhdPtr, R6XX_MC_VM_FB_LOCATION, MC->VM_FbLocation);
+    RHDRegWrite(rhdPtr, R6XX_MC_VM_MISC_OFFSET, MC->VM_MiscOffset);
+}
+
+void
+RHDMCSetup(RHDPtr rhdPtr)
+{
+    struct rhdMC *MC = rhdPtr->MC;
+    CARD32 fb_location;
+    CARD16 fb_size;
+
+    RHDFUNC(rhdPtr);
+
+    if (!MC)
+	return;
+
+    fb_location = RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION);
+    fb_size = (fb_location >> 16) - (fb_location & 0xFFFF);
+    fb_location = rhdPtr->FbIntAddress >> 24;
+    fb_location |= (fb_location + fb_size) << 24;
+    RHDRegWrite(rhdPtr, R6XX_MC_VM_FB_LOCATION, fb_location);
+    RHDRegWrite(rhdPtr, R6XX_MC_VM_MISC_OFFSET, (rhdPtr->FbIntAddress >> 8)
+		& 0xff0000);
+}
diff --git a/src/rhd_mc.h b/src/rhd_mc.h
new file mode 100644
index 0000000..06dbe66
--- /dev/null
+++ b/src/rhd_mc.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2007  Luc Verhaegen <lverhaegen@novell.com>
+ * Copyright 2007  Matthias Hopf <mhopf@novell.com>
+ * Copyright 2007  Egbert Eich   <eich@novell.com>
+ * Copyright 2007  Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+#ifndef RHD_MC_H
+# define RHD_MC_H
+
+void RHDMCInit(RHDPtr rhdPtr);
+void RHDMCDestroy(RHDPtr rhdPtr);
+void RHDSaveMC(RHDPtr rhdPtr);
+void RHDRestoreMC(RHDPtr rhdPtr);
+void RHDMCSetup(RHDPtr rhdPtr);
+
+#endif /* RHD_MC_H */
diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index cee0d57..bfb49ce 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -69,6 +69,7 @@ enum {
     PCLK_CRTC2_CNTL                = 0x0484,
 
     R6XX_MC_VM_FB_LOCATION	   = 0x2180,
+    R6XX_MC_VM_MISC_OFFSET            = 0x2C04,
     R6XX_CONFIG_MEMSIZE            = 0x5428,
     R6XX_CONFIG_FB_BASE            = 0x542C, /* AKA CONFIG_F0_BASE */
 

commit ce2607d1f534a2008cdcbd14c805074355647a8e
Author: Luc Verhaegen <libv@skynet.be>
Date:   Sat Nov 24 03:28:54 2007 +0100

    Patchlevel bump: 0.0.4.
    
    R600 LVDS is a rather big new thing, suddenly RS690M, M72, M74 and M76 devices.
    Next to that, there were quite a number of fixes.

diff --git a/configure.ac b/configure.ac
index cc9d949..4c4b9f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-radeonhd],
-        0.0.3,
+        0.0.4,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/radeonhd],
         xf86-video-radeonhd)
 

commit 35107cdcc611c5aa7977830b840692bec7fd5559
Author: Luc Verhaegen <libv@skynet.be>
Date:   Sat Nov 24 03:16:16 2007 +0100

    Connector table: HD2400XT was actually an X1550.
    
    Late night hacking. Not good.
    
    Sapphire X1550 HPD for DVI is actually HPD1, not HPD0.

diff --git a/src/rhd_id.c b/src/rhd_id.c
index 17e79eb..89bc086 100644
--- a/src/rhd_id.c
+++ b/src/rhd_id.c
@@ -280,12 +280,12 @@ RHDIdentify(int flags)
      { {RHD_CONNECTOR_NONE, "NULL", RHD_DDC_NONE, RHD_HPD_NONE, \
        { RHD_OUTPUT_NONE, RHD_OUTPUT_NONE}}}
 
-/* Sapphire HD2400XT reports 2 DVI-I, while it is one VGA and one DVI-I */
-#define VGA_B1_DVI_AB00 \
-  { {RHD_CONNECTOR_VGA, "VGA", RHD_DDC_1, RHD_HPD_NONE, \
-       { RHD_OUTPUT_DACB, RHD_OUTPUT_NONE}}, \
-    {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_0, RHD_HPD_0, \
-       { RHD_OUTPUT_DACA, RHD_OUTPUT_LVTMA}}}
+/* Sapphire X1550 reports 2x DVI-I but has only 1 VGA and 1 DVI */
+#define VGA_A0_DVI_BB11 \
+  { {RHD_CONNECTOR_VGA, "VGA", RHD_DDC_0, RHD_HPD_NONE, \
+       { RHD_OUTPUT_DACA, RHD_OUTPUT_NONE}}, \
+    {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_1, RHD_HPD_1, \
+       { RHD_OUTPUT_DACB, RHD_OUTPUT_LVTMA}}}
 
 /*
  * MacBook Pro provides a weird atombios connector table.
@@ -310,12 +310,6 @@ RHDIdentify(int flags)
     {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_1, RHD_HPD_0, \
        { RHD_OUTPUT_DACB, RHD_OUTPUT_LVTMA}}}
 
-#define VGA_A0_DVI_BB11 \
-  { {RHD_CONNECTOR_VGA, "VGA", RHD_DDC_0, RHD_HPD_NONE, \
-       { RHD_OUTPUT_DACA, RHD_OUTPUT_NONE}}, \
-    {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_1, RHD_HPD_1, \
-       { RHD_OUTPUT_DACB, RHD_OUTPUT_LVTMA}}}
-
 #define VGA_B1_DVI_AA00 \
   { {RHD_CONNECTOR_VGA, "VGA", RHD_DDC_1, RHD_HPD_NONE, \
        { RHD_OUTPUT_DACB, RHD_OUTPUT_NONE}}, \
@@ -328,6 +322,12 @@ RHDIdentify(int flags)
     {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_0, RHD_HPD_1, \
        { RHD_OUTPUT_DACA, RHD_OUTPUT_LVTMA}}}
 
+#define VGA_B1_DVI_AB00 \
+  { {RHD_CONNECTOR_VGA, "VGA", RHD_DDC_1, RHD_HPD_NONE, \
+       { RHD_OUTPUT_DACB, RHD_OUTPUT_NONE}}, \
+    {RHD_CONNECTOR_DVI, "DVI-I", RHD_DDC_0, RHD_HPD_0, \
+       { RHD_OUTPUT_DACA, RHD_OUTPUT_LVTMA}}}
+
 #define DVI_AA00_DVI_BB11 \
   { {RHD_CONNECTOR_DVI, "DVI-I 1", RHD_DDC_0, RHD_HPD_0, \
        { RHD_OUTPUT_DACA, RHD_OUTPUT_TMDSA}}, \
@@ -382,9 +382,9 @@ RHDIdentify(int flags)
 
 #define VGA_A0_DVI_BA10         ID_CONNECTORINFO_EMPTY
 #define VGA_A0_DVI_BB10         ID_CONNECTORINFO_EMPTY
-#define VGA_A0_DVI_BB11         ID_CONNECTORINFO_EMPTY
 #define VGA_B1_DVI_AA00         ID_CONNECTORINFO_EMPTY
 #define VGA_B1_DVI_AB01         ID_CONNECTORINFO_EMPTY
+#define VGA_B1_DVI_AB00         ID_CONNECTORINFO_EMPTY
 #define DVI_AA00_DVI_BB11       ID_CONNECTORINFO_EMPTY
 #define DVI_BA10_DVI_AB01       ID_CONNECTORINFO_EMPTY
 #define DVI_BB11_DVI_AA00       ID_CONNECTORINFO_EMPTY

commit 28f30774d24e991b3337612587264e0a593a5e5f
Author: Luc Verhaegen <libv@skynet.be>
Date:   Sat Nov 24 01:50:06 2007 +0100

    Warning fix: CARD32 -> unsigned int again.
    
    Server side should get fixed.

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 35b47b0..de917f2 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -1231,7 +1231,7 @@ rhdMapFB(RHDPtr rhdPtr)
 		       rhdPtr->FbIntAddress);
     if (rhdPtr->ChipSet >= RHD_R600)
 	xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "VM_FB_LOCATION: 0x%08X\n",
-		   RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION));
+		   (unsigned int) RHDRegRead(rhdPtr, R6XX_MC_VM_FB_LOCATION));
     xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Mapped FB at %p (size 0x%08X)\n",
 	       rhdPtr->FbBase, rhdPtr->FbMapSize);
     return TRUE;

commit 7caf826f822bdd61f1359241324a48bd0e6abc78
Author: Luc Verhaegen <libv@skynet.be>
Date:   Fri Nov 23 22:19:28 2007 +0100

    LVDS: Allow R600.

diff --git a/src/rhd_lvtma.c b/src/rhd_lvtma.c
index 91c66e2..9eeee18 100644
--- a/src/rhd_lvtma.c
+++ b/src/rhd_lvtma.c
@@ -142,7 +142,7 @@ LVDSModeValid(struct rhdOutput *Output, DisplayModePtr Mode)
  *
  */
 static void
-R5xxLVDSSet(struct rhdOutput *Output)
+LVDSSet(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -222,7 +222,7 @@ R5xxLVDSSet(struct rhdOutput *Output)
  *
  */
 static void
-R5xxLVDSPWRSEQInit(struct rhdOutput *Output)
+LVDSPWRSEQInit(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -252,7 +252,7 @@ R5xxLVDSPWRSEQInit(struct rhdOutput *Output)
  *
  */
 static void
-R5xxLVDSEnable(struct rhdOutput *Output)
+LVDSEnable(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -261,7 +261,7 @@ R5xxLVDSEnable(struct rhdOutput *Output)
 
     RHDFUNC(Output);
 
-    R5xxLVDSPWRSEQInit(Output);
+    LVDSPWRSEQInit(Output);
 
     /* set up the transmitter */
     RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0x0000001E, 0x0000001E);
@@ -296,7 +296,7 @@ R5xxLVDSEnable(struct rhdOutput *Output)
  *
  */
 static void
-R5xxLVDSDisable(struct rhdOutput *Output)
+LVDSDisable(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -308,7 +308,7 @@ R5xxLVDSDisable(struct rhdOutput *Output)
     if (!(RHDRegRead(Output, LVTMA_PWRSEQ_CNTL) & 0x00000010))
 	return;
 
-    R5xxLVDSPWRSEQInit(Output);
+    LVDSPWRSEQInit(Output);
 
     RHDRegMask(Output, LVTMA_PWRSEQ_CNTL, 0, 0x00000010);
 
@@ -351,20 +351,20 @@ LVDSShutdown(struct rhdOutput *Output)
  *
  */
 static void
-R5xxLVDSPower(struct rhdOutput *Output, int Power)
+LVDSPower(struct rhdOutput *Output, int Power)
 {
     RHDFUNC(Output);
 
     switch (Power) {
     case RHD_POWER_ON:
-	R5xxLVDSEnable(Output);
+	LVDSEnable(Output);
 	break;
     case RHD_POWER_RESET:
 	/*	LVDSDisable(Output);
 		break;*/
     case RHD_POWER_SHUTDOWN:
     default:
-	R5xxLVDSDisable(Output);
+	LVDSDisable(Output);
 	/* LVDSShutdown(Output); */
 	break;
     }
@@ -375,7 +375,7 @@ R5xxLVDSPower(struct rhdOutput *Output, int Power)
  *
  */
 static void
-R5xxLVDSSave(struct rhdOutput *Output)
+LVDSSave(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -405,7 +405,7 @@ R5xxLVDSSave(struct rhdOutput *Output)
  * Currently it's a dumb register dump.
  */
 static void
-R5xxLVDSRestore(struct rhdOutput *Output)
+LVDSRestore(struct rhdOutput *Output)
 {
     struct LVDSPrivate *Private = (struct LVDSPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -441,7 +441,7 @@ R5xxLVDSRestore(struct rhdOutput *Output)
  * ATI clinging desperately to a broken concept.
  */
 static struct LVDSPrivate *
-R5xxLVDSInfoRetrieve(RHDPtr rhdPtr)
+LVDSInfoRetrieve(RHDPtr rhdPtr)
 {
     struct LVDSPrivate *Private = xnfcalloc(sizeof(struct LVDSPrivate), 1);
     CARD32 tmp;
@@ -873,19 +873,13 @@ RHDLVTMAInit(RHDPtr rhdPtr, CARD8 Type)
 
     RHDFUNC(rhdPtr);
 
-    /* Stop everything except LVDS at this time */
+    /* Stop weird connector types */
     if ((Type != RHD_CONNECTOR_PANEL) && (Type != RHD_CONNECTOR_DVI)) {
 	xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "%s: unhandled connector type:"
 		   " %d\n", __func__, Type);
 	return NULL;
     }
 
-    if ((Type == RHD_CONNECTOR_PANEL) && (rhdPtr->ChipSet >= RHD_R600)) {
-	xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "%s: any other device than"
-		   " an R5xx is still unsupported.\n", __func__);
-	return NULL;
-    }
-
     Output = xnfcalloc(sizeof(struct rhdOutput), 1);
 
     Output->scrnIndex = rhdPtr->scrnIndex;
@@ -896,20 +890,18 @@ RHDLVTMAInit(RHDPtr rhdPtr, CARD8 Type)
 
     if (Type == RHD_CONNECTOR_PANEL) {
 	Output->Name = "LVDS";
-	Output->ModeValid = LVDSModeValid;
 
-	if (rhdPtr->ChipSet < RHD_R600) {
-	    Output->Mode = R5xxLVDSSet;
-	    Output->Power = R5xxLVDSPower;
-	    Output->Save = R5xxLVDSSave;
-	    Output->Restore = R5xxLVDSRestore;
-	    Output->Private = R5xxLVDSInfoRetrieve(rhdPtr);
-	}
+	Output->ModeValid = LVDSModeValid;
+	Output->Mode = LVDSSet;
+	Output->Power = LVDSPower;
+	Output->Save = LVDSSave;
+	Output->Restore = LVDSRestore;
 
+	Output->Private = LVDSInfoRetrieve(rhdPtr);
     } else {
 	Output->Name = "TMDS B";
-	Output->ModeValid = TMDSBModeValid;
 
+	Output->ModeValid = TMDSBModeValid;
 	Output->Mode = TMDSBSet;
 	Output->Power = TMDSBPower;
 	Output->Save = TMDSBSave;

commit 8144561e1e61d13b5d342b3cf3679d4593154c3c
Author: Luc Verhaegen <libv@skynet.be>
Date:   Fri Nov 23 22:11:10 2007 +0100

    TMDSB: unsplit code for TMDSB.

diff --git a/src/rhd_lvtma.c b/src/rhd_lvtma.c
index ddaf767..91c66e2 100644
--- a/src/rhd_lvtma.c
+++ b/src/rhd_lvtma.c
@@ -592,30 +592,19 @@ static struct R5xxTMDSBMacro {
     { 0x7249, 0x00F1061D }, /* R580  */
     { 0x7280, 0x0042041F }, /* RV570 */
     { 0x7288, 0x0042041F }, /* RV570 */
+    { 0x791E, 0x0001642F }, /* RS690 */
+    { 0x791F, 0x0001642F }, /* RS690 */
+    { 0x9400, 0x00020213 }, /* R600  */
+    { 0x9401, 0x00020213 }, /* R600  */
+    { 0x9402, 0x00020213 }, /* R600  */
+    { 0x9403, 0x00020213 }, /* R600  */
+    { 0x9405, 0x00020213 }, /* R600  */
+    { 0x940A, 0x00020213 }, /* R600  */
+    { 0x940B, 0x00020213 }, /* R600  */
+    { 0x940F, 0x00020213 }, /* R600  */
     { 0, 0} /* End marker */
 };
 
-static void
-R5xxTMDSBVoltageControl(struct rhdOutput *Output)
-{
-    RHDPtr rhdPtr = RHDPTRI(Output);
-    int i;
-
-    for (i = 0; R5xxTMDSBMacro[i].Device; i++)
-	if (R5xxTMDSBMacro[i].Device == rhdPtr->PciDeviceID) {
-	    RHDRegWrite(Output, LVTMA_MACRO_CONTROL, R5xxTMDSBMacro[i].Macro);
-	    return;
-	}
-
-    xf86DrvMsg(Output->scrnIndex, X_ERROR, "%s: unhandled chipset: 0x%04X.\n",
-	       __func__, rhdPtr->PciDeviceID);
-    xf86DrvMsg(Output->scrnIndex, X_INFO, "LVTMA_MACRO_CONTROL: 0x%08X\n",
-	       (unsigned int) RHDRegRead(Output, LVTMA_MACRO_CONTROL));
-}
-
-/*
- * This information is not provided in an atombios data table.
- */
 static struct RV6xxTMDSBMacro {
     CARD16 Device;
     CARD32 Macro;
@@ -630,16 +619,23 @@ static struct RV6xxTMDSBMacro {
 };
 
 static void
-R6xxTMDSBVoltageControl(struct rhdOutput *Output)
+TMDSBVoltageControl(struct rhdOutput *Output)
 {
     RHDPtr rhdPtr = RHDPTRI(Output);
     int i;
 
-    if (rhdPtr->ChipSet == RHD_RS690)
-	RHDRegWrite(Output, LVTMA_MACRO_CONTROL, 0x0001642F);
-    else if (rhdPtr->ChipSet == RHD_R600)
-	RHDRegWrite(Output, LVTMA_MACRO_CONTROL, 0x00020213);
-    else { /* RV6x0 and up */
+    if (rhdPtr->ChipSet < RHD_RV610) { /* R5xx, RS690 and R600 */
+	for (i = 0; R5xxTMDSBMacro[i].Device; i++)
+	    if (R5xxTMDSBMacro[i].Device == rhdPtr->PciDeviceID) {
+		RHDRegWrite(Output, LVTMA_MACRO_CONTROL, R5xxTMDSBMacro[i].Macro);
+		return;
+	    }
+
+	xf86DrvMsg(Output->scrnIndex, X_ERROR, "%s: unhandled chipset: 0x%04X.\n",
+		   __func__, rhdPtr->PciDeviceID);
+	xf86DrvMsg(Output->scrnIndex, X_INFO, "LVTMA_MACRO_CONTROL: 0x%08X\n",
+		   (unsigned int) RHDRegRead(Output, LVTMA_MACRO_CONTROL));
+    } else { /* RV6x0 and up */
 	for (i = 0; RV6xxTMDSBMacro[i].Device; i++)
 	    if (RV6xxTMDSBMacro[i].Device == rhdPtr->PciDeviceID) {
 		RHDRegWrite(Output, LVTMA_MACRO_CONTROL, RV6xxTMDSBMacro[i].Macro);
@@ -663,83 +659,18 @@ R6xxTMDSBVoltageControl(struct rhdOutput *Output)
  *
  */
 static void
-R5xxTMDSBSet(struct rhdOutput *Output)
+TMDSBSet(struct rhdOutput *Output)
 {
     RHDPtr rhdPtr = RHDPTRI(Output);
 
     RHDFUNC(Output);
 
     RHDRegMask(Output, LVTMA_MODE, 0x00000001, 0x00000001); /* select TMDS */
-    RHDRegMask(Output, LVTMA_REG_TEST_OUTPUT, 0x00200000, 0x00200000);
-
-    /* Clear out some HPD events first: this should be under driver control. */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x0000000C);
-    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x00070000);
-    RHDRegMask(Output, LVTMA_CNTL, 0, 0x00000010);
-
-    /* Disable the transmitter */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x00001D1F);
-
-    /* Disable bit reduction and reset temporal dither */
-    RHDRegMask(Output, LVTMA_BIT_DEPTH_CONTROL, 0, 0x00010101);
-    RHDRegMask(Output, LVTMA_BIT_DEPTH_CONTROL, 0x02000000, 0x02000000);
-    usleep(2);
-    RHDRegMask(Output, LVTMA_BIT_DEPTH_CONTROL, 0, 0x02000000);
-    RHDRegMask(Output, LVTMA_BIT_DEPTH_CONTROL, 0, 0xF0000000); /* not documented */
-
-    /* reset phase on vsync and use RGB */
-    RHDRegMask(Output, LVTMA_CNTL, 0x00001000, 0x00011000);
-
-    /* Select CRTC, select syncA, no stereosync */
-    RHDRegMask(Output, LVTMA_SOURCE_SELECT, Output->Crtc->Id, 0x00010101);
-
-    /* Single link, for now */
-    RHDRegWrite(Output, LVTMA_COLOR_FORMAT, 0);
-    RHDRegMask(Output, LVTMA_CNTL, 0, 0x01000000);
-
-    /* Disable force data */
-    RHDRegMask(Output, LVTMA_FORCE_OUTPUT_CNTL, 0, 0x00000001);
-
-    /* DC balancer enable */
-    RHDRegMask(Output, LVTMA_DCBALANCER_CONTROL, 0x00000001, 0x00000001);
-
-    R5xxTMDSBVoltageControl(Output);
-
-    /* use IDCLK */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000010);
-    /* incoherent mode */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x10000000, 0x10000000);
-    /* LVTMA only: use clock selected by previous write */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x20000000, 0x20000000);
-    /* clear LVDS clock pattern */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x03FF0000);
-
-    /* reset transmitter */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x00000002, 0x00000002);
-    usleep(2);
-    RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000002);
-    usleep(20);
-
-    /* restart data synchronisation */
-    RHDRegMask(Output, LVTMA_DATA_SYNCHRONIZATION, 0x00000001, 0x00000001);
-    RHDRegMask(Output, LVTMA_DATA_SYNCHRONIZATION, 0x00000100, 0x00000100);
-    usleep(2);
-    RHDRegMask(Output, LVTMA_DATA_SYNCHRONIZATION, 0, 0x00000001);
-}
-/*
- *
- */
-static void
-R6xxTMDSBSet(struct rhdOutput *Output)
-{
-    RHDPtr rhdPtr = RHDPTRI(Output);
-
-    RHDFUNC(Output);
-
-    RHDRegMask(Output, LVTMA_MODE, 0x00000001, 0x00000001); /* select TMDS */
-    if (rhdPtr->ChipSet == RHD_RS690)
+    if (rhdPtr->ChipSet < RHD_RS690) /* r5xx */
+	RHDRegMask(Output, LVTMA_REG_TEST_OUTPUT, 0x00200000, 0x00200000);
+    else if (rhdPtr->ChipSet == RHD_RS690)
 	RHDRegWrite(Output, LVTMA_REG_TEST_OUTPUT, 0x01120000);
-    else
+    else /* R600 and up */
 	RHDRegMask(Output, LVTMA_REG_TEST_OUTPUT, 0x00100000, 0x00100000);
 
     /* Clear out some HPD events first: this should be under driver control. */
@@ -748,7 +679,10 @@ R6xxTMDSBSet(struct rhdOutput *Output)
     RHDRegMask(Output, LVTMA_CNTL, 0, 0x00000010);
 
     /* Disable the transmitter */
-    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x00003E3E); /* !r500 */
+    if (rhdPtr->ChipSet < RHD_RS690)
+	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x00001D1F);
+    else
+	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x00003E3E);
 
     /* Disable bit reduction and reset temporal dither */
     RHDRegMask(Output, LVTMA_BIT_DEPTH_CONTROL, 0, 0x00010101);
@@ -767,7 +701,7 @@ R6xxTMDSBSet(struct rhdOutput *Output)
     RHDRegWrite(Output, LVTMA_COLOR_FORMAT, 0);
     RHDRegMask(Output, LVTMA_CNTL, 0, 0x01000000);
 
-    if (RHDPTRI(Output)->ChipSet >= RHD_RV610) /* disable split mode: !r500 */
+    if (rhdPtr->ChipSet > RHD_R600) /* Rv6xx: disable split mode */
 	RHDRegMask(Output, LVTMA_CNTL, 0, 0x20000000);
 
     /* Disable force data */
@@ -776,7 +710,7 @@ R6xxTMDSBSet(struct rhdOutput *Output)
     /* DC balancer enable */
     RHDRegMask(Output, LVTMA_DCBALANCER_CONTROL, 0x00000001, 0x00000001);
 
-    R6xxTMDSBVoltageControl(Output);
+    TMDSBVoltageControl(Output);
 
     /* use IDCLK */
     RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000010);
@@ -804,7 +738,7 @@ R6xxTMDSBSet(struct rhdOutput *Output)
  *
  */
 static void
-R5xxTMDSBPower(struct rhdOutput *Output, int Power)
+TMDSBPower(struct rhdOutput *Output, int Power)
 {
     RHDPtr rhdPtr = RHDPTRI(Output);
 
@@ -815,54 +749,29 @@ R5xxTMDSBPower(struct rhdOutput *Output, int Power)
     switch (Power) {
     case RHD_POWER_ON:
 	RHDRegMask(Output, LVTMA_CNTL, 0x00000001, 0x00000001);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0x0000001F, 0x0000001F);
+	if (rhdPtr->ChipSet < RHD_RS690)
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0x0000001F, 0x0000001F);
+	else
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0x0000003E, 0x0000003E);
 	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x00000001, 0x00000001);
 	usleep(2);
 	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000002);
 	return;
     case RHD_POWER_RESET:
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000001F);
-	return;
-    case RHD_POWER_SHUTDOWN:
-    default:
-	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x00000002, 0x00000002);
-	usleep(2);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000001);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000001F);
-	RHDRegMask(Output, LVTMA_CNTL, 0, 0x00000001);
-	return;
-    }
-}
-
-/*
- *
- */
-static void
-R6xxTMDSBPower(struct rhdOutput *Output, int Power)
-{
-    RHDPtr rhdPtr = RHDPTRI(Output);
-
-    RHDFUNC(Output);
-
-    RHDRegMask(Output, LVTMA_MODE, 0x00000001, 0x00000001); /* select TMDS */
-
-    switch (Power) {
-    case RHD_POWER_ON:
-	RHDRegMask(Output, LVTMA_CNTL, 0x00000001, 0x00000001);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0x0000003E, 0x0000003E);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x00000003, 0x00000003);
-	usleep(2);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000002);
-	return;
-    case RHD_POWER_RESET:
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000003E);
+	if (rhdPtr->ChipSet < RHD_RS690)
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000001F);
+	else
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000003E);
 	return;
     case RHD_POWER_SHUTDOWN:
     default:
 	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0x00000002, 0x00000002);
 	usleep(2);
 	RHDRegMask(Output, LVTMA_TRANSMITTER_CONTROL, 0, 0x00000001);
-	RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000003E);
+	if (rhdPtr->ChipSet < RHD_RS690)
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000001F);
+	else
+	    RHDRegMask(Output, LVTMA_TRANSMITTER_ENABLE, 0, 0x0000003E);
 	RHDRegMask(Output, LVTMA_CNTL, 0, 0x00000001);
 	return;
     }
@@ -872,35 +781,7 @@ R6xxTMDSBPower(struct rhdOutput *Output, int Power)
  *
  */
 static void
-R5xxTMDSBSave(struct rhdOutput *Output)
-{
-    struct rhdTMDSBPrivate *Private = (struct rhdTMDSBPrivate *) Output->Private;
-    RHDPtr rhdPtr = RHDPTRI(Output);
-
-    RHDFUNC(Output);
-
-    Private->StoreControl = RHDRegRead(Output, LVTMA_CNTL);
-    Private->StoreSource = RHDRegRead(Output, LVTMA_SOURCE_SELECT);
-    Private->StoreFormat = RHDRegRead(Output, LVTMA_COLOR_FORMAT);
-    Private->StoreForce = RHDRegRead(Output, LVTMA_FORCE_OUTPUT_CNTL);
-    Private->StoreReduction = RHDRegRead(Output, LVTMA_BIT_DEPTH_CONTROL);
-    Private->StoreDCBalancer = RHDRegRead(Output, LVTMA_DCBALANCER_CONTROL);
-
-    Private->StoreDataSynchro = RHDRegRead(Output, LVTMA_DATA_SYNCHRONIZATION);
-    Private->StoreMode = RHDRegRead(Output, LVTMA_MODE);
-    Private->StoreTXEnable = RHDRegRead(Output, LVTMA_TRANSMITTER_ENABLE);
-    Private->StoreMacro = RHDRegRead(Output, LVTMA_MACRO_CONTROL);
-    Private->StoreTXControl = RHDRegRead(Output, LVTMA_TRANSMITTER_CONTROL);
-    Private->StoreTestOutput = RHDRegRead(Output, LVTMA_REG_TEST_OUTPUT);
-
-    Private->Stored = TRUE;
-}
-
-/*
- *
- */
-static void
-R6xxTMDSBSave(struct rhdOutput *Output)
+TMDSBSave(struct rhdOutput *Output)
 {
     struct rhdTMDSBPrivate *Private = (struct rhdTMDSBPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -933,39 +814,7 @@ R6xxTMDSBSave(struct rhdOutput *Output)
  *
  */
 static void
-R5xxTMDSBRestore(struct rhdOutput *Output)
-{
-    struct rhdTMDSBPrivate *Private = (struct rhdTMDSBPrivate *) Output->Private;
-    RHDPtr rhdPtr = RHDPTRI(Output);
-
-    RHDFUNC(Output);
-
-    if (!Private->Stored) {
-	xf86DrvMsg(Output->scrnIndex, X_ERROR,
-		   "%s: No registers stored.\n", __func__);
-	return;
-    }
-
-    RHDRegWrite(Output, LVTMA_CNTL, Private->StoreControl);
-    RHDRegWrite(Output, LVTMA_SOURCE_SELECT, Private->StoreSource);
-    RHDRegWrite(Output, LVTMA_COLOR_FORMAT, Private->StoreFormat);
-    RHDRegWrite(Output, LVTMA_FORCE_OUTPUT_CNTL, Private->StoreForce);
-    RHDRegWrite(Output, LVTMA_BIT_DEPTH_CONTROL, Private->StoreReduction);
-    RHDRegWrite(Output, LVTMA_DCBALANCER_CONTROL, Private->StoreDCBalancer);
-
-    RHDRegWrite(Output, LVTMA_DATA_SYNCHRONIZATION, Private->StoreDataSynchro);
-    RHDRegWrite(Output, LVTMA_MODE, Private->StoreMode);
-    RHDRegWrite(Output, LVTMA_TRANSMITTER_ENABLE, Private->StoreTXEnable);
-    RHDRegWrite(Output, LVTMA_MACRO_CONTROL, Private->StoreMacro);
-    RHDRegWrite(Output, LVTMA_TRANSMITTER_CONTROL, Private->StoreTXControl);
-    RHDRegWrite(Output, LVTMA_REG_TEST_OUTPUT, Private->StoreTestOutput);
-}
-
-/*
- *
- */
-static void
-R6xxTMDSBRestore(struct rhdOutput *Output)
+TMDSBRestore(struct rhdOutput *Output)
 {
     struct rhdTMDSBPrivate *Private = (struct rhdTMDSBPrivate *) Output->Private;
     RHDPtr rhdPtr = RHDPTRI(Output);
@@ -1061,17 +910,10 @@ RHDLVTMAInit(RHDPtr rhdPtr, CARD8 Type)
 	Output->Name = "TMDS B";
 	Output->ModeValid = TMDSBModeValid;
 
-	if (rhdPtr->ChipSet < RHD_R600) {
-	    Output->Mode = R5xxTMDSBSet;
-	    Output->Power = R5xxTMDSBPower;
-	    Output->Save = R5xxTMDSBSave;
-	    Output->Restore = R5xxTMDSBRestore;
-	} else {
-	    Output->Mode = R6xxTMDSBSet;
-	    Output->Power = R6xxTMDSBPower;
-	    Output->Save = R6xxTMDSBSave;
-	    Output->Restore = R6xxTMDSBRestore;
-	}
+	Output->Mode = TMDSBSet;
+	Output->Power = TMDSBPower;
+	Output->Save = TMDSBSave;
+	Output->Restore = TMDSBRestore;
 
 	Output->Private = xnfcalloc(sizeof(struct rhdTMDSBPrivate), 1);
     }

commit 3d01d69fc3a4f23b0ab8171f60d9dc8380a6c9da
Author: Luc Verhaegen <libv@skynet.be>
Date:   Fri Nov 23 21:44:16 2007 +0100

    LVTMA: use some nasty macros to hide the shift in the register space.

diff --git a/src/rhd_lvtma.c b/src/rhd_lvtma.c
index eb33fb6..ddaf767 100644
--- a/src/rhd_lvtma.c
+++ b/src/rhd_lvtma.c
@@ -48,6 +48,47 @@
 #endif
 
 /*
+ * First of all, make it more managable to code for both R500 and R600, as
+ * there was a 1 register shift, right in the middle of the register block.
+ * There are of course much nicer ways to do the workaround i am doing here,
+ * but speed is not an issue here.
+ */
+static inline CARD16
+LVTMARegisterShift(int ChipSet, CARD16 R500, CARD16 R600)
+{
+    if (ChipSet >= RHD_RS690)
+	return R600;
+    else
+	return R500;
+}
+
+#define LVTMAREGSHIFT(r500, r600) LVTMARegisterShift(rhdPtr->ChipSet, (r500), (r600))
+
+#define LVTMA_DATA_SYNCHRONIZATION \
+    LVTMAREGSHIFT(LVTMA_R500_DATA_SYNCHRONIZATION, LVTMA_R600_DATA_SYNCHRONIZATION)



Reply to: