diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-14 15:37:13 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-17 23:40:24 -0400 |
commit | 427f7facb374b8651ff01b7700e690ef8ccae159 (patch) | |
tree | a4b33e37d583c49da5e34a67cc5f9df755022a6f /drivers/staging/tm6000/tm6000-i2c.c | |
parent | 77d966a25aa3732d79e740088ff0401ebf26b3c9 (diff) |
V4L/DVB (12852): tm6000: Fix compilation against 2.6.31
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/staging/tm6000/tm6000-i2c.c')
-rw-r--r-- | drivers/staging/tm6000/tm6000-i2c.c | 121 |
1 files changed, 2 insertions, 119 deletions
diff --git a/drivers/staging/tm6000/tm6000-i2c.c b/drivers/staging/tm6000/tm6000-i2c.c index 0df4820481c..e9ad5161756 100644 --- a/drivers/staging/tm6000/tm6000-i2c.c +++ b/drivers/staging/tm6000/tm6000-i2c.c | |||
@@ -36,10 +36,6 @@ | |||
36 | #define I2C_HW_B_TM6000 I2C_HW_B_EM28XX | 36 | #define I2C_HW_B_TM6000 I2C_HW_B_EM28XX |
37 | /* ----------------------------------------------------------- */ | 37 | /* ----------------------------------------------------------- */ |
38 | 38 | ||
39 | static unsigned int i2c_scan = 0; | ||
40 | module_param(i2c_scan, int, 0444); | ||
41 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | ||
42 | |||
43 | static unsigned int i2c_debug = 0; | 39 | static unsigned int i2c_debug = 0; |
44 | module_param(i2c_debug, int, 0644); | 40 | module_param(i2c_debug, int, 0644); |
45 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 41 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
@@ -48,47 +44,6 @@ MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | |||
48 | printk(KERN_DEBUG "%s at %s: " fmt, \ | 44 | printk(KERN_DEBUG "%s at %s: " fmt, \ |
49 | dev->name, __FUNCTION__ , ##args); } while (0) | 45 | dev->name, __FUNCTION__ , ##args); } while (0) |
50 | 46 | ||
51 | |||
52 | /* Returns 0 if address is found */ | ||
53 | static int tm6000_i2c_scan(struct i2c_adapter *i2c_adap, int addr) | ||
54 | { | ||
55 | struct tm6000_core *dev = i2c_adap->algo_data; | ||
56 | |||
57 | #if 1 | ||
58 | /* HACK: i2c scan is not working yet */ | ||
59 | if ( | ||
60 | (dev->caps.has_tuner && (addr==dev->tuner_addr)) || | ||
61 | (dev->caps.has_tda9874 && (addr==0xb0)) || | ||
62 | (dev->caps.has_eeprom && (addr==0xa0)) | ||
63 | ) { | ||
64 | printk("Hack: enabling device at addr 0x%02x\n",addr); | ||
65 | return (1); | ||
66 | } else { | ||
67 | return -ENODEV; | ||
68 | } | ||
69 | #else | ||
70 | int rc=-ENODEV; | ||
71 | char buf[1]; | ||
72 | |||
73 | /* This sends addr + 1 byte with 0 */ | ||
74 | rc = tm6000_read_write_usb (dev, | ||
75 | USB_DIR_IN | USB_TYPE_VENDOR, | ||
76 | REQ_16_SET_GET_I2C_WR1_RDN, | ||
77 | addr, 0, | ||
78 | buf, 0); | ||
79 | msleep(10); | ||
80 | |||
81 | if (rc<0) { | ||
82 | if (i2c_debug>=2) | ||
83 | printk("no device at addr 0x%02x\n",addr); | ||
84 | } | ||
85 | |||
86 | printk("Hack: check on addr 0x%02x returned %d\n",addr,rc); | ||
87 | |||
88 | return rc; | ||
89 | #endif | ||
90 | } | ||
91 | |||
92 | static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, | 47 | static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, |
93 | struct i2c_msg msgs[], int num) | 48 | struct i2c_msg msgs[], int num) |
94 | { | 49 | { |
@@ -102,10 +57,7 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
102 | i2c_dprintk(2,"%s %s addr=0x%x len=%d:", | 57 | i2c_dprintk(2,"%s %s addr=0x%x len=%d:", |
103 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", | 58 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", |
104 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); | 59 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); |
105 | if (!msgs[i].len) { | 60 | if (msgs[i].flags & I2C_M_RD) { |
106 | /* Do I2C scan */ | ||
107 | rc = tm6000_i2c_scan(i2c_adap, addr); | ||
108 | } else if (msgs[i].flags & I2C_M_RD) { | ||
109 | /* read request without preceding register selection */ | 61 | /* read request without preceding register selection */ |
110 | /* | 62 | /* |
111 | * The TM6000 only supports a read transaction | 63 | * The TM6000 only supports a read transaction |
@@ -306,36 +258,6 @@ static int tm6000_tuner_callback(void *ptr, int command, int arg) | |||
306 | return (rc); | 258 | return (rc); |
307 | } | 259 | } |
308 | 260 | ||
309 | static int attach_inform(struct i2c_client *client) | ||
310 | { | ||
311 | struct tm6000_core *dev = client->adapter->algo_data; | ||
312 | struct tuner_setup tun_setup; | ||
313 | |||
314 | i2c_dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", | ||
315 | client->driver->driver.name, client->addr, client->name); | ||
316 | |||
317 | switch (client->addr<<1) { | ||
318 | case 0xb0: | ||
319 | request_module("tvaudio"); | ||
320 | return 0; | ||
321 | } | ||
322 | |||
323 | /* If tuner, initialize the tuner part */ | ||
324 | if ( dev->tuner_addr != client->addr<<1 ) { | ||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | memset (&tun_setup, 0, sizeof(tun_setup)); | ||
329 | |||
330 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | ||
331 | tun_setup.type = dev->tuner_type; | ||
332 | tun_setup.addr = dev->tuner_addr>>1; | ||
333 | tun_setup.tuner_callback = tm6000_tuner_callback; | ||
334 | |||
335 | client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup); | ||
336 | |||
337 | return 0; | ||
338 | } | ||
339 | 261 | ||
340 | static struct i2c_algorithm tm6000_algo = { | 262 | static struct i2c_algorithm tm6000_algo = { |
341 | .master_xfer = tm6000_i2c_xfer, | 263 | .master_xfer = tm6000_i2c_xfer, |
@@ -353,7 +275,6 @@ static struct i2c_adapter tm6000_adap_template = { | |||
353 | .name = "tm6000", | 275 | .name = "tm6000", |
354 | .id = I2C_HW_B_TM6000, | 276 | .id = I2C_HW_B_TM6000, |
355 | .algo = &tm6000_algo, | 277 | .algo = &tm6000_algo, |
356 | .client_register = attach_inform, | ||
357 | }; | 278 | }; |
358 | 279 | ||
359 | static struct i2c_client tm6000_client_template = { | 280 | static struct i2c_client tm6000_client_template = { |
@@ -363,43 +284,6 @@ static struct i2c_client tm6000_client_template = { | |||
363 | /* ----------------------------------------------------------- */ | 284 | /* ----------------------------------------------------------- */ |
364 | 285 | ||
365 | /* | 286 | /* |
366 | * i2c_devs | ||
367 | * incomplete list of known devices | ||
368 | */ | ||
369 | static char *i2c_devs[128] = { | ||
370 | [0xc2 >> 1] = "tuner (analog)", | ||
371 | }; | ||
372 | |||
373 | /* | ||
374 | * do_i2c_scan() | ||
375 | * check i2c address range for devices | ||
376 | */ | ||
377 | static void do_i2c_scan(char *name, struct i2c_client *c) | ||
378 | { | ||
379 | unsigned char buf; | ||
380 | int i, rc; | ||
381 | |||
382 | for (i = 0; i < 128; i++) { | ||
383 | c->addr = i; | ||
384 | rc = i2c_master_recv(c, &buf, 0); | ||
385 | if (rc < 0) | ||
386 | continue; | ||
387 | printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n", name, | ||
388 | i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | /* | ||
393 | * tm6000_i2c_call_clients() | ||
394 | * send commands to all attached i2c devices | ||
395 | */ | ||
396 | void tm6000_i2c_call_clients(struct tm6000_core *dev, unsigned int cmd, void *arg) | ||
397 | { | ||
398 | BUG_ON(NULL == dev->i2c_adap.algo_data); | ||
399 | i2c_clients_command(&dev->i2c_adap, cmd, arg); | ||
400 | } | ||
401 | |||
402 | /* | ||
403 | * tm6000_i2c_register() | 287 | * tm6000_i2c_register() |
404 | * register i2c bus | 288 | * register i2c bus |
405 | */ | 289 | */ |
@@ -416,8 +300,7 @@ int tm6000_i2c_register(struct tm6000_core *dev) | |||
416 | dev->i2c_client = tm6000_client_template; | 300 | dev->i2c_client = tm6000_client_template; |
417 | dev->i2c_client.adapter = &dev->i2c_adap; | 301 | dev->i2c_client.adapter = &dev->i2c_adap; |
418 | 302 | ||
419 | if (i2c_scan) | 303 | i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); |
420 | do_i2c_scan(dev->name, &dev->i2c_client); | ||
421 | 304 | ||
422 | tm6000_i2c_eeprom(dev, eedata, sizeof(eedata)); | 305 | tm6000_i2c_eeprom(dev, eedata, sizeof(eedata)); |
423 | 306 | ||