From f16d90b62b23c2940ad96af9b8ade53d1940e855 Mon Sep 17 00:00:00 2001 From: Zhenyu Wang Date: Thu, 12 Mar 2009 16:53:20 +0800 Subject: [PATCH] SDVO: switch DDC bus after i2c Stop After i2c stop, control bus will return back to internal registers, we will switch DDC bus before next i2c start operation. This eliminates possible switch DDC bus command between i2c operations that causes command error with some SDVO devices. --- src/i830_sdvo.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/i830_sdvo.c b/src/i830_sdvo.c index 254b866..5bdd6d3 100644 --- a/src/i830_sdvo.c +++ b/src/i830_sdvo.c @@ -111,6 +111,9 @@ struct i830_sdvo_priv { /** DDC bus used by this SDVO output */ uint8_t ddc_bus; + /** This flag means if we should switch ddc bus before next i2c Start */ + Bool ddc_bus_switch; + /** State for save/restore */ /** @{ */ int save_sdvo_mult; @@ -1392,7 +1395,10 @@ i830_sdvo_ddc_i2c_start(I2CBusPtr b, int timeout) I2CBusPtr i2cbus = intel_output->pI2CBus; struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; - i830_sdvo_set_control_bus_switch(output, dev_priv->ddc_bus); + if (dev_priv->ddc_bus_switch) { + i830_sdvo_set_control_bus_switch(output, dev_priv->ddc_bus); + dev_priv->ddc_bus_switch = FALSE; + } return i2cbus->I2CStart(i2cbus, timeout); } @@ -1403,11 +1409,13 @@ i830_sdvo_ddc_i2c_stop(I2CDevPtr d) xf86OutputPtr output = d->pI2CBus->DriverPrivate.ptr; I830OutputPrivatePtr intel_output = output->driver_private; I2CBusPtr i2cbus = intel_output->pI2CBus, savebus; + struct i830_sdvo_priv *dev_priv = intel_output->dev_priv; savebus = d->pI2CBus; d->pI2CBus = i2cbus; i2cbus->I2CStop(d); d->pI2CBus = savebus; + dev_priv->ddc_bus_switch = TRUE; } /** @@ -2091,6 +2099,7 @@ i830_sdvo_init(ScrnInfoPtr pScrn, int output_device) ddcbus->I2CStop = i830_sdvo_ddc_i2c_stop; ddcbus->I2CAddress = i830_sdvo_ddc_i2c_address; ddcbus->DriverPrivate.ptr = output; + dev_priv->ddc_bus_switch = TRUE; if (!xf86I2CBusInit(ddcbus)) { -- 1.6.2