summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2005-12-12 15:02:17 +0000
committerLuc Verhaegen <libv@skynet.be>2005-12-12 15:02:17 +0000
commite4d09d981ff1c7d20d10210d90c025a9ba253b46 (patch)
tree90fa34b5c3b2eed864d5037a3fb676be1780e80d
parentd6ea81daf1cd5c7c507897a7454cf5810ea52cb3 (diff)
[devel-ViaPanel_to_ViaOutput]
- Move ViaPanel into ViaOutput code too. - We have an ugly workaround for the primary DotClock value and still have to keep some dotclock setting code global. - Move TV bus handling closer to the modesetting of the TV, panel does this inside PanelMode still. - Have a special run through the outputs to disable all other devices when a panel is found. - Fix daft || versus && issue when warning that the panel is unsupported. - Remove VIA/S3 copyright from via_mode.h, not a single line of the original via_bios.h remains. This abstraction is quite artificial and will not survive a panel clean-up, if that will ever happen.
-rw-r--r--src/via_driver.c41
-rw-r--r--src/via_mode.c361
-rw-r--r--src/via_mode.h40
-rw-r--r--src/via_panel.c300
4 files changed, 406 insertions, 336 deletions
diff --git a/src/via_driver.c b/src/via_driver.c
index 7e5d11a..993ea4a 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -394,7 +394,6 @@ VIAGetRec(ScrnInfoPtr pScrn)
pVia->ModeInfo = xnfcalloc(sizeof(struct ViaModeInfo), 1);
pVia->ModeInfo->scrnIndex = pScrn->scrnIndex;
- pVia->ModeInfo->PanelOptions = NULL;
pVia->Outputs = NULL;
@@ -419,9 +418,6 @@ VIAFreeRec(ScrnInfoPtr pScrn)
ViaOutputsDestroy(pScrn);
- if (pVia->ModeInfo->PanelOptions)
- xfree(pVia->ModeInfo->PanelOptions);
-
xfree(pVia->ModeInfo);
VIAUnmapMem(pScrn);
@@ -1285,13 +1281,8 @@ static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
- if (ModeInfo->PanelActive && ((pVia->Chipset != VT3122) ||
- (pVia->Chipset != VT7205)))
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Panel on %s is currently not supported.\n", pScrn->chipset);
-
/* Add own Modes */
- ViaModesAttach(pScrn, pScrn->monitor);
+ ViaOutputsModesAttach(pScrn, pScrn->monitor);
/*
* Setup the ClockRanges, which describe what clock ranges are available,
@@ -1589,12 +1580,11 @@ VIASave(ScrnInfoPtr pScrn)
static void
VIARestore(ScrnInfoPtr pScrn)
{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- VIAPtr pVia = VIAPTR(pScrn);
- struct ViaModeInfo *ModeInfo = pVia->ModeInfo;
- VIARegPtr Regs = &pVia->SavedReg;
- int i;
- CARD8 tmp;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ VIAPtr pVia = VIAPTR(pScrn);
+ VIARegPtr Regs = &pVia->SavedReg;
+ int i;
+ CARD8 tmp;
VIAFUNC(pScrn->scrnIndex);
@@ -1663,8 +1653,17 @@ VIARestore(ScrnInfoPtr pScrn)
for (i = 0; i < 68; i++)
hwp->writeCrtc(hwp, i + 0x50, Regs->CRTCRegs[i]);
- if (ModeInfo->PanelActive)
- ModeInfo->PanelPower(pScrn, TRUE);
+ /* Re-enable Panel before returning */
+ {
+ struct ViaOutput *Output = pVia->Outputs;
+
+ while (Output) {
+ if ((Output->Type == OUTPUT_PANEL) && Output->Power)
+ Output->Power(Output, TRUE);
+
+ Output = Output->Next;
+ }
+ }
ViaDisablePrimaryFIFO(pScrn);
@@ -2318,9 +2317,6 @@ static void VIADPMS(ScrnInfoPtr pScrn, int mode, int flags)
switch (mode) {
case DPMSModeOn:
- if (ModeInfo->PanelActive)
- ModeInfo->PanelPower(pScrn, TRUE);
-
ViaOutputsPower(pScrn, TRUE);
hwp->writeCrtc(hwp, 0x36, val);
@@ -2328,9 +2324,6 @@ static void VIADPMS(ScrnInfoPtr pScrn, int mode, int flags)
case DPMSModeStandby:
case DPMSModeSuspend:
case DPMSModeOff:
- if (ModeInfo->PanelActive)
- ModeInfo->PanelPower(pScrn, FALSE);
-
ViaOutputsPower(pScrn, FALSE);
val |= 0x30;
diff --git a/src/via_mode.c b/src/via_mode.c
index e223360..bb271b1 100644
--- a/src/via_mode.c
+++ b/src/via_mode.c
@@ -107,6 +107,53 @@ ViaOutputsDestroy(ScrnInfoPtr pScrn)
Output = ViaOutputDestroy(Output);
}
+/*
+ *
+ */
+static Bool
+ViaOutputAdd(ScrnInfoPtr pScrn, struct ViaOutput *Output)
+{
+ struct ViaOutput *Last = NULL;
+
+ /* Is this Output sound? */
+ if (!Output->Name || !Output->ModeValid || !Output->Mode ||
+ !Output->Power) {
+
+ if (!Output->Name)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "%s: Nameless output device.\n", __func__);
+
+ if (!Output->ModeValid)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: ModeValid "
+ "callback missing\n", __func__, Output->Name);
+
+ if (!Output->Mode)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: Mode "
+ "callback missing\n", __func__, Output->Name);
+
+ if (!Output->Power)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: Power "
+ "callback missing\n", __func__, Output->Name);
+
+ return FALSE;
+ }
+
+ /* add Output to list */
+ Last = VIAPTR(pScrn)->Outputs;
+ if (Last) {
+ while (Last->Next)
+ Last = Last->Next;
+
+ Last->Next = Output;
+ Output->Prev = Last;
+ } else {
+ VIAPTR(pScrn)->Outputs = Output;
+ Output->Prev = NULL;
+ }
+
+ return TRUE;
+}
+
#ifdef UNUSED
/*
*
@@ -154,72 +201,37 @@ static struct {
static void
ViaScanBus(ScrnInfoPtr pScrn, I2CBusPtr pI2CBus)
{
- struct ViaOutput *Output, *Last = NULL;
+ struct ViaOutput *Output;
int i;
VIAFUNC(pScrn->scrnIndex);
- for (i = 0; ViaI2CDevices[i].Init; i++)
- if (xf86I2CProbeAddress(pI2CBus, ViaI2CDevices[i].Address)) {
- I2CDevPtr pDev = xf86CreateI2CDevRec();
-
- pDev->DevName = ViaI2CDevices[i].Name;
- pDev->SlaveAddr = ViaI2CDevices[i].Address;
- pDev->pI2CBus = pI2CBus;
-
- if (!xf86I2CDevInit(pDev)) {
- xf86DestroyI2CDevRec(pDev, TRUE);
- continue;
- }
-
- Output = ViaI2CDevices[i].Init(pScrn, pDev);
-
- /* did we actually find anything? */
- if (!Output) {
- xf86DestroyI2CDevRec(pDev,TRUE);
- continue;
- }
-
- /* Is this Output sound? */
- if (!Output->Name || !Output->ModeValid || !Output->Mode ||
- !Output->Power) {
+ for (i = 0; ViaI2CDevices[i].Init; i++) {
+ I2CDevPtr pDev = NULL;
- if (!Output->Name)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "%s: Nameless output device.\n", __func__);
-
- if (!Output->ModeValid)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: ModeValid "
- "callback missing\n", __func__, Output->Name);
-
- if (!Output->Mode)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: Mode "
- "callback missing\n", __func__, Output->Name);
-
- if (!Output->Power)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: %s: Power "
- "callback missing\n", __func__, Output->Name);
-
- /* this could be a whole list */
- while (Output)
- Output = ViaOutputDestroy(Output);
-
- continue;
- }
+ if (!xf86I2CProbeAddress(pI2CBus, ViaI2CDevices[i].Address))
+ continue;
- /* add Output to list */
- Last = VIAPTR(pScrn)->Outputs;
- if (Last) {
- while (Last->Next)
- Last = Last->Next;
-
- Last->Next = Output;
- Output->Prev = Last;
- } else {
- VIAPTR(pScrn)->Outputs = Output;
- Output->Prev = NULL;
- }
+ pDev = xf86CreateI2CDevRec();
+
+ pDev->DevName = ViaI2CDevices[i].Name;
+ pDev->SlaveAddr = ViaI2CDevices[i].Address;
+ pDev->pI2CBus = pI2CBus;
+
+ if (!xf86I2CDevInit(pDev)) {
+ xf86DestroyI2CDevRec(pDev, TRUE);
+ continue;
}
+
+ Output = ViaI2CDevices[i].Init(pScrn, pDev);
+
+ /* did we actually find anything? */
+ if (!Output) {
+ xf86DestroyI2CDevRec(pDev,TRUE);
+ } else if (!ViaOutputAdd(pScrn, Output))
+ while (Output) /* could be a whole list */
+ Output = ViaOutputDestroy(Output);
+ }
}
/*
@@ -233,6 +245,11 @@ ViaOutputsInit(ScrnInfoPtr pScrn)
VIAFUNC(pScrn->scrnIndex);
+ Output = ViaPanelInit(pScrn, NULL);
+ if (Output && !ViaOutputAdd(pScrn, Output))
+ while (Output) /* could be a whole list */
+ Output = ViaOutputDestroy(Output);
+
if (pVia->pI2CBus2)
ViaScanBus(pScrn, pVia->pI2CBus2);
@@ -408,8 +425,8 @@ ViaOutputsActivePrint(ScrnInfoPtr pScrn)
struct ViaOutput *Output = VIAPTR(pScrn)->Outputs;
while (Output) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Output %s: %s.\n",
- Output->Name, Output->Active ? "Active" : "Disabled");
+ ViaDebug(pScrn->scrnIndex, "Output %s: %s.\n", Output->Name,
+ Output->Active ? "Active" : "Disabled");
Output = Output->Next;
}
@@ -426,16 +443,18 @@ ViaOutputsDetect(ScrnInfoPtr pScrn)
VIAFUNC(pScrn->scrnIndex);
+#if 0
ModeInfo->CrtPresent = FALSE;
- ViaPanelInit(pScrn, NULL);
-
+
/* Crt */
if (pVia->DDC1)
ModeInfo->CrtPresent = TRUE;
/* If any of the unichromes support this, add CRT detection here */
- else if (!ModeInfo->PanelPresent)
- ModeInfo->CrtPresent = TRUE;
+ else
+ ModeInfo->CrtPresent = FALSE;
+#endif
+ ModeInfo->CrtPresent = TRUE;
ViaOutputsInit(pScrn);
}
@@ -461,14 +480,9 @@ ViaOutputsSelect(ScrnInfoPtr pScrn)
ViaDebug(pScrn->scrnIndex, "BIOS Initialised register: 0x%02x\n",
hwp->readCrtc(hwp, 0x3E));
- ModeInfo->PanelActive = FALSE;
ModeInfo->CrtActive = FALSE;
if (!pVia->ActiveDevice) {
- /* always enable the panel when present */
- if (ModeInfo->PanelPresent)
- ModeInfo->PanelActive = TRUE;
-
ViaOutputsSense(pScrn);
/* CRT can be used with everything when present */
@@ -476,56 +490,92 @@ ViaOutputsSelect(ScrnInfoPtr pScrn)
ModeInfo->CrtActive = TRUE;
} else {
if (pVia->ActiveDevice & VIA_DEVICE_LCD) {
- if (ModeInfo->PanelPresent)
- ModeInfo->PanelActive = TRUE;
- else
+ struct ViaOutput *Output = pVia->Outputs;
+ Bool Found = FALSE;
+
+ while (Output) {
+ if (Output->Type & OUTPUT_PANEL) {
+ Found = TRUE;
+ break;
+ }
+
+ Output = Output->Next;
+ }
+
+ if (!Found)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate"
" panel: no panel is present.\n");
}
if (pVia->ActiveDevice & VIA_DEVICE_TV) {
- if (ModeInfo->PanelActive)
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate"
- " TV encoder and panel simultaneously. Not using"
- " TV encoder.\n");
- else { /* way too simplistic */
- struct ViaOutput *Output = pVia->Outputs;
- Bool Found = FALSE;
-
- while (Output) {
- if (Output->Type & OUTPUT_TV) {
- if (Output->Sense) {
- if (Output->Sense(Output))
- Output->Active = TRUE;
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Unable to activate TV encoder: "
- "no cable attached.\n");
-
- Output->Active = FALSE;
- }
- } else
+ /* way too simplistic */
+ struct ViaOutput *Output = pVia->Outputs;
+ Bool Found = FALSE;
+
+ while (Output) {
+ if (Output->Type & OUTPUT_TV) {
+ if (Output->Sense) {
+ if (Output->Sense(Output))
Output->Active = TRUE;
- Found = TRUE;
- }
-
- Output = Output->Next;
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Unable to activate TV encoder: "
+ "no cable attached.\n");
+
+ Output->Active = FALSE;
+ }
+ } else
+ Output->Active = TRUE;
+ Found = TRUE;
}
-
- if (!Found)
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate"
- " TV encoder: no TV encoder present.\n");
+
+ Output = Output->Next;
}
+
+ if (!Found)
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to activate"
+ " TV encoder: no TV encoder present.\n");
}
-
+
if ((pVia->ActiveDevice & VIA_DEVICE_CRT))
ModeInfo->CrtPresent = TRUE;
ModeInfo->CrtActive = TRUE;
}
- ViaDebug(pScrn->scrnIndex, "%s:%s%s\n", __func__,
- ModeInfo->CrtActive ? " CRT," : "",
- ModeInfo->PanelActive ? " Panel," : "");
+ /* Make sure that a panel is the only Active Output device */
+ /* BAH! */
+ {
+ struct ViaOutput *Output = pVia->Outputs, *Panel = NULL;
+
+ /* find panel */
+ while (Output) {
+ if (Output->Active && (Output->Type == OUTPUT_PANEL)) {
+ Panel = Output;
+ break;
+ }
+
+ Output = Output->Next;
+ }
+
+ /* disable everything else */
+ if (Panel) {
+ Output = pVia->Outputs;
+
+ while (Output) {
+ if ((Output != Panel) && Output->Active) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Disabling %s: "
+ "Not compatible with %s.\n", Output->Name,
+ Panel->Name);
+ Output->Active = FALSE;
+ }
+
+ Output = Output->Next;
+ }
+ }
+ }
+
+ ViaDebug(pScrn->scrnIndex, "Output CRT: %s.\n",
+ ModeInfo->CrtActive ? "Active" : "Disabled");
ViaOutputsActivePrint(pScrn);
@@ -726,16 +776,12 @@ ViaModesAttachHelper(ScrnInfoPtr pScrn, MonPtr monitorp, DisplayModePtr Modes)
*
*/
void
-ViaModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp)
+ViaOutputsModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp)
{
- struct ViaModeInfo *ModeInfo = VIAPTR(pScrn)->ModeInfo;
struct ViaOutput *Output = VIAPTR(pScrn)->Outputs;
VIAFUNC(pScrn->scrnIndex);
- if (ModeInfo->PanelActive && ModeInfo->PanelModes)
- ViaModesAttachHelper(pScrn, monitorp, ModeInfo->PanelModes);
-
while (Output) {
if (Output->Active && Output->Modes)
ViaModesAttachHelper(pScrn, monitorp, Output->Modes);
@@ -900,6 +946,9 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
ModeStatus ret;
CARD32 temp;
+ /* workaround for crappy panel code */
+ ModeInfo->PanelClock = 0x00;
+
ViaDebug(scrnIndex, "%s: Validating %s (%d)\n", __func__, mode->name,
mode->Clock);
@@ -914,15 +963,6 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
if (ret != MODE_OK)
return ret;
- if (ModeInfo->PanelActive) {
- ret = ModeInfo->PanelModeValid(pScrn, mode);
- if (ret != MODE_OK) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Mode \"%s\" not supported by"
- " panel.\n", mode->name);
- return ret;
- }
- }
-
ret = ViaOutputsModeValid(pScrn, mode);
if (ret != MODE_OK) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Mode \"%s\" not supported by"
@@ -930,7 +970,7 @@ ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
return ret;
}
- if (!ModeInfo->PanelActive && !ModeInfo->ClockSlave)
+ if (!ModeInfo->PanelClock && !ModeInfo->ClockSlave)
if (!ViaModeDotClockTranslate(pScrn, mode))
return MODE_NOCLOCK;
@@ -1224,45 +1264,43 @@ ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode)
if (!ModeInfo->CrtActive)
ViaCrtcMask(hwp, 0x36, 0x30, 0x30);
- if (ModeInfo->PanelActive)
- ModeInfo->PanelMode(pScrn, mode);
- else if (ModeInfo->PanelPresent)
- ModeInfo->PanelPower(pScrn, FALSE);
-
while (Output) {
if (Output->Active) {
if (Output->Mode) {
- /* Quick 'n dirty workaround for non-primary case */
- ViaDotclockPrimarySlave(pScrn);
-
- Output->Mode(Output, mode);
-
- /*
- * !!! Only doing DI0/DVP0 currently !!!
- */
-
- if (pVia->IsSecondary) {
- ViaCrtcMask(hwp, 0x6A, 0x80, 0x80);
- ViaCrtcMask(hwp, 0x6C, 0x80, 0x80);
+ if (Output->Type == OUTPUT_TV) {
+ /* Quick 'n dirty workaround for non-primary case */
+ ViaDotclockPrimarySlave(pScrn);
- if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev)) {
- ViaCrtcMask(hwp, 0x6B, 0x20, 0x20);
- ViaCrtcMask(hwp, 0x6C, 0x10, 0x10);
+ Output->Mode(Output, mode);
+
+ /*
+ * !!! Only doing DI0/DVP0 currently !!!
+ */
+
+ if (pVia->IsSecondary) {
+ ViaCrtcMask(hwp, 0x6A, 0x80, 0x80);
+ ViaCrtcMask(hwp, 0x6C, 0x80, 0x80);
+
+ if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev)) {
+ ViaCrtcMask(hwp, 0x6B, 0x20, 0x20);
+ ViaCrtcMask(hwp, 0x6C, 0x10, 0x10);
+ }
+
+ /* Disable LCD Scaling */
+ if (!pVia->SAMM || pVia->FirstInit)
+ hwp->writeCrtc(hwp, 0x79, 0x00);
+ } else {
+ if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev))
+ ViaCrtcMask(hwp, 0x6B, 0x80, 0x80);
}
+ ViaCrtcMask(hwp, 0x6A, 0x40, 0x40);
+ ViaCrtcMask(hwp, 0x6B, 0x01, 0x01);
+ ViaCrtcMask(hwp, 0x6C, 0x01, 0x01);
+ ViaSeqMask(hwp, 0x1E, 0xC0, 0xC0); /* Enable DI0/DVP0 */
- /* Disable LCD Scaling */
- if (!pVia->SAMM || pVia->FirstInit)
- hwp->writeCrtc(hwp, 0x79, 0x00);
- } else {
- if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev))
- ViaCrtcMask(hwp, 0x6B, 0x80, 0x80);
- }
- ViaCrtcMask(hwp, 0x6A, 0x40, 0x40);
- ViaCrtcMask(hwp, 0x6B, 0x01, 0x01);
- ViaCrtcMask(hwp, 0x6C, 0x01, 0x01);
- ViaSeqMask(hwp, 0x1E, 0xC0, 0xC0); /* Enable DI0/DVP0 */
-
- ViaDotclockPrimarySlave(pScrn);
+ ViaDotclockPrimarySlave(pScrn);
+ } else /* OUTPUT_PANEL - BAH! */
+ Output->Mode(Output, mode);
}
} else {
if (Output->Power)
@@ -1273,7 +1311,7 @@ ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
if (!ModeInfo->ClockSlave) {
- if (ModeInfo->PanelActive)
+ if (ModeInfo->PanelClock)
ViaSetPrimaryDotclock(pScrn, ModeInfo->PanelClock);
else
ViaSetPrimaryDotclock(pScrn, ViaModeDotClockTranslate(pScrn, mode));
@@ -1442,10 +1480,14 @@ ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaCrtcMask(hwp, 0x17, 0x00, 0x80);
ViaModeSecondaryVGA(pScrn, mode);
+ ViaSetSecondaryFIFO(pScrn, mode);
+ ModeInfo->PanelClock = 0x00;
while (Output) {
if (Output->Active && Output->Mode)
Output->Mode(Output, mode);
+ else if (Output->Power)
+ Output->Power(Output, FALSE);
Output = Output->Next;
}
@@ -1454,14 +1496,7 @@ ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode)
if ((pVia->Chipset != VT3122) || (pVia->ChipRev != 0x02))
ViaCrtcMask(hwp, 0x6C, 0x00, 0x1E);
- if (ModeInfo->PanelActive)
- ModeInfo->PanelMode(pScrn, mode);
- else if (ModeInfo->PanelPresent)
- ModeInfo->PanelPower(pScrn, FALSE);
-
- ViaSetSecondaryFIFO(pScrn, mode);
-
- if (ModeInfo->PanelActive)
+ if (ModeInfo->PanelClock)
ViaSetSecondaryDotclock(pScrn, ModeInfo->PanelClock);
else
ViaSetSecondaryDotclock(pScrn, ViaModeDotClockTranslate(pScrn, mode));
diff --git a/src/via_mode.h b/src/via_mode.h
index ee8a65c..d198482 100644
--- a/src/via_mode.h
+++ b/src/via_mode.h
@@ -33,39 +33,16 @@
#define TVSTANDARD_PAL 0x02
struct ViaModeInfo {
- int scrnIndex;
+ int scrnIndex;
- Bool CrtPresent;
- Bool CrtActive;
+ Bool CrtPresent;
+ Bool CrtActive;
- CARD32 Bandwidth; /* available memory bandwidth */
+ CARD32 Bandwidth; /* available memory bandwidth */
Bool ClockSlave; /* is the unichrome the master or the slave? */
- CARD32 TVStandard; /* should be moved to pVia->Scratch */
-
- /* Panel/LCD entries */
- Bool PanelPresent;
- Bool PanelActive;
- CARD32 PanelClock;
-
- /* private use */
- int PanelIndex;
- CARD16 PanelResolutionIndex;
- int panelX;
- int panelY;
-
- /* private options */
- int PanelSize;
- Bool LCDDualEdge; /* mean add-on card is 2CH or Dual or DDR */
- Bool Center;
- CARD8 BusWidth; /* Digital Output Bus Width */
-
- DisplayModePtr PanelModes;
- OptionInfoPtr PanelOptions; /* alloced */
-
- ModeStatus (*PanelModeValid) (ScrnInfoPtr pScrn, DisplayModePtr mode);
- void (*PanelMode) (ScrnInfoPtr pScrn, DisplayModePtr mode);
- void (*PanelPower) (ScrnInfoPtr pScrn, Bool On);
+ CARD32 TVStandard; /* should be moved to pVia->Scratch */
+ CARD32 PanelClock;
};
/* For Output->Type */
@@ -126,15 +103,14 @@ void ViaOutputsPower(ScrnInfoPtr pScrn, Bool On);
void ViaOutputsPrintRegs(ScrnInfoPtr pScrn, const char *function);
void ViaOutputsDetect(ScrnInfoPtr pScrn);
Bool ViaOutputsSelect(ScrnInfoPtr pScrn);
+void ViaOutputsModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp);
-
-void ViaModesAttach(ScrnInfoPtr pScrn, MonPtr monitorp);
ModeStatus ViaValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags);
void ViaModePrimary(ScrnInfoPtr pScrn, DisplayModePtr mode);
void ViaModeSecondary(ScrnInfoPtr pScrn, DisplayModePtr mode);
/* outputs: via_panel.c, via_vt162x.c and via_ch7xxx.c */
-Bool ViaPanelInit(ScrnInfoPtr pScrn, I2CDevPtr pDev);
+struct ViaOutput *ViaPanelInit(ScrnInfoPtr pScrn, I2CDevPtr pDev);
struct ViaOutput *ViaVT162xInit(ScrnInfoPtr pScrn, I2CDevPtr pDev);
struct ViaOutput *ViaCH7xxxInit(ScrnInfoPtr pScrn, I2CDevPtr pDev);
diff --git a/src/via_panel.c b/src/via_panel.c
index f531e4c..ed86d0b 100644
--- a/src/via_panel.c
+++ b/src/via_panel.c
@@ -39,6 +39,57 @@
/* Kill me. */
#include "via_panel.h"
+
+/*
+ * Output->Private
+ */
+struct ViaPanelOutputPrivate {
+ /* private use */
+ Bool Present; /* only used until init is over */
+
+ int Index;
+ CARD16 ResolutionIndex;
+ int X;
+ int Y;
+
+ /* private options */
+ int Size;
+ Bool Center;
+ CARD8 BusWidth; /* Digital Output Bus Width */
+};
+
+/*
+ *
+ */
+static void
+ViaPanelPrivateDestroy(struct ViaOutput *Output)
+{
+ struct ViaPanelOutputPrivate *Private = Output->Private;
+
+ xfree(Private);
+
+ Output->PrivateDestroy = NULL;
+}
+
+/*
+ *
+ */
+static struct ViaPanelOutputPrivate *
+ViaPanelPrivateCreate(struct ViaOutput *Output)
+{
+ struct ViaPanelOutputPrivate *Private;
+
+ VIAFUNC(Output->scrnIndex);
+
+ Output->PrivSize = sizeof(struct ViaPanelOutputPrivate);
+ Output->Private = xnfcalloc(1, Output->PrivSize);
+ Private = Output->Private;
+
+ Output->PrivateDestroy = ViaPanelPrivateDestroy;
+
+ return Output->Private;
+}
+
/*
*
* Option handling.
@@ -66,9 +117,8 @@ static OptionInfoRec ViaPanelOptions[] =
*
*/
static OptionInfoPtr
-ViaPanelGetOptions(ScrnInfoPtr pScrn)
+ViaPanelGetOptions(ScrnInfoPtr pScrn, struct ViaPanelOutputPrivate *Private)
{
- struct ViaModeInfo *ModeInfo = VIAPTR(pScrn)->ModeInfo;
OptionInfoPtr Options;
char *s = NULL;
@@ -78,14 +128,14 @@ ViaPanelGetOptions(ScrnInfoPtr pScrn)
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, Options);
/* Digital Output Bus Width Option */
- ModeInfo->BusWidth = VIA_DI_12BIT;
+ Private->BusWidth = VIA_DI_12BIT;
if ((s = xf86GetOptValString(Options, OPTION_BUSWIDTH))) {
if (!xf86NameCmp(s, "12BIT")) {
- ModeInfo->BusWidth = VIA_DI_12BIT;
+ Private->BusWidth = VIA_DI_12BIT;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Digital Output Bus Width is 12BIT\n");
} else if (!xf86NameCmp(s, "24BIT")) {
- ModeInfo->BusWidth = VIA_DI_24BIT;
+ Private->BusWidth = VIA_DI_24BIT;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Digital Output Bus Width is 24BIT\n");
}
@@ -93,10 +143,10 @@ ViaPanelGetOptions(ScrnInfoPtr pScrn)
/* LCD Center/Expend Option */
if (xf86ReturnOptValBool(Options, OPTION_CENTER, FALSE)) {
- ModeInfo->Center = TRUE;
+ Private->Center = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DVI Center is On\n");
} else
- ModeInfo->Center = FALSE;
+ Private->Center = FALSE;
/* Force the use of the Panel? */
if (xf86ReturnOptValBool(Options, OPTION_FORCEPANEL, FALSE)) {
@@ -105,45 +155,36 @@ ViaPanelGetOptions(ScrnInfoPtr pScrn)
"This is a last resort option only.\n");
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Report PCI IDs to http://unichrome.sf.net/ ASAP.\n");
- ModeInfo->PanelPresent = TRUE;
- } else
- ModeInfo->PanelPresent = FALSE;
-
- /* LCDDualEdge Option */
- ModeInfo->LCDDualEdge = FALSE;
- if (xf86ReturnOptValBool(Options, OPTION_LCDDUALEDGE, FALSE)) {
- ModeInfo->LCDDualEdge = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Option: Using Dual Edge mode to set LCD\n");
+ Private->Present = TRUE;
} else
- ModeInfo->LCDDualEdge = FALSE;
+ Private->Present = FALSE;
/* Panel Size Option */
- ModeInfo->PanelSize = VIA_PANEL_INVALID;
+ Private->Size = VIA_PANEL_INVALID;
if ((s = xf86GetOptValString(Options, OPTION_PANELSIZE))) {
if (!xf86NameCmp(s, "640x480")) {
- ModeInfo->PanelSize = VIA_PANEL6X4;
+ Private->Size = VIA_PANEL6X4;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 640x480\n");
} else if (!xf86NameCmp(s, "800x600")) {
- ModeInfo->PanelSize = VIA_PANEL8X6;
+ Private->Size = VIA_PANEL8X6;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 800x600\n");
} else if(!xf86NameCmp(s, "1024x768")) {
- ModeInfo->PanelSize = VIA_PANEL10X7;
+ Private->Size = VIA_PANEL10X7;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 1024x768\n");
} else if (!xf86NameCmp(s, "1280x768")) {
- ModeInfo->PanelSize = VIA_PANEL12X7;
+ Private->Size = VIA_PANEL12X7;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 1280x768\n");
} else if (!xf86NameCmp(s, "1280x1024")) {
- ModeInfo->PanelSize = VIA_PANEL12X10;
+ Private->Size = VIA_PANEL12X10;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 1280x1024\n");
} else if (!xf86NameCmp(s, "1400x1050")) {
- ModeInfo->PanelSize = VIA_PANEL14X10;
+ Private->Size = VIA_PANEL14X10;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Selected Panel Size is 1400x1050\n");
}
@@ -290,11 +331,9 @@ ViaPanelGetSizeFromDDCv2(ScrnInfoPtr pScrn, int *size)
*
*/
static void
-ViaPanelGetSize(ScrnInfoPtr pScrn)
+ViaPanelGetSize(ScrnInfoPtr pScrn, struct ViaPanelOutputPrivate *Private)
{
vgaHWPtr hwp = VGAHWPTR(pScrn);
- VIAPtr pVia = VIAPTR(pScrn);
- struct ViaModeInfo *ModeInfo = pVia->ModeInfo;
char *PanelSizeString[7] = {"640x480", "800x600", "1024x768", "1280x768"
"1280x1024", "1400x1050", "1600x1200"};
int size = 0;
@@ -309,44 +348,44 @@ ViaPanelGetSize(ScrnInfoPtr pScrn)
if (ret) {
switch (size) {
case 640:
- ModeInfo->PanelSize = VIA_PANEL6X4;
+ Private->Size = VIA_PANEL6X4;
break;
case 800:
- ModeInfo->PanelSize = VIA_PANEL8X6;
+ Private->Size = VIA_PANEL8X6;
break;
case 1024:
- ModeInfo->PanelSize = VIA_PANEL10X7;
+ Private->Size = VIA_PANEL10X7;
break;
case 1280:
- ModeInfo->PanelSize = VIA_PANEL12X10;
+ Private->Size = VIA_PANEL12X10;
break;
case 1400:
- ModeInfo->PanelSize = VIA_PANEL14X10;
+ Private->Size = VIA_PANEL14X10;
break;
case 1600:
- ModeInfo->PanelSize = VIA_PANEL16X12;
+ Private->Size = VIA_PANEL16X12;
break;
default:
- ModeInfo->PanelSize = VIA_PANEL_INVALID;
+ Private->Size = VIA_PANEL_INVALID;
break;
}
} else {
- ModeInfo->PanelSize = hwp->readCrtc(hwp, 0x3F) >> 4;
- if (ModeInfo->PanelSize == 0) {
+ Private->Size = hwp->readCrtc(hwp, 0x3F) >> 4;
+ if (Private->Size == 0) {
/* VIA_PANEL6X4 == 0, but that value equals unset */
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unable to "
"retrieve PanelSize: using default (1024x768)\n");
- ModeInfo->PanelSize = VIA_PANEL10X7;
+ Private->Size = VIA_PANEL10X7;
return;
}
}
- if (ModeInfo->PanelSize < 7)
+ if (Private->Size < 7)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using panel at %s.\n",
- PanelSizeString[ModeInfo->PanelSize]);
+ PanelSizeString[Private->Size]);
else
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Unknown panel size "
- "detected: %d.\n", ModeInfo->PanelSize);
+ "detected: %d.\n", Private->Size);
}
@@ -354,26 +393,26 @@ ViaPanelGetSize(ScrnInfoPtr pScrn)
*
*/
static Bool
-ViaPanelGetResolutionIndex(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ViaPanelGetResolutionIndex(struct ViaOutput *Output, DisplayModePtr mode)
{
- struct ViaModeInfo *ModeInfo = VIAPTR(pScrn)->ModeInfo;
+ struct ViaPanelOutputPrivate *Private = Output->Private;
int i;
- VIAFUNC(pScrn->scrnIndex);
- ViaDebug(pScrn->scrnIndex, "%s: Looking for %dx%d\n", __func__,
+ VIAFUNC(Output->scrnIndex);
+ ViaDebug(Output->scrnIndex, "%s: Looking for %dx%d\n", __func__,
mode->CrtcHDisplay, mode->CrtcVDisplay);
for (i = 0; ViaPanelResolutionTable[i].Index != VIA_RES_INVALID; i++) {
if ((ViaPanelResolutionTable[i].X == mode->CrtcHDisplay) &&
(ViaPanelResolutionTable[i].Y == mode->CrtcVDisplay)){
- ModeInfo->PanelResolutionIndex = ViaPanelResolutionTable[i].Index;
- ViaDebug(pScrn->scrnIndex, "%s: %d\n", __func__,
- ModeInfo->PanelResolutionIndex);
+ Private->ResolutionIndex = ViaPanelResolutionTable[i].Index;
+ ViaDebug(Output->scrnIndex, "%s: %d\n", __func__,
+ Private->ResolutionIndex);
return TRUE;
}
}
- ModeInfo->PanelResolutionIndex = VIA_RES_INVALID;
+ Private->ResolutionIndex = VIA_RES_INVALID;
return FALSE;
}
@@ -409,87 +448,82 @@ ViaPanelGetVesaMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
/*
*
- * ViaResolutionTable[i].PanelIndex is ModeInfo->PanelSize
- * ModeInfo->PanelIndex is the index to lcdTable.
+ * ViaResolutionTable[i].PanelIndex is Private->Size
+ * Private->Index is the index to lcdTable.
*
*/
static ModeStatus
-ViaPanelModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ViaPanelModeValid(struct ViaOutput *Output, DisplayModePtr mode)
{
- struct ViaModeInfo *ModeInfo = VIAPTR(pScrn)->ModeInfo;
+ ScrnInfoPtr pScrn = xf86Screens[Output->scrnIndex];
+ struct ViaPanelOutputPrivate *Private = Output->Private;
int i;
- VIAFUNC(pScrn->scrnIndex);
+ VIAFUNC(Output->scrnIndex);
- ModeInfo->PanelIndex = VIA_BIOS_NUM_PANEL;
-
- if (ModeInfo->PanelSize == VIA_PANEL_INVALID) {
- ViaPanelGetSize(pScrn);
- if (ModeInfo->PanelSize == VIA_PANEL_INVALID) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: PanelSize not set.\n",
- __func__);
- return MODE_BAD;
- }
- }
+ Private->Index = VIA_BIOS_NUM_PANEL;
if ((mode->PrivSize != sizeof(struct ViaModePriv)) ||
(mode->Private != (void *)&ViaPanelPrivate)){
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: Not a mode defined by this "
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "%s: Not a mode defined by this "
"drivers panel code.\n", __func__);
return MODE_BAD;
}
- if (!ViaPanelGetResolutionIndex(pScrn, mode)) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel does not support this"
+ if (!ViaPanelGetResolutionIndex(Output, mode)) {
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "Panel does not support this"
" resolution: %s\n", mode->name);
return MODE_BAD;
}
for (i = 0; ViaPanelResolutionTable[i].Index != VIA_RES_INVALID; i++)
- if (ViaPanelResolutionTable[i].PanelIndex == ModeInfo->PanelSize) {
- ModeInfo->panelX = ViaPanelResolutionTable[i].X;
- ModeInfo->panelY = ViaPanelResolutionTable[i].Y;
+ if (ViaPanelResolutionTable[i].PanelIndex == Private->Size) {
+ Private->X = ViaPanelResolutionTable[i].X;
+ Private->Y = ViaPanelResolutionTable[i].Y;
break;
}
if (ViaPanelResolutionTable[i].Index == VIA_RES_INVALID) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: Unable to find matching "
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "%s: Unable to find matching "
"PanelSize in ViaPanelResolutionTable.\n", __func__);
return MODE_BAD;
}
- if ((ModeInfo->panelX != mode->CrtcHDisplay) ||
- (ModeInfo->panelY != mode->CrtcVDisplay)) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: Non-native resolutions are "
+ if ((Private->X != mode->CrtcHDisplay) ||
+ (Private->Y != mode->CrtcVDisplay)) {
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "%s: Non-native resolutions are "
"broken.\n", __func__);
return MODE_BAD;
}
for (i = 0; i < VIA_BIOS_NUM_PANEL; i++)
- if (lcdTable[i].fpSize == ModeInfo->PanelSize) {
+ if (lcdTable[i].fpSize == Private->Size) {
int modeNum, tmp;
modeNum = ViaPanelGetVesaMode(pScrn, mode);
if (modeNum == 0xFFFF) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Unable to determine "
+ xf86DrvMsg(Output->scrnIndex, X_ERROR, "%s: Unable to determine "
"matching VESA modenumber.\n", __func__);
return MODE_BAD;
}
tmp = 0x01 << (modeNum & 0xF);
if ((CARD16)(tmp) & lcdTable[i].SuptMode[(modeNum >> 4)]) {
- ModeInfo->PanelIndex = i;
- ViaDebug(pScrn->scrnIndex, "%s: index: %d (%dx%d)\n", __func__,
- ModeInfo->PanelIndex, ModeInfo->panelX, ModeInfo->panelY);
+ Private->Index = i;
+ ViaDebug(Output->scrnIndex, "%s: index: %d (%dx%d)\n", __func__,
+ Private->Index, Private->X, Private->Y);
+
+ /* work around */
+ VIAPTR(pScrn)->ModeInfo->PanelClock = 1;
return MODE_OK;
}
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: Unable to match given "
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "%s: Unable to match given "
"mode with this PanelSize.\n", __func__);
return MODE_BAD;
}
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s: Unable to match PanelSize with an"
+ xf86DrvMsg(Output->scrnIndex, X_INFO, "%s: Unable to match PanelSize with an"
" lcdTable entry.\n", __func__);
return MODE_BAD;
}
@@ -499,25 +533,28 @@ ViaPanelModeValid(ScrnInfoPtr pScrn, DisplayModePtr mode)
* Broken, only does native mode decently. I (Luc) personally broke this.
*/
static void
-ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
+ViaPanelMode(struct ViaOutput *Output, DisplayModePtr mode)
{
+ ScrnInfoPtr pScrn = xf86Screens[Output->scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
struct ViaModeInfo *ModeInfo = pVia->ModeInfo;
- VIALCDModeTableRec Table = lcdTable[ModeInfo->PanelIndex];
+
+ struct ViaPanelOutputPrivate *Private = Output->Private;
+ VIALCDModeTableRec Table = lcdTable[Private->Index];
CARD8 modeNum = 0;
CARD32 Clock;
int resIdx;
int i, j, misc;
- VIAFUNC(pScrn->scrnIndex);
+ VIAFUNC(Output->scrnIndex);
- if (ModeInfo->PanelSize == VIA_PANEL12X10)
+ if (Private->Size == VIA_PANEL12X10)
hwp->writeCrtc(hwp, 0x89, 0x07);
/* Set LCD InitTb Regs */
- if (ModeInfo->BusWidth == VIA_DI_12BIT) {
+ if (Private->BusWidth == VIA_DI_12BIT) {
if (pVia->IsSecondary)
Clock = Table.InitTb.LCDClk_12Bit;
else {
@@ -541,8 +578,8 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaVgahwWrite(hwp, 0x300 + Table.InitTb.port[i], Table.InitTb.offset[i],
0x301 + Table.InitTb.port[i], Table.InitTb.data[i]);
- if ((mode->CrtcHDisplay != ModeInfo->panelX) ||
- (mode->CrtcVDisplay != ModeInfo->panelY)) {
+ if ((mode->CrtcHDisplay != Private->X) ||
+ (mode->CrtcVDisplay != Private->Y)) {
VIALCDModeEntryPtr Main;
VIALCDMPatchEntryPtr Patch1, Patch2;
int numPatch1, numPatch2;
@@ -550,7 +587,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
resIdx = VIA_RES_INVALID;
/* Find MxxxCtr & MxxxExp Index */
- switch (ModeInfo->PanelResolutionIndex) {
+ switch (Private->ResolutionIndex) {
case VIA_RES_640X480:
resIdx = 0;
break;
@@ -566,7 +603,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
case VIA_RES_1280X768:
case VIA_RES_1280X960:
case VIA_RES_1280X1024:
- if (ModeInfo->PanelSize == VIA_PANEL12X10)
+ if (Private->Size == VIA_PANEL12X10)
resIdx = VIA_RES_INVALID;
else
resIdx = 4;
@@ -581,12 +618,12 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
resIdx = 0;
if (resIdx == VIA_RES_INVALID) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Failed to find a "
+ xf86DrvMsg(Output->scrnIndex, X_ERROR, "%s: Failed to find a "
"suitable Panel Size index.\n", __func__);
return;
}
- if (ModeInfo->Center) {
+ if (Private->Center) {
Main = &(Table.MCtr[resIdx]);
Patch1 = Table.MPatchDP1Ctr;
numPatch1 = Table.numMPatchDP1Ctr;
@@ -606,7 +643,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaVgahwWrite(hwp, 0x300 + Main->port[i], Main->offset[i],
0x301 + Main->port[i], Main->data[i]);
- if (ModeInfo->BusWidth == VIA_DI_12BIT) {
+ if (Private->BusWidth == VIA_DI_12BIT) {
if (pVia->IsSecondary)
Clock = Main->LCDClk_12Bit;
else
@@ -620,7 +657,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
j = ViaPanelGetVesaMode(pScrn, mode);
if (j == 0xFFFF) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Unable to determine "
+ xf86DrvMsg(Output->scrnIndex, X_ERROR, "%s: Unable to determine "
"matching VESA modenumber.\n", __func__);
return;
}
@@ -638,7 +675,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaVgahwWrite(hwp, 0x300 + Patch2->port[j], Patch2->offset[j],
0x301 + Patch2->port[j], Patch2->data[j]);
- if (ModeInfo->BusWidth == VIA_DI_12BIT) {
+ if (Private->BusWidth == VIA_DI_12BIT) {
if (pVia->IsSecondary)
Clock = Patch2->LCDClk_12Bit;
else
@@ -679,7 +716,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaSeqMask(hwp, 0x16, 0x40, 0x40);
/* Enable Simultaneous */
- if (ModeInfo->BusWidth == VIA_DI_12BIT) {
+ if (Private->BusWidth == VIA_DI_12BIT) {
hwp->writeCrtc(hwp, 0x6B, 0xA8);
if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev))
@@ -696,7 +733,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
ViaSeqMask(hwp, 0x16, 0x00, 0x40);
/* Enable SAMM */
- if (ModeInfo->BusWidth == VIA_DI_12BIT) {
+ if (Private->BusWidth == VIA_DI_12BIT) {
ViaCrtcMask(hwp, 0x6B, 0x20, 0x20);
if ((pVia->Chipset == VT3122) && VT3122_REV_IS_AX(pVia->ChipRev))
hwp->writeCrtc(hwp, 0x93, 0xB1);
@@ -709,7 +746,7 @@ ViaPanelMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
hwp->writeCrtc(hwp, 0x6A, 0xC8);
}
- ModeInfo->PanelPower(pScrn, TRUE);
+ Output->Power(Output, TRUE);
}
@@ -734,14 +771,15 @@ ViaPanelPowerSequence(vgaHWPtr hwp, VIALCDPowerSeqRec Sequence)
*
*/
static void
-ViaPanelPower(ScrnInfoPtr pScrn, Bool On)
+ViaPanelPower(struct ViaOutput *Output, Bool On)
{
+ ScrnInfoPtr pScrn = xf86Screens[Output->scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
- struct ViaModeInfo *ModeInfo = pVia->ModeInfo;
+ struct ViaPanelOutputPrivate *Private = Output->Private;
int i;
- ViaDebug(pScrn->scrnIndex, "%s: %s.\n", __func__, On ? "On" : "Off");
+ ViaDebug(Output->scrnIndex, "%s: %s.\n", __func__, On ? "On" : "Off");
/* Enable LCD */
if (On)
@@ -751,9 +789,9 @@ ViaPanelPower(ScrnInfoPtr pScrn, Bool On)
/* Find Panel Size Index for PowerSeq Table */
if (pVia->Chipset == VT3122) {
- if (ModeInfo->PanelSize != VIA_PANEL_INVALID) {
+ if (Private->Size != VIA_PANEL_INVALID) {
for (i = 0; i < NumPowerOn; i++) {
- if (lcdTable[ModeInfo->PanelIndex].powerSeq == powerOn[i].powerSeq)
+ if (lcdTable[Private->Index].powerSeq == powerOn[i].powerSeq)
break;
}
} else
@@ -773,38 +811,66 @@ ViaPanelPower(ScrnInfoPtr pScrn, Bool On)
/*
* future: I2CDevPtr for LVDS encoders.
*/
-Bool
+struct ViaOutput *
ViaPanelInit(ScrnInfoPtr pScrn, I2CDevPtr pDev)
{
- VIAPtr pVia = VIAPTR(pScrn);
- struct ViaModeInfo *ModeInfo = pVia->ModeInfo;
+ VIAPtr pVia = VIAPTR(pScrn);
+ struct ViaOutput *Output;
+ struct ViaPanelOutputPrivate *Private;
VIAFUNC(pScrn->scrnIndex);
if (pDev)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "%s: Ignoring I2C Device"
" passed.\n", __func__);
+
+ Output = xnfcalloc(1, sizeof(struct ViaOutput));
+
+ Output->Prev = NULL;
+ Output->Next = NULL;
+ Output->scrnIndex = pScrn->scrnIndex;
+ Output->I2CDev = pDev;
+ Output->Type = OUTPUT_PANEL;
+
+ Private = ViaPanelPrivateCreate(Output);
/* Parse options here ourselves. */
- ModeInfo->PanelOptions = ViaPanelGetOptions(pScrn);
+ Output->Options = ViaPanelGetOptions(pScrn, Private);
/* Is there even a panel present? */
- if (!ModeInfo->PanelPresent) {
+ if (!Private->Present) {
if (pVia->Id && pVia->Id->HasPanel) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Enabling panel from"
" PCI-Subsystem Id information.\n");
- ModeInfo->PanelPresent = TRUE;
+ Private->Present = TRUE;
} else {
- xfree(ModeInfo->PanelOptions);
- ModeInfo->PanelOptions = NULL;
- return FALSE;
+ Output->PrivateDestroy(Output);
+
+ xfree(Output->Options);
+ xfree(Output);
+ return NULL;
}
}
- ModeInfo->PanelModeValid = ViaPanelModeValid;
- ModeInfo->PanelMode = ViaPanelMode;
- ModeInfo->PanelPower = ViaPanelPower;
- ModeInfo->PanelModes = ViaPanelModes;
+ if ((pVia->Chipset != VT3122) && (pVia->Chipset != VT7205))
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Panel on %s is currently "
+ "not supported.\n", pScrn->chipset);
- return TRUE;
+ if (Private->Size == VIA_PANEL_INVALID)
+ ViaPanelGetSize(pScrn, Private);
+
+ Output->Name = "Panel";
+
+ Output->ClockMaster = FALSE;
+ Output->Modes = ViaPanelModes;
+
+ Output->Save = NULL;
+ Output->Restore = NULL;
+ Output->Sense = NULL;
+ Output->ModeValid = ViaPanelModeValid;
+ Output->Mode = ViaPanelMode;
+ Output->Power = ViaPanelPower;
+ Output->PrintRegs = NULL;
+
+ return Output;
}