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"
44 #include "tuner-xc2028.h"
45 #include "tuner-simple.h"
47 #include "dibx000_common.h"
50 #include "stv0900_reg.h"
56 #include "netup-eeprom.h"
57 #include "netup-init.h"
61 #include "cx23885-f300.h"
62 #include "altera-ci.h"
68 #include "stb6100_cfg.h"
72 static unsigned int debug
;
74 #define dprintk(level, fmt, arg...)\
75 do { if (debug >= level)\
76 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
79 /* ------------------------------------------------------------------ */
81 static unsigned int alt_tuner
;
82 module_param(alt_tuner
, int, 0644);
83 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
85 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
87 /* ------------------------------------------------------------------ */
89 static int dvb_buf_setup(struct videobuf_queue
*q
,
90 unsigned int *count
, unsigned int *size
)
92 struct cx23885_tsport
*port
= q
->priv_data
;
94 port
->ts_packet_size
= 188 * 4;
95 port
->ts_packet_count
= 32;
97 *size
= port
->ts_packet_size
* port
->ts_packet_count
;
102 static int dvb_buf_prepare(struct videobuf_queue
*q
,
103 struct videobuf_buffer
*vb
, enum v4l2_field field
)
105 struct cx23885_tsport
*port
= q
->priv_data
;
106 return cx23885_buf_prepare(q
, port
, (struct cx23885_buffer
*)vb
, field
);
109 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
111 struct cx23885_tsport
*port
= q
->priv_data
;
112 cx23885_buf_queue(port
, (struct cx23885_buffer
*)vb
);
115 static void dvb_buf_release(struct videobuf_queue
*q
,
116 struct videobuf_buffer
*vb
)
118 cx23885_free_buffer(q
, (struct cx23885_buffer
*)vb
);
121 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
);
123 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport
*port
, int open
)
125 struct videobuf_dvb_frontends
*f
;
126 struct videobuf_dvb_frontend
*fe
;
128 f
= &port
->frontends
;
130 if (f
->gate
<= 1) /* undefined or fe0 */
131 fe
= videobuf_dvb_get_frontend(f
, 1);
133 fe
= videobuf_dvb_get_frontend(f
, f
->gate
);
135 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
136 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
139 * FIXME: Improve this path to avoid calling the
140 * cx23885_dvb_set_frontend() every time it passes here.
142 cx23885_dvb_set_frontend(fe
->dvb
.frontend
);
145 static struct videobuf_queue_ops dvb_qops
= {
146 .buf_setup
= dvb_buf_setup
,
147 .buf_prepare
= dvb_buf_prepare
,
148 .buf_queue
= dvb_buf_queue
,
149 .buf_release
= dvb_buf_release
,
152 static struct s5h1409_config hauppauge_generic_config
= {
153 .demod_address
= 0x32 >> 1,
154 .output_mode
= S5H1409_SERIAL_OUTPUT
,
155 .gpio
= S5H1409_GPIO_ON
,
157 .inversion
= S5H1409_INVERSION_OFF
,
158 .status_mode
= S5H1409_DEMODLOCKING
,
159 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
162 static struct tda10048_config hauppauge_hvr1200_config
= {
163 .demod_address
= 0x10 >> 1,
164 .output_mode
= TDA10048_SERIAL_OUTPUT
,
165 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
166 .inversion
= TDA10048_INVERSION_ON
,
167 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
168 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
169 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
170 .clk_freq_khz
= TDA10048_CLK_16000
,
173 static struct tda10048_config hauppauge_hvr1210_config
= {
174 .demod_address
= 0x10 >> 1,
175 .output_mode
= TDA10048_SERIAL_OUTPUT
,
176 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
177 .inversion
= TDA10048_INVERSION_ON
,
178 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
179 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
180 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
181 .clk_freq_khz
= TDA10048_CLK_16000
,
184 static struct s5h1409_config hauppauge_ezqam_config
= {
185 .demod_address
= 0x32 >> 1,
186 .output_mode
= S5H1409_SERIAL_OUTPUT
,
187 .gpio
= S5H1409_GPIO_OFF
,
189 .inversion
= S5H1409_INVERSION_ON
,
190 .status_mode
= S5H1409_DEMODLOCKING
,
191 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
194 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
195 .demod_address
= 0x32 >> 1,
196 .output_mode
= S5H1409_SERIAL_OUTPUT
,
197 .gpio
= S5H1409_GPIO_OFF
,
199 .inversion
= S5H1409_INVERSION_OFF
,
200 .status_mode
= S5H1409_DEMODLOCKING
,
201 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
204 static struct s5h1409_config hauppauge_hvr1500_config
= {
205 .demod_address
= 0x32 >> 1,
206 .output_mode
= S5H1409_SERIAL_OUTPUT
,
207 .gpio
= S5H1409_GPIO_OFF
,
208 .inversion
= S5H1409_INVERSION_OFF
,
209 .status_mode
= S5H1409_DEMODLOCKING
,
210 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
213 static struct mt2131_config hauppauge_generic_tunerconfig
= {
217 static struct lgdt330x_config fusionhdtv_5_express
= {
218 .demod_address
= 0x0e,
219 .demod_chip
= LGDT3303
,
223 static struct s5h1409_config hauppauge_hvr1500q_config
= {
224 .demod_address
= 0x32 >> 1,
225 .output_mode
= S5H1409_SERIAL_OUTPUT
,
226 .gpio
= S5H1409_GPIO_ON
,
228 .inversion
= S5H1409_INVERSION_OFF
,
229 .status_mode
= S5H1409_DEMODLOCKING
,
230 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
233 static struct s5h1409_config dvico_s5h1409_config
= {
234 .demod_address
= 0x32 >> 1,
235 .output_mode
= S5H1409_SERIAL_OUTPUT
,
236 .gpio
= S5H1409_GPIO_ON
,
238 .inversion
= S5H1409_INVERSION_OFF
,
239 .status_mode
= S5H1409_DEMODLOCKING
,
240 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
243 static struct s5h1411_config dvico_s5h1411_config
= {
244 .output_mode
= S5H1411_SERIAL_OUTPUT
,
245 .gpio
= S5H1411_GPIO_ON
,
246 .qam_if
= S5H1411_IF_44000
,
247 .vsb_if
= S5H1411_IF_44000
,
248 .inversion
= S5H1411_INVERSION_OFF
,
249 .status_mode
= S5H1411_DEMODLOCKING
,
250 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
253 static struct s5h1411_config hcw_s5h1411_config
= {
254 .output_mode
= S5H1411_SERIAL_OUTPUT
,
255 .gpio
= S5H1411_GPIO_OFF
,
256 .vsb_if
= S5H1411_IF_44000
,
257 .qam_if
= S5H1411_IF_4000
,
258 .inversion
= S5H1411_INVERSION_ON
,
259 .status_mode
= S5H1411_DEMODLOCKING
,
260 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
263 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
268 static struct xc5000_config dvico_xc5000_tunerconfig
= {
273 static struct tda829x_config tda829x_no_probe
= {
274 .probe_tuner
= TDA829X_DONT_PROBE
,
277 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
278 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
279 .if_lvl
= 6, .rfagc_top
= 0x37 },
280 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
281 .if_lvl
= 6, .rfagc_top
= 0x37 },
284 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
285 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
286 .if_lvl
= 1, .rfagc_top
= 0x37, },
287 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
288 .if_lvl
= 1, .rfagc_top
= 0x37, },
289 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
290 .if_lvl
= 1, .rfagc_top
= 0x37, },
293 static struct tda18271_config hauppauge_tda18271_config
= {
294 .std_map
= &hauppauge_tda18271_std_map
,
295 .gate
= TDA18271_GATE_ANALOG
,
296 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
299 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
300 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
301 .gate
= TDA18271_GATE_ANALOG
,
302 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
305 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
306 .gate
= TDA18271_GATE_DIGITAL
,
307 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
310 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
311 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
312 .if_lvl
= 1, .rfagc_top
= 0x58 },
313 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
314 .if_lvl
= 1, .rfagc_top
= 0x58 },
317 static struct tda18271_config hauppauge_hvr127x_config
= {
318 .std_map
= &hauppauge_hvr127x_std_map
,
319 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
322 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
324 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
325 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
326 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
328 .spectral_inversion
= 1,
333 static struct dibx000_agc_config xc3028_agc_config
= {
334 BAND_VHF
| BAND_UHF
, /* band_caps */
336 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
337 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
338 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
339 * P_agc_nb_est=2, P_agc_write=0
341 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
342 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
345 21, /* time_stabiliz */
357 39718, /* agc2_max */
366 29, /* agc2_slope1 */
367 29, /* agc2_slope2 */
374 1, /* perform_agc_softsplit */
377 /* PLL Configuration for COFDM BW_MHz = 8.000000
378 * With external clock = 30.000000 */
379 static struct dibx000_bandwidth_config xc3028_bw_config
= {
380 60000, /* internal */
381 30000, /* sampling */
382 1, /* pll_cfg: prediv */
383 8, /* pll_cfg: ratio */
384 3, /* pll_cfg: range */
385 1, /* pll_cfg: reset */
386 0, /* pll_cfg: bypass */
387 0, /* misc: refdiv */
388 0, /* misc: bypclk_div */
389 1, /* misc: IO_CLK_en_core */
390 1, /* misc: ADClkSrc */
391 0, /* misc: modulo */
392 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
393 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
395 30000000 /* xtal_hz */
398 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
399 .output_mpeg2_in_188_bytes
= 1,
400 .hostbus_diversity
= 1,
401 .tuner_is_baseband
= 0,
404 .agc_config_count
= 1,
405 .agc
= &xc3028_agc_config
,
406 .bw
= &xc3028_bw_config
,
408 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
409 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
410 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
416 .output_mode
= OUTMODE_MPEG2_SERIAL
,
419 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
420 .demod_address
= 0x0f,
423 .disable_i2c_gate_ctrl
= 1,
426 static struct stv0900_reg stv0900_ts_regs
[] = {
427 { R0900_TSGENERAL
, 0x00 },
428 { R0900_P1_TSSPEED
, 0x40 },
429 { R0900_P2_TSSPEED
, 0x40 },
430 { R0900_P1_TSCFGM
, 0xc0 },
431 { R0900_P2_TSCFGM
, 0xc0 },
432 { R0900_P1_TSCFGH
, 0xe0 },
433 { R0900_P2_TSCFGH
, 0xe0 },
434 { R0900_P1_TSCFGL
, 0x20 },
435 { R0900_P2_TSCFGL
, 0x20 },
436 { 0xffff, 0xff }, /* terminate */
439 static struct stv0900_config netup_stv0900_config
= {
440 .demod_address
= 0x68,
441 .demod_mode
= 1, /* dual */
443 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
444 .diseqc_mode
= 2,/* 2/3 PWM */
445 .ts_config_regs
= stv0900_ts_regs
,
446 .tun1_maddress
= 0,/* 0x60 */
447 .tun2_maddress
= 3,/* 0x63 */
448 .tun1_adc
= 1,/* 1 Vpp */
449 .tun2_adc
= 1,/* 1 Vpp */
452 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
456 .gain
= 8, /* +16 dB - maximum gain */
459 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
463 .gain
= 8, /* +16 dB - maximum gain */
466 static struct cx24116_config tbs_cx24116_config
= {
467 .demod_address
= 0x55,
470 static struct ds3000_config tevii_ds3000_config
= {
471 .demod_address
= 0x68,
474 static struct cx24116_config dvbworld_cx24116_config
= {
475 .demod_address
= 0x05,
478 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
479 .prod
= LGS8GXX_PROD_LGS8GL5
,
480 .demod_address
= 0x19,
484 .if_clk_freq
= 30400, /* 30.4 MHz */
485 .if_freq
= 5380, /* 5.38 MHz */
492 static struct xc5000_config mygica_x8506_xc5000_config
= {
497 static struct stv090x_config prof_8000_stv090x_config
= {
499 .demod_mode
= STV090x_SINGLE
,
500 .clk_mode
= STV090x_CLK_EXT
,
503 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
504 .repeater_level
= STV090x_RPTLEVEL_64
,
505 .adc1_range
= STV090x_ADC_2Vpp
,
506 .diseqc_envelope_mode
= false,
508 .tuner_get_frequency
= stb6100_get_frequency
,
509 .tuner_set_frequency
= stb6100_set_frequency
,
510 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
511 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
514 static struct stb6100_config prof_8000_stb6100_config
= {
515 .tuner_address
= 0x60,
516 .refclock
= 27000000,
519 static int p8000_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
521 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
522 struct cx23885_dev
*dev
= port
->dev
;
524 if (voltage
== SEC_VOLTAGE_18
)
525 cx_write(MC417_RWD
, 0x00001e00);
526 else if (voltage
== SEC_VOLTAGE_13
)
527 cx_write(MC417_RWD
, 0x00001a00);
529 cx_write(MC417_RWD
, 0x00001800);
533 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
535 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
536 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
537 struct cx23885_dev
*dev
= port
->dev
;
539 switch (dev
->board
) {
540 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
541 switch (p
->modulation
) {
543 cx23885_gpio_clear(dev
, GPIO_5
);
548 cx23885_gpio_set(dev
, GPIO_5
);
552 case CX23885_BOARD_MYGICA_X8506
:
553 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
554 /* Select Digital TV */
555 cx23885_gpio_set(dev
, GPIO_0
);
561 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
562 .prod
= LGS8GXX_PROD_LGS8G75
,
563 .demod_address
= 0x19,
567 .if_clk_freq
= 30400, /* 30.4 MHz */
568 .if_freq
= 6500, /* 6.50 MHz */
572 .adc_vpp
= 2, /* 1.6 Vpp */
576 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
581 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
582 .prod
= ATBM8830_PROD_8830
,
583 .demod_address
= 0x44,
585 .ts_sampling_edge
= 1,
587 .osc_clk_freq
= 30400, /* in kHz */
588 .if_freq
= 0, /* zero IF */
595 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
600 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
601 .prod
= ATBM8830_PROD_8830
,
602 .demod_address
= 0x44,
604 .ts_sampling_edge
= 1,
606 .osc_clk_freq
= 30400, /* in kHz */
607 .if_freq
= 0, /* zero IF */
614 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
618 static struct stv0367_config netup_stv0367_config
[] = {
620 .demod_address
= 0x1c,
627 .demod_address
= 0x1d,
636 static struct xc5000_config netup_xc5000_config
[] = {
646 static struct drxk_config terratec_drxk_config
[] = {
656 static struct mt2063_config terratec_mt2063_config
[] = {
658 .tuner_address
= 0x60,
660 .tuner_address
= 0x67,
664 static const struct tda10071_config hauppauge_tda10071_config
= {
666 .tuner_i2c_addr
= 0x54,
668 .ts_mode
= TDA10071_TS_SERIAL
,
670 .xtal
= 40444000, /* 40.444 MHz */
671 .pll_multiplier
= 20,
674 static const struct a8293_config hauppauge_a8293_config
= {
678 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
680 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
681 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
684 mem
= cx_read(MC417_RWD
);
686 cx_set(MC417_OEN
, ALT_DATA
);
688 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
690 mem
|= (data
& ALT_DATA
);
700 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
702 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
704 cx_write(MC417_RWD
, mem
); /* start RW cycle */
707 mem
= cx_read(MC417_RWD
);
708 if ((mem
& ALT_RDY
) == 0)
710 if (time_after(jiffies
, timeout
))
715 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
717 return mem
& ALT_DATA
;
722 static int dvb_register(struct cx23885_tsport
*port
)
724 struct cx23885_dev
*dev
= port
->dev
;
725 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
726 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
727 int mfe_shared
= 0; /* bus not shared by default */
730 /* Get the first frontend */
731 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
735 /* init struct videobuf_dvb */
736 fe0
->dvb
.name
= dev
->name
;
738 /* multi-frontend gate control is undefined or defaults to fe0 */
739 port
->frontends
.gate
= 0;
741 /* Sets the gate control callback to be used by i2c command calls */
742 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
745 switch (dev
->board
) {
746 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
747 i2c_bus
= &dev
->i2c_bus
[0];
748 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
749 &hauppauge_generic_config
,
751 if (fe0
->dvb
.frontend
!= NULL
) {
752 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
754 &hauppauge_generic_tunerconfig
, 0);
757 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
758 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
759 i2c_bus
= &dev
->i2c_bus
[0];
760 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
761 &hauppauge_lgdt3305_config
,
763 if (fe0
->dvb
.frontend
!= NULL
) {
764 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
765 0x60, &dev
->i2c_bus
[1].i2c_adap
,
766 &hauppauge_hvr127x_config
);
769 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
770 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
771 i2c_bus
= &dev
->i2c_bus
[0];
772 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
775 if (fe0
->dvb
.frontend
!= NULL
) {
776 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
777 0x60, &dev
->i2c_bus
[1].i2c_adap
,
778 &hauppauge_tda18271_config
);
781 tda18271_attach(&dev
->ts1
.analog_fe
,
782 0x60, &dev
->i2c_bus
[1].i2c_adap
,
783 &hauppauge_tda18271_config
);
786 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
787 i2c_bus
= &dev
->i2c_bus
[0];
791 dvb_attach(s5h1409_attach
,
792 &hauppauge_ezqam_config
,
794 if (fe0
->dvb
.frontend
!= NULL
) {
795 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
796 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
798 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
799 0x60, &dev
->i2c_bus
[1].i2c_adap
,
800 &hauppauge_tda18271_config
);
806 dvb_attach(s5h1409_attach
,
807 &hauppauge_generic_config
,
809 if (fe0
->dvb
.frontend
!= NULL
)
810 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
812 &hauppauge_generic_tunerconfig
, 0);
816 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
817 i2c_bus
= &dev
->i2c_bus
[0];
818 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
819 &hauppauge_hvr1800lp_config
,
821 if (fe0
->dvb
.frontend
!= NULL
) {
822 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
824 &hauppauge_generic_tunerconfig
, 0);
827 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
828 i2c_bus
= &dev
->i2c_bus
[0];
829 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
830 &fusionhdtv_5_express
,
832 if (fe0
->dvb
.frontend
!= NULL
) {
833 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
834 &i2c_bus
->i2c_adap
, 0x61,
835 TUNER_LG_TDVS_H06XF
);
838 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
839 i2c_bus
= &dev
->i2c_bus
[1];
840 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
841 &hauppauge_hvr1500q_config
,
842 &dev
->i2c_bus
[0].i2c_adap
);
843 if (fe0
->dvb
.frontend
!= NULL
)
844 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
846 &hauppauge_hvr1500q_tunerconfig
);
848 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
849 i2c_bus
= &dev
->i2c_bus
[1];
850 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
851 &hauppauge_hvr1500_config
,
852 &dev
->i2c_bus
[0].i2c_adap
);
853 if (fe0
->dvb
.frontend
!= NULL
) {
854 struct dvb_frontend
*fe
;
855 struct xc2028_config cfg
= {
856 .i2c_adap
= &i2c_bus
->i2c_adap
,
859 static struct xc2028_ctrl ctl
= {
860 .fname
= XC2028_DEFAULT_FIRMWARE
,
862 .demod
= XC3028_FE_OREN538
,
865 fe
= dvb_attach(xc2028_attach
,
866 fe0
->dvb
.frontend
, &cfg
);
867 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
868 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
871 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
872 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
873 i2c_bus
= &dev
->i2c_bus
[0];
874 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
875 &hauppauge_hvr1200_config
,
877 if (fe0
->dvb
.frontend
!= NULL
) {
878 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
879 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
881 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
882 0x60, &dev
->i2c_bus
[1].i2c_adap
,
883 &hauppauge_hvr1200_tuner_config
);
886 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
887 i2c_bus
= &dev
->i2c_bus
[0];
888 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
889 &hauppauge_hvr1210_config
,
891 if (fe0
->dvb
.frontend
!= NULL
) {
892 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
893 0x60, &dev
->i2c_bus
[1].i2c_adap
,
894 &hauppauge_hvr1210_tuner_config
);
897 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
898 i2c_bus
= &dev
->i2c_bus
[0];
899 fe0
->dvb
.frontend
= dvb_attach(dib7000p_attach
,
901 0x12, &hauppauge_hvr1400_dib7000_config
);
902 if (fe0
->dvb
.frontend
!= NULL
) {
903 struct dvb_frontend
*fe
;
904 struct xc2028_config cfg
= {
905 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
908 static struct xc2028_ctrl ctl
= {
909 .fname
= XC3028L_DEFAULT_FIRMWARE
,
911 .demod
= XC3028_FE_DIBCOM52
,
912 /* This is true for all demods with
914 .type
= XC2028_D2633
,
917 fe
= dvb_attach(xc2028_attach
,
918 fe0
->dvb
.frontend
, &cfg
);
919 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
920 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
923 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
924 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
926 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
927 &dvico_s5h1409_config
,
929 if (fe0
->dvb
.frontend
== NULL
)
930 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
931 &dvico_s5h1411_config
,
933 if (fe0
->dvb
.frontend
!= NULL
)
934 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
936 &dvico_xc5000_tunerconfig
);
938 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
939 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
941 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
942 &dvico_fusionhdtv_xc3028
,
944 if (fe0
->dvb
.frontend
!= NULL
) {
945 struct dvb_frontend
*fe
;
946 struct xc2028_config cfg
= {
947 .i2c_adap
= &i2c_bus
->i2c_adap
,
950 static struct xc2028_ctrl ctl
= {
951 .fname
= XC2028_DEFAULT_FIRMWARE
,
953 .demod
= XC3028_FE_ZARLINK456
,
956 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
958 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
959 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
963 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
964 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
965 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
966 i2c_bus
= &dev
->i2c_bus
[0];
968 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
969 &dvico_fusionhdtv_xc3028
,
971 if (fe0
->dvb
.frontend
!= NULL
) {
972 struct dvb_frontend
*fe
;
973 struct xc2028_config cfg
= {
974 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
977 static struct xc2028_ctrl ctl
= {
978 .fname
= XC2028_DEFAULT_FIRMWARE
,
980 .demod
= XC3028_FE_ZARLINK456
,
983 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
985 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
986 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
989 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
990 i2c_bus
= &dev
->i2c_bus
[0];
992 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
993 &dvico_fusionhdtv_xc3028
,
995 if (fe0
->dvb
.frontend
!= NULL
) {
996 struct dvb_frontend
*fe
;
997 struct xc4000_config cfg
= {
1000 .dvb_amplitude
= 134,
1001 .set_smoothedcvbs
= 1,
1005 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1006 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1008 printk(KERN_ERR
"%s/2: xc4000 attach failed\n",
1010 goto frontend_detach
;
1014 case CX23885_BOARD_TBS_6920
:
1015 i2c_bus
= &dev
->i2c_bus
[1];
1017 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1018 &tbs_cx24116_config
,
1019 &i2c_bus
->i2c_adap
);
1020 if (fe0
->dvb
.frontend
!= NULL
)
1021 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1024 case CX23885_BOARD_TEVII_S470
:
1025 i2c_bus
= &dev
->i2c_bus
[1];
1027 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1028 &tevii_ds3000_config
,
1029 &i2c_bus
->i2c_adap
);
1030 if (fe0
->dvb
.frontend
!= NULL
)
1031 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1034 case CX23885_BOARD_DVBWORLD_2005
:
1035 i2c_bus
= &dev
->i2c_bus
[1];
1037 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1038 &dvbworld_cx24116_config
,
1039 &i2c_bus
->i2c_adap
);
1041 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1042 i2c_bus
= &dev
->i2c_bus
[0];
1046 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1047 &netup_stv0900_config
,
1048 &i2c_bus
->i2c_adap
, 0);
1049 if (fe0
->dvb
.frontend
!= NULL
) {
1050 if (dvb_attach(stv6110_attach
,
1052 &netup_stv6110_tunerconfig_a
,
1053 &i2c_bus
->i2c_adap
)) {
1054 if (!dvb_attach(lnbh24_attach
,
1057 LNBH24_PCL
| LNBH24_TTX
,
1060 "No LNBH24 found!\n");
1067 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1068 &netup_stv0900_config
,
1069 &i2c_bus
->i2c_adap
, 1);
1070 if (fe0
->dvb
.frontend
!= NULL
) {
1071 if (dvb_attach(stv6110_attach
,
1073 &netup_stv6110_tunerconfig_b
,
1074 &i2c_bus
->i2c_adap
)) {
1075 if (!dvb_attach(lnbh24_attach
,
1078 LNBH24_PCL
| LNBH24_TTX
,
1081 "No LNBH24 found!\n");
1088 case CX23885_BOARD_MYGICA_X8506
:
1089 i2c_bus
= &dev
->i2c_bus
[0];
1090 i2c_bus2
= &dev
->i2c_bus
[1];
1091 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1092 &mygica_x8506_lgs8gl5_config
,
1093 &i2c_bus
->i2c_adap
);
1094 if (fe0
->dvb
.frontend
!= NULL
) {
1095 dvb_attach(xc5000_attach
,
1097 &i2c_bus2
->i2c_adap
,
1098 &mygica_x8506_xc5000_config
);
1101 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1102 i2c_bus
= &dev
->i2c_bus
[0];
1103 i2c_bus2
= &dev
->i2c_bus
[1];
1104 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1105 &magicpro_prohdtve2_lgs8g75_config
,
1106 &i2c_bus
->i2c_adap
);
1107 if (fe0
->dvb
.frontend
!= NULL
) {
1108 dvb_attach(xc5000_attach
,
1110 &i2c_bus2
->i2c_adap
,
1111 &magicpro_prohdtve2_xc5000_config
);
1114 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1115 i2c_bus
= &dev
->i2c_bus
[0];
1116 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1117 &hcw_s5h1411_config
,
1118 &i2c_bus
->i2c_adap
);
1119 if (fe0
->dvb
.frontend
!= NULL
)
1120 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1121 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1122 &hauppauge_tda18271_config
);
1124 tda18271_attach(&dev
->ts1
.analog_fe
,
1125 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1126 &hauppauge_tda18271_config
);
1129 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1130 i2c_bus
= &dev
->i2c_bus
[0];
1131 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1132 &hcw_s5h1411_config
,
1133 &i2c_bus
->i2c_adap
);
1134 if (fe0
->dvb
.frontend
!= NULL
)
1135 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1136 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1137 &hauppauge_tda18271_config
);
1139 case CX23885_BOARD_MYGICA_X8558PRO
:
1143 i2c_bus
= &dev
->i2c_bus
[0];
1144 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1145 &mygica_x8558pro_atbm8830_cfg1
,
1146 &i2c_bus
->i2c_adap
);
1147 if (fe0
->dvb
.frontend
!= NULL
) {
1148 dvb_attach(max2165_attach
,
1151 &mygic_x8558pro_max2165_cfg1
);
1156 i2c_bus
= &dev
->i2c_bus
[1];
1157 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1158 &mygica_x8558pro_atbm8830_cfg2
,
1159 &i2c_bus
->i2c_adap
);
1160 if (fe0
->dvb
.frontend
!= NULL
) {
1161 dvb_attach(max2165_attach
,
1164 &mygic_x8558pro_max2165_cfg2
);
1169 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1170 i2c_bus
= &dev
->i2c_bus
[0];
1171 mfe_shared
= 1;/* MFE */
1172 port
->frontends
.gate
= 0;/* not clear for me yet */
1174 /* MFE frontend 1 DVB-T */
1175 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1176 &netup_stv0367_config
[port
->nr
- 1],
1177 &i2c_bus
->i2c_adap
);
1178 if (fe0
->dvb
.frontend
!= NULL
) {
1179 if (NULL
== dvb_attach(xc5000_attach
,
1182 &netup_xc5000_config
[port
->nr
- 1]))
1183 goto frontend_detach
;
1184 /* load xc5000 firmware */
1185 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1187 /* MFE frontend 2 */
1188 fe1
= videobuf_dvb_get_frontend(&port
->frontends
, 2);
1190 goto frontend_detach
;
1192 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1193 &netup_stv0367_config
[port
->nr
- 1],
1194 &i2c_bus
->i2c_adap
);
1195 if (fe1
->dvb
.frontend
!= NULL
) {
1196 fe1
->dvb
.frontend
->id
= 1;
1197 if (NULL
== dvb_attach(xc5000_attach
,
1200 &netup_xc5000_config
[port
->nr
- 1]))
1201 goto frontend_detach
;
1204 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1205 i2c_bus
= &dev
->i2c_bus
[0];
1206 i2c_bus2
= &dev
->i2c_bus
[1];
1211 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1212 &terratec_drxk_config
[0],
1213 &i2c_bus
->i2c_adap
);
1214 if (fe0
->dvb
.frontend
!= NULL
) {
1215 if (!dvb_attach(mt2063_attach
,
1217 &terratec_mt2063_config
[0],
1218 &i2c_bus2
->i2c_adap
))
1219 goto frontend_detach
;
1224 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1225 &terratec_drxk_config
[1],
1226 &i2c_bus
->i2c_adap
);
1227 if (fe0
->dvb
.frontend
!= NULL
) {
1228 if (!dvb_attach(mt2063_attach
,
1230 &terratec_mt2063_config
[1],
1231 &i2c_bus2
->i2c_adap
))
1232 goto frontend_detach
;
1237 case CX23885_BOARD_TEVII_S471
:
1238 i2c_bus
= &dev
->i2c_bus
[1];
1240 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1241 &tevii_ds3000_config
,
1242 &i2c_bus
->i2c_adap
);
1244 case CX23885_BOARD_PROF_8000
:
1245 i2c_bus
= &dev
->i2c_bus
[0];
1247 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1248 &prof_8000_stv090x_config
,
1250 STV090x_DEMODULATOR_0
);
1251 if (fe0
->dvb
.frontend
!= NULL
) {
1252 if (!dvb_attach(stb6100_attach
,
1254 &prof_8000_stb6100_config
,
1255 &i2c_bus
->i2c_adap
))
1256 goto frontend_detach
;
1258 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1261 case CX23885_BOARD_HAUPPAUGE_HVR4400
:
1262 i2c_bus
= &dev
->i2c_bus
[0];
1263 fe0
->dvb
.frontend
= dvb_attach(tda10071_attach
,
1264 &hauppauge_tda10071_config
,
1265 &i2c_bus
->i2c_adap
);
1266 if (fe0
->dvb
.frontend
!= NULL
) {
1267 dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
1269 &hauppauge_a8293_config
);
1273 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
1274 " isn't supported yet\n",
1279 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
1280 printk(KERN_ERR
"%s: frontend initialization failed\n",
1282 goto frontend_detach
;
1285 /* define general-purpose callback pointer */
1286 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1288 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1290 /* Ensure all frontends negotiate bus access */
1291 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1293 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1296 /* Put the analog decoder in standby to keep it quiet */
1297 call_all(dev
, core
, s_power
, 0);
1299 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
1300 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
1302 /* register everything */
1303 ret
= videobuf_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
1304 &dev
->pci
->dev
, adapter_nr
, mfe_shared
);
1306 goto frontend_detach
;
1309 switch (dev
->board
) {
1310 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1311 static struct netup_card_info cinfo
;
1313 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1314 memcpy(port
->frontends
.adapter
.proposed_mac
,
1315 cinfo
.port
[port
->nr
- 1].mac
, 6);
1316 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1317 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1319 netup_ci_init(port
);
1322 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1323 struct altera_ci_config netup_ci_cfg
= {
1324 .dev
= dev
,/* magic number to identify*/
1325 .adapter
= &port
->frontends
.adapter
,/* for CI */
1326 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1327 .fpga_rw
= netup_altera_fpga_rw
,
1330 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1333 case CX23885_BOARD_TEVII_S470
: {
1334 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1339 /* Read entire EEPROM */
1340 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1341 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1342 printk(KERN_INFO
"TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1343 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1351 port
->gate_ctrl
= NULL
;
1352 videobuf_dvb_dealloc_frontends(&port
->frontends
);
1356 int cx23885_dvb_register(struct cx23885_tsport
*port
)
1359 struct videobuf_dvb_frontend
*fe0
;
1360 struct cx23885_dev
*dev
= port
->dev
;
1363 /* Here we need to allocate the correct number of frontends,
1364 * as reflected in the cards struct. The reality is that currently
1365 * no cx23885 boards support this - yet. But, if we don't modify this
1366 * code then the second frontend would never be allocated (later)
1367 * and fail with error before the attach in dvb_register().
1368 * Without these changes we risk an OOPS later. The changes here
1369 * are for safety, and should provide a good foundation for the
1370 * future addition of any multi-frontend cx23885 based boards.
1372 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
1373 port
->num_frontends
);
1375 for (i
= 1; i
<= port
->num_frontends
; i
++) {
1376 if (videobuf_dvb_alloc_frontend(
1377 &port
->frontends
, i
) == NULL
) {
1378 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1382 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, i
);
1386 dprintk(1, "%s\n", __func__
);
1387 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
1396 /* We have to init the queue for each frontend on a port. */
1397 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
1398 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &dvb_qops
,
1399 &dev
->pci
->dev
, &port
->slock
,
1400 V4L2_BUF_TYPE_VIDEO_CAPTURE
, V4L2_FIELD_TOP
,
1401 sizeof(struct cx23885_buffer
), port
, NULL
);
1403 err
= dvb_register(port
);
1405 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
1411 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
1413 struct videobuf_dvb_frontend
*fe0
;
1415 /* FIXME: in an error condition where the we have
1416 * an expected number of frontends (attach problem)
1417 * then this might not clean up correctly, if 1
1419 * This comment only applies to future boards IF they
1420 * implement MFE support.
1422 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
1423 if (fe0
&& fe0
->dvb
.frontend
)
1424 videobuf_dvb_unregister_bus(&port
->frontends
);
1426 switch (port
->dev
->board
) {
1427 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1428 netup_ci_exit(port
);
1430 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1431 altera_ci_release(port
->dev
, port
->nr
);
1435 port
->gate_ctrl
= NULL
;