aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-09-14 04:13:54 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:01:32 -0500
commit1cba97d71dca1a3c22b4d7f97893249817036215 (patch)
tree0673ba7cce40953ee97eabb822899f2a5cf0b3d4 /drivers/media
parent1a156045ab06b2cce8cf46e7bf53da26ab33b084 (diff)
V4L/DVB (6471): tuner: i2c_client cannot be part of the tuner struct
The bus-based I2C subsystem allocates the i2c_client struct. So if in order to be able to convert the tuner to the bus-based I2C API the embedded i2c_client struct must be removed from the tuner struct and replaced with a pointer. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tda8290.c22
-rw-r--r--drivers/media/video/tda9887.c22
-rw-r--r--drivers/media/video/tuner-core.c51
-rw-r--r--drivers/media/video/tuner-driver.h14
4 files changed, 59 insertions, 50 deletions
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index ed22be0f5941..c7705cbab2fb 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -608,22 +608,22 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
608 608
609 switch (priv->ver) { 609 switch (priv->ver) {
610 case TDA8290 | TDA8275: 610 case TDA8290 | TDA8275:
611 strlcpy(t->i2c.name, "tda8290+75", sizeof(t->i2c.name)); 611 strlcpy(t->i2c->name, "tda8290+75", sizeof(t->i2c->name));
612 break; 612 break;
613 case TDA8295 | TDA8275: 613 case TDA8295 | TDA8275:
614 strlcpy(t->i2c.name, "tda8295+75", sizeof(t->i2c.name)); 614 strlcpy(t->i2c->name, "tda8295+75", sizeof(t->i2c->name));
615 break; 615 break;
616 case TDA8290 | TDA8275A: 616 case TDA8290 | TDA8275A:
617 strlcpy(t->i2c.name, "tda8290+75a", sizeof(t->i2c.name)); 617 strlcpy(t->i2c->name, "tda8290+75a", sizeof(t->i2c->name));
618 break; 618 break;
619 case TDA8295 | TDA8275A: 619 case TDA8295 | TDA8275A:
620 strlcpy(t->i2c.name, "tda8295+75a", sizeof(t->i2c.name)); 620 strlcpy(t->i2c->name, "tda8295+75a", sizeof(t->i2c->name));
621 break; 621 break;
622 case TDA8290 | TDA18271: 622 case TDA8290 | TDA18271:
623 strlcpy(t->i2c.name, "tda8290+18271", sizeof(t->i2c.name)); 623 strlcpy(t->i2c->name, "tda8290+18271", sizeof(t->i2c->name));
624 break; 624 break;
625 case TDA8295 | TDA18271: 625 case TDA8295 | TDA18271:
626 strlcpy(t->i2c.name, "tda8295+18271", sizeof(t->i2c.name)); 626 strlcpy(t->i2c->name, "tda8295+18271", sizeof(t->i2c->name));
627 break; 627 break;
628 default: 628 default:
629 return -EINVAL; 629 return -EINVAL;
@@ -665,8 +665,8 @@ int tda829x_attach(struct tuner *t)
665 return -ENOMEM; 665 return -ENOMEM;
666 fe->analog_demod_priv = priv; 666 fe->analog_demod_priv = priv;
667 667
668 priv->i2c_props.addr = t->i2c.addr; 668 priv->i2c_props.addr = t->i2c->addr;
669 priv->i2c_props.adap = t->i2c.adapter; 669 priv->i2c_props.adap = t->i2c->adapter;
670 priv->cfg.config = &t->config; 670 priv->cfg.config = &t->config;
671 priv->cfg.tuner_callback = t->tuner_callback; 671 priv->cfg.tuner_callback = t->tuner_callback;
672 priv->t = t; 672 priv->t = t;
@@ -696,7 +696,7 @@ int tda829x_attach(struct tuner *t)
696 } else if (priv->ver & TDA8295) 696 } else if (priv->ver & TDA8295)
697 tda8295_init_if(fe); 697 tda8295_init_if(fe);
698 698
699 tuner_info("type set to %s\n", t->i2c.name); 699 tuner_info("type set to %s\n", t->i2c->name);
700 700
701 t->mode = V4L2_TUNER_ANALOG_TV; 701 t->mode = V4L2_TUNER_ANALOG_TV;
702 702
@@ -707,8 +707,8 @@ EXPORT_SYMBOL_GPL(tda829x_attach);
707int tda8290_probe(struct tuner *t) 707int tda8290_probe(struct tuner *t)
708{ 708{
709 struct tuner_i2c_props i2c_props = { 709 struct tuner_i2c_props i2c_props = {
710 .adap = t->i2c.adapter, 710 .adap = t->i2c->adapter,
711 .addr = t->i2c.addr 711 .addr = t->i2c->addr
712 }; 712 };
713 713
714 unsigned char soft_reset[] = { 0x00, 0x00 }; 714 unsigned char soft_reset[] = { 0x00, 0x00 };
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 080bd308073b..dfa2964d7ef3 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -24,14 +24,14 @@ static int tda9887_debug;
24module_param_named(debug, tda9887_debug, int, 0644); 24module_param_named(debug, tda9887_debug, int, 0644);
25 25
26#define tda9887_info(fmt, arg...) do {\ 26#define tda9887_info(fmt, arg...) do {\
27 printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ 27 printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \
28 i2c_adapter_id(priv->t->i2c.adapter), \ 28 i2c_adapter_id(priv->t->i2c->adapter), \
29 priv->t->i2c.addr, ##arg); } while (0) 29 priv->t->i2c->addr, ##arg); } while (0)
30#define tda9887_dbg(fmt, arg...) do {\ 30#define tda9887_dbg(fmt, arg...) do {\
31 if (tda9887_debug) \ 31 if (tda9887_debug) \
32 printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ 32 printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \
33 i2c_adapter_id(priv->t->i2c.adapter), \ 33 i2c_adapter_id(priv->t->i2c->adapter), \
34 priv->t->i2c.addr, ##arg); } while (0) 34 priv->t->i2c->addr, ##arg); } while (0)
35 35
36struct tda9887_priv { 36struct tda9887_priv {
37 struct tuner_i2c_props i2c_props; 37 struct tuner_i2c_props i2c_props;
@@ -651,14 +651,14 @@ int tda9887_attach(struct tuner *t)
651 return -ENOMEM; 651 return -ENOMEM;
652 t->fe.analog_demod_priv = priv; 652 t->fe.analog_demod_priv = priv;
653 653
654 priv->i2c_props.addr = t->i2c.addr; 654 priv->i2c_props.addr = t->i2c->addr;
655 priv->i2c_props.adap = t->i2c.adapter; 655 priv->i2c_props.adap = t->i2c->adapter;
656 priv->t = t; 656 priv->t = t;
657 657
658 strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); 658 strlcpy(t->i2c->name, "tda9887", sizeof(t->i2c->name));
659 659
660 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, 660 tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c->addr,
661 t->i2c.driver->driver.name); 661 t->i2c->driver->driver.name);
662 662
663 t->fe.ops.analog_demod_ops = &tda9887_tuner_ops; 663 t->fe.ops.analog_demod_ops = &tda9887_tuner_ops;
664 664
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index bff6e6a3e268..41ff4d2604af 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -226,20 +226,20 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
226static void tuner_i2c_address_check(struct tuner *t) 226static void tuner_i2c_address_check(struct tuner *t)
227{ 227{
228 if ((t->type == UNSET || t->type == TUNER_ABSENT) || 228 if ((t->type == UNSET || t->type == TUNER_ABSENT) ||
229 ((t->i2c.addr < 0x64) || (t->i2c.addr > 0x6f))) 229 ((t->i2c->addr < 0x64) || (t->i2c->addr > 0x6f)))
230 return; 230 return;
231 231
232 tuner_warn("====================== WARNING! ======================\n"); 232 tuner_warn("====================== WARNING! ======================\n");
233 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n"); 233 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n");
234 tuner_warn("will soon be dropped. This message indicates that your\n"); 234 tuner_warn("will soon be dropped. This message indicates that your\n");
235 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n", 235 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n",
236 t->i2c.name, t->i2c.addr); 236 t->i2c->name, t->i2c->addr);
237 tuner_warn("To ensure continued support for your device, please\n"); 237 tuner_warn("To ensure continued support for your device, please\n");
238 tuner_warn("send a copy of this message, along with full dmesg\n"); 238 tuner_warn("send a copy of this message, along with full dmesg\n");
239 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); 239 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n");
240 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); 240 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n");
241 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", 241 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n",
242 t->i2c.adapter->name, t->i2c.addr, t->type, 242 t->i2c->adapter->name, t->i2c->addr, t->type,
243 tuners[t->type].name); 243 tuners[t->type].name);
244 tuner_warn("====================== WARNING! ======================\n"); 244 tuner_warn("====================== WARNING! ======================\n");
245} 245}
@@ -250,7 +250,7 @@ static void attach_simple_tuner(struct tuner *t)
250 .type = t->type, 250 .type = t->type,
251 .tun = &tuners[t->type] 251 .tun = &tuners[t->type]
252 }; 252 };
253 simple_tuner_attach(&t->fe, t->i2c.adapter, t->i2c.addr, &cfg); 253 simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
254} 254}
255 255
256static void set_type(struct i2c_client *c, unsigned int type, 256static void set_type(struct i2c_client *c, unsigned int type,
@@ -292,7 +292,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
292 292
293 switch (t->type) { 293 switch (t->type) {
294 case TUNER_MT2032: 294 case TUNER_MT2032:
295 microtune_attach(&t->fe, t->i2c.adapter, t->i2c.addr); 295 microtune_attach(&t->fe, t->i2c->adapter, t->i2c->addr);
296 break; 296 break;
297 case TUNER_PHILIPS_TDA8290: 297 case TUNER_PHILIPS_TDA8290:
298 { 298 {
@@ -300,7 +300,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
300 break; 300 break;
301 } 301 }
302 case TUNER_TEA5767: 302 case TUNER_TEA5767:
303 if (tea5767_attach(&t->fe, t->i2c.adapter, t->i2c.addr) == NULL) { 303 if (tea5767_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) {
304 t->type = TUNER_ABSENT; 304 t->type = TUNER_ABSENT;
305 t->mode_mask = T_UNINITIALIZED; 305 t->mode_mask = T_UNINITIALIZED;
306 return; 306 return;
@@ -308,7 +308,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
308 t->mode_mask = T_RADIO; 308 t->mode_mask = T_RADIO;
309 break; 309 break;
310 case TUNER_TEA5761: 310 case TUNER_TEA5761:
311 if (tea5761_attach(&t->fe, t->i2c.adapter, t->i2c.addr) == NULL) { 311 if (tea5761_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) {
312 t->type = TUNER_ABSENT; 312 t->type = TUNER_ABSENT;
313 t->mode_mask = T_UNINITIALIZED; 313 t->mode_mask = T_UNINITIALIZED;
314 return; 314 return;
@@ -348,13 +348,14 @@ static void set_type(struct i2c_client *c, unsigned int type,
348 if (((NULL == ops) || 348 if (((NULL == ops) ||
349 ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) && 349 ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) &&
350 (fe_tuner_ops->set_analog_params)) { 350 (fe_tuner_ops->set_analog_params)) {
351 strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); 351 strlcpy(t->i2c->name, fe_tuner_ops->info.name,
352 sizeof(t->i2c->name));
352 353
353 t->fe.ops.analog_demod_ops = &tuner_core_ops; 354 t->fe.ops.analog_demod_ops = &tuner_core_ops;
354 t->fe.analog_demod_priv = t; 355 t->fe.analog_demod_priv = t;
355 } 356 }
356 357
357 tuner_info("type set to %s\n", t->i2c.name); 358 tuner_info("type set to %s\n", t->i2c->name);
358 359
359 if (t->mode_mask == T_UNINITIALIZED) 360 if (t->mode_mask == T_UNINITIALIZED)
360 t->mode_mask = new_mode_mask; 361 t->mode_mask = new_mode_mask;
@@ -579,16 +580,23 @@ static unsigned default_mode_mask;
579 */ 580 */
580static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) 581static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
581{ 582{
583 struct i2c_client *client;
582 struct tuner *t; 584 struct tuner *t;
583 585
584 client_template.adapter = adap; 586 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
585 client_template.addr = addr; 587 if (NULL == client)
588 return -ENOMEM;
586 589
587 t = kzalloc(sizeof(struct tuner), GFP_KERNEL); 590 t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
588 if (NULL == t) 591 if (NULL == t) {
592 kfree(client);
589 return -ENOMEM; 593 return -ENOMEM;
590 memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); 594 }
591 i2c_set_clientdata(&t->i2c, t); 595 t->i2c = client;
596 client_template.adapter = adap;
597 client_template.addr = addr;
598 memcpy(client, &client_template, sizeof(struct i2c_client));
599 i2c_set_clientdata(client, t);
592 t->type = UNSET; 600 t->type = UNSET;
593 t->audmode = V4L2_TUNER_MODE_STEREO; 601 t->audmode = V4L2_TUNER_MODE_STEREO;
594 t->mode_mask = T_UNINITIALIZED; 602 t->mode_mask = T_UNINITIALIZED;
@@ -598,7 +606,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
598 int i,rc; 606 int i,rc;
599 607
600 memset(buffer, 0, sizeof(buffer)); 608 memset(buffer, 0, sizeof(buffer));
601 rc = i2c_master_recv(&t->i2c, buffer, sizeof(buffer)); 609 rc = i2c_master_recv(client, buffer, sizeof(buffer));
602 tuner_info("I2C RECV = "); 610 tuner_info("I2C RECV = ");
603 for (i=0;i<rc;i++) 611 for (i=0;i<rc;i++)
604 printk("%02x ",buffer[i]); 612 printk("%02x ",buffer[i]);
@@ -612,7 +620,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
612 if (!no_autodetect) { 620 if (!no_autodetect) {
613 switch (addr) { 621 switch (addr) {
614 case 0x10: 622 case 0x10:
615 if (tea5761_autodetection(t->i2c.adapter, t->i2c.addr) != EINVAL) { 623 if (tea5761_autodetection(t->i2c->adapter, t->i2c->addr) != EINVAL) {
616 t->type = TUNER_TEA5761; 624 t->type = TUNER_TEA5761;
617 t->mode_mask = T_RADIO; 625 t->mode_mask = T_RADIO;
618 t->mode = T_STANDBY; 626 t->mode = T_STANDBY;
@@ -639,7 +647,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
639 } 647 }
640 break; 648 break;
641 case 0x60: 649 case 0x60:
642 if (tea5767_autodetection(t->i2c.adapter, t->i2c.addr) != EINVAL) { 650 if (tea5767_autodetection(t->i2c->adapter, t->i2c->addr) != EINVAL) {
643 t->type = TUNER_TEA5767; 651 t->type = TUNER_TEA5767;
644 t->mode_mask = T_RADIO; 652 t->mode_mask = T_RADIO;
645 t->mode = T_STANDBY; 653 t->mode = T_STANDBY;
@@ -664,8 +672,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
664 /* Should be just before return */ 672 /* Should be just before return */
665register_client: 673register_client:
666 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); 674 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
667 i2c_attach_client (&t->i2c); 675 i2c_attach_client (client);
668 set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback); 676 set_type (client,t->type, t->mode_mask, t->config, t->tuner_callback);
669 return 0; 677 return 0;
670} 678}
671 679
@@ -711,7 +719,7 @@ static int tuner_detach(struct i2c_client *client)
711 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; 719 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
712 int err; 720 int err;
713 721
714 err = i2c_detach_client(&t->i2c); 722 err = i2c_detach_client(t->i2c);
715 if (err) { 723 if (err) {
716 tuner_warn 724 tuner_warn
717 ("Client deregistration failed, client not detached.\n"); 725 ("Client deregistration failed, client not detached.\n");
@@ -722,6 +730,7 @@ static int tuner_detach(struct i2c_client *client)
722 ops->release(&t->fe); 730 ops->release(&t->fe);
723 731
724 kfree(t); 732 kfree(t);
733 kfree(client);
725 return 0; 734 return 0;
726} 735}
727 736
@@ -770,7 +779,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
770 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; 779 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
771 780
772 if (tuner_debug>1) 781 if (tuner_debug>1)
773 v4l_i2c_print_ioctl(&(t->i2c),cmd); 782 v4l_i2c_print_ioctl(client,cmd);
774 783
775 switch (cmd) { 784 switch (cmd) {
776 /* --- configuration --- */ 785 /* --- configuration --- */
diff --git a/drivers/media/video/tuner-driver.h b/drivers/media/video/tuner-driver.h
index 728cacd21682..0df136e58eb3 100644
--- a/drivers/media/video/tuner-driver.h
+++ b/drivers/media/video/tuner-driver.h
@@ -45,7 +45,7 @@ struct analog_tuner_ops {
45 45
46struct tuner { 46struct tuner {
47 /* device */ 47 /* device */
48 struct i2c_client i2c; 48 struct i2c_client *i2c;
49 49
50 unsigned int type; /* chip type */ 50 unsigned int type; /* chip type */
51 51
@@ -71,16 +71,16 @@ struct tuner {
71/* ------------------------------------------------------------------------ */ 71/* ------------------------------------------------------------------------ */
72 72
73#define tuner_warn(fmt, arg...) do {\ 73#define tuner_warn(fmt, arg...) do {\
74 printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 74 printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
75 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 75 i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
76#define tuner_info(fmt, arg...) do {\ 76#define tuner_info(fmt, arg...) do {\
77 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 77 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
78 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 78 i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
79#define tuner_dbg(fmt, arg...) do {\ 79#define tuner_dbg(fmt, arg...) do {\
80 extern int tuner_debug; \ 80 extern int tuner_debug; \
81 if (tuner_debug) \ 81 if (tuner_debug) \
82 printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ 82 printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
83 i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) 83 i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
84 84
85#endif /* __TUNER_DRIVER_H__ */ 85#endif /* __TUNER_DRIVER_H__ */
86 86