aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bttv-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/bttv-i2c.c')
-rw-r--r--drivers/media/video/bttv-i2c.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index e684df37eb0e..77619eb131f6 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -5,7 +5,7 @@
5 bttv - Bt848 frame grabber driver 5 bttv - Bt848 frame grabber driver
6 6
7 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 7 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
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 This program is free software; you can redistribute it and/or modify 11 This program is free software; you can redistribute it and/or modify
@@ -237,7 +237,7 @@ bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
237 err: 237 err:
238 if (i2c_debug) 238 if (i2c_debug)
239 printk(" ERR: %d\n",retval); 239 printk(" ERR: %d\n",retval);
240 return retval; 240 return retval;
241} 241}
242 242
243static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) 243static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
@@ -290,7 +290,13 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = {
290 290
291static int attach_inform(struct i2c_client *client) 291static int attach_inform(struct i2c_client *client)
292{ 292{
293 struct bttv *btv = i2c_get_adapdata(client->adapter); 293 struct bttv *btv = i2c_get_adapdata(client->adapter);
294 int addr=ADDR_UNSET;
295
296
297 if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr)
298 addr = bttv_tvcards[btv->c.type].tuner_addr;
299
294 300
295 if (bttv_debug) 301 if (bttv_debug)
296 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n", 302 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
@@ -300,19 +306,20 @@ static int attach_inform(struct i2c_client *client)
300 return 0; 306 return 0;
301 307
302 if (btv->tuner_type != UNSET) { 308 if (btv->tuner_type != UNSET) {
303 struct tuner_setup tun_setup; 309 struct tuner_setup tun_setup;
310
311 if ((addr==ADDR_UNSET) ||
312 (addr==client->addr)) {
304 313
305 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; 314 tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV | T_RADIO;
306 tun_setup.type = btv->tuner_type; 315 tun_setup.type = btv->tuner_type;
307 tun_setup.addr = ADDR_UNSET; 316 tun_setup.addr = addr;
317 bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup);
318 }
308 319
309 client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
310 } 320 }
311 321
312 if (btv->pinnacle_id != UNSET) 322 return 0;
313 client->driver->command(client,AUDC_CONFIG_PINNACLE,
314 &btv->pinnacle_id);
315 return 0;
316} 323}
317 324
318void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg) 325void bttv_call_i2c_clients(struct bttv *btv, unsigned int cmd, void *arg)
@@ -330,43 +337,43 @@ static struct i2c_client bttv_i2c_client_template = {
330/* read I2C */ 337/* read I2C */
331int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) 338int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for)
332{ 339{
333 unsigned char buffer = 0; 340 unsigned char buffer = 0;
334 341
335 if (0 != btv->i2c_rc) 342 if (0 != btv->i2c_rc)
336 return -1; 343 return -1;
337 if (bttv_verbose && NULL != probe_for) 344 if (bttv_verbose && NULL != probe_for)
338 printk(KERN_INFO "bttv%d: i2c: checking for %s @ 0x%02x... ", 345 printk(KERN_INFO "bttv%d: i2c: checking for %s @ 0x%02x... ",
339 btv->c.nr,probe_for,addr); 346 btv->c.nr,probe_for,addr);
340 btv->i2c_client.addr = addr >> 1; 347 btv->i2c_client.addr = addr >> 1;
341 if (1 != i2c_master_recv(&btv->i2c_client, &buffer, 1)) { 348 if (1 != i2c_master_recv(&btv->i2c_client, &buffer, 1)) {
342 if (NULL != probe_for) { 349 if (NULL != probe_for) {
343 if (bttv_verbose) 350 if (bttv_verbose)
344 printk("not found\n"); 351 printk("not found\n");
345 } else 352 } else
346 printk(KERN_WARNING "bttv%d: i2c read 0x%x: error\n", 353 printk(KERN_WARNING "bttv%d: i2c read 0x%x: error\n",
347 btv->c.nr,addr); 354 btv->c.nr,addr);
348 return -1; 355 return -1;
349 } 356 }
350 if (bttv_verbose && NULL != probe_for) 357 if (bttv_verbose && NULL != probe_for)
351 printk("found\n"); 358 printk("found\n");
352 return buffer; 359 return buffer;
353} 360}
354 361
355/* write I2C */ 362/* write I2C */
356int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, 363int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
357 unsigned char b2, int both) 364 unsigned char b2, int both)
358{ 365{
359 unsigned char buffer[2]; 366 unsigned char buffer[2];
360 int bytes = both ? 2 : 1; 367 int bytes = both ? 2 : 1;
361 368
362 if (0 != btv->i2c_rc) 369 if (0 != btv->i2c_rc)
363 return -1; 370 return -1;
364 btv->i2c_client.addr = addr >> 1; 371 btv->i2c_client.addr = addr >> 1;
365 buffer[0] = b1; 372 buffer[0] = b1;
366 buffer[1] = b2; 373 buffer[1] = b2;
367 if (bytes != i2c_master_send(&btv->i2c_client, buffer, bytes)) 374 if (bytes != i2c_master_send(&btv->i2c_client, buffer, bytes))
368 return -1; 375 return -1;
369 return 0; 376 return 0;
370} 377}
371 378
372/* read EEPROM content */ 379/* read EEPROM content */
@@ -431,8 +438,8 @@ int __devinit init_bttv_i2c(struct bttv *btv)
431 "bt%d #%d [%s]", btv->id, btv->c.nr, 438 "bt%d #%d [%s]", btv->id, btv->c.nr,
432 btv->use_i2c_hw ? "hw" : "sw"); 439 btv->use_i2c_hw ? "hw" : "sw");
433 440
434 i2c_set_adapdata(&btv->c.i2c_adap, btv); 441 i2c_set_adapdata(&btv->c.i2c_adap, btv);
435 btv->i2c_client.adapter = &btv->c.i2c_adap; 442 btv->i2c_client.adapter = &btv->c.i2c_adap;
436 443
437#ifdef I2C_CLASS_TV_ANALOG 444#ifdef I2C_CLASS_TV_ANALOG
438 if (bttv_tvcards[btv->c.type].no_video) 445 if (bttv_tvcards[btv->c.type].no_video)