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"
43 #include "tuner-xc2028.h"
44 #include "tuner-simple.h"
46 #include "dibx000_common.h"
49 #include "stv0900_reg.h"
55 #include "netup-eeprom.h"
56 #include "netup-init.h"
60 #include "cx23885-f300.h"
62 static unsigned int debug
;
64 #define dprintk(level, fmt, arg...)\
65 do { if (debug >= level)\
66 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
69 /* ------------------------------------------------------------------ */
71 static unsigned int alt_tuner
;
72 module_param(alt_tuner
, int, 0644);
73 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
75 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
77 /* ------------------------------------------------------------------ */
79 static int dvb_buf_setup(struct videobuf_queue
*q
,
80 unsigned int *count
, unsigned int *size
)
82 struct cx23885_tsport
*port
= q
->priv_data
;
84 port
->ts_packet_size
= 188 * 4;
85 port
->ts_packet_count
= 32;
87 *size
= port
->ts_packet_size
* port
->ts_packet_count
;
92 static int dvb_buf_prepare(struct videobuf_queue
*q
,
93 struct videobuf_buffer
*vb
, enum v4l2_field field
)
95 struct cx23885_tsport
*port
= q
->priv_data
;
96 return cx23885_buf_prepare(q
, port
, (struct cx23885_buffer
*)vb
, field
);
99 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
101 struct cx23885_tsport
*port
= q
->priv_data
;
102 cx23885_buf_queue(port
, (struct cx23885_buffer
*)vb
);
105 static void dvb_buf_release(struct videobuf_queue
*q
,
106 struct videobuf_buffer
*vb
)
108 cx23885_free_buffer(q
, (struct cx23885_buffer
*)vb
);
111 static struct videobuf_queue_ops dvb_qops
= {
112 .buf_setup
= dvb_buf_setup
,
113 .buf_prepare
= dvb_buf_prepare
,
114 .buf_queue
= dvb_buf_queue
,
115 .buf_release
= dvb_buf_release
,
118 static struct s5h1409_config hauppauge_generic_config
= {
119 .demod_address
= 0x32 >> 1,
120 .output_mode
= S5H1409_SERIAL_OUTPUT
,
121 .gpio
= S5H1409_GPIO_ON
,
123 .inversion
= S5H1409_INVERSION_OFF
,
124 .status_mode
= S5H1409_DEMODLOCKING
,
125 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
128 static struct tda10048_config hauppauge_hvr1200_config
= {
129 .demod_address
= 0x10 >> 1,
130 .output_mode
= TDA10048_SERIAL_OUTPUT
,
131 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
132 .inversion
= TDA10048_INVERSION_ON
,
133 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
134 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
135 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
136 .clk_freq_khz
= TDA10048_CLK_16000
,
139 static struct tda10048_config hauppauge_hvr1210_config
= {
140 .demod_address
= 0x10 >> 1,
141 .output_mode
= TDA10048_SERIAL_OUTPUT
,
142 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
143 .inversion
= TDA10048_INVERSION_ON
,
144 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
145 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
146 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
147 .clk_freq_khz
= TDA10048_CLK_16000
,
150 static struct s5h1409_config hauppauge_ezqam_config
= {
151 .demod_address
= 0x32 >> 1,
152 .output_mode
= S5H1409_SERIAL_OUTPUT
,
153 .gpio
= S5H1409_GPIO_OFF
,
155 .inversion
= S5H1409_INVERSION_ON
,
156 .status_mode
= S5H1409_DEMODLOCKING
,
157 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
160 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
161 .demod_address
= 0x32 >> 1,
162 .output_mode
= S5H1409_SERIAL_OUTPUT
,
163 .gpio
= S5H1409_GPIO_OFF
,
165 .inversion
= S5H1409_INVERSION_OFF
,
166 .status_mode
= S5H1409_DEMODLOCKING
,
167 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
170 static struct s5h1409_config hauppauge_hvr1500_config
= {
171 .demod_address
= 0x32 >> 1,
172 .output_mode
= S5H1409_SERIAL_OUTPUT
,
173 .gpio
= S5H1409_GPIO_OFF
,
174 .inversion
= S5H1409_INVERSION_OFF
,
175 .status_mode
= S5H1409_DEMODLOCKING
,
176 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
179 static struct mt2131_config hauppauge_generic_tunerconfig
= {
183 static struct lgdt330x_config fusionhdtv_5_express
= {
184 .demod_address
= 0x0e,
185 .demod_chip
= LGDT3303
,
189 static struct s5h1409_config hauppauge_hvr1500q_config
= {
190 .demod_address
= 0x32 >> 1,
191 .output_mode
= S5H1409_SERIAL_OUTPUT
,
192 .gpio
= S5H1409_GPIO_ON
,
194 .inversion
= S5H1409_INVERSION_OFF
,
195 .status_mode
= S5H1409_DEMODLOCKING
,
196 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
199 static struct s5h1409_config dvico_s5h1409_config
= {
200 .demod_address
= 0x32 >> 1,
201 .output_mode
= S5H1409_SERIAL_OUTPUT
,
202 .gpio
= S5H1409_GPIO_ON
,
204 .inversion
= S5H1409_INVERSION_OFF
,
205 .status_mode
= S5H1409_DEMODLOCKING
,
206 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
209 static struct s5h1411_config dvico_s5h1411_config
= {
210 .output_mode
= S5H1411_SERIAL_OUTPUT
,
211 .gpio
= S5H1411_GPIO_ON
,
212 .qam_if
= S5H1411_IF_44000
,
213 .vsb_if
= S5H1411_IF_44000
,
214 .inversion
= S5H1411_INVERSION_OFF
,
215 .status_mode
= S5H1411_DEMODLOCKING
,
216 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
219 static struct s5h1411_config hcw_s5h1411_config
= {
220 .output_mode
= S5H1411_SERIAL_OUTPUT
,
221 .gpio
= S5H1411_GPIO_OFF
,
222 .vsb_if
= S5H1411_IF_44000
,
223 .qam_if
= S5H1411_IF_4000
,
224 .inversion
= S5H1411_INVERSION_ON
,
225 .status_mode
= S5H1411_DEMODLOCKING
,
226 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
229 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
234 static struct xc5000_config dvico_xc5000_tunerconfig
= {
239 static struct tda829x_config tda829x_no_probe
= {
240 .probe_tuner
= TDA829X_DONT_PROBE
,
243 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
244 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
245 .if_lvl
= 6, .rfagc_top
= 0x37 },
246 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
247 .if_lvl
= 6, .rfagc_top
= 0x37 },
250 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
251 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
252 .if_lvl
= 1, .rfagc_top
= 0x37, },
253 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
254 .if_lvl
= 1, .rfagc_top
= 0x37, },
255 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
256 .if_lvl
= 1, .rfagc_top
= 0x37, },
259 static struct tda18271_config hauppauge_tda18271_config
= {
260 .std_map
= &hauppauge_tda18271_std_map
,
261 .gate
= TDA18271_GATE_ANALOG
,
262 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
265 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
266 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
267 .gate
= TDA18271_GATE_ANALOG
,
268 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
271 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
272 .gate
= TDA18271_GATE_DIGITAL
,
273 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
276 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
277 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
278 .if_lvl
= 1, .rfagc_top
= 0x58 },
279 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
280 .if_lvl
= 1, .rfagc_top
= 0x58 },
283 static struct tda18271_config hauppauge_hvr127x_config
= {
284 .std_map
= &hauppauge_hvr127x_std_map
,
285 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
288 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
290 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
291 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
292 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
294 .spectral_inversion
= 1,
299 static struct dibx000_agc_config xc3028_agc_config
= {
300 BAND_VHF
| BAND_UHF
, /* band_caps */
302 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
303 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
304 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
305 * P_agc_nb_est=2, P_agc_write=0
307 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
308 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
311 21, /* time_stabiliz */
323 39718, /* agc2_max */
332 29, /* agc2_slope1 */
333 29, /* agc2_slope2 */
340 1, /* perform_agc_softsplit */
343 /* PLL Configuration for COFDM BW_MHz = 8.000000
344 * With external clock = 30.000000 */
345 static struct dibx000_bandwidth_config xc3028_bw_config
= {
346 60000, /* internal */
347 30000, /* sampling */
348 1, /* pll_cfg: prediv */
349 8, /* pll_cfg: ratio */
350 3, /* pll_cfg: range */
351 1, /* pll_cfg: reset */
352 0, /* pll_cfg: bypass */
353 0, /* misc: refdiv */
354 0, /* misc: bypclk_div */
355 1, /* misc: IO_CLK_en_core */
356 1, /* misc: ADClkSrc */
357 0, /* misc: modulo */
358 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
359 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
361 30000000 /* xtal_hz */
364 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
365 .output_mpeg2_in_188_bytes
= 1,
366 .hostbus_diversity
= 1,
367 .tuner_is_baseband
= 0,
370 .agc_config_count
= 1,
371 .agc
= &xc3028_agc_config
,
372 .bw
= &xc3028_bw_config
,
374 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
375 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
376 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
382 .output_mode
= OUTMODE_MPEG2_SERIAL
,
385 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
386 .demod_address
= 0x0f,
389 .disable_i2c_gate_ctrl
= 1,
392 static struct stv0900_reg stv0900_ts_regs
[] = {
393 { R0900_TSGENERAL
, 0x00 },
394 { R0900_P1_TSSPEED
, 0x40 },
395 { R0900_P2_TSSPEED
, 0x40 },
396 { R0900_P1_TSCFGM
, 0xc0 },
397 { R0900_P2_TSCFGM
, 0xc0 },
398 { R0900_P1_TSCFGH
, 0xe0 },
399 { R0900_P2_TSCFGH
, 0xe0 },
400 { R0900_P1_TSCFGL
, 0x20 },
401 { R0900_P2_TSCFGL
, 0x20 },
402 { 0xffff, 0xff }, /* terminate */
405 static struct stv0900_config netup_stv0900_config
= {
406 .demod_address
= 0x68,
407 .demod_mode
= 1, /* dual */
409 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
410 .diseqc_mode
= 2,/* 2/3 PWM */
411 .ts_config_regs
= stv0900_ts_regs
,
412 .tun1_maddress
= 0,/* 0x60 */
413 .tun2_maddress
= 3,/* 0x63 */
414 .tun1_adc
= 1,/* 1 Vpp */
415 .tun2_adc
= 1,/* 1 Vpp */
418 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
422 .gain
= 8, /* +16 dB - maximum gain */
425 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
429 .gain
= 8, /* +16 dB - maximum gain */
432 static struct cx24116_config tbs_cx24116_config
= {
433 .demod_address
= 0x55,
436 static struct ds3000_config tevii_ds3000_config
= {
437 .demod_address
= 0x68,
440 static struct cx24116_config dvbworld_cx24116_config
= {
441 .demod_address
= 0x05,
444 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
445 .prod
= LGS8GXX_PROD_LGS8GL5
,
446 .demod_address
= 0x19,
450 .if_clk_freq
= 30400, /* 30.4 MHz */
451 .if_freq
= 5380, /* 5.38 MHz */
458 static struct xc5000_config mygica_x8506_xc5000_config
= {
463 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
,
464 struct dvb_frontend_parameters
*param
)
466 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
467 struct cx23885_dev
*dev
= port
->dev
;
469 switch (dev
->board
) {
470 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
471 switch (param
->u
.vsb
.modulation
) {
473 cx23885_gpio_clear(dev
, GPIO_5
);
478 cx23885_gpio_set(dev
, GPIO_5
);
482 case CX23885_BOARD_MYGICA_X8506
:
483 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
484 /* Select Digital TV */
485 cx23885_gpio_set(dev
, GPIO_0
);
491 static int cx23885_dvb_fe_ioctl_override(struct dvb_frontend
*fe
,
492 unsigned int cmd
, void *parg
,
498 case DVB_FE_IOCTL_PRE
:
501 case FE_SET_FRONTEND
:
502 err
= cx23885_dvb_set_frontend(fe
,
503 (struct dvb_frontend_parameters
*) parg
);
508 case DVB_FE_IOCTL_POST
:
509 /* no post-ioctl handling required */
516 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
517 .prod
= LGS8GXX_PROD_LGS8G75
,
518 .demod_address
= 0x19,
522 .if_clk_freq
= 30400, /* 30.4 MHz */
523 .if_freq
= 6500, /* 6.50 MHz */
527 .adc_vpp
= 2, /* 1.6 Vpp */
531 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
536 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
537 .prod
= ATBM8830_PROD_8830
,
538 .demod_address
= 0x44,
540 .ts_sampling_edge
= 1,
542 .osc_clk_freq
= 30400, /* in kHz */
543 .if_freq
= 0, /* zero IF */
550 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
555 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
556 .prod
= ATBM8830_PROD_8830
,
557 .demod_address
= 0x44,
559 .ts_sampling_edge
= 1,
561 .osc_clk_freq
= 30400, /* in kHz */
562 .if_freq
= 0, /* zero IF */
569 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
574 static int dvb_register(struct cx23885_tsport
*port
)
576 struct cx23885_dev
*dev
= port
->dev
;
577 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
578 struct videobuf_dvb_frontend
*fe0
;
581 /* Get the first frontend */
582 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
586 /* init struct videobuf_dvb */
587 fe0
->dvb
.name
= dev
->name
;
590 switch (dev
->board
) {
591 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
592 i2c_bus
= &dev
->i2c_bus
[0];
593 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
594 &hauppauge_generic_config
,
596 if (fe0
->dvb
.frontend
!= NULL
) {
597 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
599 &hauppauge_generic_tunerconfig
, 0);
602 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
603 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
604 i2c_bus
= &dev
->i2c_bus
[0];
605 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
606 &hauppauge_lgdt3305_config
,
608 if (fe0
->dvb
.frontend
!= NULL
) {
609 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
610 0x60, &dev
->i2c_bus
[1].i2c_adap
,
611 &hauppauge_hvr127x_config
);
614 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
615 i2c_bus
= &dev
->i2c_bus
[0];
616 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
619 if (fe0
->dvb
.frontend
!= NULL
) {
620 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
621 0x60, &dev
->i2c_bus
[1].i2c_adap
,
622 &hauppauge_tda18271_config
);
625 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
626 i2c_bus
= &dev
->i2c_bus
[0];
630 dvb_attach(s5h1409_attach
,
631 &hauppauge_ezqam_config
,
633 if (fe0
->dvb
.frontend
!= NULL
) {
634 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
635 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
637 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
638 0x60, &dev
->i2c_bus
[1].i2c_adap
,
639 &hauppauge_tda18271_config
);
645 dvb_attach(s5h1409_attach
,
646 &hauppauge_generic_config
,
648 if (fe0
->dvb
.frontend
!= NULL
)
649 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
651 &hauppauge_generic_tunerconfig
, 0);
655 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
656 i2c_bus
= &dev
->i2c_bus
[0];
657 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
658 &hauppauge_hvr1800lp_config
,
660 if (fe0
->dvb
.frontend
!= NULL
) {
661 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
663 &hauppauge_generic_tunerconfig
, 0);
666 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
667 i2c_bus
= &dev
->i2c_bus
[0];
668 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
669 &fusionhdtv_5_express
,
671 if (fe0
->dvb
.frontend
!= NULL
) {
672 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
673 &i2c_bus
->i2c_adap
, 0x61,
674 TUNER_LG_TDVS_H06XF
);
677 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
678 i2c_bus
= &dev
->i2c_bus
[1];
679 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
680 &hauppauge_hvr1500q_config
,
681 &dev
->i2c_bus
[0].i2c_adap
);
682 if (fe0
->dvb
.frontend
!= NULL
)
683 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
685 &hauppauge_hvr1500q_tunerconfig
);
687 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
688 i2c_bus
= &dev
->i2c_bus
[1];
689 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
690 &hauppauge_hvr1500_config
,
691 &dev
->i2c_bus
[0].i2c_adap
);
692 if (fe0
->dvb
.frontend
!= NULL
) {
693 struct dvb_frontend
*fe
;
694 struct xc2028_config cfg
= {
695 .i2c_adap
= &i2c_bus
->i2c_adap
,
698 static struct xc2028_ctrl ctl
= {
699 .fname
= XC2028_DEFAULT_FIRMWARE
,
701 .demod
= XC3028_FE_OREN538
,
704 fe
= dvb_attach(xc2028_attach
,
705 fe0
->dvb
.frontend
, &cfg
);
706 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
707 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
710 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
711 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
712 i2c_bus
= &dev
->i2c_bus
[0];
713 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
714 &hauppauge_hvr1200_config
,
716 if (fe0
->dvb
.frontend
!= NULL
) {
717 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
718 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
720 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
721 0x60, &dev
->i2c_bus
[1].i2c_adap
,
722 &hauppauge_hvr1200_tuner_config
);
725 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
726 i2c_bus
= &dev
->i2c_bus
[0];
727 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
728 &hauppauge_hvr1210_config
,
730 if (fe0
->dvb
.frontend
!= NULL
) {
731 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
732 0x60, &dev
->i2c_bus
[1].i2c_adap
,
733 &hauppauge_hvr1210_tuner_config
);
736 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
737 i2c_bus
= &dev
->i2c_bus
[0];
738 fe0
->dvb
.frontend
= dvb_attach(dib7000p_attach
,
740 0x12, &hauppauge_hvr1400_dib7000_config
);
741 if (fe0
->dvb
.frontend
!= NULL
) {
742 struct dvb_frontend
*fe
;
743 struct xc2028_config cfg
= {
744 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
747 static struct xc2028_ctrl ctl
= {
748 .fname
= XC3028L_DEFAULT_FIRMWARE
,
751 /* This is true for all demods with
753 .type
= XC2028_D2633
,
756 fe
= dvb_attach(xc2028_attach
,
757 fe0
->dvb
.frontend
, &cfg
);
758 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
759 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
762 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
763 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
765 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
766 &dvico_s5h1409_config
,
768 if (fe0
->dvb
.frontend
== NULL
)
769 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
770 &dvico_s5h1411_config
,
772 if (fe0
->dvb
.frontend
!= NULL
)
773 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
775 &dvico_xc5000_tunerconfig
);
777 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
778 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
780 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
781 &dvico_fusionhdtv_xc3028
,
783 if (fe0
->dvb
.frontend
!= NULL
) {
784 struct dvb_frontend
*fe
;
785 struct xc2028_config cfg
= {
786 .i2c_adap
= &i2c_bus
->i2c_adap
,
789 static struct xc2028_ctrl ctl
= {
790 .fname
= XC2028_DEFAULT_FIRMWARE
,
792 .demod
= XC3028_FE_ZARLINK456
,
795 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
797 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
798 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
802 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
803 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
804 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
805 i2c_bus
= &dev
->i2c_bus
[0];
807 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
808 &dvico_fusionhdtv_xc3028
,
810 if (fe0
->dvb
.frontend
!= NULL
) {
811 struct dvb_frontend
*fe
;
812 struct xc2028_config cfg
= {
813 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
816 static struct xc2028_ctrl ctl
= {
817 .fname
= XC2028_DEFAULT_FIRMWARE
,
819 .demod
= XC3028_FE_ZARLINK456
,
822 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
824 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
825 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
828 case CX23885_BOARD_TBS_6920
:
829 i2c_bus
= &dev
->i2c_bus
[1];
831 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
834 if (fe0
->dvb
.frontend
!= NULL
)
835 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
838 case CX23885_BOARD_TEVII_S470
:
839 i2c_bus
= &dev
->i2c_bus
[1];
841 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
842 &tevii_ds3000_config
,
844 if (fe0
->dvb
.frontend
!= NULL
)
845 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
848 case CX23885_BOARD_DVBWORLD_2005
:
849 i2c_bus
= &dev
->i2c_bus
[1];
851 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
852 &dvbworld_cx24116_config
,
855 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
856 i2c_bus
= &dev
->i2c_bus
[0];
860 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
861 &netup_stv0900_config
,
862 &i2c_bus
->i2c_adap
, 0);
863 if (fe0
->dvb
.frontend
!= NULL
) {
864 if (dvb_attach(stv6110_attach
,
866 &netup_stv6110_tunerconfig_a
,
867 &i2c_bus
->i2c_adap
)) {
868 if (!dvb_attach(lnbh24_attach
,
871 LNBH24_PCL
| LNBH24_TTX
,
874 "No LNBH24 found!\n");
881 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
882 &netup_stv0900_config
,
883 &i2c_bus
->i2c_adap
, 1);
884 if (fe0
->dvb
.frontend
!= NULL
) {
885 if (dvb_attach(stv6110_attach
,
887 &netup_stv6110_tunerconfig_b
,
888 &i2c_bus
->i2c_adap
)) {
889 if (!dvb_attach(lnbh24_attach
,
892 LNBH24_PCL
| LNBH24_TTX
,
895 "No LNBH24 found!\n");
902 case CX23885_BOARD_MYGICA_X8506
:
903 i2c_bus
= &dev
->i2c_bus
[0];
904 i2c_bus2
= &dev
->i2c_bus
[1];
905 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
906 &mygica_x8506_lgs8gl5_config
,
908 if (fe0
->dvb
.frontend
!= NULL
) {
909 dvb_attach(xc5000_attach
,
912 &mygica_x8506_xc5000_config
);
915 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
916 i2c_bus
= &dev
->i2c_bus
[0];
917 i2c_bus2
= &dev
->i2c_bus
[1];
918 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
919 &magicpro_prohdtve2_lgs8g75_config
,
921 if (fe0
->dvb
.frontend
!= NULL
) {
922 dvb_attach(xc5000_attach
,
925 &magicpro_prohdtve2_xc5000_config
);
928 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
929 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
930 i2c_bus
= &dev
->i2c_bus
[0];
931 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
934 if (fe0
->dvb
.frontend
!= NULL
)
935 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
936 0x60, &dev
->i2c_bus
[0].i2c_adap
,
937 &hauppauge_tda18271_config
);
939 case CX23885_BOARD_MYGICA_X8558PRO
:
943 i2c_bus
= &dev
->i2c_bus
[0];
944 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
945 &mygica_x8558pro_atbm8830_cfg1
,
947 if (fe0
->dvb
.frontend
!= NULL
) {
948 dvb_attach(max2165_attach
,
951 &mygic_x8558pro_max2165_cfg1
);
956 i2c_bus
= &dev
->i2c_bus
[1];
957 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
958 &mygica_x8558pro_atbm8830_cfg2
,
960 if (fe0
->dvb
.frontend
!= NULL
) {
961 dvb_attach(max2165_attach
,
964 &mygic_x8558pro_max2165_cfg2
);
971 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
972 " isn't supported yet\n",
976 if (NULL
== fe0
->dvb
.frontend
) {
977 printk(KERN_ERR
"%s: frontend initialization failed\n",
981 /* define general-purpose callback pointer */
982 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
984 /* Put the analog decoder in standby to keep it quiet */
985 call_all(dev
, core
, s_power
, 0);
987 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
988 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
990 /* register everything */
991 ret
= videobuf_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
992 &dev
->pci
->dev
, adapter_nr
, 0,
993 cx23885_dvb_fe_ioctl_override
);
996 switch (dev
->board
) {
997 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
998 static struct netup_card_info cinfo
;
1000 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1001 memcpy(port
->frontends
.adapter
.proposed_mac
,
1002 cinfo
.port
[port
->nr
- 1].mac
, 6);
1003 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1004 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1006 netup_ci_init(port
);
1014 int cx23885_dvb_register(struct cx23885_tsport
*port
)
1017 struct videobuf_dvb_frontend
*fe0
;
1018 struct cx23885_dev
*dev
= port
->dev
;
1021 /* Here we need to allocate the correct number of frontends,
1022 * as reflected in the cards struct. The reality is that currently
1023 * no cx23885 boards support this - yet. But, if we don't modify this
1024 * code then the second frontend would never be allocated (later)
1025 * and fail with error before the attach in dvb_register().
1026 * Without these changes we risk an OOPS later. The changes here
1027 * are for safety, and should provide a good foundation for the
1028 * future addition of any multi-frontend cx23885 based boards.
1030 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
1031 port
->num_frontends
);
1033 for (i
= 1; i
<= port
->num_frontends
; i
++) {
1034 if (videobuf_dvb_alloc_frontend(
1035 &port
->frontends
, i
) == NULL
) {
1036 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1040 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, i
);
1044 dprintk(1, "%s\n", __func__
);
1045 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
1054 /* We have to init the queue for each frontend on a port. */
1055 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
1056 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &dvb_qops
,
1057 &dev
->pci
->dev
, &port
->slock
,
1058 V4L2_BUF_TYPE_VIDEO_CAPTURE
, V4L2_FIELD_TOP
,
1059 sizeof(struct cx23885_buffer
), port
);
1061 err
= dvb_register(port
);
1063 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
1069 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
1071 struct videobuf_dvb_frontend
*fe0
;
1073 /* FIXME: in an error condition where the we have
1074 * an expected number of frontends (attach problem)
1075 * then this might not clean up correctly, if 1
1077 * This comment only applies to future boards IF they
1078 * implement MFE support.
1080 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
1081 if (fe0
->dvb
.frontend
)
1082 videobuf_dvb_unregister_bus(&port
->frontends
);
1084 switch (port
->dev
->board
) {
1085 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1086 netup_ci_exit(port
);