Commit 0be9774d authored by Kevin Brace's avatar Kevin Brace Committed by Connor Behan

Move R128InitDDARegisters to r128_crtc.c

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's avatarKevin Brace <kevinbrace@gmx.com>
parent 732ab991
......@@ -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);
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment