aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-i2c.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:37:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:18 -0500
commitd5e5265315770bda46c50ecaa64e2b9790f2064c (patch)
tree5c92fa1125dee3f766bd06f18840ce78bf0cd861 /drivers/media/video/em28xx/em28xx-i2c.c
parentda45a2a5b96afd7188c058a55eb2917d6524c0cf (diff)
[PATCH] v4l: 784: several improvement on i2c ir handling for em2820
- Several Improvement on I2C IR handling for em2820: - moved Pinnacle IR table (ir_codes_em2820) to em2820-input.c - IR struct renamed and moved to a header file. - New file to handle em2820-specific IR. - Some cleanups. - attach now detects I2C IR and calls em2820-specific IR code - IR compat code moved to compat.h - New header with struct IR_i2c there, to allow it to be used by board-specific input handlers. - Some improvements at em28xx board detection: - Board detection message improved to show interface and class. - Now it doesn't touch audio interfaces. Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-i2c.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index a7b6f678f979..f6bfc038777e 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -26,10 +26,10 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <media/tuner.h>
30#include <linux/video_decoder.h> 29#include <linux/video_decoder.h>
31 30
32#include "em2820.h" 31#include "em2820.h"
32#include <media/tuner.h>
33 33
34/* ----------------------------------------------------------- */ 34/* ----------------------------------------------------------- */
35 35
@@ -41,14 +41,11 @@ static unsigned int i2c_debug = 0;
41module_param(i2c_debug, int, 0644); 41module_param(i2c_debug, int, 0644);
42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
43 43
44#define dprintk(fmt, args...) if (i2c_debug) do {\ 44#define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\
45 printk(KERN_DEBUG "%s: %s: " fmt "\n",\
46 dev->name, __FUNCTION__ , ##args); } while (0)
47#define dprintk1(fmt, args...) if (i2c_debug) do{ \
48 printk(KERN_DEBUG "%s: %s: " fmt, \
49 dev->name, __FUNCTION__ , ##args); } while (0)
50#define dprintk2(fmt, args...) if (i2c_debug) do {\
51 printk(fmt , ##args); } while (0) 45 printk(fmt , ##args); } while (0)
46#define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \
47 printk(KERN_DEBUG "%s at %s: " fmt, \
48 dev->name, __FUNCTION__ , ##args); } while (0)
52 49
53/* 50/*
54 * em2800_i2c_send_max4() 51 * em2800_i2c_send_max4()
@@ -238,7 +235,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
238 return 0; 235 return 0;
239 for (i = 0; i < num; i++) { 236 for (i = 0; i < num; i++) {
240 addr = msgs[i].addr << 1; 237 addr = msgs[i].addr << 1;
241 dprintk1("%s %s addr=%x len=%d:", 238 dprintk2(2,"%s %s addr=%x len=%d:",
242 (msgs[i].flags & I2C_M_RD) ? "read" : "write", 239 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
243 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); 240 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
244 if (!msgs[i].len) { /* no len: check only for device presence */ 241 if (!msgs[i].len) { /* no len: check only for device presence */
@@ -247,7 +244,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
247 else 244 else
248 rc = em2820_i2c_check_for_device(dev, addr); 245 rc = em2820_i2c_check_for_device(dev, addr);
249 if (rc < 0) { 246 if (rc < 0) {
250 dprintk2(" no device\n"); 247 dprintk2(2," no device\n");
251 return rc; 248 return rc;
252 } 249 }
253 250
@@ -261,14 +258,14 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
261 rc = em2820_i2c_recv_bytes(dev, addr, 258 rc = em2820_i2c_recv_bytes(dev, addr,
262 msgs[i].buf, 259 msgs[i].buf,
263 msgs[i].len); 260 msgs[i].len);
264 if (i2c_debug) { 261 if (i2c_debug>=2) {
265 for (byte = 0; byte < msgs[i].len; byte++) { 262 for (byte = 0; byte < msgs[i].len; byte++) {
266 printk(" %02x", msgs[i].buf[byte]); 263 printk(" %02x", msgs[i].buf[byte]);
267 } 264 }
268 } 265 }
269 } else { 266 } else {
270 /* write bytes */ 267 /* write bytes */
271 if (i2c_debug) { 268 if (i2c_debug>=2) {
272 for (byte = 0; byte < msgs[i].len; byte++) 269 for (byte = 0; byte < msgs[i].len; byte++)
273 printk(" %02x", msgs[i].buf[byte]); 270 printk(" %02x", msgs[i].buf[byte]);
274 } 271 }
@@ -284,13 +281,13 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
284 if (rc < 0) 281 if (rc < 0)
285 goto err; 282 goto err;
286 } 283 }
287 if (i2c_debug) 284 if (i2c_debug>=2)
288 printk("\n"); 285 printk("\n");
289 } 286 }
290 287
291 return num; 288 return num;
292 err: 289 err:
293 dprintk2(" ERROR: %i\n", rc); 290 dprintk2(2," ERROR: %i\n", rc);
294 return rc; 291 return rc;
295} 292}
296 293
@@ -436,26 +433,34 @@ static int attach_inform(struct i2c_client *client)
436{ 433{
437 struct em2820 *dev = client->adapter->algo_data; 434 struct em2820 *dev = client->adapter->algo_data;
438 435
439 dprintk("address %x", client->addr << 1);
440 switch (client->addr << 1) { 436 switch (client->addr << 1) {
441 case 0x86: 437 case 0x86:
442 em2820_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf); 438 em2820_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf);
443 break; 439 break;
444 case 0x4a: 440 case 0x4a:
445 dprintk1("attach_inform: saa7113 detected.\n"); 441 dprintk1(1,"attach_inform: saa7113 detected.\n");
446 break; 442 break;
447 case 0xa0: 443 case 0xa0:
448 dprintk1("attach_inform: eeprom detected.\n"); 444 dprintk1(1,"attach_inform: eeprom detected.\n");
445 break;
446 case 0x60:
447 case 0x8e:
448 {
449 struct IR_i2c *ir = i2c_get_clientdata(client);
450 dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys);
451 em2820_set_ir(dev,ir);
449 break; 452 break;
453 }
450 case 0x80: 454 case 0x80:
451 case 0x88: 455 case 0x88:
452 dprintk1("attach_inform: msp34xx detected.\n"); 456 dprintk1(1,"attach_inform: msp34xx detected.\n");
453 break; 457 break;
454 case 0xb8: 458 case 0xb8:
455 case 0xba: 459 case 0xba:
456 dprintk1("attach_inform: tvp5150 detected.\n"); 460 dprintk1(1,"attach_inform: tvp5150 detected.\n");
457 break; 461 break;
458 default: 462 default:
463 dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1);
459 dev->tuner_addr = client->addr; 464 dev->tuner_addr = client->addr;
460 em2820_set_tuner(-1, client); 465 em2820_set_tuner(-1, client);
461 } 466 }