2 * Driver for the Conexant CX23885 PCIe bridge
4 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/device.h>
26 #include <linux/kthread.h>
27 #include <linux/file.h>
28 #include <linux/suspend.h>
31 #include <media/v4l2-common.h>
33 #include "dvb_ca_en50221.h"
42 #include "tuner-xc2028.h"
43 #include "tuner-simple.h"
45 #include "dibx000_common.h"
52 #include "netup-eeprom.h"
53 #include "netup-init.h"
56 static unsigned int debug;
58 #define dprintk(level, fmt, arg...)\
59 do { if (debug >= level)\
60 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
63 /* ------------------------------------------------------------------ */
65 static unsigned int alt_tuner;
66 module_param(alt_tuner, int, 0644);
67 MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
69 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
71 /* ------------------------------------------------------------------ */
73 static int dvb_buf_setup(struct videobuf_queue *q,
74 unsigned int *count, unsigned int *size)
76 struct cx23885_tsport *port = q->priv_data;
78 port->ts_packet_size = 188 * 4;
79 port->ts_packet_count = 32;
81 *size = port->ts_packet_size * port->ts_packet_count;
86 static int dvb_buf_prepare(struct videobuf_queue *q,
87 struct videobuf_buffer *vb, enum v4l2_field field)
89 struct cx23885_tsport *port = q->priv_data;
90 return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field);
93 static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
95 struct cx23885_tsport *port = q->priv_data;
96 cx23885_buf_queue(port, (struct cx23885_buffer *)vb);
99 static void dvb_buf_release(struct videobuf_queue *q,
100 struct videobuf_buffer *vb)
102 cx23885_free_buffer(q, (struct cx23885_buffer *)vb);
105 static struct videobuf_queue_ops dvb_qops = {
106 .buf_setup = dvb_buf_setup,
107 .buf_prepare = dvb_buf_prepare,
108 .buf_queue = dvb_buf_queue,
109 .buf_release = dvb_buf_release,
112 static struct s5h1409_config hauppauge_generic_config = {
113 .demod_address = 0x32 >> 1,
114 .output_mode = S5H1409_SERIAL_OUTPUT,
115 .gpio = S5H1409_GPIO_ON,
117 .inversion = S5H1409_INVERSION_OFF,
118 .status_mode = S5H1409_DEMODLOCKING,
119 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
122 static struct tda10048_config hauppauge_hvr1200_config = {
123 .demod_address = 0x10 >> 1,
124 .output_mode = TDA10048_SERIAL_OUTPUT,
125 .fwbulkwritelen = TDA10048_BULKWRITE_200,
126 .inversion = TDA10048_INVERSION_ON,
127 .dtv6_if_freq_khz = TDA10048_IF_3300,
128 .dtv7_if_freq_khz = TDA10048_IF_3800,
129 .dtv8_if_freq_khz = TDA10048_IF_4300,
130 .clk_freq_khz = TDA10048_CLK_16000,
133 static struct tda10048_config hauppauge_hvr1210_config = {
134 .demod_address = 0x10 >> 1,
135 .output_mode = TDA10048_SERIAL_OUTPUT,
136 .fwbulkwritelen = TDA10048_BULKWRITE_200,
137 .inversion = TDA10048_INVERSION_ON,
138 .if_freq_khz = TDA10048_IF_4000,
139 .clk_freq_khz = TDA10048_CLK_16000,
142 static struct s5h1409_config hauppauge_ezqam_config = {
143 .demod_address = 0x32 >> 1,
144 .output_mode = S5H1409_SERIAL_OUTPUT,
145 .gpio = S5H1409_GPIO_OFF,
147 .inversion = S5H1409_INVERSION_ON,
148 .status_mode = S5H1409_DEMODLOCKING,
149 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
152 static struct s5h1409_config hauppauge_hvr1800lp_config = {
153 .demod_address = 0x32 >> 1,
154 .output_mode = S5H1409_SERIAL_OUTPUT,
155 .gpio = S5H1409_GPIO_OFF,
157 .inversion = S5H1409_INVERSION_OFF,
158 .status_mode = S5H1409_DEMODLOCKING,
159 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
162 static struct s5h1409_config hauppauge_hvr1500_config = {
163 .demod_address = 0x32 >> 1,
164 .output_mode = S5H1409_SERIAL_OUTPUT,
165 .gpio = S5H1409_GPIO_OFF,
166 .inversion = S5H1409_INVERSION_OFF,
167 .status_mode = S5H1409_DEMODLOCKING,
168 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
171 static struct mt2131_config hauppauge_generic_tunerconfig = {
175 static struct lgdt330x_config fusionhdtv_5_express = {
176 .demod_address = 0x0e,
177 .demod_chip = LGDT3303,
181 static struct s5h1409_config hauppauge_hvr1500q_config = {
182 .demod_address = 0x32 >> 1,
183 .output_mode = S5H1409_SERIAL_OUTPUT,
184 .gpio = S5H1409_GPIO_ON,
186 .inversion = S5H1409_INVERSION_OFF,
187 .status_mode = S5H1409_DEMODLOCKING,
188 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
191 static struct s5h1409_config dvico_s5h1409_config = {
192 .demod_address = 0x32 >> 1,
193 .output_mode = S5H1409_SERIAL_OUTPUT,
194 .gpio = S5H1409_GPIO_ON,
196 .inversion = S5H1409_INVERSION_OFF,
197 .status_mode = S5H1409_DEMODLOCKING,
198 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
201 static struct s5h1411_config dvico_s5h1411_config = {
202 .output_mode = S5H1411_SERIAL_OUTPUT,
203 .gpio = S5H1411_GPIO_ON,
204 .qam_if = S5H1411_IF_44000,
205 .vsb_if = S5H1411_IF_44000,
206 .inversion = S5H1411_INVERSION_OFF,
207 .status_mode = S5H1411_DEMODLOCKING,
208 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
211 static struct s5h1411_config hcw_s5h1411_config = {
212 .output_mode = S5H1411_SERIAL_OUTPUT,
213 .gpio = S5H1411_GPIO_OFF,
214 .vsb_if = S5H1411_IF_44000,
215 .qam_if = S5H1411_IF_4000,
216 .inversion = S5H1411_INVERSION_ON,
217 .status_mode = S5H1411_DEMODLOCKING,
218 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
221 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
226 static struct xc5000_config dvico_xc5000_tunerconfig = {
231 static struct tda829x_config tda829x_no_probe = {
232 .probe_tuner = TDA829X_DONT_PROBE,
235 static struct tda18271_std_map hauppauge_tda18271_std_map = {
236 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
237 .if_lvl = 6, .rfagc_top = 0x37 },
238 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
239 .if_lvl = 6, .rfagc_top = 0x37 },
242 static struct tda18271_config hauppauge_tda18271_config = {
243 .std_map = &hauppauge_tda18271_std_map,
244 .gate = TDA18271_GATE_ANALOG,
247 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
248 .gate = TDA18271_GATE_ANALOG,
251 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
252 .gate = TDA18271_GATE_DIGITAL,
255 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
256 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
257 .if_lvl = 1, .rfagc_top = 0x58 },
258 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
259 .if_lvl = 1, .rfagc_top = 0x58 },
262 static struct tda18271_config hauppauge_hvr127x_config = {
263 .std_map = &hauppauge_hvr127x_std_map,
266 static struct lgdt3305_config hauppauge_lgdt3305_config = {
268 .mpeg_mode = LGDT3305_MPEG_SERIAL,
269 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
270 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
272 .spectral_inversion = 1,
277 static struct dibx000_agc_config xc3028_agc_config = {
278 BAND_VHF | BAND_UHF, /* band_caps */
280 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
281 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
282 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
283 * P_agc_nb_est=2, P_agc_write=0
285 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
286 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
289 21, /* time_stabiliz */
301 39718, /* agc2_max */
310 29, /* agc2_slope1 */
311 29, /* agc2_slope2 */
318 1, /* perform_agc_softsplit */
321 /* PLL Configuration for COFDM BW_MHz = 8.000000
322 * With external clock = 30.000000 */
323 static struct dibx000_bandwidth_config xc3028_bw_config = {
324 60000, /* internal */
325 30000, /* sampling */
326 1, /* pll_cfg: prediv */
327 8, /* pll_cfg: ratio */
328 3, /* pll_cfg: range */
329 1, /* pll_cfg: reset */
330 0, /* pll_cfg: bypass */
331 0, /* misc: refdiv */
332 0, /* misc: bypclk_div */
333 1, /* misc: IO_CLK_en_core */
334 1, /* misc: ADClkSrc */
335 0, /* misc: modulo */
336 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
337 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
339 30000000 /* xtal_hz */
342 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
343 .output_mpeg2_in_188_bytes = 1,
344 .hostbus_diversity = 1,
345 .tuner_is_baseband = 0,
348 .agc_config_count = 1,
349 .agc = &xc3028_agc_config,
350 .bw = &xc3028_bw_config,
352 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
353 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
354 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
360 .output_mode = OUTMODE_MPEG2_SERIAL,
363 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
364 .demod_address = 0x0f,
367 .disable_i2c_gate_ctrl = 1,
370 static struct stv0900_config netup_stv0900_config = {
371 .demod_address = 0x68,
373 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
374 .diseqc_mode = 2,/* 2/3 PWM */
375 .path1_mode = 2,/*Serial continues clock */
376 .path2_mode = 2,/*Serial continues clock */
377 .tun1_maddress = 0,/* 0x60 */
378 .tun2_maddress = 3,/* 0x63 */
379 .tun1_adc = 1,/* 1 Vpp */
380 .tun2_adc = 1,/* 1 Vpp */
383 static struct stv6110_config netup_stv6110_tunerconfig_a = {
389 static struct stv6110_config netup_stv6110_tunerconfig_b = {
395 static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
397 struct cx23885_tsport *port = fe->dvb->priv;
398 struct cx23885_dev *dev = port->dev;
400 if (voltage == SEC_VOLTAGE_18)
401 cx_write(MC417_RWD, 0x00001e00);/* GPIO-13 high */
402 else if (voltage == SEC_VOLTAGE_13)
403 cx_write(MC417_RWD, 0x00001a00);/* GPIO-13 low */
405 cx_write(MC417_RWD, 0x00001800);/* GPIO-12 low */
409 static struct cx24116_config tbs_cx24116_config = {
410 .demod_address = 0x05,
413 static struct cx24116_config tevii_cx24116_config = {
414 .demod_address = 0x55,
417 static struct cx24116_config dvbworld_cx24116_config = {
418 .demod_address = 0x05,
421 static int dvb_register(struct cx23885_tsport *port)
423 struct cx23885_dev *dev = port->dev;
424 struct cx23885_i2c *i2c_bus = NULL;
425 struct videobuf_dvb_frontend *fe0;
428 /* Get the first frontend */
429 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
433 /* init struct videobuf_dvb */
434 fe0->dvb.name = dev->name;
437 switch (dev->board) {
438 case CX23885_BOARD_HAUPPAUGE_HVR1250:
439 i2c_bus = &dev->i2c_bus[0];
440 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
441 &hauppauge_generic_config,
443 if (fe0->dvb.frontend != NULL) {
444 dvb_attach(mt2131_attach, fe0->dvb.frontend,
446 &hauppauge_generic_tunerconfig, 0);
449 case CX23885_BOARD_HAUPPAUGE_HVR1270:
450 case CX23885_BOARD_HAUPPAUGE_HVR1275:
451 i2c_bus = &dev->i2c_bus[0];
452 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
453 &hauppauge_lgdt3305_config,
455 if (fe0->dvb.frontend != NULL) {
456 dvb_attach(tda18271_attach, fe0->dvb.frontend,
457 0x60, &dev->i2c_bus[1].i2c_adap,
458 &hauppauge_hvr127x_config);
461 case CX23885_BOARD_HAUPPAUGE_HVR1255:
462 i2c_bus = &dev->i2c_bus[0];
463 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
466 if (fe0->dvb.frontend != NULL) {
467 dvb_attach(tda18271_attach, fe0->dvb.frontend,
468 0x60, &dev->i2c_bus[1].i2c_adap,
469 &hauppauge_tda18271_config);
472 case CX23885_BOARD_HAUPPAUGE_HVR1800:
473 i2c_bus = &dev->i2c_bus[0];
477 dvb_attach(s5h1409_attach,
478 &hauppauge_ezqam_config,
480 if (fe0->dvb.frontend != NULL) {
481 dvb_attach(tda829x_attach, fe0->dvb.frontend,
482 &dev->i2c_bus[1].i2c_adap, 0x42,
484 dvb_attach(tda18271_attach, fe0->dvb.frontend,
485 0x60, &dev->i2c_bus[1].i2c_adap,
486 &hauppauge_tda18271_config);
492 dvb_attach(s5h1409_attach,
493 &hauppauge_generic_config,
495 if (fe0->dvb.frontend != NULL)
496 dvb_attach(mt2131_attach, fe0->dvb.frontend,
498 &hauppauge_generic_tunerconfig, 0);
502 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
503 i2c_bus = &dev->i2c_bus[0];
504 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
505 &hauppauge_hvr1800lp_config,
507 if (fe0->dvb.frontend != NULL) {
508 dvb_attach(mt2131_attach, fe0->dvb.frontend,
510 &hauppauge_generic_tunerconfig, 0);
513 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
514 i2c_bus = &dev->i2c_bus[0];
515 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
516 &fusionhdtv_5_express,
518 if (fe0->dvb.frontend != NULL) {
519 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
520 &i2c_bus->i2c_adap, 0x61,
521 TUNER_LG_TDVS_H06XF);
524 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
525 i2c_bus = &dev->i2c_bus[1];
526 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
527 &hauppauge_hvr1500q_config,
528 &dev->i2c_bus[0].i2c_adap);
529 if (fe0->dvb.frontend != NULL)
530 dvb_attach(xc5000_attach, fe0->dvb.frontend,
532 &hauppauge_hvr1500q_tunerconfig);
534 case CX23885_BOARD_HAUPPAUGE_HVR1500:
535 i2c_bus = &dev->i2c_bus[1];
536 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
537 &hauppauge_hvr1500_config,
538 &dev->i2c_bus[0].i2c_adap);
539 if (fe0->dvb.frontend != NULL) {
540 struct dvb_frontend *fe;
541 struct xc2028_config cfg = {
542 .i2c_adap = &i2c_bus->i2c_adap,
545 static struct xc2028_ctrl ctl = {
546 .fname = XC2028_DEFAULT_FIRMWARE,
548 .demod = XC3028_FE_OREN538,
551 fe = dvb_attach(xc2028_attach,
552 fe0->dvb.frontend, &cfg);
553 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
554 fe->ops.tuner_ops.set_config(fe, &ctl);
557 case CX23885_BOARD_HAUPPAUGE_HVR1200:
558 case CX23885_BOARD_HAUPPAUGE_HVR1700:
559 i2c_bus = &dev->i2c_bus[0];
560 fe0->dvb.frontend = dvb_attach(tda10048_attach,
561 &hauppauge_hvr1200_config,
563 if (fe0->dvb.frontend != NULL) {
564 dvb_attach(tda829x_attach, fe0->dvb.frontend,
565 &dev->i2c_bus[1].i2c_adap, 0x42,
567 dvb_attach(tda18271_attach, fe0->dvb.frontend,
568 0x60, &dev->i2c_bus[1].i2c_adap,
569 &hauppauge_hvr1200_tuner_config);
572 case CX23885_BOARD_HAUPPAUGE_HVR1210:
573 i2c_bus = &dev->i2c_bus[0];
574 fe0->dvb.frontend = dvb_attach(tda10048_attach,
575 &hauppauge_hvr1210_config,
577 if (fe0->dvb.frontend != NULL) {
578 dvb_attach(tda18271_attach, fe0->dvb.frontend,
579 0x60, &dev->i2c_bus[1].i2c_adap,
580 &hauppauge_hvr1210_tuner_config);
583 case CX23885_BOARD_HAUPPAUGE_HVR1400:
584 i2c_bus = &dev->i2c_bus[0];
585 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
587 0x12, &hauppauge_hvr1400_dib7000_config);
588 if (fe0->dvb.frontend != NULL) {
589 struct dvb_frontend *fe;
590 struct xc2028_config cfg = {
591 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
594 static struct xc2028_ctrl ctl = {
595 .fname = XC3028L_DEFAULT_FIRMWARE,
598 /* This is true for all demods with
600 .type = XC2028_D2633,
603 fe = dvb_attach(xc2028_attach,
604 fe0->dvb.frontend, &cfg);
605 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
606 fe->ops.tuner_ops.set_config(fe, &ctl);
609 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
610 i2c_bus = &dev->i2c_bus[port->nr - 1];
612 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
613 &dvico_s5h1409_config,
615 if (fe0->dvb.frontend == NULL)
616 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
617 &dvico_s5h1411_config,
619 if (fe0->dvb.frontend != NULL)
620 dvb_attach(xc5000_attach, fe0->dvb.frontend,
622 &dvico_xc5000_tunerconfig);
624 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
625 i2c_bus = &dev->i2c_bus[port->nr - 1];
627 fe0->dvb.frontend = dvb_attach(zl10353_attach,
628 &dvico_fusionhdtv_xc3028,
630 if (fe0->dvb.frontend != NULL) {
631 struct dvb_frontend *fe;
632 struct xc2028_config cfg = {
633 .i2c_adap = &i2c_bus->i2c_adap,
636 static struct xc2028_ctrl ctl = {
637 .fname = XC2028_DEFAULT_FIRMWARE,
639 .demod = XC3028_FE_ZARLINK456,
642 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
644 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
645 fe->ops.tuner_ops.set_config(fe, &ctl);
649 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
650 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
651 i2c_bus = &dev->i2c_bus[0];
653 fe0->dvb.frontend = dvb_attach(zl10353_attach,
654 &dvico_fusionhdtv_xc3028,
656 if (fe0->dvb.frontend != NULL) {
657 struct dvb_frontend *fe;
658 struct xc2028_config cfg = {
659 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
662 static struct xc2028_ctrl ctl = {
663 .fname = XC2028_DEFAULT_FIRMWARE,
665 .demod = XC3028_FE_ZARLINK456,
668 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
670 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
671 fe->ops.tuner_ops.set_config(fe, &ctl);
674 case CX23885_BOARD_TBS_6920:
675 i2c_bus = &dev->i2c_bus[0];
677 fe0->dvb.frontend = dvb_attach(cx24116_attach,
680 if (fe0->dvb.frontend != NULL)
681 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
684 case CX23885_BOARD_TEVII_S470:
685 i2c_bus = &dev->i2c_bus[1];
687 fe0->dvb.frontend = dvb_attach(cx24116_attach,
688 &tevii_cx24116_config,
690 if (fe0->dvb.frontend != NULL)
691 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
694 case CX23885_BOARD_DVBWORLD_2005:
695 i2c_bus = &dev->i2c_bus[1];
697 fe0->dvb.frontend = dvb_attach(cx24116_attach,
698 &dvbworld_cx24116_config,
701 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
702 i2c_bus = &dev->i2c_bus[0];
706 fe0->dvb.frontend = dvb_attach(stv0900_attach,
707 &netup_stv0900_config,
708 &i2c_bus->i2c_adap, 0);
709 if (fe0->dvb.frontend != NULL) {
710 if (dvb_attach(stv6110_attach,
712 &netup_stv6110_tunerconfig_a,
713 &i2c_bus->i2c_adap)) {
714 if (!dvb_attach(lnbh24_attach,
717 LNBH24_PCL, 0, 0x09))
719 "No LNBH24 found!\n");
726 fe0->dvb.frontend = dvb_attach(stv0900_attach,
727 &netup_stv0900_config,
728 &i2c_bus->i2c_adap, 1);
729 if (fe0->dvb.frontend != NULL) {
730 if (dvb_attach(stv6110_attach,
732 &netup_stv6110_tunerconfig_b,
733 &i2c_bus->i2c_adap)) {
734 if (!dvb_attach(lnbh24_attach,
737 LNBH24_PCL, 0, 0x0a))
739 "No LNBH24 found!\n");
747 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
748 " isn't supported yet\n",
752 if (NULL == fe0->dvb.frontend) {
753 printk(KERN_ERR "%s: frontend initialization failed\n",
757 /* define general-purpose callback pointer */
758 fe0->dvb.frontend->callback = cx23885_tuner_callback;
760 /* Put the analog decoder in standby to keep it quiet */
761 call_all(dev, tuner, s_standby);
763 if (fe0->dvb.frontend->ops.analog_ops.standby)
764 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
766 /* register everything */
767 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
768 &dev->pci->dev, adapter_nr, 0);
771 switch (dev->board) {
772 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
773 static struct netup_card_info cinfo;
775 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
776 memcpy(port->frontends.adapter.proposed_mac,
777 cinfo.port[port->nr - 1].mac, 6);
778 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC="
779 "%02X:%02X:%02X:%02X:%02X:%02X\n",
781 port->frontends.adapter.proposed_mac[0],
782 port->frontends.adapter.proposed_mac[1],
783 port->frontends.adapter.proposed_mac[2],
784 port->frontends.adapter.proposed_mac[3],
785 port->frontends.adapter.proposed_mac[4],
786 port->frontends.adapter.proposed_mac[5]);
796 int cx23885_dvb_register(struct cx23885_tsport *port)
799 struct videobuf_dvb_frontend *fe0;
800 struct cx23885_dev *dev = port->dev;
803 /* Here we need to allocate the correct number of frontends,
804 * as reflected in the cards struct. The reality is that currrently
805 * no cx23885 boards support this - yet. But, if we don't modify this
806 * code then the second frontend would never be allocated (later)
807 * and fail with error before the attach in dvb_register().
808 * Without these changes we risk an OOPS later. The changes here
809 * are for safety, and should provide a good foundation for the
810 * future addition of any multi-frontend cx23885 based boards.
812 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
813 port->num_frontends);
815 for (i = 1; i <= port->num_frontends; i++) {
816 if (videobuf_dvb_alloc_frontend(
817 &port->frontends, i) == NULL) {
818 printk(KERN_ERR "%s() failed to alloc\n", __func__);
822 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
826 dprintk(1, "%s\n", __func__);
827 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
836 /* We have to init the queue for each frontend on a port. */
837 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
838 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
839 &dev->pci->dev, &port->slock,
840 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
841 sizeof(struct cx23885_buffer), port);
843 err = dvb_register(port);
845 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
851 int cx23885_dvb_unregister(struct cx23885_tsport *port)
853 struct videobuf_dvb_frontend *fe0;
855 /* FIXME: in an error condition where the we have
856 * an expected number of frontends (attach problem)
857 * then this might not clean up correctly, if 1
859 * This comment only applies to future boards IF they
860 * implement MFE support.
862 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
863 if (fe0->dvb.frontend)
864 videobuf_dvb_unregister_bus(&port->frontends);
866 switch (port->dev->board) {
867 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: