[PATCH xf86-video-r128 3/4] Move R128InitDDARegisters to r128_crtc.c

Kevin Brace kevinbrace at gmx.com
Mon Jun 18 01:20:05 UTC 2018


It does not make sense for this function to be inside r128_driver.c
since it is only called from a function inside r128_crtc.c.

Signed-off-by: Kevin Brace <kevinbrace at gmx.com>
---
 src/r128.h        |  1 -
 src/r128_crtc.c   | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/r128_driver.c | 73 ---------------------------------------------------
 3 files changed, 78 insertions(+), 74 deletions(-)

diff --git a/src/r128.h b/src/r128.h
index e666dfb..464388b 100644
--- a/src/r128.h
+++ b/src/r128.h
@@ -526,7 +526,6 @@ extern void        R128InitCommonRegisters(R128SavePtr save, R128InfoPtr info);
 extern void        R128InitRMXRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output, DisplayModePtr mode);
 extern void        R128InitFPRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output);
 extern void        R128InitLVDSRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr output);
-extern Bool        R128InitDDARegisters(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, DisplayModePtr mode);
 extern Bool        R128InitDDA2Registers(xf86CrtcPtr crtc, R128SavePtr save, R128PLLPtr pll, DisplayModePtr mode);
 extern void        R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore);
 extern void        R128RestoreDACRegisters(ScrnInfoPtr pScrn, R128SavePtr restore);
diff --git a/src/r128_crtc.c b/src/r128_crtc.c
index 9750204..f4844e0 100644
--- a/src/r128_crtc.c
+++ b/src/r128_crtc.c
@@ -48,6 +48,11 @@
 #include "r128_reg.h"
 
 
+#ifndef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#endif
+
+
 /* Define CRTC registers for requested video mode. */
 Bool R128InitCrtcRegisters(xf86CrtcPtr crtc, R128SavePtr save, DisplayModePtr mode)
 {
@@ -618,6 +623,79 @@ void R128RestorePLL2Registers(ScrnInfoPtr pScrn, R128SavePtr restore)
 
 }
 
+/* Define DDA registers for requested video mode. */
+Bool R128InitDDARegisters(xf86CrtcPtr crtc, R128SavePtr save,
+                 R128PLLPtr pll, DisplayModePtr mode)
+{
+    ScrnInfoPtr pScrn = crtc->scrn;
+    R128InfoPtr info  = R128PTR(pScrn);
+    xf86OutputPtr output = R128FirstOutput(crtc);
+    R128OutputPrivatePtr r128_output = output->driver_private;
+
+    int         DisplayFifoWidth = 128;
+    int         DisplayFifoDepth = 32;
+    int         XclkFreq;
+    int         VclkFreq;
+    int         XclksPerTransfer;
+    int         XclksPerTransferPrecise;
+    int         UseablePrecision;
+    int         Roff;
+    int         Ron;
+
+    XclkFreq = pll->xclk;
+
+    VclkFreq = R128Div(pll->reference_freq * save->feedback_div,
+               pll->reference_div * save->post_div);
+
+    if (info->isDFP && !info->isPro2 && r128_output->PanelXRes > 0) {
+        if (r128_output->PanelXRes != mode->CrtcHDisplay)
+            VclkFreq = (VclkFreq * mode->CrtcHDisplay) / r128_output->PanelXRes;
+    }
+
+    XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth,
+                   VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
+
+    UseablePrecision = R128MinBits(XclksPerTransfer) + 1;
+
+    XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth)
+                      << (11 - UseablePrecision),
+                      VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
+
+    Roff  = XclksPerTransferPrecise * (DisplayFifoDepth - 4);
+
+    Ron   = (4 * info->ram->MB
+         + 3 * MAX(info->ram->Trcd - 2, 0)
+         + 2 * info->ram->Trp
+         + info->ram->Twr
+         + info->ram->CL
+         + info->ram->Tr2w
+         + XclksPerTransfer) << (11 - UseablePrecision);
+
+    if (Ron + info->ram->Rloop >= Roff) {
+    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+           "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n",
+           Ron, info->ram->Rloop, Roff);
+    return FALSE;
+    }
+
+    save->dda_config = (XclksPerTransferPrecise
+            | (UseablePrecision << 16)
+            | (info->ram->Rloop << 20));
+
+    save->dda_on_off = (Ron << 16) | Roff;
+
+    R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n",
+           XclkFreq,
+           VclkFreq,
+           XclksPerTransfer,
+           XclksPerTransferPrecise,
+           UseablePrecision));
+    R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n",
+           Roff, Ron, info->ram->Rloop));
+
+    return TRUE;
+}
+
 static void r128_crtc_load_lut(xf86CrtcPtr crtc);
 
 static void r128_crtc_dpms(xf86CrtcPtr crtc, int mode)
diff --git a/src/r128_driver.c b/src/r128_driver.c
index 2fd9bf2..8ac8c0e 100644
--- a/src/r128_driver.c
+++ b/src/r128_driver.c
@@ -2618,79 +2618,6 @@ void R128InitLVDSRegisters(R128SavePtr orig, R128SavePtr save, xf86OutputPtr out
         save->lvds_gen_cntl &= ~R128_LVDS_SEL_CRTC2;
 }
 
-/* Define DDA registers for requested video mode. */
-Bool R128InitDDARegisters(xf86CrtcPtr crtc, R128SavePtr save,
-				 R128PLLPtr pll, DisplayModePtr mode)
-{
-    ScrnInfoPtr pScrn = crtc->scrn;
-    R128InfoPtr info  = R128PTR(pScrn);
-    xf86OutputPtr output = R128FirstOutput(crtc);
-    R128OutputPrivatePtr r128_output = output->driver_private;
-
-    int         DisplayFifoWidth = 128;
-    int         DisplayFifoDepth = 32;
-    int         XclkFreq;
-    int         VclkFreq;
-    int         XclksPerTransfer;
-    int         XclksPerTransferPrecise;
-    int         UseablePrecision;
-    int         Roff;
-    int         Ron;
-
-    XclkFreq = pll->xclk;
-
-    VclkFreq = R128Div(pll->reference_freq * save->feedback_div,
-		       pll->reference_div * save->post_div);
-
-    if (info->isDFP && !info->isPro2 && r128_output->PanelXRes > 0) {
-        if (r128_output->PanelXRes != mode->CrtcHDisplay)
-            VclkFreq = (VclkFreq * mode->CrtcHDisplay) / r128_output->PanelXRes;
-    }
-
-    XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth,
-			       VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
-
-    UseablePrecision = R128MinBits(XclksPerTransfer) + 1;
-
-    XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth)
-				      << (11 - UseablePrecision),
-				      VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
-
-    Roff  = XclksPerTransferPrecise * (DisplayFifoDepth - 4);
-
-    Ron   = (4 * info->ram->MB
-	     + 3 * MAX(info->ram->Trcd - 2, 0)
-	     + 2 * info->ram->Trp
-	     + info->ram->Twr
-	     + info->ram->CL
-	     + info->ram->Tr2w
-	     + XclksPerTransfer) << (11 - UseablePrecision);
-
-    if (Ron + info->ram->Rloop >= Roff) {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		   "(Ron = %d) + (Rloop = %d) >= (Roff = %d)\n",
-		   Ron, info->ram->Rloop, Roff);
-	return FALSE;
-    }
-
-    save->dda_config = (XclksPerTransferPrecise
-			| (UseablePrecision << 16)
-			| (info->ram->Rloop << 20));
-
-    save->dda_on_off = (Ron << 16) | Roff;
-
-    R128TRACE(("XclkFreq = %d; VclkFreq = %d; per = %d, %d (useable = %d)\n",
-	       XclkFreq,
-	       VclkFreq,
-	       XclksPerTransfer,
-	       XclksPerTransferPrecise,
-	       UseablePrecision));
-    R128TRACE(("Roff = %d, Ron = %d, Rloop = %d\n",
-	       Roff, Ron, info->ram->Rloop));
-
-    return TRUE;
-}
-
 /* Define DDA2 registers for requested video mode. */
 Bool R128InitDDA2Registers(xf86CrtcPtr crtc, R128SavePtr save,
 				 R128PLLPtr pll, DisplayModePtr mode)
-- 
2.7.4



More information about the xorg-driver-ati mailing list