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"
53 #include "netup-eeprom.h"
54 #include "netup-init.h"
57 static unsigned int debug
;
59 #define dprintk(level, fmt, arg...)\
60 do { if (debug >= level)\
61 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
64 /* ------------------------------------------------------------------ */
66 static unsigned int alt_tuner
;
67 module_param(alt_tuner
, int, 0644);
68 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
70 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
72 /* ------------------------------------------------------------------ */
74 static int dvb_buf_setup(struct videobuf_queue
*q
,
75 unsigned int *count
, unsigned int *size
)
77 struct cx23885_tsport
*port
= q
->priv_data
;
79 port
->ts_packet_size
= 188 * 4;
80 port
->ts_packet_count
= 32;
82 *size
= port
->ts_packet_size
* port
->ts_packet_count
;
87 static int dvb_buf_prepare(struct videobuf_queue
*q
,
88 struct videobuf_buffer
*vb
, enum v4l2_field field
)
90 struct cx23885_tsport
*port
= q
->priv_data
;
91 return cx23885_buf_prepare(q
, port
, (struct cx23885_buffer
*)vb
, field
);
94 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
96 struct cx23885_tsport
*port
= q
->priv_data
;
97 cx23885_buf_queue(port
, (struct cx23885_buffer
*)vb
);
100 static void dvb_buf_release(struct videobuf_queue
*q
,
101 struct videobuf_buffer
*vb
)
103 cx23885_free_buffer(q
, (struct cx23885_buffer
*)vb
);
106 static struct videobuf_queue_ops dvb_qops
= {
107 .buf_setup
= dvb_buf_setup
,
108 .buf_prepare
= dvb_buf_prepare
,
109 .buf_queue
= dvb_buf_queue
,
110 .buf_release
= dvb_buf_release
,
113 static struct s5h1409_config hauppauge_generic_config
= {
114 .demod_address
= 0x32 >> 1,
115 .output_mode
= S5H1409_SERIAL_OUTPUT
,
116 .gpio
= S5H1409_GPIO_ON
,
118 .inversion
= S5H1409_INVERSION_OFF
,
119 .status_mode
= S5H1409_DEMODLOCKING
,
120 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
123 static struct tda10048_config hauppauge_hvr1200_config
= {
124 .demod_address
= 0x10 >> 1,
125 .output_mode
= TDA10048_SERIAL_OUTPUT
,
126 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
127 .inversion
= TDA10048_INVERSION_ON
,
128 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
129 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
130 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
131 .clk_freq_khz
= TDA10048_CLK_16000
,
134 static struct tda10048_config hauppauge_hvr1210_config
= {
135 .demod_address
= 0x10 >> 1,
136 .output_mode
= TDA10048_SERIAL_OUTPUT
,
137 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
138 .inversion
= TDA10048_INVERSION_ON
,
139 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
140 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
141 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
142 .clk_freq_khz
= TDA10048_CLK_16000
,
145 static struct s5h1409_config hauppauge_ezqam_config
= {
146 .demod_address
= 0x32 >> 1,
147 .output_mode
= S5H1409_SERIAL_OUTPUT
,
148 .gpio
= S5H1409_GPIO_OFF
,
150 .inversion
= S5H1409_INVERSION_ON
,
151 .status_mode
= S5H1409_DEMODLOCKING
,
152 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
155 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
156 .demod_address
= 0x32 >> 1,
157 .output_mode
= S5H1409_SERIAL_OUTPUT
,
158 .gpio
= S5H1409_GPIO_OFF
,
160 .inversion
= S5H1409_INVERSION_OFF
,
161 .status_mode
= S5H1409_DEMODLOCKING
,
162 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
165 static struct s5h1409_config hauppauge_hvr1500_config
= {
166 .demod_address
= 0x32 >> 1,
167 .output_mode
= S5H1409_SERIAL_OUTPUT
,
168 .gpio
= S5H1409_GPIO_OFF
,
169 .inversion
= S5H1409_INVERSION_OFF
,
170 .status_mode
= S5H1409_DEMODLOCKING
,
171 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
174 static struct mt2131_config hauppauge_generic_tunerconfig
= {
178 static struct lgdt330x_config fusionhdtv_5_express
= {
179 .demod_address
= 0x0e,
180 .demod_chip
= LGDT3303
,
184 static struct s5h1409_config hauppauge_hvr1500q_config
= {
185 .demod_address
= 0x32 >> 1,
186 .output_mode
= S5H1409_SERIAL_OUTPUT
,
187 .gpio
= S5H1409_GPIO_ON
,
189 .inversion
= S5H1409_INVERSION_OFF
,
190 .status_mode
= S5H1409_DEMODLOCKING
,
191 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
194 static struct s5h1409_config dvico_s5h1409_config
= {
195 .demod_address
= 0x32 >> 1,
196 .output_mode
= S5H1409_SERIAL_OUTPUT
,
197 .gpio
= S5H1409_GPIO_ON
,
199 .inversion
= S5H1409_INVERSION_OFF
,
200 .status_mode
= S5H1409_DEMODLOCKING
,
201 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
204 static struct s5h1411_config dvico_s5h1411_config
= {
205 .output_mode
= S5H1411_SERIAL_OUTPUT
,
206 .gpio
= S5H1411_GPIO_ON
,
207 .qam_if
= S5H1411_IF_44000
,
208 .vsb_if
= S5H1411_IF_44000
,
209 .inversion
= S5H1411_INVERSION_OFF
,
210 .status_mode
= S5H1411_DEMODLOCKING
,
211 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
214 static struct s5h1411_config hcw_s5h1411_config
= {
215 .output_mode
= S5H1411_SERIAL_OUTPUT
,
216 .gpio
= S5H1411_GPIO_OFF
,
217 .vsb_if
= S5H1411_IF_44000
,
218 .qam_if
= S5H1411_IF_4000
,
219 .inversion
= S5H1411_INVERSION_ON
,
220 .status_mode
= S5H1411_DEMODLOCKING
,
221 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
224 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
229 static struct xc5000_config dvico_xc5000_tunerconfig
= {
234 static struct tda829x_config tda829x_no_probe
= {
235 .probe_tuner
= TDA829X_DONT_PROBE
,
238 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
239 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
240 .if_lvl
= 6, .rfagc_top
= 0x37 },
241 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
242 .if_lvl
= 6, .rfagc_top
= 0x37 },
245 static struct tda18271_config hauppauge_tda18271_config
= {
246 .std_map
= &hauppauge_tda18271_std_map
,
247 .gate
= TDA18271_GATE_ANALOG
,
250 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
251 .gate
= TDA18271_GATE_ANALOG
,
254 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
255 .gate
= TDA18271_GATE_DIGITAL
,
258 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
259 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
260 .if_lvl
= 1, .rfagc_top
= 0x58 },
261 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
262 .if_lvl
= 1, .rfagc_top
= 0x58 },
265 static struct tda18271_config hauppauge_hvr127x_config
= {
266 .std_map
= &hauppauge_hvr127x_std_map
,
269 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
271 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
272 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
273 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
275 .spectral_inversion
= 1,
280 static struct dibx000_agc_config xc3028_agc_config
= {
281 BAND_VHF
| BAND_UHF
, /* band_caps */
283 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
284 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
285 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
286 * P_agc_nb_est=2, P_agc_write=0
288 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
289 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
292 21, /* time_stabiliz */
304 39718, /* agc2_max */
313 29, /* agc2_slope1 */
314 29, /* agc2_slope2 */
321 1, /* perform_agc_softsplit */
324 /* PLL Configuration for COFDM BW_MHz = 8.000000
325 * With external clock = 30.000000 */
326 static struct dibx000_bandwidth_config xc3028_bw_config
= {
327 60000, /* internal */
328 30000, /* sampling */
329 1, /* pll_cfg: prediv */
330 8, /* pll_cfg: ratio */
331 3, /* pll_cfg: range */
332 1, /* pll_cfg: reset */
333 0, /* pll_cfg: bypass */
334 0, /* misc: refdiv */
335 0, /* misc: bypclk_div */
336 1, /* misc: IO_CLK_en_core */
337 1, /* misc: ADClkSrc */
338 0, /* misc: modulo */
339 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
340 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
342 30000000 /* xtal_hz */
345 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
346 .output_mpeg2_in_188_bytes
= 1,
347 .hostbus_diversity
= 1,
348 .tuner_is_baseband
= 0,
351 .agc_config_count
= 1,
352 .agc
= &xc3028_agc_config
,
353 .bw
= &xc3028_bw_config
,
355 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
356 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
357 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
363 .output_mode
= OUTMODE_MPEG2_SERIAL
,
366 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
367 .demod_address
= 0x0f,
370 .disable_i2c_gate_ctrl
= 1,
373 static struct stv0900_config netup_stv0900_config
= {
374 .demod_address
= 0x68,
376 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
377 .diseqc_mode
= 2,/* 2/3 PWM */
378 .path1_mode
= 2,/*Serial continues clock */
379 .path2_mode
= 2,/*Serial continues clock */
380 .tun1_maddress
= 0,/* 0x60 */
381 .tun2_maddress
= 3,/* 0x63 */
382 .tun1_adc
= 1,/* 1 Vpp */
383 .tun2_adc
= 1,/* 1 Vpp */
386 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
392 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
398 static int tbs_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
400 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
401 struct cx23885_dev
*dev
= port
->dev
;
403 if (voltage
== SEC_VOLTAGE_18
)
404 cx_write(MC417_RWD
, 0x00001e00);/* GPIO-13 high */
405 else if (voltage
== SEC_VOLTAGE_13
)
406 cx_write(MC417_RWD
, 0x00001a00);/* GPIO-13 low */
408 cx_write(MC417_RWD
, 0x00001800);/* GPIO-12 low */
412 static struct cx24116_config tbs_cx24116_config
= {
413 .demod_address
= 0x05,
416 static struct cx24116_config tevii_cx24116_config
= {
417 .demod_address
= 0x55,
420 static struct cx24116_config dvbworld_cx24116_config
= {
421 .demod_address
= 0x05,
424 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
425 .prod
= LGS8GXX_PROD_LGS8GL5
,
426 .demod_address
= 0x19,
430 .if_clk_freq
= 30400, /* 30.4 MHz */
431 .if_freq
= 5380, /* 5.38 MHz */
438 static struct xc5000_config mygica_x8506_xc5000_config
= {
443 static int dvb_register(struct cx23885_tsport
*port
)
445 struct cx23885_dev
*dev
= port
->dev
;
446 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
447 struct videobuf_dvb_frontend
*fe0
;
450 /* Get the first frontend */
451 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
455 /* init struct videobuf_dvb */
456 fe0
->dvb
.name
= dev
->name
;
459 switch (dev
->board
) {
460 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
461 i2c_bus
= &dev
->i2c_bus
[0];
462 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
463 &hauppauge_generic_config
,
465 if (fe0
->dvb
.frontend
!= NULL
) {
466 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
468 &hauppauge_generic_tunerconfig
, 0);
471 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
472 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
473 i2c_bus
= &dev
->i2c_bus
[0];
474 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
475 &hauppauge_lgdt3305_config
,
477 if (fe0
->dvb
.frontend
!= NULL
) {
478 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
479 0x60, &dev
->i2c_bus
[1].i2c_adap
,
480 &hauppauge_hvr127x_config
);
483 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
484 i2c_bus
= &dev
->i2c_bus
[0];
485 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
488 if (fe0
->dvb
.frontend
!= NULL
) {
489 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
490 0x60, &dev
->i2c_bus
[1].i2c_adap
,
491 &hauppauge_tda18271_config
);
494 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
495 i2c_bus
= &dev
->i2c_bus
[0];
499 dvb_attach(s5h1409_attach
,
500 &hauppauge_ezqam_config
,
502 if (fe0
->dvb
.frontend
!= NULL
) {
503 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
504 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
506 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
507 0x60, &dev
->i2c_bus
[1].i2c_adap
,
508 &hauppauge_tda18271_config
);
514 dvb_attach(s5h1409_attach
,
515 &hauppauge_generic_config
,
517 if (fe0
->dvb
.frontend
!= NULL
)
518 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
520 &hauppauge_generic_tunerconfig
, 0);
524 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
525 i2c_bus
= &dev
->i2c_bus
[0];
526 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
527 &hauppauge_hvr1800lp_config
,
529 if (fe0
->dvb
.frontend
!= NULL
) {
530 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
532 &hauppauge_generic_tunerconfig
, 0);
535 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
536 i2c_bus
= &dev
->i2c_bus
[0];
537 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
538 &fusionhdtv_5_express
,
540 if (fe0
->dvb
.frontend
!= NULL
) {
541 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
542 &i2c_bus
->i2c_adap
, 0x61,
543 TUNER_LG_TDVS_H06XF
);
546 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
547 i2c_bus
= &dev
->i2c_bus
[1];
548 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
549 &hauppauge_hvr1500q_config
,
550 &dev
->i2c_bus
[0].i2c_adap
);
551 if (fe0
->dvb
.frontend
!= NULL
)
552 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
554 &hauppauge_hvr1500q_tunerconfig
);
556 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
557 i2c_bus
= &dev
->i2c_bus
[1];
558 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
559 &hauppauge_hvr1500_config
,
560 &dev
->i2c_bus
[0].i2c_adap
);
561 if (fe0
->dvb
.frontend
!= NULL
) {
562 struct dvb_frontend
*fe
;
563 struct xc2028_config cfg
= {
564 .i2c_adap
= &i2c_bus
->i2c_adap
,
567 static struct xc2028_ctrl ctl
= {
568 .fname
= XC2028_DEFAULT_FIRMWARE
,
570 .demod
= XC3028_FE_OREN538
,
573 fe
= dvb_attach(xc2028_attach
,
574 fe0
->dvb
.frontend
, &cfg
);
575 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
576 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
579 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
580 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
581 i2c_bus
= &dev
->i2c_bus
[0];
582 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
583 &hauppauge_hvr1200_config
,
585 if (fe0
->dvb
.frontend
!= NULL
) {
586 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
587 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
589 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
590 0x60, &dev
->i2c_bus
[1].i2c_adap
,
591 &hauppauge_hvr1200_tuner_config
);
594 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
595 i2c_bus
= &dev
->i2c_bus
[0];
596 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
597 &hauppauge_hvr1210_config
,
599 if (fe0
->dvb
.frontend
!= NULL
) {
600 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
601 0x60, &dev
->i2c_bus
[1].i2c_adap
,
602 &hauppauge_hvr1210_tuner_config
);
605 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
606 i2c_bus
= &dev
->i2c_bus
[0];
607 fe0
->dvb
.frontend
= dvb_attach(dib7000p_attach
,
609 0x12, &hauppauge_hvr1400_dib7000_config
);
610 if (fe0
->dvb
.frontend
!= NULL
) {
611 struct dvb_frontend
*fe
;
612 struct xc2028_config cfg
= {
613 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
616 static struct xc2028_ctrl ctl
= {
617 .fname
= XC3028L_DEFAULT_FIRMWARE
,
620 /* This is true for all demods with
622 .type
= XC2028_D2633
,
625 fe
= dvb_attach(xc2028_attach
,
626 fe0
->dvb
.frontend
, &cfg
);
627 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
628 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
631 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
632 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
634 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
635 &dvico_s5h1409_config
,
637 if (fe0
->dvb
.frontend
== NULL
)
638 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
639 &dvico_s5h1411_config
,
641 if (fe0
->dvb
.frontend
!= NULL
)
642 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
644 &dvico_xc5000_tunerconfig
);
646 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
647 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
649 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
650 &dvico_fusionhdtv_xc3028
,
652 if (fe0
->dvb
.frontend
!= NULL
) {
653 struct dvb_frontend
*fe
;
654 struct xc2028_config cfg
= {
655 .i2c_adap
= &i2c_bus
->i2c_adap
,
658 static struct xc2028_ctrl ctl
= {
659 .fname
= XC2028_DEFAULT_FIRMWARE
,
661 .demod
= XC3028_FE_ZARLINK456
,
664 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
666 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
667 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
671 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
672 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
673 i2c_bus
= &dev
->i2c_bus
[0];
675 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
676 &dvico_fusionhdtv_xc3028
,
678 if (fe0
->dvb
.frontend
!= NULL
) {
679 struct dvb_frontend
*fe
;
680 struct xc2028_config cfg
= {
681 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
684 static struct xc2028_ctrl ctl
= {
685 .fname
= XC2028_DEFAULT_FIRMWARE
,
687 .demod
= XC3028_FE_ZARLINK456
,
690 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
692 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
693 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
696 case CX23885_BOARD_TBS_6920
:
697 i2c_bus
= &dev
->i2c_bus
[0];
699 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
702 if (fe0
->dvb
.frontend
!= NULL
)
703 fe0
->dvb
.frontend
->ops
.set_voltage
= tbs_set_voltage
;
706 case CX23885_BOARD_TEVII_S470
:
707 i2c_bus
= &dev
->i2c_bus
[1];
709 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
710 &tevii_cx24116_config
,
712 if (fe0
->dvb
.frontend
!= NULL
)
713 fe0
->dvb
.frontend
->ops
.set_voltage
= tbs_set_voltage
;
716 case CX23885_BOARD_DVBWORLD_2005
:
717 i2c_bus
= &dev
->i2c_bus
[1];
719 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
720 &dvbworld_cx24116_config
,
723 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
724 i2c_bus
= &dev
->i2c_bus
[0];
728 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
729 &netup_stv0900_config
,
730 &i2c_bus
->i2c_adap
, 0);
731 if (fe0
->dvb
.frontend
!= NULL
) {
732 if (dvb_attach(stv6110_attach
,
734 &netup_stv6110_tunerconfig_a
,
735 &i2c_bus
->i2c_adap
)) {
736 if (!dvb_attach(lnbh24_attach
,
739 LNBH24_PCL
, 0, 0x09))
741 "No LNBH24 found!\n");
748 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
749 &netup_stv0900_config
,
750 &i2c_bus
->i2c_adap
, 1);
751 if (fe0
->dvb
.frontend
!= NULL
) {
752 if (dvb_attach(stv6110_attach
,
754 &netup_stv6110_tunerconfig_b
,
755 &i2c_bus
->i2c_adap
)) {
756 if (!dvb_attach(lnbh24_attach
,
759 LNBH24_PCL
, 0, 0x0a))
761 "No LNBH24 found!\n");
768 case CX23885_BOARD_MYGICA_X8506
:
769 i2c_bus
= &dev
->i2c_bus
[0];
770 i2c_bus2
= &dev
->i2c_bus
[1];
771 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
772 &mygica_x8506_lgs8gl5_config
,
774 if (fe0
->dvb
.frontend
!= NULL
) {
775 dvb_attach(xc5000_attach
,
778 &mygica_x8506_xc5000_config
);
782 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
783 " isn't supported yet\n",
787 if (NULL
== fe0
->dvb
.frontend
) {
788 printk(KERN_ERR
"%s: frontend initialization failed\n",
792 /* define general-purpose callback pointer */
793 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
795 /* Put the analog decoder in standby to keep it quiet */
796 call_all(dev
, tuner
, s_standby
);
798 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
799 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
801 /* register everything */
802 ret
= videobuf_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
803 &dev
->pci
->dev
, adapter_nr
, 0);
806 switch (dev
->board
) {
807 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
808 static struct netup_card_info cinfo
;
810 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
811 memcpy(port
->frontends
.adapter
.proposed_mac
,
812 cinfo
.port
[port
->nr
- 1].mac
, 6);
813 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC="
814 "%02X:%02X:%02X:%02X:%02X:%02X\n",
816 port
->frontends
.adapter
.proposed_mac
[0],
817 port
->frontends
.adapter
.proposed_mac
[1],
818 port
->frontends
.adapter
.proposed_mac
[2],
819 port
->frontends
.adapter
.proposed_mac
[3],
820 port
->frontends
.adapter
.proposed_mac
[4],
821 port
->frontends
.adapter
.proposed_mac
[5]);
831 int cx23885_dvb_register(struct cx23885_tsport
*port
)
834 struct videobuf_dvb_frontend
*fe0
;
835 struct cx23885_dev
*dev
= port
->dev
;
838 /* Here we need to allocate the correct number of frontends,
839 * as reflected in the cards struct. The reality is that currrently
840 * no cx23885 boards support this - yet. But, if we don't modify this
841 * code then the second frontend would never be allocated (later)
842 * and fail with error before the attach in dvb_register().
843 * Without these changes we risk an OOPS later. The changes here
844 * are for safety, and should provide a good foundation for the
845 * future addition of any multi-frontend cx23885 based boards.
847 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
848 port
->num_frontends
);
850 for (i
= 1; i
<= port
->num_frontends
; i
++) {
851 if (videobuf_dvb_alloc_frontend(
852 &port
->frontends
, i
) == NULL
) {
853 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
857 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, i
);
861 dprintk(1, "%s\n", __func__
);
862 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
871 /* We have to init the queue for each frontend on a port. */
872 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
873 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &dvb_qops
,
874 &dev
->pci
->dev
, &port
->slock
,
875 V4L2_BUF_TYPE_VIDEO_CAPTURE
, V4L2_FIELD_TOP
,
876 sizeof(struct cx23885_buffer
), port
);
878 err
= dvb_register(port
);
880 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
886 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
888 struct videobuf_dvb_frontend
*fe0
;
890 /* FIXME: in an error condition where the we have
891 * an expected number of frontends (attach problem)
892 * then this might not clean up correctly, if 1
894 * This comment only applies to future boards IF they
895 * implement MFE support.
897 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
898 if (fe0
->dvb
.frontend
)
899 videobuf_dvb_unregister_bus(&port
->frontends
);
901 switch (port
->dev
->board
) {
902 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: