aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx23885/cx23885-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/cx23885/cx23885-dvb.c')
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c691
1 files changed, 538 insertions, 153 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 4cb90317ff45..c47d18270cfc 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
71#include "si2165.h" 71#include "si2165.h"
72#include "si2168.h" 72#include "si2168.h"
73#include "si2157.h" 73#include "si2157.h"
74#include "sp2.h"
74#include "m88ds3103.h" 75#include "m88ds3103.h"
75#include "m88ts2022.h" 76#include "m88ts2022.h"
76 77
@@ -101,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
101 port->ts_packet_count = 32; 102 port->ts_packet_count = 32;
102 *num_planes = 1; 103 *num_planes = 1;
103 sizes[0] = port->ts_packet_size * port->ts_packet_count; 104 sizes[0] = port->ts_packet_size * port->ts_packet_count;
105 alloc_ctxs[0] = port->dev->alloc_ctx;
104 *num_buffers = 32; 106 *num_buffers = 32;
105 return 0; 107 return 0;
106} 108}
@@ -121,11 +123,8 @@ static void buffer_finish(struct vb2_buffer *vb)
121 struct cx23885_dev *dev = port->dev; 123 struct cx23885_dev *dev = port->dev;
122 struct cx23885_buffer *buf = container_of(vb, 124 struct cx23885_buffer *buf = container_of(vb,
123 struct cx23885_buffer, vb); 125 struct cx23885_buffer, vb);
124 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
125 126
126 cx23885_free_buffer(dev, buf); 127 cx23885_free_buffer(dev, buf);
127
128 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
129} 128}
130 129
131static void buffer_queue(struct vb2_buffer *vb) 130static void buffer_queue(struct vb2_buffer *vb)
@@ -616,6 +615,103 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
616 return 0; 615 return 0;
617} 616}
618 617
618static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
619 fe_sec_voltage_t voltage)
620{
621 struct cx23885_tsport *port = fe->dvb->priv;
622 struct cx23885_dev *dev = port->dev;
623
624 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
625
626 switch (voltage) {
627 case SEC_VOLTAGE_13:
628 cx23885_gpio_set(dev, GPIO_13);
629 cx23885_gpio_clear(dev, GPIO_12);
630 break;
631 case SEC_VOLTAGE_18:
632 cx23885_gpio_set(dev, GPIO_13);
633 cx23885_gpio_set(dev, GPIO_12);
634 break;
635 case SEC_VOLTAGE_OFF:
636 cx23885_gpio_clear(dev, GPIO_13);
637 cx23885_gpio_clear(dev, GPIO_12);
638 break;
639 }
640 /* call the frontend set_voltage function */
641 return port->fe_set_voltage(fe, voltage);
642}
643
644static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
645 u8 data, int *mem)
646{
647 /* MC417 */
648 #define SP2_DATA 0x000000ff
649 #define SP2_WR 0x00008000
650 #define SP2_RD 0x00004000
651 #define SP2_ACK 0x00001000
652 #define SP2_ADHI 0x00000800
653 #define SP2_ADLO 0x00000400
654 #define SP2_CS1 0x00000200
655 #define SP2_CS0 0x00000100
656 #define SP2_EN_ALL 0x00001000
657 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
658
659 struct cx23885_tsport *port = priv;
660 struct cx23885_dev *dev = port->dev;
661 int ret;
662 int tmp = 0;
663 unsigned long timeout;
664
665 mutex_lock(&dev->gpio_lock);
666
667 /* write addr */
668 cx_write(MC417_OEN, SP2_EN_ALL);
669 cx_write(MC417_RWD, SP2_CTRL_OFF |
670 SP2_ADLO | (0xff & addr));
671 cx_clear(MC417_RWD, SP2_ADLO);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADHI | (0xff & (addr >> 8)));
674 cx_clear(MC417_RWD, SP2_ADHI);
675
676 if (read)
677 /* data in */
678 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
679 else
680 /* data out */
681 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
682
683 /* chip select 0 */
684 cx_clear(MC417_RWD, SP2_CS0);
685
686 /* read/write */
687 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
688
689 /* wait for a maximum of 1 msec */
690 timeout = jiffies + msecs_to_jiffies(1);
691 while (!time_after(jiffies, timeout)) {
692 tmp = cx_read(MC417_RWD);
693 if ((tmp & SP2_ACK) == 0)
694 break;
695 usleep_range(50, 100);
696 }
697
698 cx_set(MC417_RWD, SP2_CTRL_OFF);
699 *mem = tmp & 0xff;
700
701 mutex_unlock(&dev->gpio_lock);
702
703 if (!read) {
704 if (*mem < 0) {
705 ret = -EREMOTEIO;
706 goto err;
707 }
708 }
709
710 return 0;
711err:
712 return ret;
713}
714
619static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) 715static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
620{ 716{
621 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 717 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -793,6 +889,32 @@ static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
793 .agc = 0x99, 889 .agc = 0x99,
794}; 890};
795 891
892static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
893 .i2c_addr = 0x68,
894 .clock = 27000000,
895 .i2c_wr_max = 33,
896 .clock_out = 0,
897 .ts_mode = M88DS3103_TS_CI,
898 .ts_clk = 10000,
899 .ts_clk_pol = 1,
900 .lnb_en_pol = 1,
901 .lnb_hv_pol = 0,
902 .agc = 0x99,
903};
904
905static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
906 .i2c_addr = 0x68,
907 .clock = 27000000,
908 .i2c_wr_max = 33,
909 .clock_out = 0,
910 .ts_mode = M88DS3103_TS_SERIAL,
911 .ts_clk = 96000,
912 .ts_clk_pol = 0,
913 .lnb_en_pol = 1,
914 .lnb_hv_pol = 0,
915 .agc = 0x99,
916};
917
796static int netup_altera_fpga_rw(void *device, int flag, int data, int read) 918static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
797{ 919{
798 struct cx23885_dev *dev = (struct cx23885_dev *)device; 920 struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -944,11 +1066,13 @@ static int dvb_register(struct cx23885_tsport *port)
944 struct vb2_dvb_frontend *fe0, *fe1 = NULL; 1066 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
945 struct si2168_config si2168_config; 1067 struct si2168_config si2168_config;
946 struct si2157_config si2157_config; 1068 struct si2157_config si2157_config;
1069 struct sp2_config sp2_config;
947 struct m88ts2022_config m88ts2022_config; 1070 struct m88ts2022_config m88ts2022_config;
948 struct i2c_board_info info; 1071 struct i2c_board_info info;
949 struct i2c_adapter *adapter; 1072 struct i2c_adapter *adapter;
950 struct i2c_client *client_demod; 1073 struct i2c_client *client_demod = NULL, *client_tuner = NULL, *client_ci = NULL;
951 struct i2c_client *client_tuner; 1074 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1075 int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage) = NULL;
952 int mfe_shared = 0; /* bus not shared by default */ 1076 int mfe_shared = 0; /* bus not shared by default */
953 int ret; 1077 int ret;
954 1078
@@ -973,11 +1097,11 @@ static int dvb_register(struct cx23885_tsport *port)
973 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1097 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
974 &hauppauge_generic_config, 1098 &hauppauge_generic_config,
975 &i2c_bus->i2c_adap); 1099 &i2c_bus->i2c_adap);
976 if (fe0->dvb.frontend != NULL) { 1100 if (fe0->dvb.frontend == NULL)
977 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1101 break;
978 &i2c_bus->i2c_adap, 1102 dvb_attach(mt2131_attach, fe0->dvb.frontend,
979 &hauppauge_generic_tunerconfig, 0); 1103 &i2c_bus->i2c_adap,
980 } 1104 &hauppauge_generic_tunerconfig, 0);
981 break; 1105 break;
982 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1106 case CX23885_BOARD_HAUPPAUGE_HVR1270:
983 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1107 case CX23885_BOARD_HAUPPAUGE_HVR1275:
@@ -985,11 +1109,11 @@ static int dvb_register(struct cx23885_tsport *port)
985 fe0->dvb.frontend = dvb_attach(lgdt3305_attach, 1109 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
986 &hauppauge_lgdt3305_config, 1110 &hauppauge_lgdt3305_config,
987 &i2c_bus->i2c_adap); 1111 &i2c_bus->i2c_adap);
988 if (fe0->dvb.frontend != NULL) { 1112 if (fe0->dvb.frontend == NULL)
989 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1113 break;
990 0x60, &dev->i2c_bus[1].i2c_adap, 1114 dvb_attach(tda18271_attach, fe0->dvb.frontend,
991 &hauppauge_hvr127x_config); 1115 0x60, &dev->i2c_bus[1].i2c_adap,
992 } 1116 &hauppauge_hvr127x_config);
993 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) 1117 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
994 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1118 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
995 break; 1119 break;
@@ -999,11 +1123,12 @@ static int dvb_register(struct cx23885_tsport *port)
999 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1123 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1000 &hcw_s5h1411_config, 1124 &hcw_s5h1411_config,
1001 &i2c_bus->i2c_adap); 1125 &i2c_bus->i2c_adap);
1002 if (fe0->dvb.frontend != NULL) { 1126 if (fe0->dvb.frontend == NULL)
1003 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1127 break;
1004 0x60, &dev->i2c_bus[1].i2c_adap, 1128
1005 &hauppauge_tda18271_config); 1129 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1006 } 1130 0x60, &dev->i2c_bus[1].i2c_adap,
1131 &hauppauge_tda18271_config);
1007 1132
1008 tda18271_attach(&dev->ts1.analog_fe, 1133 tda18271_attach(&dev->ts1.analog_fe,
1009 0x60, &dev->i2c_bus[1].i2c_adap, 1134 0x60, &dev->i2c_bus[1].i2c_adap,
@@ -1018,14 +1143,15 @@ static int dvb_register(struct cx23885_tsport *port)
1018 dvb_attach(s5h1409_attach, 1143 dvb_attach(s5h1409_attach,
1019 &hauppauge_ezqam_config, 1144 &hauppauge_ezqam_config,
1020 &i2c_bus->i2c_adap); 1145 &i2c_bus->i2c_adap);
1021 if (fe0->dvb.frontend != NULL) { 1146 if (fe0->dvb.frontend == NULL)
1022 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1147 break;
1023 &dev->i2c_bus[1].i2c_adap, 0x42, 1148
1024 &tda829x_no_probe); 1149 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1025 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1150 &dev->i2c_bus[1].i2c_adap, 0x42,
1026 0x60, &dev->i2c_bus[1].i2c_adap, 1151 &tda829x_no_probe);
1027 &hauppauge_tda18271_config); 1152 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1028 } 1153 0x60, &dev->i2c_bus[1].i2c_adap,
1154 &hauppauge_tda18271_config);
1029 break; 1155 break;
1030 case 0: 1156 case 0:
1031 default: 1157 default:
@@ -1033,11 +1159,11 @@ static int dvb_register(struct cx23885_tsport *port)
1033 dvb_attach(s5h1409_attach, 1159 dvb_attach(s5h1409_attach,
1034 &hauppauge_generic_config, 1160 &hauppauge_generic_config,
1035 &i2c_bus->i2c_adap); 1161 &i2c_bus->i2c_adap);
1036 if (fe0->dvb.frontend != NULL) 1162 if (fe0->dvb.frontend == NULL)
1037 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1163 break;
1038 &i2c_bus->i2c_adap, 1164 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1039 &hauppauge_generic_tunerconfig, 0); 1165 &i2c_bus->i2c_adap,
1040 break; 1166 &hauppauge_generic_tunerconfig, 0);
1041 } 1167 }
1042 break; 1168 break;
1043 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 1169 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
@@ -1045,32 +1171,33 @@ static int dvb_register(struct cx23885_tsport *port)
1045 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1171 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1046 &hauppauge_hvr1800lp_config, 1172 &hauppauge_hvr1800lp_config,
1047 &i2c_bus->i2c_adap); 1173 &i2c_bus->i2c_adap);
1048 if (fe0->dvb.frontend != NULL) { 1174 if (fe0->dvb.frontend == NULL)
1049 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1175 break;
1050 &i2c_bus->i2c_adap, 1176 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1051 &hauppauge_generic_tunerconfig, 0); 1177 &i2c_bus->i2c_adap,
1052 } 1178 &hauppauge_generic_tunerconfig, 0);
1053 break; 1179 break;
1054 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 1180 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
1055 i2c_bus = &dev->i2c_bus[0]; 1181 i2c_bus = &dev->i2c_bus[0];
1056 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1182 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1057 &fusionhdtv_5_express, 1183 &fusionhdtv_5_express,
1058 &i2c_bus->i2c_adap); 1184 &i2c_bus->i2c_adap);
1059 if (fe0->dvb.frontend != NULL) { 1185 if (fe0->dvb.frontend == NULL)
1060 dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1186 break;
1061 &i2c_bus->i2c_adap, 0x61, 1187 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1062 TUNER_LG_TDVS_H06XF); 1188 &i2c_bus->i2c_adap, 0x61,
1063 } 1189 TUNER_LG_TDVS_H06XF);
1064 break; 1190 break;
1065 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 1191 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1066 i2c_bus = &dev->i2c_bus[1]; 1192 i2c_bus = &dev->i2c_bus[1];
1067 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1193 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1068 &hauppauge_hvr1500q_config, 1194 &hauppauge_hvr1500q_config,
1069 &dev->i2c_bus[0].i2c_adap); 1195 &dev->i2c_bus[0].i2c_adap);
1070 if (fe0->dvb.frontend != NULL) 1196 if (fe0->dvb.frontend == NULL)
1071 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1197 break;
1072 &i2c_bus->i2c_adap, 1198 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1073 &hauppauge_hvr1500q_tunerconfig); 1199 &i2c_bus->i2c_adap,
1200 &hauppauge_hvr1500q_tunerconfig);
1074 break; 1201 break;
1075 case CX23885_BOARD_HAUPPAUGE_HVR1500: 1202 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1076 i2c_bus = &dev->i2c_bus[1]; 1203 i2c_bus = &dev->i2c_bus[1];
@@ -1101,14 +1228,14 @@ static int dvb_register(struct cx23885_tsport *port)
1101 fe0->dvb.frontend = dvb_attach(tda10048_attach, 1228 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1102 &hauppauge_hvr1200_config, 1229 &hauppauge_hvr1200_config,
1103 &i2c_bus->i2c_adap); 1230 &i2c_bus->i2c_adap);
1104 if (fe0->dvb.frontend != NULL) { 1231 if (fe0->dvb.frontend == NULL)
1105 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1232 break;
1106 &dev->i2c_bus[1].i2c_adap, 0x42, 1233 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1107 &tda829x_no_probe); 1234 &dev->i2c_bus[1].i2c_adap, 0x42,
1108 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1235 &tda829x_no_probe);
1109 0x60, &dev->i2c_bus[1].i2c_adap, 1236 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1110 &hauppauge_hvr1200_tuner_config); 1237 0x60, &dev->i2c_bus[1].i2c_adap,
1111 } 1238 &hauppauge_hvr1200_tuner_config);
1112 break; 1239 break;
1113 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1240 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1114 i2c_bus = &dev->i2c_bus[0]; 1241 i2c_bus = &dev->i2c_bus[0];
@@ -1367,12 +1494,10 @@ static int dvb_register(struct cx23885_tsport *port)
1367 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1494 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1368 &mygica_x8506_lgs8gl5_config, 1495 &mygica_x8506_lgs8gl5_config,
1369 &i2c_bus->i2c_adap); 1496 &i2c_bus->i2c_adap);
1370 if (fe0->dvb.frontend != NULL) { 1497 if (fe0->dvb.frontend == NULL)
1371 dvb_attach(xc5000_attach, 1498 break;
1372 fe0->dvb.frontend, 1499 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1373 &i2c_bus2->i2c_adap, 1500 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1374 &mygica_x8506_xc5000_config);
1375 }
1376 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1501 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1377 break; 1502 break;
1378 case CX23885_BOARD_MYGICA_X8507: 1503 case CX23885_BOARD_MYGICA_X8507:
@@ -1381,12 +1506,12 @@ static int dvb_register(struct cx23885_tsport *port)
1381 fe0->dvb.frontend = dvb_attach(mb86a20s_attach, 1506 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1382 &mygica_x8507_mb86a20s_config, 1507 &mygica_x8507_mb86a20s_config,
1383 &i2c_bus->i2c_adap); 1508 &i2c_bus->i2c_adap);
1384 if (fe0->dvb.frontend != NULL) { 1509 if (fe0->dvb.frontend == NULL)
1385 dvb_attach(xc5000_attach, 1510 break;
1386 fe0->dvb.frontend, 1511
1387 &i2c_bus2->i2c_adap, 1512 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1388 &mygica_x8507_xc5000_config); 1513 &i2c_bus2->i2c_adap,
1389 } 1514 &mygica_x8507_xc5000_config);
1390 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1515 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1391 break; 1516 break;
1392 case CX23885_BOARD_MAGICPRO_PROHDTVE2: 1517 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
@@ -1395,12 +1520,11 @@ static int dvb_register(struct cx23885_tsport *port)
1395 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1520 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1396 &magicpro_prohdtve2_lgs8g75_config, 1521 &magicpro_prohdtve2_lgs8g75_config,
1397 &i2c_bus->i2c_adap); 1522 &i2c_bus->i2c_adap);
1398 if (fe0->dvb.frontend != NULL) { 1523 if (fe0->dvb.frontend == NULL)
1399 dvb_attach(xc5000_attach, 1524 break;
1400 fe0->dvb.frontend, 1525 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1401 &i2c_bus2->i2c_adap, 1526 &i2c_bus2->i2c_adap,
1402 &magicpro_prohdtve2_xc5000_config); 1527 &magicpro_prohdtve2_xc5000_config);
1403 }
1404 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1528 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1405 break; 1529 break;
1406 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1530 case CX23885_BOARD_HAUPPAUGE_HVR1850:
@@ -1408,10 +1532,11 @@ static int dvb_register(struct cx23885_tsport *port)
1408 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1532 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1409 &hcw_s5h1411_config, 1533 &hcw_s5h1411_config,
1410 &i2c_bus->i2c_adap); 1534 &i2c_bus->i2c_adap);
1411 if (fe0->dvb.frontend != NULL) 1535 if (fe0->dvb.frontend == NULL)
1412 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1536 break;
1413 0x60, &dev->i2c_bus[0].i2c_adap, 1537 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1414 &hauppauge_tda18271_config); 1538 0x60, &dev->i2c_bus[0].i2c_adap,
1539 &hauppauge_tda18271_config);
1415 1540
1416 tda18271_attach(&dev->ts1.analog_fe, 1541 tda18271_attach(&dev->ts1.analog_fe,
1417 0x60, &dev->i2c_bus[1].i2c_adap, 1542 0x60, &dev->i2c_bus[1].i2c_adap,
@@ -1423,10 +1548,11 @@ static int dvb_register(struct cx23885_tsport *port)
1423 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1548 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1424 &hcw_s5h1411_config, 1549 &hcw_s5h1411_config,
1425 &i2c_bus->i2c_adap); 1550 &i2c_bus->i2c_adap);
1426 if (fe0->dvb.frontend != NULL) 1551 if (fe0->dvb.frontend == NULL)
1427 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1552 break;
1428 0x60, &dev->i2c_bus[0].i2c_adap, 1553 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1429 &hauppauge_tda18271_config); 1554 0x60, &dev->i2c_bus[0].i2c_adap,
1555 &hauppauge_tda18271_config);
1430 break; 1556 break;
1431 case CX23885_BOARD_MYGICA_X8558PRO: 1557 case CX23885_BOARD_MYGICA_X8558PRO:
1432 switch (port->nr) { 1558 switch (port->nr) {
@@ -1436,12 +1562,11 @@ static int dvb_register(struct cx23885_tsport *port)
1436 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1562 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1437 &mygica_x8558pro_atbm8830_cfg1, 1563 &mygica_x8558pro_atbm8830_cfg1,
1438 &i2c_bus->i2c_adap); 1564 &i2c_bus->i2c_adap);
1439 if (fe0->dvb.frontend != NULL) { 1565 if (fe0->dvb.frontend == NULL)
1440 dvb_attach(max2165_attach, 1566 break;
1441 fe0->dvb.frontend, 1567 dvb_attach(max2165_attach, fe0->dvb.frontend,
1442 &i2c_bus->i2c_adap, 1568 &i2c_bus->i2c_adap,
1443 &mygic_x8558pro_max2165_cfg1); 1569 &mygic_x8558pro_max2165_cfg1);
1444 }
1445 break; 1570 break;
1446 /* port C */ 1571 /* port C */
1447 case 2: 1572 case 2:
@@ -1449,13 +1574,11 @@ static int dvb_register(struct cx23885_tsport *port)
1449 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1574 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1450 &mygica_x8558pro_atbm8830_cfg2, 1575 &mygica_x8558pro_atbm8830_cfg2,
1451 &i2c_bus->i2c_adap); 1576 &i2c_bus->i2c_adap);
1452 if (fe0->dvb.frontend != NULL) { 1577 if (fe0->dvb.frontend == NULL)
1453 dvb_attach(max2165_attach, 1578 break;
1454 fe0->dvb.frontend, 1579 dvb_attach(max2165_attach, fe0->dvb.frontend,
1455 &i2c_bus->i2c_adap, 1580 &i2c_bus->i2c_adap,
1456 &mygic_x8558pro_max2165_cfg2); 1581 &mygic_x8558pro_max2165_cfg2);
1457 }
1458 break;
1459 } 1582 }
1460 break; 1583 break;
1461 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: 1584 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
@@ -1467,15 +1590,15 @@ static int dvb_register(struct cx23885_tsport *port)
1467 fe0->dvb.frontend = dvb_attach(stv0367ter_attach, 1590 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1468 &netup_stv0367_config[port->nr - 1], 1591 &netup_stv0367_config[port->nr - 1],
1469 &i2c_bus->i2c_adap); 1592 &i2c_bus->i2c_adap);
1470 if (fe0->dvb.frontend != NULL) { 1593 if (fe0->dvb.frontend == NULL)
1471 if (NULL == dvb_attach(xc5000_attach, 1594 break;
1472 fe0->dvb.frontend, 1595 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1473 &i2c_bus->i2c_adap, 1596 &i2c_bus->i2c_adap,
1474 &netup_xc5000_config[port->nr - 1])) 1597 &netup_xc5000_config[port->nr - 1]))
1475 goto frontend_detach; 1598 goto frontend_detach;
1476 /* load xc5000 firmware */ 1599 /* load xc5000 firmware */
1477 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); 1600 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1478 } 1601
1479 /* MFE frontend 2 */ 1602 /* MFE frontend 2 */
1480 fe1 = vb2_dvb_get_frontend(&port->frontends, 2); 1603 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1481 if (fe1 == NULL) 1604 if (fe1 == NULL)
@@ -1484,14 +1607,15 @@ static int dvb_register(struct cx23885_tsport *port)
1484 fe1->dvb.frontend = dvb_attach(stv0367cab_attach, 1607 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1485 &netup_stv0367_config[port->nr - 1], 1608 &netup_stv0367_config[port->nr - 1],
1486 &i2c_bus->i2c_adap); 1609 &i2c_bus->i2c_adap);
1487 if (fe1->dvb.frontend != NULL) { 1610 if (fe1->dvb.frontend == NULL)
1488 fe1->dvb.frontend->id = 1; 1611 break;
1489 if (NULL == dvb_attach(xc5000_attach, 1612
1490 fe1->dvb.frontend, 1613 fe1->dvb.frontend->id = 1;
1491 &i2c_bus->i2c_adap, 1614 if (NULL == dvb_attach(xc5000_attach,
1492 &netup_xc5000_config[port->nr - 1])) 1615 fe1->dvb.frontend,
1493 goto frontend_detach; 1616 &i2c_bus->i2c_adap,
1494 } 1617 &netup_xc5000_config[port->nr - 1]))
1618 goto frontend_detach;
1495 break; 1619 break;
1496 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 1620 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1497 i2c_bus = &dev->i2c_bus[0]; 1621 i2c_bus = &dev->i2c_bus[0];
@@ -1503,26 +1627,26 @@ static int dvb_register(struct cx23885_tsport *port)
1503 fe0->dvb.frontend = dvb_attach(drxk_attach, 1627 fe0->dvb.frontend = dvb_attach(drxk_attach,
1504 &terratec_drxk_config[0], 1628 &terratec_drxk_config[0],
1505 &i2c_bus->i2c_adap); 1629 &i2c_bus->i2c_adap);
1506 if (fe0->dvb.frontend != NULL) { 1630 if (fe0->dvb.frontend == NULL)
1507 if (!dvb_attach(mt2063_attach, 1631 break;
1508 fe0->dvb.frontend, 1632 if (!dvb_attach(mt2063_attach,
1509 &terratec_mt2063_config[0], 1633 fe0->dvb.frontend,
1510 &i2c_bus2->i2c_adap)) 1634 &terratec_mt2063_config[0],
1511 goto frontend_detach; 1635 &i2c_bus2->i2c_adap))
1512 } 1636 goto frontend_detach;
1513 break; 1637 break;
1514 /* port c */ 1638 /* port c */
1515 case 2: 1639 case 2:
1516 fe0->dvb.frontend = dvb_attach(drxk_attach, 1640 fe0->dvb.frontend = dvb_attach(drxk_attach,
1517 &terratec_drxk_config[1], 1641 &terratec_drxk_config[1],
1518 &i2c_bus->i2c_adap); 1642 &i2c_bus->i2c_adap);
1519 if (fe0->dvb.frontend != NULL) { 1643 if (fe0->dvb.frontend == NULL)
1520 if (!dvb_attach(mt2063_attach, 1644 break;
1521 fe0->dvb.frontend, 1645 if (!dvb_attach(mt2063_attach,
1522 &terratec_mt2063_config[1], 1646 fe0->dvb.frontend,
1523 &i2c_bus2->i2c_adap)) 1647 &terratec_mt2063_config[1],
1524 goto frontend_detach; 1648 &i2c_bus2->i2c_adap))
1525 } 1649 goto frontend_detach;
1526 break; 1650 break;
1527 } 1651 }
1528 break; 1652 break;
@@ -1532,10 +1656,10 @@ static int dvb_register(struct cx23885_tsport *port)
1532 fe0->dvb.frontend = dvb_attach(ds3000_attach, 1656 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1533 &tevii_ds3000_config, 1657 &tevii_ds3000_config,
1534 &i2c_bus->i2c_adap); 1658 &i2c_bus->i2c_adap);
1535 if (fe0->dvb.frontend != NULL) { 1659 if (fe0->dvb.frontend == NULL)
1536 dvb_attach(ts2020_attach, fe0->dvb.frontend, 1660 break;
1537 &tevii_ts2020_config, &i2c_bus->i2c_adap); 1661 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1538 } 1662 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1539 break; 1663 break;
1540 case CX23885_BOARD_PROF_8000: 1664 case CX23885_BOARD_PROF_8000:
1541 i2c_bus = &dev->i2c_bus[0]; 1665 i2c_bus = &dev->i2c_bus[0];
@@ -1544,15 +1668,15 @@ static int dvb_register(struct cx23885_tsport *port)
1544 &prof_8000_stv090x_config, 1668 &prof_8000_stv090x_config,
1545 &i2c_bus->i2c_adap, 1669 &i2c_bus->i2c_adap,
1546 STV090x_DEMODULATOR_0); 1670 STV090x_DEMODULATOR_0);
1547 if (fe0->dvb.frontend != NULL) { 1671 if (fe0->dvb.frontend == NULL)
1548 if (!dvb_attach(stb6100_attach, 1672 break;
1549 fe0->dvb.frontend, 1673 if (!dvb_attach(stb6100_attach,
1550 &prof_8000_stb6100_config, 1674 fe0->dvb.frontend,
1551 &i2c_bus->i2c_adap)) 1675 &prof_8000_stb6100_config,
1552 goto frontend_detach; 1676 &i2c_bus->i2c_adap))
1677 goto frontend_detach;
1553 1678
1554 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; 1679 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1555 }
1556 break; 1680 break;
1557 case CX23885_BOARD_HAUPPAUGE_HVR4400: 1681 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1558 i2c_bus = &dev->i2c_bus[0]; 1682 i2c_bus = &dev->i2c_bus[0];
@@ -1563,30 +1687,31 @@ static int dvb_register(struct cx23885_tsport *port)
1563 fe0->dvb.frontend = dvb_attach(tda10071_attach, 1687 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1564 &hauppauge_tda10071_config, 1688 &hauppauge_tda10071_config,
1565 &i2c_bus->i2c_adap); 1689 &i2c_bus->i2c_adap);
1566 if (fe0->dvb.frontend != NULL) { 1690 if (fe0->dvb.frontend == NULL)
1567 if (!dvb_attach(a8293_attach, fe0->dvb.frontend, 1691 break;
1568 &i2c_bus->i2c_adap, 1692 if (!dvb_attach(a8293_attach, fe0->dvb.frontend,
1569 &hauppauge_a8293_config)) 1693 &i2c_bus->i2c_adap,
1570 goto frontend_detach; 1694 &hauppauge_a8293_config))
1571 } 1695 goto frontend_detach;
1572 break; 1696 break;
1573 /* port c */ 1697 /* port c */
1574 case 2: 1698 case 2:
1575 fe0->dvb.frontend = dvb_attach(si2165_attach, 1699 fe0->dvb.frontend = dvb_attach(si2165_attach,
1576 &hauppauge_hvr4400_si2165_config, 1700 &hauppauge_hvr4400_si2165_config,
1577 &i2c_bus->i2c_adap); 1701 &i2c_bus->i2c_adap);
1578 if (fe0->dvb.frontend != NULL) { 1702 if (fe0->dvb.frontend == NULL)
1579 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 1703 break;
1580 if (!dvb_attach(tda18271_attach, 1704 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1581 fe0->dvb.frontend, 1705 if (!dvb_attach(tda18271_attach,
1582 0x60, &i2c_bus2->i2c_adap, 1706 fe0->dvb.frontend,
1583 &hauppauge_hvr4400_tuner_config)) 1707 0x60, &i2c_bus2->i2c_adap,
1584 goto frontend_detach; 1708 &hauppauge_hvr4400_tuner_config))
1585 } 1709 goto frontend_detach;
1586 break; 1710 break;
1587 } 1711 }
1588 break; 1712 break;
1589 case CX23885_BOARD_DVBSKY_T9580: 1713 case CX23885_BOARD_DVBSKY_T9580:
1714 case CX23885_BOARD_DVBSKY_S950:
1590 i2c_bus = &dev->i2c_bus[0]; 1715 i2c_bus = &dev->i2c_bus[0];
1591 i2c_bus2 = &dev->i2c_bus[1]; 1716 i2c_bus2 = &dev->i2c_bus[1];
1592 switch (port->nr) { 1717 switch (port->nr) {
@@ -1680,6 +1805,201 @@ static int dvb_register(struct cx23885_tsport *port)
1680 break; 1805 break;
1681 } 1806 }
1682 break; 1807 break;
1808 case CX23885_BOARD_DVBSKY_T980C:
1809 case CX23885_BOARD_TT_CT2_4500_CI:
1810 i2c_bus = &dev->i2c_bus[1];
1811 i2c_bus2 = &dev->i2c_bus[0];
1812
1813 /* attach frontend */
1814 memset(&si2168_config, 0, sizeof(si2168_config));
1815 si2168_config.i2c_adapter = &adapter;
1816 si2168_config.fe = &fe0->dvb.frontend;
1817 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1818 memset(&info, 0, sizeof(struct i2c_board_info));
1819 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1820 info.addr = 0x64;
1821 info.platform_data = &si2168_config;
1822 request_module(info.type);
1823 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1824 if (client_demod == NULL ||
1825 client_demod->dev.driver == NULL)
1826 goto frontend_detach;
1827 if (!try_module_get(client_demod->dev.driver->owner)) {
1828 i2c_unregister_device(client_demod);
1829 goto frontend_detach;
1830 }
1831 port->i2c_client_demod = client_demod;
1832
1833 /* attach tuner */
1834 memset(&si2157_config, 0, sizeof(si2157_config));
1835 si2157_config.fe = fe0->dvb.frontend;
1836 memset(&info, 0, sizeof(struct i2c_board_info));
1837 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1838 info.addr = 0x60;
1839 info.platform_data = &si2157_config;
1840 request_module(info.type);
1841 client_tuner = i2c_new_device(adapter, &info);
1842 if (client_tuner == NULL ||
1843 client_tuner->dev.driver == NULL) {
1844 module_put(client_demod->dev.driver->owner);
1845 i2c_unregister_device(client_demod);
1846 goto frontend_detach;
1847 }
1848 if (!try_module_get(client_tuner->dev.driver->owner)) {
1849 i2c_unregister_device(client_tuner);
1850 module_put(client_demod->dev.driver->owner);
1851 i2c_unregister_device(client_demod);
1852 goto frontend_detach;
1853 }
1854 port->i2c_client_tuner = client_tuner;
1855 break;
1856 case CX23885_BOARD_DVBSKY_S950C:
1857 i2c_bus = &dev->i2c_bus[1];
1858 i2c_bus2 = &dev->i2c_bus[0];
1859
1860 /* attach frontend */
1861 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1862 &dvbsky_s950c_m88ds3103_config,
1863 &i2c_bus->i2c_adap, &adapter);
1864 if (fe0->dvb.frontend == NULL)
1865 break;
1866
1867 /* attach tuner */
1868 memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
1869 m88ts2022_config.fe = fe0->dvb.frontend;
1870 m88ts2022_config.clock = 27000000;
1871 memset(&info, 0, sizeof(struct i2c_board_info));
1872 strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
1873 info.addr = 0x60;
1874 info.platform_data = &m88ts2022_config;
1875 request_module(info.type);
1876 client_tuner = i2c_new_device(adapter, &info);
1877 if (client_tuner == NULL ||
1878 client_tuner->dev.driver == NULL)
1879 goto frontend_detach;
1880 if (!try_module_get(client_tuner->dev.driver->owner)) {
1881 i2c_unregister_device(client_tuner);
1882 goto frontend_detach;
1883 }
1884
1885 /* delegate signal strength measurement to tuner */
1886 fe0->dvb.frontend->ops.read_signal_strength =
1887 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1888
1889 port->i2c_client_tuner = client_tuner;
1890 break;
1891 case CX23885_BOARD_DVBSKY_S952:
1892 switch (port->nr) {
1893 /* port b */
1894 case 1:
1895 i2c_bus = &dev->i2c_bus[1];
1896 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
1897 p_set_voltage = dvbsky_t9580_set_voltage;
1898 break;
1899 /* port c */
1900 case 2:
1901 i2c_bus = &dev->i2c_bus[0];
1902 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
1903 p_set_voltage = dvbsky_s952_portc_set_voltage;
1904 break;
1905 }
1906
1907 /* attach frontend */
1908 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1909 p_m88ds3103_config,
1910 &i2c_bus->i2c_adap, &adapter);
1911 if (fe0->dvb.frontend == NULL)
1912 break;
1913
1914 /* attach tuner */
1915 memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
1916 m88ts2022_config.fe = fe0->dvb.frontend;
1917 m88ts2022_config.clock = 27000000;
1918 memset(&info, 0, sizeof(struct i2c_board_info));
1919 strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
1920 info.addr = 0x60;
1921 info.platform_data = &m88ts2022_config;
1922 request_module(info.type);
1923 client_tuner = i2c_new_device(adapter, &info);
1924 if (client_tuner == NULL ||
1925 client_tuner->dev.driver == NULL)
1926 goto frontend_detach;
1927 if (!try_module_get(client_tuner->dev.driver->owner)) {
1928 i2c_unregister_device(client_tuner);
1929 goto frontend_detach;
1930 }
1931
1932 /* delegate signal strength measurement to tuner */
1933 fe0->dvb.frontend->ops.read_signal_strength =
1934 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1935
1936 /*
1937 * for setting the voltage we need to set GPIOs on
1938 * the card.
1939 */
1940 port->fe_set_voltage =
1941 fe0->dvb.frontend->ops.set_voltage;
1942 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
1943
1944 port->i2c_client_tuner = client_tuner;
1945 break;
1946 case CX23885_BOARD_DVBSKY_T982:
1947 memset(&si2168_config, 0, sizeof(si2168_config));
1948 switch (port->nr) {
1949 /* port b */
1950 case 1:
1951 i2c_bus = &dev->i2c_bus[1];
1952 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1953 break;
1954 /* port c */
1955 case 2:
1956 i2c_bus = &dev->i2c_bus[0];
1957 si2168_config.ts_mode = SI2168_TS_SERIAL;
1958 break;
1959 }
1960
1961 /* attach frontend */
1962 si2168_config.i2c_adapter = &adapter;
1963 si2168_config.fe = &fe0->dvb.frontend;
1964 memset(&info, 0, sizeof(struct i2c_board_info));
1965 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1966 info.addr = 0x64;
1967 info.platform_data = &si2168_config;
1968 request_module(info.type);
1969 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1970 if (client_demod == NULL ||
1971 client_demod->dev.driver == NULL)
1972 goto frontend_detach;
1973 if (!try_module_get(client_demod->dev.driver->owner)) {
1974 i2c_unregister_device(client_demod);
1975 goto frontend_detach;
1976 }
1977 port->i2c_client_demod = client_demod;
1978
1979 /* attach tuner */
1980 memset(&si2157_config, 0, sizeof(si2157_config));
1981 si2157_config.fe = fe0->dvb.frontend;
1982 memset(&info, 0, sizeof(struct i2c_board_info));
1983 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1984 info.addr = 0x60;
1985 info.platform_data = &si2157_config;
1986 request_module(info.type);
1987 client_tuner = i2c_new_device(adapter, &info);
1988 if (client_tuner == NULL ||
1989 client_tuner->dev.driver == NULL) {
1990 module_put(client_demod->dev.driver->owner);
1991 i2c_unregister_device(client_demod);
1992 goto frontend_detach;
1993 }
1994 if (!try_module_get(client_tuner->dev.driver->owner)) {
1995 i2c_unregister_device(client_tuner);
1996 module_put(client_demod->dev.driver->owner);
1997 i2c_unregister_device(client_demod);
1998 port->i2c_client_demod = NULL;
1999 goto frontend_detach;
2000 }
2001 port->i2c_client_tuner = client_tuner;
2002 break;
1683 default: 2003 default:
1684 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2004 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
1685 " isn't supported yet\n", 2005 " isn't supported yet\n",
@@ -1754,7 +2074,10 @@ static int dvb_register(struct cx23885_tsport *port)
1754 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); 2074 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1755 break; 2075 break;
1756 } 2076 }
1757 case CX23885_BOARD_DVBSKY_T9580: { 2077 case CX23885_BOARD_DVBSKY_T9580:
2078 case CX23885_BOARD_DVBSKY_S950:
2079 case CX23885_BOARD_DVBSKY_S952:
2080 case CX23885_BOARD_DVBSKY_T982: {
1758 u8 eeprom[256]; /* 24C02 i2c eeprom */ 2081 u8 eeprom[256]; /* 24C02 i2c eeprom */
1759 2082
1760 if (port->nr > 2) 2083 if (port->nr > 2)
@@ -1764,12 +2087,67 @@ static int dvb_register(struct cx23885_tsport *port)
1764 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 2087 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1765 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 2088 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1766 sizeof(eeprom)); 2089 sizeof(eeprom));
1767 printk(KERN_INFO "DVBSky T9580 port %d MAC address: %pM\n", 2090 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1768 port->nr, eeprom + 0xc0 + (port->nr-1) * 8); 2091 cx23885_boards[dev->board].name, port->nr,
2092 eeprom + 0xc0 + (port->nr-1) * 8);
1769 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + 2093 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1770 (port->nr-1) * 8, 6); 2094 (port->nr-1) * 8, 6);
1771 break; 2095 break;
1772 } 2096 }
2097 case CX23885_BOARD_DVBSKY_S950C:
2098 case CX23885_BOARD_DVBSKY_T980C:
2099 case CX23885_BOARD_TT_CT2_4500_CI: {
2100 u8 eeprom[256]; /* 24C02 i2c eeprom */
2101
2102 /* attach CI */
2103 memset(&sp2_config, 0, sizeof(sp2_config));
2104 sp2_config.dvb_adap = &port->frontends.adapter;
2105 sp2_config.priv = port;
2106 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
2107 memset(&info, 0, sizeof(struct i2c_board_info));
2108 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
2109 info.addr = 0x40;
2110 info.platform_data = &sp2_config;
2111 request_module(info.type);
2112 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2113 if (client_ci == NULL ||
2114 client_ci->dev.driver == NULL) {
2115 if (client_tuner) {
2116 module_put(client_tuner->dev.driver->owner);
2117 i2c_unregister_device(client_tuner);
2118 }
2119 if (client_demod) {
2120 module_put(client_demod->dev.driver->owner);
2121 i2c_unregister_device(client_demod);
2122 }
2123 goto frontend_detach;
2124 }
2125 if (!try_module_get(client_ci->dev.driver->owner)) {
2126 i2c_unregister_device(client_ci);
2127 if (client_tuner) {
2128 module_put(client_tuner->dev.driver->owner);
2129 i2c_unregister_device(client_tuner);
2130 }
2131 if (client_demod) {
2132 module_put(client_demod->dev.driver->owner);
2133 i2c_unregister_device(client_demod);
2134 }
2135 goto frontend_detach;
2136 }
2137 port->i2c_client_ci = client_ci;
2138
2139 if (port->nr != 1)
2140 break;
2141
2142 /* Read entire EEPROM */
2143 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
2144 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
2145 sizeof(eeprom));
2146 printk(KERN_INFO "%s MAC address: %pM\n",
2147 cx23885_boards[dev->board].name, eeprom + 0xc0);
2148 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
2149 break;
2150 }
1773 } 2151 }
1774 2152
1775 return ret; 2153 return ret;
@@ -1810,7 +2188,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
1810 2188
1811 fe0 = vb2_dvb_get_frontend(&port->frontends, i); 2189 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
1812 if (!fe0) 2190 if (!fe0)
1813 err = -EINVAL; 2191 return -EINVAL;
1814 2192
1815 dprintk(1, "%s\n", __func__); 2193 dprintk(1, "%s\n", __func__);
1816 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", 2194 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
@@ -1853,6 +2231,13 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
1853 struct vb2_dvb_frontend *fe0; 2231 struct vb2_dvb_frontend *fe0;
1854 struct i2c_client *client; 2232 struct i2c_client *client;
1855 2233
2234 /* remove I2C client for CI */
2235 client = port->i2c_client_ci;
2236 if (client) {
2237 module_put(client->dev.driver->owner);
2238 i2c_unregister_device(client);
2239 }
2240
1856 /* remove I2C client for tuner */ 2241 /* remove I2C client for tuner */
1857 client = port->i2c_client_tuner; 2242 client = port->i2c_client_tuner;
1858 if (client) { 2243 if (client) {