summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-05-06 13:02:36 -0400
committerAdam Jackson <ajax@redhat.com>2009-05-06 13:02:36 -0400
commitb3fc1acaedd5d45b2c8eb2ba99b24579cf7d2a79 (patch)
treed2c0122665ba02dce8186e5842dc2a87605fd445
parentbf6aee62b891d4305cb96f8a37e625e5cf7c1504 (diff)
Normalize DDC for the second head.
The exit path wasn't symmetric with the exit path for the first head.
-rw-r--r--src/mga_driver.c204
1 files changed, 98 insertions, 106 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 0851824..dcf5a3a 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -1402,128 +1402,120 @@ MGACountRam(ScrnInfoPtr pScrn)
static xf86MonPtr
MGAdoDDC(ScrnInfoPtr pScrn)
{
- vgaHWPtr hwp;
- MGAPtr pMga;
- xf86MonPtr MonInfo = NULL;
-
- hwp = VGAHWPTR(pScrn);
- pMga = MGAPTR(pScrn);
-
- /* Load DDC if we have the code to use it */
- /* This gives us DDC1 */
- if (pMga->ddc1Read || pMga->i2cInit) {
- if (xf86LoadSubModule(pScrn, "ddc")) {
- xf86LoaderReqSymLists(ddcSymbols, NULL);
+ vgaHWPtr hwp;
+ MGAPtr pMga;
+ xf86MonPtr MonInfo = NULL;
+ char *from = NULL;
+
+ hwp = VGAHWPTR(pScrn);
+ pMga = MGAPTR(pScrn);
+
+ /* Load DDC if we have the code to use it */
+ /* This gives us DDC1 */
+ if (pMga->ddc1Read || pMga->i2cInit) {
+ if (xf86LoadSubModule(pScrn, "ddc")) {
+ xf86LoaderReqSymLists(ddcSymbols, NULL);
} else {
- /* ddc module not found, we can do without it */
- pMga->ddc1Read = NULL;
- pMga->DDC_Bus1 = NULL;
- pMga->DDC_Bus2 = NULL;
- return NULL;
+ /* ddc module not found, we can do without it */
+ pMga->ddc1Read = NULL;
+ pMga->DDC_Bus1 = NULL;
+ pMga->DDC_Bus2 = NULL;
+ return NULL;
}
} else
- return NULL;
+ return NULL;
/* - DDC can use I2C bus */
/* Load I2C if we have the code to use it */
if (pMga->i2cInit) {
- if ( xf86LoadSubModule(pScrn, "i2c") ) {
- xf86LoaderReqSymLists(i2cSymbols,NULL);
- } else {
- /* i2c module not found, we can do without it */
- pMga->i2cInit = NULL;
- pMga->DDC_Bus1 = NULL;
- pMga->DDC_Bus2 = NULL;
- }
+ if ( xf86LoadSubModule(pScrn, "i2c") ) {
+ xf86LoaderReqSymLists(i2cSymbols, NULL);
+ } else {
+ /* i2c module not found, we can do without it */
+ pMga->i2cInit = NULL;
+ pMga->DDC_Bus1 = NULL;
+ pMga->DDC_Bus2 = NULL;
+ }
}
- /* Map the MGA memory and MMIO areas */
- if (!MGAMapMem(pScrn))
- return NULL;
-
- /* Initialise the MMIO vgahw functions */
- vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET);
- vgaHWGetIOBase(hwp);
-
- /* Map the VGA memory when the primary video */
- if (pMga->Primary) {
- hwp->MapSize = 0x10000;
- if (!vgaHWMapMem(pScrn))
- return NULL;
- } else {
- /* XXX Need to write an MGA mode ddc1SetSpeed */
- if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) {
- pMga->DDC1SetSpeed = NULL;
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
- "DDC1 disabled - chip not in VGA mode\n");
- }
- }
-
- /* Save the current state */
- MGASave(pScrn);
-
- /* It is now safe to talk to the card */
-
- /* Initialize I2C buses - used by DDC if available */
- if (pMga->i2cInit) {
- pMga->i2cInit(pScrn);
- }
-
- /* DDC for second head... */
- if (pMga->SecondCrtc && pMga->DDC_Bus2) {
- MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus2);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n",
- (void *)MonInfo);
- xf86PrintEDID(MonInfo);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n");
- xf86SetDDCproperties(pScrn, MonInfo);
- return MonInfo;
- }
+ /* Map the MGA memory and MMIO areas */
+ if (!MGAMapMem(pScrn))
+ return NULL;
+
+ /* Initialise the MMIO vgahw functions */
+ vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET);
+ vgaHWGetIOBase(hwp);
- else {
+ /* Map the VGA memory when the primary video */
+ if (pMga->Primary) {
+ hwp->MapSize = 0x10000;
+ if (!vgaHWMapMem(pScrn))
+ return NULL;
+ } else {
+ /* XXX Need to write an MGA mode ddc1SetSpeed */
+ if (pMga->DDC1SetSpeed == vgaHWddc1SetSpeedWeak()) {
+ pMga->DDC1SetSpeed = NULL;
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+ "DDC1 disabled - chip not in VGA mode\n");
+ }
+ }
+
+ /* Save the current state */
+ MGASave(pScrn);
+
+ /* It is now safe to talk to the card */
+
+ /* Initialize I2C buses - used by DDC if available */
+ if (pMga->i2cInit) {
+ pMga->i2cInit(pScrn);
+ }
+
+ /* DDC for second head... */
+ if (pMga->SecondCrtc && pMga->DDC_Bus2) {
+ MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pMga->DDC_Bus2);
+ from = "I2C";
+ } else {
/* Its the first head... */
- if (pMga->DDC_Bus1) {
- MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex,pMga->DDC_Bus1);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "I2C Monitor info: %p\n", (void *) MonInfo);
- xf86PrintEDID(MonInfo);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of I2C Monitor info\n");
- }
- if (!MonInfo)
- /* Read and output monitor info using DDC1 */
- if (pMga->ddc1Read && pMga->DDC1SetSpeed) {
- MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex,
- pMga->DDC1SetSpeed,
- pMga->ddc1Read ) ;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DDC Monitor info: %p\n", (void *) MonInfo);
- xf86PrintEDID( MonInfo );
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of DDC Monitor info\n");
- }
- if (!MonInfo){
+ if (pMga->DDC_Bus1) {
+ MonInfo = xf86DoEDID_DDC2(pScrn->scrnIndex, pMga->DDC_Bus1);
+ from = "I2C";
+ }
+ if (!MonInfo)
+ /* Read and output monitor info using DDC1 */
+ if (pMga->ddc1Read && pMga->DDC1SetSpeed) {
+ MonInfo = xf86DoEDID_DDC1(pScrn->scrnIndex,
+ pMga->DDC1SetSpeed,
+ pMga->ddc1Read ) ;
+ from = "DDC1";
+ }
+ if (!MonInfo){
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
- pVbe = VBEInit(NULL,pMga->pEnt->index);
- MonInfo = vbeDoEDID(pVbe, NULL);
- vbeFree(pVbe);
-
- if (MonInfo){
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VBE DDC Monitor info: %p\n", (void *) MonInfo);
- xf86PrintEDID( MonInfo );
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of VBE DDC Monitor info\n\n");
- }
+ pVbe = VBEInit(NULL, pMga->pEnt->index);
+ MonInfo = vbeDoEDID(pVbe, NULL);
+ vbeFree(pVbe);
+ from = "VBE";
}
- }
- }
- /* Restore previous state and unmap MGA memory and MMIO areas */
- MGARestore(pScrn);
- MGAUnmapMem(pScrn);
- /* Unmap vga memory if we mapped it */
- if (xf86IsPrimaryPci(pMga->PciInfo) && !pMga->FBDev) {
- vgaHWUnmapMem(pScrn);
- }
+ }
+ }
+
+ if (MonInfo) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s monitor info\n", from);
+ xf86PrintEDID(MonInfo);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "end of monitor info\n");
+ }
+
+ /* Restore previous state and unmap MGA memory and MMIO areas */
+ MGARestore(pScrn);
+ MGAUnmapMem(pScrn);
+ /* Unmap vga memory if we mapped it */
+ if (xf86IsPrimaryPci(pMga->PciInfo) && !pMga->FBDev) {
+ vgaHWUnmapMem(pScrn);
+ }
- xf86SetDDCproperties(pScrn, MonInfo);
+ xf86SetDDCproperties(pScrn, MonInfo);
- return MonInfo;
+ return MonInfo;
}
#ifdef DISABLE_VGA_IO