diff --git a/src/via_analog.c b/src/via_analog.c index 473b7aa..935e37a 100644 --- a/src/via_analog.c +++ b/src/via_analog.c @@ -249,6 +249,54 @@ viaAnalogDetectConnector(ScrnInfoPtr pScrn) } +/* + * Detect I2C bus for analog (VGA). + */ +static Bool +viaAnalogDetectI2CBus(ScrnInfoPtr pScrn, xf86OutputPtr output) +{ + VIAPtr pVia = VIAPTR(pScrn); + VIADisplayPtr pVIADisplay = pVia->pVIADisplay; + VIAAnalogPtr pVIAAnalog = (VIAAnalogPtr) output->driver_private; + I2CBusPtr pI2CBus; + Bool i2cBusDetected = FALSE; + + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Entered %s.\n", __func__)); + + if (pVIAAnalog->i2cBus & VIA_I2C_BUS1) { + pI2CBus = pVIADisplay->pI2CBus1; + } else { + pI2CBus = NULL; + } + + if (pI2CBus) { + i2cBusDetected = xf86I2CProbeAddress(pI2CBus, 0xA0); + if (i2cBusDetected) { + goto exit; + } + } + + if (pVIAAnalog->i2cBus & VIA_I2C_BUS2) { + pI2CBus = pVIADisplay->pI2CBus2; + } else { + pI2CBus = NULL; + } + + if (pI2CBus) { + i2cBusDetected = xf86I2CProbeAddress(pI2CBus, 0xA0); + if (i2cBusDetected) { + goto exit; + } + } + +exit: + DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Exiting %s.\n", __func__)); + return i2cBusDetected; +} + + static void via_analog_create_resources(xf86OutputPtr output) { @@ -372,24 +420,24 @@ via_analog_detect(xf86OutputPtr output) { ScrnInfoPtr pScrn = output->scrn; xf86OutputStatus status = XF86OutputStatusDisconnected; - Bool connectorDetected; + Bool i2cDetected; DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Entered via_analog_detect.\n")); xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "Probing for a VGA connector . . .\n"); + "Probing for analog (VGA) . . .\n"); - connectorDetected = viaAnalogDetectConnector(pScrn); - if (!connectorDetected) { + i2cDetected = viaAnalogDetectI2CBus(pScrn, output); + if (!i2cDetected) { xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "VGA connector not detected.\n"); + "Analog (VGA) not detected.\n"); goto exit; } status = XF86OutputStatusConnected; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, - "VGA connector detected.\n"); + "Analog (VGA) detected.\n"); exit: DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Exiting via_analog_detect.\n"));