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 .dtv6_if_freq_khz = TDA10048_IF_3300,
139 .dtv7_if_freq_khz = TDA10048_IF_3500,
140 .dtv8_if_freq_khz = TDA10048_IF_4000,
141 .clk_freq_khz = TDA10048_CLK_16000,
144 static struct s5h1409_config hauppauge_ezqam_config = {
145 .demod_address = 0x32 >> 1,
146 .output_mode = S5H1409_SERIAL_OUTPUT,
147 .gpio = S5H1409_GPIO_OFF,
149 .inversion = S5H1409_INVERSION_ON,
150 .status_mode = S5H1409_DEMODLOCKING,
151 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
154 static struct s5h1409_config hauppauge_hvr1800lp_config = {
155 .demod_address = 0x32 >> 1,
156 .output_mode = S5H1409_SERIAL_OUTPUT,
157 .gpio = S5H1409_GPIO_OFF,
159 .inversion = S5H1409_INVERSION_OFF,
160 .status_mode = S5H1409_DEMODLOCKING,
161 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
164 static struct s5h1409_config hauppauge_hvr1500_config = {
165 .demod_address = 0x32 >> 1,
166 .output_mode = S5H1409_SERIAL_OUTPUT,
167 .gpio = S5H1409_GPIO_OFF,
168 .inversion = S5H1409_INVERSION_OFF,
169 .status_mode = S5H1409_DEMODLOCKING,
170 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
173 static struct mt2131_config hauppauge_generic_tunerconfig = {
177 static struct lgdt330x_config fusionhdtv_5_express = {
178 .demod_address = 0x0e,
179 .demod_chip = LGDT3303,
183 static struct s5h1409_config hauppauge_hvr1500q_config = {
184 .demod_address = 0x32 >> 1,
185 .output_mode = S5H1409_SERIAL_OUTPUT,
186 .gpio = S5H1409_GPIO_ON,
188 .inversion = S5H1409_INVERSION_OFF,
189 .status_mode = S5H1409_DEMODLOCKING,
190 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
193 static struct s5h1409_config dvico_s5h1409_config = {
194 .demod_address = 0x32 >> 1,
195 .output_mode = S5H1409_SERIAL_OUTPUT,
196 .gpio = S5H1409_GPIO_ON,
198 .inversion = S5H1409_INVERSION_OFF,
199 .status_mode = S5H1409_DEMODLOCKING,
200 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
203 static struct s5h1411_config dvico_s5h1411_config = {
204 .output_mode = S5H1411_SERIAL_OUTPUT,
205 .gpio = S5H1411_GPIO_ON,
206 .qam_if = S5H1411_IF_44000,
207 .vsb_if = S5H1411_IF_44000,
208 .inversion = S5H1411_INVERSION_OFF,
209 .status_mode = S5H1411_DEMODLOCKING,
210 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
213 static struct s5h1411_config hcw_s5h1411_config = {
214 .output_mode = S5H1411_SERIAL_OUTPUT,
215 .gpio = S5H1411_GPIO_OFF,
216 .vsb_if = S5H1411_IF_44000,
217 .qam_if = S5H1411_IF_4000,
218 .inversion = S5H1411_INVERSION_ON,
219 .status_mode = S5H1411_DEMODLOCKING,
220 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
223 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
228 static struct xc5000_config dvico_xc5000_tunerconfig = {
233 static struct tda829x_config tda829x_no_probe = {
234 .probe_tuner = TDA829X_DONT_PROBE,
237 static struct tda18271_std_map hauppauge_tda18271_std_map = {
238 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
239 .if_lvl = 6, .rfagc_top = 0x37 },
240 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
241 .if_lvl = 6, .rfagc_top = 0x37 },
244 static struct tda18271_config hauppauge_tda18271_config = {
245 .std_map = &hauppauge_tda18271_std_map,
246 .gate = TDA18271_GATE_ANALOG,
249 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
250 .gate = TDA18271_GATE_ANALOG,
253 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
254 .gate = TDA18271_GATE_DIGITAL,
257 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
258 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
259 .if_lvl = 1, .rfagc_top = 0x58 },
260 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
261 .if_lvl = 1, .rfagc_top = 0x58 },
264 static struct tda18271_config hauppauge_hvr127x_config = {
265 .std_map = &hauppauge_hvr127x_std_map,
268 static struct lgdt3305_config hauppauge_lgdt3305_config = {
270 .mpeg_mode = LGDT3305_MPEG_SERIAL,
271 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
272 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
274 .spectral_inversion = 1,
279 static struct dibx000_agc_config xc3028_agc_config = {
280 BAND_VHF | BAND_UHF, /* band_caps */
282 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
283 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
284 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
285 * P_agc_nb_est=2, P_agc_write=0
287 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
288 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
291 21, /* time_stabiliz */
303 39718, /* agc2_max */
312 29, /* agc2_slope1 */
313 29, /* agc2_slope2 */
320 1, /* perform_agc_softsplit */
323 /* PLL Configuration for COFDM BW_MHz = 8.000000
324 * With external clock = 30.000000 */
325 static struct dibx000_bandwidth_config xc3028_bw_config = {
326 60000, /* internal */
327 30000, /* sampling */
328 1, /* pll_cfg: prediv */
329 8, /* pll_cfg: ratio */
330 3, /* pll_cfg: range */
331 1, /* pll_cfg: reset */
332 0, /* pll_cfg: bypass */
333 0, /* misc: refdiv */
334 0, /* misc: bypclk_div */
335 1, /* misc: IO_CLK_en_core */
336 1, /* misc: ADClkSrc */
337 0, /* misc: modulo */
338 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
339 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
341 30000000 /* xtal_hz */
344 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
345 .output_mpeg2_in_188_bytes = 1,
346 .hostbus_diversity = 1,
347 .tuner_is_baseband = 0,
350 .agc_config_count = 1,
351 .agc = &xc3028_agc_config,
352 .bw = &xc3028_bw_config,
354 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
355 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
356 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
362 .output_mode = OUTMODE_MPEG2_SERIAL,
365 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
366 .demod_address = 0x0f,
369 .disable_i2c_gate_ctrl = 1,
372 static struct stv0900_config netup_stv0900_config = {
373 .demod_address = 0x68,
375 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
376 .diseqc_mode = 2,/* 2/3 PWM */
377 .path1_mode = 2,/*Serial continues clock */
378 .path2_mode = 2,/*Serial continues clock */
379 .tun1_maddress = 0,/* 0x60 */
380 .tun2_maddress = 3,/* 0x63 */
381 .tun1_adc = 1,/* 1 Vpp */
382 .tun2_adc = 1,/* 1 Vpp */
385 static struct stv6110_config netup_stv6110_tunerconfig_a = {
391 static struct stv6110_config netup_stv6110_tunerconfig_b = {
397 static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
399 struct cx23885_tsport *port = fe->dvb->priv;
400 struct cx23885_dev *dev = port->dev;
402 if (voltage == SEC_VOLTAGE_18)
403 cx_write(MC417_RWD, 0x00001e00);/* GPIO-13 high */
404 else if (voltage == SEC_VOLTAGE_13)
405 cx_write(MC417_RWD, 0x00001a00);/* GPIO-13 low */
407 cx_write(MC417_RWD, 0x00001800);/* GPIO-12 low */
411 static struct cx24116_config tbs_cx24116_config = {
412 .demod_address = 0x05,
415 static struct cx24116_config tevii_cx24116_config = {
416 .demod_address = 0x55,
419 static struct cx24116_config dvbworld_cx24116_config = {
420 .demod_address = 0x05,
423 static int dvb_register(struct cx23885_tsport *port)
425 struct cx23885_dev *dev = port->dev;
426 struct cx23885_i2c *i2c_bus = NULL;
427 struct videobuf_dvb_frontend *fe0;
430 /* Get the first frontend */
431 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
435 /* init struct videobuf_dvb */
436 fe0->dvb.name = dev->name;
439 switch (dev->board) {
440 case CX23885_BOARD_HAUPPAUGE_HVR1250:
441 i2c_bus = &dev->i2c_bus[0];
442 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
443 &hauppauge_generic_config,
445 if (fe0->dvb.frontend != NULL) {
446 dvb_attach(mt2131_attach, fe0->dvb.frontend,
448 &hauppauge_generic_tunerconfig, 0);
451 case CX23885_BOARD_HAUPPAUGE_HVR1270:
452 case CX23885_BOARD_HAUPPAUGE_HVR1275:
453 i2c_bus = &dev->i2c_bus[0];
454 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
455 &hauppauge_lgdt3305_config,
457 if (fe0->dvb.frontend != NULL) {
458 dvb_attach(tda18271_attach, fe0->dvb.frontend,
459 0x60, &dev->i2c_bus[1].i2c_adap,
460 &hauppauge_hvr127x_config);
463 case CX23885_BOARD_HAUPPAUGE_HVR1255:
464 i2c_bus = &dev->i2c_bus[0];
465 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
468 if (fe0->dvb.frontend != NULL) {
469 dvb_attach(tda18271_attach, fe0->dvb.frontend,
470 0x60, &dev->i2c_bus[1].i2c_adap,
471 &hauppauge_tda18271_config);
474 case CX23885_BOARD_HAUPPAUGE_HVR1800:
475 i2c_bus = &dev->i2c_bus[0];
479 dvb_attach(s5h1409_attach,
480 &hauppauge_ezqam_config,
482 if (fe0->dvb.frontend != NULL) {
483 dvb_attach(tda829x_attach, fe0->dvb.frontend,
484 &dev->i2c_bus[1].i2c_adap, 0x42,
486 dvb_attach(tda18271_attach, fe0->dvb.frontend,
487 0x60, &dev->i2c_bus[1].i2c_adap,
488 &hauppauge_tda18271_config);
494 dvb_attach(s5h1409_attach,
495 &hauppauge_generic_config,
497 if (fe0->dvb.frontend != NULL)
498 dvb_attach(mt2131_attach, fe0->dvb.frontend,
500 &hauppauge_generic_tunerconfig, 0);
504 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
505 i2c_bus = &dev->i2c_bus[0];
506 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
507 &hauppauge_hvr1800lp_config,
509 if (fe0->dvb.frontend != NULL) {
510 dvb_attach(mt2131_attach, fe0->dvb.frontend,
512 &hauppauge_generic_tunerconfig, 0);
515 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
516 i2c_bus = &dev->i2c_bus[0];
517 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
518 &fusionhdtv_5_express,
520 if (fe0->dvb.frontend != NULL) {
521 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
522 &i2c_bus->i2c_adap, 0x61,
523 TUNER_LG_TDVS_H06XF);
526 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
527 i2c_bus = &dev->i2c_bus[1];
528 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
529 &hauppauge_hvr1500q_config,
530 &dev->i2c_bus[0].i2c_adap);
531 if (fe0->dvb.frontend != NULL)
532 dvb_attach(xc5000_attach, fe0->dvb.frontend,
534 &hauppauge_hvr1500q_tunerconfig);
536 case CX23885_BOARD_HAUPPAUGE_HVR1500:
537 i2c_bus = &dev->i2c_bus[1];
538 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
539 &hauppauge_hvr1500_config,
540 &dev->i2c_bus[0].i2c_adap);
541 if (fe0->dvb.frontend != NULL) {
542 struct dvb_frontend *fe;
543 struct xc2028_config cfg = {
544 .i2c_adap = &i2c_bus->i2c_adap,
547 static struct xc2028_ctrl ctl = {
548 .fname = XC2028_DEFAULT_FIRMWARE,
550 .demod = XC3028_FE_OREN538,
553 fe = dvb_attach(xc2028_attach,
554 fe0->dvb.frontend, &cfg);
555 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
556 fe->ops.tuner_ops.set_config(fe, &ctl);
559 case CX23885_BOARD_HAUPPAUGE_HVR1200:
560 case CX23885_BOARD_HAUPPAUGE_HVR1700:
561 i2c_bus = &dev->i2c_bus[0];
562 fe0->dvb.frontend = dvb_attach(tda10048_attach,
563 &hauppauge_hvr1200_config,
565 if (fe0->dvb.frontend != NULL) {
566 dvb_attach(tda829x_attach, fe0->dvb.frontend,
567 &dev->i2c_bus[1].i2c_adap, 0x42,
569 dvb_attach(tda18271_attach, fe0->dvb.frontend,
570 0x60, &dev->i2c_bus[1].i2c_adap,
571 &hauppauge_hvr1200_tuner_config);
574 case CX23885_BOARD_HAUPPAUGE_HVR1210:
575 i2c_bus = &dev->i2c_bus[0];
576 fe0->dvb.frontend = dvb_attach(tda10048_attach,
577 &hauppauge_hvr1210_config,
579 if (fe0->dvb.frontend != NULL) {
580 dvb_attach(tda18271_attach, fe0->dvb.frontend,
581 0x60, &dev->i2c_bus[1].i2c_adap,
582 &hauppauge_hvr1210_tuner_config);
585 case CX23885_BOARD_HAUPPAUGE_HVR1400:
586 i2c_bus = &dev->i2c_bus[0];
587 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
589 0x12, &hauppauge_hvr1400_dib7000_config);
590 if (fe0->dvb.frontend != NULL) {
591 struct dvb_frontend *fe;
592 struct xc2028_config cfg = {
593 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
596 static struct xc2028_ctrl ctl = {
597 .fname = XC3028L_DEFAULT_FIRMWARE,
600 /* This is true for all demods with
602 .type = XC2028_D2633,
605 fe = dvb_attach(xc2028_attach,
606 fe0->dvb.frontend, &cfg);
607 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
608 fe->ops.tuner_ops.set_config(fe, &ctl);
611 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
612 i2c_bus = &dev->i2c_bus[port->nr - 1];
614 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
615 &dvico_s5h1409_config,
617 if (fe0->dvb.frontend == NULL)
618 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
619 &dvico_s5h1411_config,
621 if (fe0->dvb.frontend != NULL)
622 dvb_attach(xc5000_attach, fe0->dvb.frontend,
624 &dvico_xc5000_tunerconfig);
626 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
627 i2c_bus = &dev->i2c_bus[port->nr - 1];
629 fe0->dvb.frontend = dvb_attach(zl10353_attach,
630 &dvico_fusionhdtv_xc3028,
632 if (fe0->dvb.frontend != NULL) {
633 struct dvb_frontend *fe;
634 struct xc2028_config cfg = {
635 .i2c_adap = &i2c_bus->i2c_adap,
638 static struct xc2028_ctrl ctl = {
639 .fname = XC2028_DEFAULT_FIRMWARE,
641 .demod = XC3028_FE_ZARLINK456,
644 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
646 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
647 fe->ops.tuner_ops.set_config(fe, &ctl);
651 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
652 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
653 i2c_bus = &dev->i2c_bus[0];
655 fe0->dvb.frontend = dvb_attach(zl10353_attach,
656 &dvico_fusionhdtv_xc3028,
658 if (fe0->dvb.frontend != NULL) {
659 struct dvb_frontend *fe;
660 struct xc2028_config cfg = {
661 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
664 static struct xc2028_ctrl ctl = {
665 .fname = XC2028_DEFAULT_FIRMWARE,
667 .demod = XC3028_FE_ZARLINK456,
670 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
672 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
673 fe->ops.tuner_ops.set_config(fe, &ctl);
676 case CX23885_BOARD_TBS_6920:
677 i2c_bus = &dev->i2c_bus[0];
679 fe0->dvb.frontend = dvb_attach(cx24116_attach,
682 if (fe0->dvb.frontend != NULL)
683 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
686 case CX23885_BOARD_TEVII_S470:
687 i2c_bus = &dev->i2c_bus[1];
689 fe0->dvb.frontend = dvb_attach(cx24116_attach,
690 &tevii_cx24116_config,
692 if (fe0->dvb.frontend != NULL)
693 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
696 case CX23885_BOARD_DVBWORLD_2005:
697 i2c_bus = &dev->i2c_bus[1];
699 fe0->dvb.frontend = dvb_attach(cx24116_attach,
700 &dvbworld_cx24116_config,
703 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
704 i2c_bus = &dev->i2c_bus[0];
708 fe0->dvb.frontend = dvb_attach(stv0900_attach,
709 &netup_stv0900_config,
710 &i2c_bus->i2c_adap, 0);
711 if (fe0->dvb.frontend != NULL) {
712 if (dvb_attach(stv6110_attach,
714 &netup_stv6110_tunerconfig_a,
715 &i2c_bus->i2c_adap)) {
716 if (!dvb_attach(lnbh24_attach,
719 LNBH24_PCL, 0, 0x09))
721 "No LNBH24 found!\n");
728 fe0->dvb.frontend = dvb_attach(stv0900_attach,
729 &netup_stv0900_config,
730 &i2c_bus->i2c_adap, 1);
731 if (fe0->dvb.frontend != NULL) {
732 if (dvb_attach(stv6110_attach,
734 &netup_stv6110_tunerconfig_b,
735 &i2c_bus->i2c_adap)) {
736 if (!dvb_attach(lnbh24_attach,
739 LNBH24_PCL, 0, 0x0a))
741 "No LNBH24 found!\n");
749 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
750 " isn't supported yet\n",
754 if (NULL == fe0->dvb.frontend) {
755 printk(KERN_ERR "%s: frontend initialization failed\n",
759 /* define general-purpose callback pointer */
760 fe0->dvb.frontend->callback = cx23885_tuner_callback;
762 /* Put the analog decoder in standby to keep it quiet */
763 call_all(dev, tuner, s_standby);
765 if (fe0->dvb.frontend->ops.analog_ops.standby)
766 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
768 /* register everything */
769 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
770 &dev->pci->dev, adapter_nr, 0);
773 switch (dev->board) {
774 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
775 static struct netup_card_info cinfo;
777 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
778 memcpy(port->frontends.adapter.proposed_mac,
779 cinfo.port[port->nr - 1].mac, 6);
780 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC="
781 "%02X:%02X:%02X:%02X:%02X:%02X\n",
783 port->frontends.adapter.proposed_mac[0],
784 port->frontends.adapter.proposed_mac[1],
785 port->frontends.adapter.proposed_mac[2],
786 port->frontends.adapter.proposed_mac[3],
787 port->frontends.adapter.proposed_mac[4],
788 port->frontends.adapter.proposed_mac[5]);
798 int cx23885_dvb_register(struct cx23885_tsport *port)
801 struct videobuf_dvb_frontend *fe0;
802 struct cx23885_dev *dev = port->dev;
805 /* Here we need to allocate the correct number of frontends,
806 * as reflected in the cards struct. The reality is that currrently
807 * no cx23885 boards support this - yet. But, if we don't modify this
808 * code then the second frontend would never be allocated (later)
809 * and fail with error before the attach in dvb_register().
810 * Without these changes we risk an OOPS later. The changes here
811 * are for safety, and should provide a good foundation for the
812 * future addition of any multi-frontend cx23885 based boards.
814 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
815 port->num_frontends);
817 for (i = 1; i <= port->num_frontends; i++) {
818 if (videobuf_dvb_alloc_frontend(
819 &port->frontends, i) == NULL) {
820 printk(KERN_ERR "%s() failed to alloc\n", __func__);
824 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
828 dprintk(1, "%s\n", __func__);
829 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
838 /* We have to init the queue for each frontend on a port. */
839 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
840 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
841 &dev->pci->dev, &port->slock,
842 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
843 sizeof(struct cx23885_buffer), port);
845 err = dvb_register(port);
847 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
853 int cx23885_dvb_unregister(struct cx23885_tsport *port)
855 struct videobuf_dvb_frontend *fe0;
857 /* FIXME: in an error condition where the we have
858 * an expected number of frontends (attach problem)
859 * then this might not clean up correctly, if 1
861 * This comment only applies to future boards IF they
862 * implement MFE support.
864 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
865 if (fe0->dvb.frontend)
866 videobuf_dvb_unregister_bus(&port->frontends);
868 switch (port->dev->board) {
869 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: