aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-09-06 18:04:28 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 11:30:35 -0400
commit141276b57e1f83a86b8e77554b36511be0a7049c (patch)
treefe0e93f7eeaca9ba6b06bd74bf6758b8a1986b94 /drivers/media/video
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')
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c16
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c10
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 4b562b386fcf..03ee170181f2 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -8,6 +8,9 @@
8 & Marcus Metzler (mocm@thp.uni-koeln.de) 8 & Marcus Metzler (mocm@thp.uni-koeln.de)
9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> 9 (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org>
10 10
11 (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
12 - Multituner support and i2c address binding
13
11 This program is free software; you can redistribute it and/or modify 14 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by 15 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or 16 the Free Software Foundation; either version 2 of the License, or
@@ -45,10 +48,18 @@ static int i2c_debug;
45static int i2c_hw; 48static int i2c_hw;
46static int i2c_scan; 49static int i2c_scan;
47module_param(i2c_debug, int, 0644); 50module_param(i2c_debug, int, 0644);
51MODULE_PARM_DESC(i2c_hw,"configure i2c debug level");
48module_param(i2c_hw, int, 0444); 52module_param(i2c_hw, int, 0444);
53MODULE_PARM_DESC(i2c_hw,"force use of hardware i2c support, "
54 "instead of software bitbang");
49module_param(i2c_scan, int, 0444); 55module_param(i2c_scan, int, 0444);
50MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 56MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
51 57
58static unsigned int i2c_udelay = 5;
59module_param(i2c_udelay, int, 0444);
60MODULE_PARM_DESC(i2c_udelay,"soft i2c delay at insmod time, in usecs "
61 "(should be 5 or higher). Lower value means higher bus speed.");
62
52/* ----------------------------------------------------------------------- */ 63/* ----------------------------------------------------------------------- */
53/* I2C functions - bitbanging adapter (software i2c) */ 64/* I2C functions - bitbanging adapter (software i2c) */
54 65
@@ -426,6 +437,11 @@ int __devinit init_bttv_i2c(struct bttv *btv)
426 sizeof(bttv_i2c_adap_hw_template)); 437 sizeof(bttv_i2c_adap_hw_template));
427 } else { 438 } else {
428 /* bt848 */ 439 /* bt848 */
440 /* Prevents usage of invalid delay values */
441 if (i2c_udelay<5)
442 i2c_udelay=5;
443 bttv_i2c_algo_bit_template.udelay=i2c_udelay;
444
429 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template, 445 memcpy(&btv->c.i2c_adap, &bttv_i2c_adap_sw_template,
430 sizeof(bttv_i2c_adap_sw_template)); 446 sizeof(bttv_i2c_adap_sw_template));
431 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template, 447 memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template,
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;
43module_param(i2c_scan, int, 0444); 43module_param(i2c_scan, int, 0444);
44MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 44MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
45 45
46static unsigned int i2c_udelay = 5;
47module_param(i2c_udelay, int, 0644);
48MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs "
49 "(should be 5 or higher). Lower value means higher bus speed.");
50
46#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \ 51#define dprintk(level,fmt, arg...) if (i2c_debug >= level) \
47 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg) 52 printk(KERN_DEBUG "%s: " fmt, core->name , ## arg)
48 53
@@ -202,6 +207,11 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
202/* init + register i2c algo-bit adapter */ 207/* init + register i2c algo-bit adapter */
203int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci) 208int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
204{ 209{
210 /* Prevents usage of invalid delay values */
211 if (i2c_udelay<5)
212 i2c_udelay=5;
213 cx8800_i2c_algo_template.udelay=i2c_udelay;
214
205 memcpy(&core->i2c_adap, &cx8800_i2c_adap_template, 215 memcpy(&core->i2c_adap, &cx8800_i2c_adap_template,
206 sizeof(core->i2c_adap)); 216 sizeof(core->i2c_adap));
207 memcpy(&core->i2c_algo, &cx8800_i2c_algo_template, 217 memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,