aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/video/cx88/cx88-i2c.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-09-06 19:04:28 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 12:30:35 -0300
commit141276b57e1f83a86b8e77554b36511be0a7049c (patch)
treefe0e93f7eeaca9ba6b06bd74bf6758b8a1986b94 /drivers/media/video/cx88/cx88-i2c.c
parent48c06d5e2d63c1d6282c0f7fe67741a39d6c1852 (diff)
V4L/DVB (4609): Improved i2c performance on software bitbang algoritm
Software I2C were using a very conservative value of udelay=16, meaning about 20Kbps. According with Philips I2C datasheet, the i2c should answer well for times at the order of 4.7 us. So, using udelay=5 should work for all devices. After this patch, the speed should be close to 66,67 Kbps, with the current kernel software bitbang, with 30/60 duty cycle. Anyway, added a new parameter (i2c_udelay) that would allow using conservative values, if eventually a hardware doesn't support the datasheet values. Thanks to Jean Delvare <khali@linux-fr.org> for pointing this improvement. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx88/cx88-i2c.c')
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 2aec4c18268a..a74ed632dda0 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -43,6 +43,11 @@ static unsigned int i2c_scan = 0;
module_param(i2c_scan, int, 0444);
MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
+static unsigned int i2c_udelay = 5;
+module_param(i2c_udelay, int, 0644);
+MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs "
+ "(should be 5 or higher). Lower value means higher bus speed.");
+
#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \
printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
@@ -202,6 +207,11 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
/* init + register i2c algo-bit adapter */
int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
{
+ /* Prevents usage of invalid delay values */
+ if (i2c_udelay<5)
+ i2c_udelay=5;
+ cx8800_i2c_algo_template.udelay=i2c_udelay;
+
memcpy(&core->i2c_adap, &cx8800_i2c_adap_template,
sizeof(core->i2c_adap));
memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,