diff options
Diffstat (limited to 'linux/drivers/media/common/saa7146_i2c.c')
-rw-r--r-- | linux/drivers/media/common/saa7146_i2c.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/linux/drivers/media/common/saa7146_i2c.c b/linux/drivers/media/common/saa7146_i2c.c index ed5f23930..1a2781da6 100644 --- a/linux/drivers/media/common/saa7146_i2c.c +++ b/linux/drivers/media/common/saa7146_i2c.c @@ -188,6 +188,8 @@ int saa7146_i2c_reset(struct saa7146_dev *dev) return 0; } +static int use_i2c_irq = 1; + /* this functions writes out the data-byte 'dword' to the i2c-device. it returns 0 if ok, -1 if the transfer failed, -2 if the transfer failed badly (e.g. address error) */ @@ -197,9 +199,23 @@ int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword) int i = 0; u32 status = 0, mc2 = 0; - DEB_I2C(("before: 0x%08x\n",*dword)); - /* write out i2c-command */ +if( 0 != use_i2c_irq ) { + dev->i2c_op = 1; + DEB_I2C(("before: 0x%08x (status: 0x%08x), %d\n",*dword,saa7146_read(dev, I2C_STATUS), dev->i2c_op)); + + saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); + saa7146_write(dev, I2C_TRANSFER, *dword); + IER_ENABLE(dev, MASK_16|MASK_17); + saa7146_write(dev, MC2, (MASK_00 | MASK_16)); + + wait_event_interruptible(dev->i2c_wq, (0 == dev->i2c_op) ); + if( 0 != dev->i2c_op ) { + printk("saa7146: bogus i2c stuff happened.\n"); + dev->i2c_op = 0; + } + status = saa7146_read(dev, I2C_STATUS); +} else { saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); saa7146_write(dev, I2C_TRANSFER, *dword); saa7146_write(dev, MC2, (MASK_00 | MASK_16)); @@ -232,6 +248,7 @@ int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword) DEB_I2C(("timeout error. #2\n")); return -1; } +} /* give a detailed status report */ if ( 0 != (status & SAA7146_I2C_ERR)) { @@ -378,6 +395,8 @@ struct i2c_algorithm saa7146_algo = { int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate) { + DEB_EE(("bitrate: 0x%08x\n",bitrate)); + dev->i2c_bitrate = bitrate; saa7146_i2c_reset(dev); |