aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schwarzott <zzam@gentoo.org>2014-10-02 01:20:59 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-10-30 15:18:22 -0400
commitc3c3f1ae8bab74c99fa211c76b035a41523e83dd (patch)
tree3acfa168d161401c8004de2767fa52711380c1f9
parentd032ca1283b68446df0adbec4561463b3f0aa147 (diff)
[media] cx231xx: add wrapper to get the i2c_adapter pointer
This is a preparation for mapping I2C_1_MUX_1 and I2C_1_MUX_3 later to the seperate muxed i2c adapters. Map mux adapters to I2C_1 for now. Add local variables for i2c_adapters in dvb_init to get line lengths shorter. Signed-off-by: Matthias Schwarzott <zzam@gentoo.org> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c8
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-dvb.c42
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-i2c.c20
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-input.c3
-rw-r--r--drivers/media/usb/cx231xx/cx231xx.h1
5 files changed, 50 insertions, 24 deletions
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 2f027c70f786..f5fb93a79a9f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1033,7 +1033,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
1033 /* request some modules */ 1033 /* request some modules */
1034 if (dev->board.decoder == CX231XX_AVDECODER) { 1034 if (dev->board.decoder == CX231XX_AVDECODER) {
1035 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1035 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1036 &dev->i2c_bus[I2C_0].i2c_adap, 1036 cx231xx_get_i2c_adap(dev, I2C_0),
1037 "cx25840", 0x88 >> 1, NULL); 1037 "cx25840", 0x88 >> 1, NULL);
1038 if (dev->sd_cx25840 == NULL) 1038 if (dev->sd_cx25840 == NULL)
1039 cx231xx_info("cx25840 subdev registration failure\n"); 1039 cx231xx_info("cx25840 subdev registration failure\n");
@@ -1043,8 +1043,10 @@ void cx231xx_card_setup(struct cx231xx *dev)
1043 1043
1044 /* Initialize the tuner */ 1044 /* Initialize the tuner */
1045 if (dev->board.tuner_type != TUNER_ABSENT) { 1045 if (dev->board.tuner_type != TUNER_ABSENT) {
1046 struct i2c_adapter *tuner_i2c = cx231xx_get_i2c_adap(dev,
1047 dev->board.tuner_i2c_master);
1046 dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, 1048 dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1047 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 1049 tuner_i2c,
1048 "tuner", 1050 "tuner",
1049 dev->tuner_addr, NULL); 1051 dev->tuner_addr, NULL);
1050 if (dev->sd_tuner == NULL) 1052 if (dev->sd_tuner == NULL)
@@ -1062,7 +1064,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
1062 struct i2c_client client; 1064 struct i2c_client client;
1063 1065
1064 memset(&client, 0, sizeof(client)); 1066 memset(&client, 0, sizeof(client));
1065 client.adapter = &dev->i2c_bus[I2C_1].i2c_adap; 1067 client.adapter = cx231xx_get_i2c_adap(dev, I2C_1);
1066 client.addr = 0xa0 >> 1; 1068 client.addr = 0xa0 >> 1;
1067 1069
1068 read_eeprom(dev, &client, eeprom, sizeof(eeprom)); 1070 read_eeprom(dev, &client, eeprom, sizeof(eeprom));
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 6c7b5e250eed..869c433fbbbf 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -378,7 +378,7 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
378 struct xc5000_config cfg; 378 struct xc5000_config cfg;
379 379
380 memset(&cfg, 0, sizeof(cfg)); 380 memset(&cfg, 0, sizeof(cfg));
381 cfg.i2c_adap = &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap; 381 cfg.i2c_adap = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
382 cfg.i2c_addr = addr; 382 cfg.i2c_addr = addr;
383 383
384 if (!dev->dvb->frontend) { 384 if (!dev->dvb->frontend) {
@@ -583,6 +583,8 @@ static int dvb_init(struct cx231xx *dev)
583{ 583{
584 int result = 0; 584 int result = 0;
585 struct cx231xx_dvb *dvb; 585 struct cx231xx_dvb *dvb;
586 struct i2c_adapter *tuner_i2c;
587 struct i2c_adapter *demod_i2c;
586 588
587 if (!dev->board.has_dvb) { 589 if (!dev->board.has_dvb) {
588 /* This device does not support the extension */ 590 /* This device does not support the extension */
@@ -599,6 +601,8 @@ static int dvb_init(struct cx231xx *dev)
599 dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; 601 dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq;
600 dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; 602 dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner;
601 603
604 tuner_i2c = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
605 demod_i2c = cx231xx_get_i2c_adap(dev, dev->board.demod_i2c_master);
602 mutex_lock(&dev->lock); 606 mutex_lock(&dev->lock);
603 cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); 607 cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
604 cx231xx_demod_reset(dev); 608 cx231xx_demod_reset(dev);
@@ -609,7 +613,7 @@ static int dvb_init(struct cx231xx *dev)
609 613
610 dev->dvb->frontend = dvb_attach(s5h1432_attach, 614 dev->dvb->frontend = dvb_attach(s5h1432_attach,
611 &dvico_s5h1432_config, 615 &dvico_s5h1432_config,
612 &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); 616 demod_i2c);
613 617
614 if (dev->dvb->frontend == NULL) { 618 if (dev->dvb->frontend == NULL) {
615 printk(DRIVER_NAME 619 printk(DRIVER_NAME
@@ -622,7 +626,7 @@ static int dvb_init(struct cx231xx *dev)
622 dvb->frontend->callback = cx231xx_tuner_callback; 626 dvb->frontend->callback = cx231xx_tuner_callback;
623 627
624 if (!dvb_attach(xc5000_attach, dev->dvb->frontend, 628 if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
625 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 629 tuner_i2c,
626 &cnxt_rde250_tunerconfig)) { 630 &cnxt_rde250_tunerconfig)) {
627 result = -EINVAL; 631 result = -EINVAL;
628 goto out_free; 632 goto out_free;
@@ -634,7 +638,7 @@ static int dvb_init(struct cx231xx *dev)
634 638
635 dev->dvb->frontend = dvb_attach(s5h1411_attach, 639 dev->dvb->frontend = dvb_attach(s5h1411_attach,
636 &xc5000_s5h1411_config, 640 &xc5000_s5h1411_config,
637 &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); 641 demod_i2c);
638 642
639 if (dev->dvb->frontend == NULL) { 643 if (dev->dvb->frontend == NULL) {
640 printk(DRIVER_NAME 644 printk(DRIVER_NAME
@@ -647,7 +651,7 @@ static int dvb_init(struct cx231xx *dev)
647 dvb->frontend->callback = cx231xx_tuner_callback; 651 dvb->frontend->callback = cx231xx_tuner_callback;
648 652
649 if (!dvb_attach(xc5000_attach, dev->dvb->frontend, 653 if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
650 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 654 tuner_i2c,
651 &cnxt_rdu250_tunerconfig)) { 655 &cnxt_rdu250_tunerconfig)) {
652 result = -EINVAL; 656 result = -EINVAL;
653 goto out_free; 657 goto out_free;
@@ -657,7 +661,7 @@ static int dvb_init(struct cx231xx *dev)
657 661
658 dev->dvb->frontend = dvb_attach(s5h1432_attach, 662 dev->dvb->frontend = dvb_attach(s5h1432_attach,
659 &dvico_s5h1432_config, 663 &dvico_s5h1432_config,
660 &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); 664 demod_i2c);
661 665
662 if (dev->dvb->frontend == NULL) { 666 if (dev->dvb->frontend == NULL) {
663 printk(DRIVER_NAME 667 printk(DRIVER_NAME
@@ -670,7 +674,7 @@ static int dvb_init(struct cx231xx *dev)
670 dvb->frontend->callback = cx231xx_tuner_callback; 674 dvb->frontend->callback = cx231xx_tuner_callback;
671 675
672 if (!dvb_attach(tda18271_attach, dev->dvb->frontend, 676 if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
673 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 677 0x60, tuner_i2c,
674 &cnxt_rde253s_tunerconfig)) { 678 &cnxt_rde253s_tunerconfig)) {
675 result = -EINVAL; 679 result = -EINVAL;
676 goto out_free; 680 goto out_free;
@@ -681,7 +685,7 @@ static int dvb_init(struct cx231xx *dev)
681 685
682 dev->dvb->frontend = dvb_attach(s5h1411_attach, 686 dev->dvb->frontend = dvb_attach(s5h1411_attach,
683 &tda18271_s5h1411_config, 687 &tda18271_s5h1411_config,
684 &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); 688 demod_i2c);
685 689
686 if (dev->dvb->frontend == NULL) { 690 if (dev->dvb->frontend == NULL) {
687 printk(DRIVER_NAME 691 printk(DRIVER_NAME
@@ -694,7 +698,7 @@ static int dvb_init(struct cx231xx *dev)
694 dvb->frontend->callback = cx231xx_tuner_callback; 698 dvb->frontend->callback = cx231xx_tuner_callback;
695 699
696 if (!dvb_attach(tda18271_attach, dev->dvb->frontend, 700 if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
697 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 701 0x60, tuner_i2c,
698 &cnxt_rde253s_tunerconfig)) { 702 &cnxt_rde253s_tunerconfig)) {
699 result = -EINVAL; 703 result = -EINVAL;
700 goto out_free; 704 goto out_free;
@@ -703,11 +707,11 @@ static int dvb_init(struct cx231xx *dev)
703 case CX231XX_BOARD_HAUPPAUGE_EXETER: 707 case CX231XX_BOARD_HAUPPAUGE_EXETER:
704 708
705 printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n", 709 printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n",
706 __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); 710 __func__, i2c_adapter_id(tuner_i2c));
707 711
708 dev->dvb->frontend = dvb_attach(lgdt3305_attach, 712 dev->dvb->frontend = dvb_attach(lgdt3305_attach,
709 &hcw_lgdt3305_config, 713 &hcw_lgdt3305_config,
710 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap); 714 tuner_i2c);
711 715
712 if (dev->dvb->frontend == NULL) { 716 if (dev->dvb->frontend == NULL) {
713 printk(DRIVER_NAME 717 printk(DRIVER_NAME
@@ -720,7 +724,7 @@ static int dvb_init(struct cx231xx *dev)
720 dvb->frontend->callback = cx231xx_tuner_callback; 724 dvb->frontend->callback = cx231xx_tuner_callback;
721 725
722 dvb_attach(tda18271_attach, dev->dvb->frontend, 726 dvb_attach(tda18271_attach, dev->dvb->frontend,
723 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 727 0x60, tuner_i2c,
724 &hcw_tda18271_config); 728 &hcw_tda18271_config);
725 break; 729 break;
726 730
@@ -728,7 +732,7 @@ static int dvb_init(struct cx231xx *dev)
728 732
729 dev->dvb->frontend = dvb_attach(si2165_attach, 733 dev->dvb->frontend = dvb_attach(si2165_attach,
730 &hauppauge_930C_HD_1113xx_si2165_config, 734 &hauppauge_930C_HD_1113xx_si2165_config,
731 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap 735 tuner_i2c
732 ); 736 );
733 737
734 if (dev->dvb->frontend == NULL) { 738 if (dev->dvb->frontend == NULL) {
@@ -745,7 +749,7 @@ static int dvb_init(struct cx231xx *dev)
745 749
746 dvb_attach(tda18271_attach, dev->dvb->frontend, 750 dvb_attach(tda18271_attach, dev->dvb->frontend,
747 0x60, 751 0x60,
748 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 752 tuner_i2c,
749 &hcw_tda18271_config); 753 &hcw_tda18271_config);
750 754
751 dev->cx231xx_reset_analog_tuner = NULL; 755 dev->cx231xx_reset_analog_tuner = NULL;
@@ -761,7 +765,7 @@ static int dvb_init(struct cx231xx *dev)
761 765
762 dev->dvb->frontend = dvb_attach(si2165_attach, 766 dev->dvb->frontend = dvb_attach(si2165_attach,
763 &pctv_quatro_stick_1114xx_si2165_config, 767 &pctv_quatro_stick_1114xx_si2165_config,
764 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap 768 tuner_i2c
765 ); 769 );
766 770
767 if (dev->dvb->frontend == NULL) { 771 if (dev->dvb->frontend == NULL) {
@@ -786,7 +790,7 @@ static int dvb_init(struct cx231xx *dev)
786 request_module("si2157"); 790 request_module("si2157");
787 791
788 client = i2c_new_device( 792 client = i2c_new_device(
789 &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 793 tuner_i2c,
790 &info); 794 &info);
791 if (client == NULL || client->dev.driver == NULL) { 795 if (client == NULL || client->dev.driver == NULL) {
792 dvb_frontend_detach(dev->dvb->frontend); 796 dvb_frontend_detach(dev->dvb->frontend);
@@ -811,11 +815,11 @@ static int dvb_init(struct cx231xx *dev)
811 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID: 815 case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID:
812 816
813 printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n", 817 printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n",
814 __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); 818 __func__, i2c_adapter_id(tuner_i2c));
815 819
816 dev->dvb->frontend = dvb_attach(mb86a20s_attach, 820 dev->dvb->frontend = dvb_attach(mb86a20s_attach,
817 &pv_mb86a20s_config, 821 &pv_mb86a20s_config,
818 &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); 822 demod_i2c);
819 823
820 if (dev->dvb->frontend == NULL) { 824 if (dev->dvb->frontend == NULL) {
821 printk(DRIVER_NAME 825 printk(DRIVER_NAME
@@ -828,7 +832,7 @@ static int dvb_init(struct cx231xx *dev)
828 dvb->frontend->callback = cx231xx_tuner_callback; 832 dvb->frontend->callback = cx231xx_tuner_callback;
829 833
830 dvb_attach(tda18271_attach, dev->dvb->frontend, 834 dvb_attach(tda18271_attach, dev->dvb->frontend,
831 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, 835 0x60, tuner_i2c,
832 &pv_tda18271_config); 836 &pv_tda18271_config);
833 break; 837 break;
834 838
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 45057167227c..af9180f3bf30 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -483,7 +483,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
483 struct i2c_client client; 483 struct i2c_client client;
484 484
485 memset(&client, 0, sizeof(client)); 485 memset(&client, 0, sizeof(client));
486 client.adapter = &dev->i2c_bus[i2c_port].i2c_adap; 486 client.adapter = cx231xx_get_i2c_adap(dev, i2c_port);
487 487
488 cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port); 488 cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port);
489 for (i = 0; i < 128; i++) { 489 for (i = 0; i < 128; i++) {
@@ -537,3 +537,21 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
537 i2c_del_adapter(&bus->i2c_adap); 537 i2c_del_adapter(&bus->i2c_adap);
538 return 0; 538 return 0;
539} 539}
540
541struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
542{
543 switch (i2c_port) {
544 case I2C_0:
545 return &dev->i2c_bus[0].i2c_adap;
546 case I2C_1:
547 return &dev->i2c_bus[1].i2c_adap;
548 case I2C_2:
549 return &dev->i2c_bus[2].i2c_adap;
550 case I2C_1_MUX_1:
551 case I2C_1_MUX_3:
552 return &dev->i2c_bus[1].i2c_adap;
553 default:
554 return NULL;
555 }
556}
557EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap);
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index 05f0434919d4..5ae2ce3f51b1 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -100,7 +100,8 @@ int cx231xx_ir_init(struct cx231xx *dev)
100 ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master; 100 ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
101 dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n", 101 dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
102 ir_i2c_bus, info.addr); 102 ir_i2c_bus, info.addr);
103 dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info); 103 dev->ir_i2c_client = i2c_new_device(
104 cx231xx_get_i2c_adap(dev, ir_i2c_bus), &info);
104 105
105 return 0; 106 return 0;
106} 107}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 377216ba5e93..f03338bdb949 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -754,6 +754,7 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
754void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port); 754void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
755int cx231xx_i2c_register(struct cx231xx_i2c *bus); 755int cx231xx_i2c_register(struct cx231xx_i2c *bus);
756int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); 756int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
757struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port);
757 758
758/* Internal block control functions */ 759/* Internal block control functions */
759int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, 760int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr,