24 #include <linux/module.h>
26 #include <linux/device.h>
69 static unsigned int debug;
73 static unsigned int dvb_buf_tscnt = 32;
79 #define dprintk(level,fmt, arg...) if (debug >= level) \
80 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
93 *count = dvb_buf_tscnt;
117 .buf_setup = dvb_buf_setup,
118 .buf_prepare = dvb_buf_prepare,
119 .buf_queue = dvb_buf_queue,
120 .buf_release = dvb_buf_release,
125 static int cx88_dvb_bus_ctrl(
struct dvb_frontend* fe,
int acquire)
142 dev->frontends.active_fe_id = fe_id;
146 dev->frontends.active_fe_id = 0;
162 f = &core->
dvbdev->frontends;
172 if (fe && fe->
dvb.frontend && fe->
dvb.frontend->ops.i2c_gate_ctrl)
173 fe->
dvb.frontend->ops.i2c_gate_ctrl(fe->
dvb.frontend, open);
178 static int dvico_fusionhdtv_demod_init(
struct dvb_frontend* fe)
180 static const u8 clock_config [] = {
CLOCK_CTL, 0x38, 0x39 };
182 static const u8 adc_ctl_1_cfg [] = {
ADC_CTL_1, 0x40 };
183 static const u8 agc_cfg [] = {
AGC_TARGET, 0x24, 0x20 };
184 static const u8 gpp_ctl_cfg [] = {
GPP_CTL, 0x33 };
185 static const u8 capt_range_cfg[] = {
CAPT_RANGE, 0x32 };
187 mt352_write(fe, clock_config,
sizeof(clock_config));
189 mt352_write(fe, reset,
sizeof(reset));
190 mt352_write(fe, adc_ctl_1_cfg,
sizeof(adc_ctl_1_cfg));
192 mt352_write(fe, agc_cfg,
sizeof(agc_cfg));
193 mt352_write(fe, gpp_ctl_cfg,
sizeof(gpp_ctl_cfg));
194 mt352_write(fe, capt_range_cfg,
sizeof(capt_range_cfg));
198 static int dvico_dual_demod_init(
struct dvb_frontend *fe)
200 static const u8 clock_config [] = {
CLOCK_CTL, 0x38, 0x38 };
201 static const u8 reset [] = {
RESET, 0x80 };
202 static const u8 adc_ctl_1_cfg [] = {
ADC_CTL_1, 0x40 };
203 static const u8 agc_cfg [] = {
AGC_TARGET, 0x28, 0x20 };
204 static const u8 gpp_ctl_cfg [] = {
GPP_CTL, 0x33 };
205 static const u8 capt_range_cfg[] = {
CAPT_RANGE, 0x32 };
207 mt352_write(fe, clock_config,
sizeof(clock_config));
209 mt352_write(fe, reset,
sizeof(reset));
210 mt352_write(fe, adc_ctl_1_cfg,
sizeof(adc_ctl_1_cfg));
212 mt352_write(fe, agc_cfg,
sizeof(agc_cfg));
213 mt352_write(fe, gpp_ctl_cfg,
sizeof(gpp_ctl_cfg));
214 mt352_write(fe, capt_range_cfg,
sizeof(capt_range_cfg));
219 static int dntv_live_dvbt_demod_init(
struct dvb_frontend* fe)
221 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
222 static const u8 reset [] = { 0x50, 0x80 };
223 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
224 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
225 0x00, 0xFF, 0x00, 0x40, 0x40 };
226 static const u8 dntv_extra[] = { 0xB5, 0x7A };
227 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
229 mt352_write(fe, clock_config,
sizeof(clock_config));
231 mt352_write(fe, reset,
sizeof(reset));
232 mt352_write(fe, adc_ctl_1_cfg,
sizeof(adc_ctl_1_cfg));
234 mt352_write(fe, agc_cfg,
sizeof(agc_cfg));
236 mt352_write(fe, dntv_extra,
sizeof(dntv_extra));
237 mt352_write(fe, capt_range_cfg,
sizeof(capt_range_cfg));
243 .demod_address = 0x0f,
244 .demod_init = dvico_fusionhdtv_demod_init,
247 static const struct mt352_config dntv_live_dvbt_config = {
248 .demod_address = 0x0f,
249 .demod_init = dntv_live_dvbt_demod_init,
252 static const struct mt352_config dvico_fusionhdtv_dual = {
253 .demod_address = 0x0f,
254 .demod_init = dvico_dual_demod_init,
257 static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
258 .demod_address = (0x1e >> 1),
264 .demod_address = 0x08,
267 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
268 static int dntv_live_dvbt_pro_demod_init(
struct dvb_frontend* fe)
270 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
271 static const u8 reset [] = { 0x50, 0x80 };
272 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
273 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
274 0x00, 0xFF, 0x00, 0x40, 0x40 };
275 static const u8 dntv_extra[] = { 0xB5, 0x7A };
276 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
278 mt352_write(fe, clock_config,
sizeof(clock_config));
280 mt352_write(fe, reset,
sizeof(reset));
281 mt352_write(fe, adc_ctl_1_cfg,
sizeof(adc_ctl_1_cfg));
283 mt352_write(fe, agc_cfg,
sizeof(agc_cfg));
285 mt352_write(fe, dntv_extra,
sizeof(dntv_extra));
286 mt352_write(fe, capt_range_cfg,
sizeof(capt_range_cfg));
291 static const struct mt352_config dntv_live_dvbt_pro_config = {
294 .demod_init = dntv_live_dvbt_pro_demod_init,
299 .demod_address = 0x0f,
304 .demod_address = 0x0f,
309 static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
310 .demod_address = 0x0f,
313 .demod_init = dvico_fusionhdtv_demod_init,
317 .demod_address = 0x0f,
321 .demod_address = 0x43,
326 .demod_address = 0x63,
330 static int or51132_set_ts_param(
struct dvb_frontend* fe,
int is_punctured)
338 .demod_address = 0x15,
339 .set_ts_params = or51132_set_ts_param,
347 dprintk(1,
"%s: index = %d\n", __func__, index);
355 static int lgdt330x_set_ts_param(
struct dvb_frontend* fe,
int is_punctured)
366 .demod_address = 0x0e,
369 .set_ts_params = lgdt330x_set_ts_param,
373 .demod_address = 0x0e,
376 .set_ts_params = lgdt330x_set_ts_param,
380 .demod_address = 0x59,
383 .set_ts_params = lgdt330x_set_ts_param,
386 static int nxt200x_set_ts_param(
struct dvb_frontend* fe,
int is_punctured)
394 .demod_address = 0x0a,
395 .set_ts_params = nxt200x_set_ts_param,
398 static int cx24123_set_ts_param(
struct dvb_frontend* fe,
406 static int kworld_dvbs_100_set_voltage(
struct dvb_frontend* fe,
417 if (core->prev_set_voltage)
418 return core->prev_set_voltage(fe, voltage);
422 static int geniatech_dvbs_set_voltage(
struct dvb_frontend *fe,
429 dprintk(1,
"LNB Voltage OFF\n");
433 if (core->prev_set_voltage)
434 return core->prev_set_voltage(fe, voltage);
438 static int tevii_dvbs_set_voltage(
struct dvb_frontend *fe,
457 if (core->prev_set_voltage)
458 return core->prev_set_voltage(fe, voltage);
470 dprintk(1,
"LNB SEC Voltage=13\n");
474 dprintk(1,
"LNB SEC Voltage=18\n");
478 dprintk(1,
"LNB Voltage OFF\n");
483 if (core->prev_set_voltage)
484 return core->prev_set_voltage(fe, voltage);
489 .demod_address = 0x55,
490 .set_ts_params = cx24123_set_ts_param,
494 .demod_address = 0x55,
495 .set_ts_params = cx24123_set_ts_param,
499 .demod_address = 0x15,
500 .set_ts_params = cx24123_set_ts_param,
504 static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
505 .demod_address = 0x32 >> 1,
514 static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
515 .demod_address = 0x32 >> 1,
524 .demod_address = 0x32 >> 1,
532 static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
538 .demod_address = (0x1e >> 1),
544 .demod_address = (0x1e >> 1),
559 static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
560 .i2c_address = 0xc2 >> 1,
570 .i2c_adap = &dev->
core->i2c_adap,
580 if (!fe0->
dvb.frontend) {
582 "Can't attach xc3028\n",
620 if (!fe0->
dvb.frontend) {
622 "Can't attach xc4000\n",
643 static int cx24116_set_ts_param(
struct dvb_frontend *fe,
652 static int stv0900_set_ts_param(
struct dvb_frontend *fe,
661 static int cx24116_reset_device(
struct dvb_frontend *fe)
678 .demod_address = 0x05,
679 .set_ts_params = cx24116_set_ts_param,
680 .reset_device = cx24116_reset_device,
684 .demod_address = 0x55,
685 .set_ts_params = cx24116_set_ts_param,
686 .reset_device = cx24116_reset_device,
699 .demod_address = 0x68,
700 .set_ts_params = ds3000_set_ts_param,
704 .demod_address = 0x6a,
712 .set_ts_params = stv0900_set_ts_param,
716 .tuner_address = 0x60,
717 .refclock = 27000000,
721 .demod_address = 0x68,
722 .inittab = sharp_z0194a_inittab,
729 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
730 .set_ts_params = cx24116_set_ts_param,
734 .demod_address = 0x68,
736 .set_ts_params = cx24116_set_ts_param,
739 static int cx8802_alloc_frontends(
struct cx8802_dev *dev)
746 INIT_LIST_HEAD(&dev->frontends.felist);
748 if (!core->
board.num_frontends)
752 core->
board.num_frontends);
753 for (i = 1; i <= core->
board.num_frontends; i++) {
766 static const u8 samsung_smt_7020_inittab[] = {
818 static int samsung_smt_7020_tuner_set_params(
struct dvb_frontend *fe)
828 .len =
sizeof(
buf) };
832 buf[0] = (div >> 8) & 0x7f;
840 if (fe->
ops.i2c_gate_ctrl)
841 fe->
ops.i2c_gate_ctrl(fe, 1);
849 static int samsung_smt_7020_set_tone(
struct dvb_frontend *fe,
871 static int samsung_smt_7020_set_voltage(
struct dvb_frontend *fe,
882 .len =
sizeof(
data) };
904 static int samsung_smt_7020_stv0299_set_symbol_rate(
struct dvb_frontend *fe,
910 if (srate < 1500000) {
913 }
else if (srate < 3000000) {
916 }
else if (srate < 7000000) {
919 }
else if (srate < 14000000) {
922 }
else if (srate < 30000000) {
925 }
else if (srate < 45000000) {
930 stv0299_writereg(fe, 0x13, aclk);
931 stv0299_writereg(fe, 0x14, bclk);
932 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
933 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
934 stv0299_writereg(fe, 0x21, ratio & 0xf0);
941 .demod_address = 0x68,
942 .inittab = samsung_smt_7020_inittab,
949 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
952 static int dvb_register(
struct cx8802_dev *dev)
960 printk(
KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->
name);
961 goto frontend_detach;
967 goto frontend_detach;
970 dev->frontends.gate = 0;
979 &connexant_refboard_config,
981 if (fe0->
dvb.frontend !=
NULL) {
985 goto frontend_detach;
993 &connexant_refboard_config,
995 if (fe0->
dvb.frontend !=
NULL) {
999 goto frontend_detach;
1007 &hauppauge_hvr_config,
1009 if (fe0->
dvb.frontend !=
NULL) {
1012 TUNER_PHILIPS_FMD1216ME_MK3))
1013 goto frontend_detach;
1018 &hauppauge_hvr_config,
1020 if (fe0->
dvb.frontend !=
NULL) {
1023 TUNER_PHILIPS_FMD1216MEX_MK3))
1024 goto frontend_detach;
1030 dev->frontends.gate = 2;
1033 &hauppauge_novas_config,
1034 &dev->
core->i2c_adap);
1035 if (fe0->
dvb.frontend) {
1038 &dev->
core->i2c_adap,
1040 goto frontend_detach;
1045 goto frontend_detach;
1048 &hauppauge_hvr_config,
1049 &dev->
core->i2c_adap);
1050 if (fe1->
dvb.frontend) {
1051 fe1->
dvb.frontend->id = 1;
1054 &dev->
core->i2c_adap,
1055 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1056 goto frontend_detach;
1063 if (fe0->
dvb.frontend !=
NULL) {
1066 goto frontend_detach;
1071 &dvico_fusionhdtv_plus_v1_1,
1073 if (fe0->
dvb.frontend !=
NULL) {
1076 goto frontend_detach;
1083 &dvico_fusionhdtv_dual,
1085 if (fe0->
dvb.frontend !=
NULL) {
1088 goto frontend_detach;
1093 &dvico_fusionhdtv_plus_v1_1,
1095 if (fe0->
dvb.frontend !=
NULL) {
1098 goto frontend_detach;
1105 if (fe0->
dvb.frontend !=
NULL) {
1108 goto frontend_detach;
1115 &dntv_live_dvbt_config,
1117 if (fe0->
dvb.frontend !=
NULL) {
1120 goto frontend_detach;
1124 #if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
1127 &dev->vp3054->adap);
1128 if (fe0->
dvb.frontend !=
NULL) {
1131 TUNER_PHILIPS_FMD1216ME_MK3))
1132 goto frontend_detach;
1141 &dvico_fusionhdtv_hybrid,
1143 if (fe0->
dvb.frontend !=
NULL) {
1146 TUNER_THOMSON_FE6600))
1147 goto frontend_detach;
1152 &dvico_fusionhdtv_xc3028,
1154 if (fe0->
dvb.frontend ==
NULL)
1156 &dvico_fusionhdtv_mt352_xc3028,
1163 if (fe0->
dvb.frontend)
1164 fe0->
dvb.frontend->ops.i2c_gate_ctrl =
NULL;
1165 if (attach_xc3028(0x61, dev) < 0)
1166 goto frontend_detach;
1171 if (fe0->
dvb.frontend !=
NULL) {
1174 TUNER_THOMSON_DTT761X))
1175 goto frontend_detach;
1188 fusionhdtv_3_gold.
pll_rf_set = lgdt330x_pll_rf_set;
1192 if (fe0->
dvb.frontend !=
NULL) {
1195 TUNER_MICROTUNE_4042FI5))
1196 goto frontend_detach;
1210 if (fe0->
dvb.frontend !=
NULL) {
1213 TUNER_THOMSON_DTT761X))
1214 goto frontend_detach;
1228 if (fe0->
dvb.frontend !=
NULL) {
1231 TUNER_LG_TDVS_H06XF))
1232 goto frontend_detach;
1235 goto frontend_detach;
1249 if (fe0->
dvb.frontend !=
NULL) {
1252 TUNER_LG_TDVS_H06XF))
1253 goto frontend_detach;
1256 goto frontend_detach;
1263 if (fe0->
dvb.frontend !=
NULL) {
1266 TUNER_PHILIPS_TUV1236D))
1267 goto frontend_detach;
1273 &hauppauge_novas_config,
1275 if (fe0->
dvb.frontend) {
1278 goto frontend_detach;
1283 &kworld_dvbs_100_config,
1285 if (fe0->
dvb.frontend) {
1286 core->prev_set_voltage = fe0->
dvb.frontend->ops.set_voltage;
1287 fe0->
dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
1292 &geniatech_dvbs_config,
1294 if (fe0->
dvb.frontend) {
1295 core->prev_set_voltage = fe0->
dvb.frontend->ops.set_voltage;
1296 fe0->
dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
1301 &pinnacle_pctv_hd_800i_config,
1303 if (fe0->
dvb.frontend !=
NULL) {
1306 &pinnacle_pctv_hd_800i_tuner_config))
1307 goto frontend_detach;
1312 &dvico_hdtv5_pci_nano_config,
1314 if (fe0->
dvb.frontend !=
NULL) {
1327 fe0->
dvb.frontend, &cfg);
1328 if (fe !=
NULL && fe->
ops.tuner_ops.set_config !=
NULL)
1329 fe->
ops.tuner_ops.set_config(fe, &ctl);
1335 &cx88_pinnacle_hybrid_pctv,
1337 if (fe0->
dvb.frontend) {
1338 fe0->
dvb.frontend->ops.i2c_gate_ctrl =
NULL;
1339 if (attach_xc3028(0x61, dev) < 0)
1340 goto frontend_detach;
1346 &cx88_pinnacle_hybrid_pctv,
1348 if (fe0->
dvb.frontend) {
1350 .i2c_address = 0x61,
1352 .dvb_amplitude = 134,
1353 .set_smoothedcvbs = 1,
1356 fe0->
dvb.frontend->ops.i2c_gate_ctrl =
NULL;
1357 if (attach_xc4000(dev, &cfg) < 0)
1358 goto frontend_detach;
1365 &cx88_geniatech_x8000_mt,
1367 if (attach_xc3028(0x61, dev) < 0)
1368 goto frontend_detach;
1372 &kworld_atsc_120_config,
1374 if (attach_xc3028(0x61, dev) < 0)
1375 goto frontend_detach;
1379 &dvico_fusionhdtv7_config,
1381 if (fe0->
dvb.frontend !=
NULL) {
1384 &dvico_fusionhdtv7_tuner_config))
1385 goto frontend_detach;
1391 dev->frontends.gate = 2;
1394 &hauppauge_hvr4000_config,
1395 &dev->
core->i2c_adap);
1396 if (fe0->
dvb.frontend) {
1399 &dev->
core->i2c_adap,
1401 goto frontend_detach;
1406 goto frontend_detach;
1409 &hauppauge_hvr_config,
1410 &dev->
core->i2c_adap);
1411 if (fe1->
dvb.frontend) {
1412 fe1->
dvb.frontend->id = 1;
1415 &dev->
core->i2c_adap,
1416 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1417 goto frontend_detach;
1422 &hauppauge_hvr4000_config,
1423 &dev->
core->i2c_adap);
1424 if (fe0->
dvb.frontend) {
1427 &dev->
core->i2c_adap,
1429 goto frontend_detach;
1436 &tevii_tuner_sharp_config,
1438 if (fe0->
dvb.frontend !=
NULL) {
1441 goto frontend_detach;
1442 core->prev_set_voltage = fe0->
dvb.frontend->ops.set_voltage;
1443 fe0->
dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1447 &tevii_tuner_earda_config,
1449 if (fe0->
dvb.frontend !=
NULL) {
1452 goto frontend_detach;
1453 core->prev_set_voltage = fe0->
dvb.frontend->ops.set_voltage;
1454 fe0->
dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1462 if (fe0->
dvb.frontend !=
NULL)
1463 fe0->
dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1467 &tevii_ds3000_config,
1469 if (fe0->
dvb.frontend !=
NULL)
1470 fe0->
dvb.frontend->ops.set_voltage =
1471 tevii_dvbs_set_voltage;
1478 &hauppauge_hvr4000_config,
1480 if (fe0->
dvb.frontend !=
NULL)
1481 fe0->
dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
1485 &cx88_terratec_cinergy_ht_pci_mkii_config,
1487 if (fe0->
dvb.frontend) {
1488 fe0->
dvb.frontend->ops.i2c_gate_ctrl =
NULL;
1489 if (attach_xc3028(0x61, dev) < 0)
1490 goto frontend_detach;
1497 &prof_7301_stv0900_config,
1499 if (fe0->
dvb.frontend !=
NULL) {
1501 &prof_7301_stb6100_config,
1503 goto frontend_detach;
1505 tuner_ops = &fe0->
dvb.frontend->ops.tuner_ops;
1511 core->prev_set_voltage =
1512 fe0->
dvb.frontend->ops.set_voltage;
1513 fe0->
dvb.frontend->ops.set_voltage =
1514 tevii_dvbs_set_voltage;
1529 &samsung_stv0299_config,
1530 &dev->
core->i2c_adap);
1531 if (fe0->
dvb.frontend) {
1532 fe0->
dvb.frontend->ops.tuner_ops.set_params =
1533 samsung_smt_7020_tuner_set_params;
1534 fe0->
dvb.frontend->tuner_priv =
1535 &dev->
core->i2c_adap;
1536 fe0->
dvb.frontend->ops.set_voltage =
1537 samsung_smt_7020_set_voltage;
1538 fe0->
dvb.frontend->ops.set_tone =
1539 samsung_smt_7020_set_tone;
1548 if (fe0->
dvb.frontend) {
1549 core->prev_set_voltage =
1550 fe0->
dvb.frontend->ops.set_voltage;
1551 fe0->
dvb.frontend->ops.set_voltage =
1557 printk(
KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
1562 if ( (
NULL == fe0->
dvb.frontend) || (fe1 &&
NULL == fe1->
dvb.frontend) ) {
1564 "%s/2: frontend initialization failed\n",
1566 goto frontend_detach;
1572 fe0->
dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1574 fe1->
dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1581 &dev->
pci->dev, adapter_nr, mfe_shared);
1583 goto frontend_detach;
1595 static int cx8802_dvb_advise_acquire(
struct cx8802_driver *drv)
1599 dprintk( 1,
"%s\n", __func__);
1628 switch (core->
dvbdev->frontends.active_fe_id) {
1634 core->
dvbdev->ts_gen_cntrl = 0x02;
1641 core->
dvbdev->ts_gen_cntrl = 0x0c;
1659 static int cx8802_dvb_advise_release(
struct cx8802_driver *drv)
1663 dprintk( 1,
"%s\n", __func__);
1686 dprintk( 1,
"%s\n", __func__);
1687 dprintk( 1,
" ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
1706 err = cx8802_alloc_frontends(dev);
1711 for (i = 1; i <= core->
board.num_frontends; i++) {
1725 fe->
dvb.name = dev->
core->name;
1728 err = dvb_register(dev);
1745 dprintk( 1,
"%s\n", __func__);
1759 .probe = cx8802_dvb_probe,
1760 .remove = cx8802_dvb_remove,
1761 .advise_acquire = cx8802_dvb_advise_acquire,
1762 .advise_release = cx8802_dvb_advise_release,
1765 static int __init dvb_init(
void)
1772 static void __exit dvb_fini(
void)