aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx88/cx88-dvb.c')
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c230
1 files changed, 122 insertions, 108 deletions
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 309ca5e68063..da4dd4913d9f 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -406,7 +406,7 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
406 cx_write(MO_GP0_IO, 0x00006060); 406 cx_write(MO_GP0_IO, 0x00006060);
407 break; 407 break;
408 case SEC_VOLTAGE_OFF: 408 case SEC_VOLTAGE_OFF:
409 printk("LNB Voltage SEC_VOLTAGE_off\n"); 409 printk("LNB Voltage SEC_VOLTAGE_off\n");
410 break; 410 break;
411 } 411 }
412 412
@@ -606,7 +606,7 @@ static int dvb_register(struct cx8802_dev *dev)
606 /* Get the first frontend */ 606 /* Get the first frontend */
607 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 607 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
608 if (!fe0) 608 if (!fe0)
609 return -EINVAL; 609 goto frontend_detach;
610 610
611 /* multi-frontend gate control is undefined or defaults to fe0 */ 611 /* multi-frontend gate control is undefined or defaults to fe0 */
612 dev->frontends.gate = 0; 612 dev->frontends.gate = 0;
@@ -653,38 +653,35 @@ static int dvb_register(struct cx8802_dev *dev)
653 } 653 }
654 break; 654 break;
655 case CX88_BOARD_HAUPPAUGE_HVR3000: 655 case CX88_BOARD_HAUPPAUGE_HVR3000:
656 /* MFE frontend 1 */
657 mfe_shared = 1;
658 dev->frontends.gate = 2;
656 /* DVB-S init */ 659 /* DVB-S init */
657 fe0->dvb.frontend = dvb_attach(cx24123_attach, 660 fe0->dvb.frontend = dvb_attach(cx24123_attach,
658 &hauppauge_novas_config, 661 &hauppauge_novas_config,
659 &dev->core->i2c_adap); 662 &dev->core->i2c_adap);
660 if (fe0->dvb.frontend) { 663 if (fe0->dvb.frontend) {
661 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend, 664 if (!dvb_attach(isl6421_attach,
662 &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { 665 fe0->dvb.frontend,
663 dprintk( 1, "%s(): HVR3000 - DVB-S LNB Init: failed\n", __func__); 666 &dev->core->i2c_adap,
664 } 667 0x08, ISL6421_DCL, 0x00))
665 } else { 668 goto frontend_detach;
666 dprintk( 1, "%s(): HVR3000 - DVB-S Init: failed\n", __func__);
667 } 669 }
668 /* DVB-T init */ 670 /* MFE frontend 2 */
669 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); 671 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
670 if (fe1) { 672 if (!fe1)
671 dev->frontends.gate = 2; 673 goto frontend_detach;
672 mfe_shared = 1; 674 /* DVB-T init */
673 fe1->dvb.frontend = dvb_attach(cx22702_attach, 675 fe1->dvb.frontend = dvb_attach(cx22702_attach,
674 &hauppauge_hvr_config, 676 &hauppauge_hvr_config,
675 &dev->core->i2c_adap); 677 &dev->core->i2c_adap);
676 if (fe1->dvb.frontend) { 678 if (fe1->dvb.frontend) {
677 fe1->dvb.frontend->id = 1; 679 fe1->dvb.frontend->id = 1;
678 if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, 680 if (!dvb_attach(simple_tuner_attach,
679 &dev->core->i2c_adap, 0x61, 681 fe1->dvb.frontend,
680 TUNER_PHILIPS_FMD1216ME_MK3)) { 682 &dev->core->i2c_adap,
681 dprintk( 1, "%s(): HVR3000 - DVB-T misc Init: failed\n", __func__); 683 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
682 } 684 goto frontend_detach;
683 } else {
684 dprintk( 1, "%s(): HVR3000 - DVB-T Init: failed\n", __func__);
685 }
686 } else {
687 dprintk( 1, "%s(): HVR3000 - DVB-T Init: can't find frontend 2.\n", __func__);
688 } 685 }
689 break; 686 break;
690 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 687 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
@@ -998,50 +995,51 @@ static int dvb_register(struct cx8802_dev *dev)
998 } 995 }
999 break; 996 break;
1000 case CX88_BOARD_HAUPPAUGE_HVR4000: 997 case CX88_BOARD_HAUPPAUGE_HVR4000:
998 /* MFE frontend 1 */
999 mfe_shared = 1;
1000 dev->frontends.gate = 2;
1001 /* DVB-S/S2 Init */ 1001 /* DVB-S/S2 Init */
1002 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1002 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1003 &hauppauge_hvr4000_config, 1003 &hauppauge_hvr4000_config,
1004 &dev->core->i2c_adap); 1004 &dev->core->i2c_adap);
1005 if (fe0->dvb.frontend) { 1005 if (fe0->dvb.frontend) {
1006 if(!dvb_attach(isl6421_attach, fe0->dvb.frontend, 1006 if (!dvb_attach(isl6421_attach,
1007 &dev->core->i2c_adap, 0x08, ISL6421_DCL, 0x00)) { 1007 fe0->dvb.frontend,
1008 dprintk( 1, "%s(): HVR4000 - DVB-S LNB Init: failed\n", __func__); 1008 &dev->core->i2c_adap,
1009 } 1009 0x08, ISL6421_DCL, 0x00))
1010 } else { 1010 goto frontend_detach;
1011 dprintk( 1, "%s(): HVR4000 - DVB-S Init: failed\n", __func__);
1012 } 1011 }
1013 /* DVB-T Init */ 1012 /* MFE frontend 2 */
1014 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2); 1013 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
1015 if (fe1) { 1014 if (!fe1)
1016 dev->frontends.gate = 2; 1015 goto frontend_detach;
1017 mfe_shared = 1; 1016 /* DVB-T Init */
1018 fe1->dvb.frontend = dvb_attach(cx22702_attach, 1017 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1019 &hauppauge_hvr_config, 1018 &hauppauge_hvr_config,
1020 &dev->core->i2c_adap); 1019 &dev->core->i2c_adap);
1021 if (fe1->dvb.frontend) { 1020 if (fe1->dvb.frontend) {
1022 fe1->dvb.frontend->id = 1; 1021 fe1->dvb.frontend->id = 1;
1023 if(!dvb_attach(simple_tuner_attach, fe1->dvb.frontend, 1022 if (!dvb_attach(simple_tuner_attach,
1024 &dev->core->i2c_adap, 0x61, 1023 fe1->dvb.frontend,
1025 TUNER_PHILIPS_FMD1216ME_MK3)) { 1024 &dev->core->i2c_adap,
1026 dprintk( 1, "%s(): HVR4000 - DVB-T misc Init: failed\n", __func__); 1025 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1027 } 1026 goto frontend_detach;
1028 } else {
1029 dprintk( 1, "%s(): HVR4000 - DVB-T Init: failed\n", __func__);
1030 }
1031 } else {
1032 dprintk( 1, "%s(): HVR4000 - DVB-T Init: can't find frontend 2.\n", __func__);
1033 } 1027 }
1034 break; 1028 break;
1035 case CX88_BOARD_HAUPPAUGE_HVR4000LITE: 1029 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1036 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1030 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1037 &hauppauge_hvr4000_config, 1031 &hauppauge_hvr4000_config,
1038 &dev->core->i2c_adap); 1032 &dev->core->i2c_adap);
1039 if (fe0->dvb.frontend) { 1033 if (fe0->dvb.frontend) {
1040 dvb_attach(isl6421_attach, fe0->dvb.frontend, 1034 if (!dvb_attach(isl6421_attach,
1041 &dev->core->i2c_adap, 1035 fe0->dvb.frontend,
1042 0x08, ISL6421_DCL, 0x00); 1036 &dev->core->i2c_adap,
1037 0x08, ISL6421_DCL, 0x00))
1038 goto frontend_detach;
1043 } 1039 }
1044 break; 1040 break;
1041 case CX88_BOARD_PROF_6200:
1042 case CX88_BOARD_TBS_8910:
1045 case CX88_BOARD_TEVII_S420: 1043 case CX88_BOARD_TEVII_S420:
1046 fe0->dvb.frontend = dvb_attach(stv0299_attach, 1044 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1047 &tevii_tuner_sharp_config, 1045 &tevii_tuner_sharp_config,
@@ -1070,21 +1068,18 @@ static int dvb_register(struct cx8802_dev *dev)
1070 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1068 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1071 &tevii_s460_config, 1069 &tevii_s460_config,
1072 &core->i2c_adap); 1070 &core->i2c_adap);
1073 if (fe0->dvb.frontend != NULL) { 1071 if (fe0->dvb.frontend != NULL)
1074 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1075 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1072 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1076 }
1077 break; 1073 break;
1078 case CX88_BOARD_OMICOM_SS4_PCI: 1074 case CX88_BOARD_OMICOM_SS4_PCI:
1079 case CX88_BOARD_TBS_8920: 1075 case CX88_BOARD_TBS_8920:
1080 case CX88_BOARD_PROF_7300: 1076 case CX88_BOARD_PROF_7300:
1077 case CX88_BOARD_SATTRADE_ST4200:
1081 fe0->dvb.frontend = dvb_attach(cx24116_attach, 1078 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1082 &hauppauge_hvr4000_config, 1079 &hauppauge_hvr4000_config,
1083 &core->i2c_adap); 1080 &core->i2c_adap);
1084 if (fe0->dvb.frontend != NULL) { 1081 if (fe0->dvb.frontend != NULL)
1085 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1086 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage; 1082 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1087 }
1088 break; 1083 break;
1089 default: 1084 default:
1090 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 1085 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
@@ -1092,11 +1087,11 @@ static int dvb_register(struct cx8802_dev *dev)
1092 break; 1087 break;
1093 } 1088 }
1094 1089
1095 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) { 1090 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
1096 printk(KERN_ERR 1091 printk(KERN_ERR
1097 "%s/2: frontend initialization failed\n", 1092 "%s/2: frontend initialization failed\n",
1098 core->name); 1093 core->name);
1099 return -EINVAL; 1094 goto frontend_detach;
1100 } 1095 }
1101 /* define general-purpose callback pointer */ 1096 /* define general-purpose callback pointer */
1102 fe0->dvb.frontend->callback = cx88_tuner_callback; 1097 fe0->dvb.frontend->callback = cx88_tuner_callback;
@@ -1133,40 +1128,44 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
1133 * on the bus. Take the bus from the cx23416 and enable the 1128 * on the bus. Take the bus from the cx23416 and enable the
1134 * cx22702 demod 1129 * cx22702 demod
1135 */ 1130 */
1136 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */ 1131 /* Toggle reset on cx22702 leaving i2c active */
1132 cx_set(MO_GP0_IO, 0x00000080);
1133 udelay(1000);
1134 cx_clear(MO_GP0_IO, 0x00000080);
1135 udelay(50);
1136 cx_set(MO_GP0_IO, 0x00000080);
1137 udelay(1000);
1138 /* enable the cx22702 pins */
1137 cx_clear(MO_GP0_IO, 0x00000004); 1139 cx_clear(MO_GP0_IO, 0x00000004);
1138 udelay(1000); 1140 udelay(1000);
1139 break; 1141 break;
1140 1142
1141 case CX88_BOARD_HAUPPAUGE_HVR3000: 1143 case CX88_BOARD_HAUPPAUGE_HVR3000:
1142 case CX88_BOARD_HAUPPAUGE_HVR4000: 1144 case CX88_BOARD_HAUPPAUGE_HVR4000:
1143 if(core->dvbdev->frontends.active_fe_id == 1) { 1145 /* Toggle reset on cx22702 leaving i2c active */
1144 /* DVB-S/S2 Enabled */ 1146 cx_set(MO_GP0_IO, 0x00000080);
1145 1147 udelay(1000);
1146 /* Toggle reset on cx22702 leaving i2c active */ 1148 cx_clear(MO_GP0_IO, 0x00000080);
1147 cx_write(MO_GP0_IO, (core->board.input[0].gpio0 & 0x0000ff00) | 0x00000080); 1149 udelay(50);
1148 udelay(1000); 1150 cx_set(MO_GP0_IO, 0x00000080);
1149 cx_clear(MO_GP0_IO, 0x00000080); 1151 udelay(1000);
1150 udelay(50); 1152 switch (core->dvbdev->frontends.active_fe_id) {
1151 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset */ 1153 case 1: /* DVB-S/S2 Enabled */
1152 cx_set(MO_GP0_IO, 0x00000004); /* tri-state the cx22702 pins */ 1154 /* tri-state the cx22702 pins */
1153 udelay(1000); 1155 cx_set(MO_GP0_IO, 0x00000004);
1154 1156 /* Take the cx24116/cx24123 out of reset */
1155 cx_write(MO_SRST_IO, 1); /* Take the cx24116/cx24123 out of reset */ 1157 cx_write(MO_SRST_IO, 1);
1156 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */ 1158 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
1157 } else 1159 break;
1158 if (core->dvbdev->frontends.active_fe_id == 2) { 1160 case 2: /* DVB-T Enabled */
1159 /* DVB-T Enabled */
1160
1161 /* Put the cx24116/cx24123 into reset */ 1161 /* Put the cx24116/cx24123 into reset */
1162 cx_write(MO_SRST_IO, 0); 1162 cx_write(MO_SRST_IO, 0);
1163 1163 /* enable the cx22702 pins */
1164 /* cx22702 out of reset and enable it */
1165 cx_set(MO_GP0_IO, 0x00000080);
1166 cx_clear(MO_GP0_IO, 0x00000004); 1164 cx_clear(MO_GP0_IO, 0x00000004);
1167 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */ 1165 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
1168 udelay(1000); 1166 break;
1169 } 1167 }
1168 udelay(1000);
1170 break; 1169 break;
1171 1170
1172 default: 1171 default:
@@ -1199,8 +1198,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1199{ 1198{
1200 struct cx88_core *core = drv->core; 1199 struct cx88_core *core = drv->core;
1201 struct cx8802_dev *dev = drv->core->dvbdev; 1200 struct cx8802_dev *dev = drv->core->dvbdev;
1202 int err, i; 1201 int err;
1203 struct videobuf_dvb_frontend *fe;
1204 1202
1205 dprintk( 1, "%s\n", __func__); 1203 dprintk( 1, "%s\n", __func__);
1206 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", 1204 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
@@ -1216,31 +1214,47 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
1216 /* If vp3054 isn't enabled, a stub will just return 0 */ 1214 /* If vp3054 isn't enabled, a stub will just return 0 */
1217 err = vp3054_i2c_probe(dev); 1215 err = vp3054_i2c_probe(dev);
1218 if (0 != err) 1216 if (0 != err)
1219 goto fail_core; 1217 goto fail_probe;
1220 1218
1221 /* dvb stuff */ 1219 /* dvb stuff */
1222 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); 1220 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
1223 dev->ts_gen_cntrl = 0x0c; 1221 dev->ts_gen_cntrl = 0x0c;
1224 1222
1225 for (i = 1; i <= core->board.num_frontends; i++) { 1223 err = -ENODEV;
1226 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i); 1224 if (core->board.num_frontends) {
1227 if (!fe) { 1225 struct videobuf_dvb_frontend *fe;
1228 printk(KERN_ERR "%s() failed to get frontend(%d)\n", __func__, i); 1226 int i;
1229 continue; 1227
1228 for (i = 1; i <= core->board.num_frontends; i++) {
1229 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1230 if (fe == NULL) {
1231 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
1232 __func__, i);
1233 goto fail_probe;
1234 }
1235 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
1236 &dev->pci->dev, &dev->slock,
1237 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1238 V4L2_FIELD_TOP,
1239 sizeof(struct cx88_buffer),
1240 dev);
1241 /* init struct videobuf_dvb */
1242 fe->dvb.name = dev->core->name;
1230 } 1243 }
1231 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops, 1244 } else {
1232 &dev->pci->dev, &dev->slock, 1245 /* no frontends allocated */
1233 V4L2_BUF_TYPE_VIDEO_CAPTURE, 1246 printk(KERN_ERR "%s/2 .num_frontends should be non-zero\n",
1234 V4L2_FIELD_TOP, 1247 core->name);
1235 sizeof(struct cx88_buffer), 1248 goto fail_core;
1236 dev);
1237 /* init struct videobuf_dvb */
1238 fe->dvb.name = dev->core->name;
1239 } 1249 }
1240 err = dvb_register(dev); 1250 err = dvb_register(dev);
1241 if (err != 0) 1251 if (err)
1252 /* frontends/adapter de-allocated in dvb_register */
1242 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n", 1253 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1243 core->name, err); 1254 core->name, err);
1255 return err;
1256fail_probe:
1257 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
1244fail_core: 1258fail_core:
1245 return err; 1259 return err;
1246} 1260}