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"
62 #include "cx23885-f300.h"
63 #include "altera-ci.h"
69 #include "stb6100_cfg.h"
74 static unsigned int debug
;
76 #define dprintk(level, fmt, arg...)\
77 do { if (debug >= level)\
78 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
81 /* ------------------------------------------------------------------ */
83 static unsigned int alt_tuner
;
84 module_param(alt_tuner
, int, 0644);
85 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
87 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
89 /* ------------------------------------------------------------------ */
91 static int dvb_buf_setup(struct videobuf_queue
*q
,
92 unsigned int *count
, unsigned int *size
)
94 struct cx23885_tsport
*port
= q
->priv_data
;
96 port
->ts_packet_size
= 188 * 4;
97 port
->ts_packet_count
= 32;
99 *size
= port
->ts_packet_size
* port
->ts_packet_count
;
104 static int dvb_buf_prepare(struct videobuf_queue
*q
,
105 struct videobuf_buffer
*vb
, enum v4l2_field field
)
107 struct cx23885_tsport
*port
= q
->priv_data
;
108 return cx23885_buf_prepare(q
, port
, (struct cx23885_buffer
*)vb
, field
);
111 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
113 struct cx23885_tsport
*port
= q
->priv_data
;
114 cx23885_buf_queue(port
, (struct cx23885_buffer
*)vb
);
117 static void dvb_buf_release(struct videobuf_queue
*q
,
118 struct videobuf_buffer
*vb
)
120 cx23885_free_buffer(q
, (struct cx23885_buffer
*)vb
);
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 static struct videobuf_queue_ops dvb_qops
= {
140 .buf_setup
= dvb_buf_setup
,
141 .buf_prepare
= dvb_buf_prepare
,
142 .buf_queue
= dvb_buf_queue
,
143 .buf_release
= dvb_buf_release
,
146 static struct s5h1409_config hauppauge_generic_config
= {
147 .demod_address
= 0x32 >> 1,
148 .output_mode
= S5H1409_SERIAL_OUTPUT
,
149 .gpio
= S5H1409_GPIO_ON
,
151 .inversion
= S5H1409_INVERSION_OFF
,
152 .status_mode
= S5H1409_DEMODLOCKING
,
153 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
156 static struct tda10048_config hauppauge_hvr1200_config
= {
157 .demod_address
= 0x10 >> 1,
158 .output_mode
= TDA10048_SERIAL_OUTPUT
,
159 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
160 .inversion
= TDA10048_INVERSION_ON
,
161 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
162 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
163 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
164 .clk_freq_khz
= TDA10048_CLK_16000
,
167 static struct tda10048_config hauppauge_hvr1210_config
= {
168 .demod_address
= 0x10 >> 1,
169 .output_mode
= TDA10048_SERIAL_OUTPUT
,
170 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
171 .inversion
= TDA10048_INVERSION_ON
,
172 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
173 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
174 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
175 .clk_freq_khz
= TDA10048_CLK_16000
,
178 static struct s5h1409_config hauppauge_ezqam_config
= {
179 .demod_address
= 0x32 >> 1,
180 .output_mode
= S5H1409_SERIAL_OUTPUT
,
181 .gpio
= S5H1409_GPIO_OFF
,
183 .inversion
= S5H1409_INVERSION_ON
,
184 .status_mode
= S5H1409_DEMODLOCKING
,
185 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
188 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
189 .demod_address
= 0x32 >> 1,
190 .output_mode
= S5H1409_SERIAL_OUTPUT
,
191 .gpio
= S5H1409_GPIO_OFF
,
193 .inversion
= S5H1409_INVERSION_OFF
,
194 .status_mode
= S5H1409_DEMODLOCKING
,
195 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
198 static struct s5h1409_config hauppauge_hvr1500_config
= {
199 .demod_address
= 0x32 >> 1,
200 .output_mode
= S5H1409_SERIAL_OUTPUT
,
201 .gpio
= S5H1409_GPIO_OFF
,
202 .inversion
= S5H1409_INVERSION_OFF
,
203 .status_mode
= S5H1409_DEMODLOCKING
,
204 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
207 static struct mt2131_config hauppauge_generic_tunerconfig
= {
211 static struct lgdt330x_config fusionhdtv_5_express
= {
212 .demod_address
= 0x0e,
213 .demod_chip
= LGDT3303
,
217 static struct s5h1409_config hauppauge_hvr1500q_config
= {
218 .demod_address
= 0x32 >> 1,
219 .output_mode
= S5H1409_SERIAL_OUTPUT
,
220 .gpio
= S5H1409_GPIO_ON
,
222 .inversion
= S5H1409_INVERSION_OFF
,
223 .status_mode
= S5H1409_DEMODLOCKING
,
224 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
227 static struct s5h1409_config dvico_s5h1409_config
= {
228 .demod_address
= 0x32 >> 1,
229 .output_mode
= S5H1409_SERIAL_OUTPUT
,
230 .gpio
= S5H1409_GPIO_ON
,
232 .inversion
= S5H1409_INVERSION_OFF
,
233 .status_mode
= S5H1409_DEMODLOCKING
,
234 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
237 static struct s5h1411_config dvico_s5h1411_config
= {
238 .output_mode
= S5H1411_SERIAL_OUTPUT
,
239 .gpio
= S5H1411_GPIO_ON
,
240 .qam_if
= S5H1411_IF_44000
,
241 .vsb_if
= S5H1411_IF_44000
,
242 .inversion
= S5H1411_INVERSION_OFF
,
243 .status_mode
= S5H1411_DEMODLOCKING
,
244 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
247 static struct s5h1411_config hcw_s5h1411_config
= {
248 .output_mode
= S5H1411_SERIAL_OUTPUT
,
249 .gpio
= S5H1411_GPIO_OFF
,
250 .vsb_if
= S5H1411_IF_44000
,
251 .qam_if
= S5H1411_IF_4000
,
252 .inversion
= S5H1411_INVERSION_ON
,
253 .status_mode
= S5H1411_DEMODLOCKING
,
254 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
257 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
262 static struct xc5000_config dvico_xc5000_tunerconfig
= {
267 static struct tda829x_config tda829x_no_probe
= {
268 .probe_tuner
= TDA829X_DONT_PROBE
,
271 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
272 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
273 .if_lvl
= 6, .rfagc_top
= 0x37 },
274 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
275 .if_lvl
= 6, .rfagc_top
= 0x37 },
278 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
279 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
280 .if_lvl
= 1, .rfagc_top
= 0x37, },
281 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
282 .if_lvl
= 1, .rfagc_top
= 0x37, },
283 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
284 .if_lvl
= 1, .rfagc_top
= 0x37, },
287 static struct tda18271_config hauppauge_tda18271_config
= {
288 .std_map
= &hauppauge_tda18271_std_map
,
289 .gate
= TDA18271_GATE_ANALOG
,
290 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
293 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
294 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
295 .gate
= TDA18271_GATE_ANALOG
,
296 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
299 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
300 .gate
= TDA18271_GATE_DIGITAL
,
301 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
304 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
305 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
306 .if_lvl
= 1, .rfagc_top
= 0x58 },
307 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
308 .if_lvl
= 1, .rfagc_top
= 0x58 },
311 static struct tda18271_config hauppauge_hvr127x_config
= {
312 .std_map
= &hauppauge_hvr127x_std_map
,
313 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
316 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
318 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
319 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
320 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
322 .spectral_inversion
= 1,
327 static struct dibx000_agc_config xc3028_agc_config
= {
328 BAND_VHF
| BAND_UHF
, /* band_caps */
330 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
331 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
332 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
333 * P_agc_nb_est=2, P_agc_write=0
335 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
336 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
339 21, /* time_stabiliz */
351 39718, /* agc2_max */
360 29, /* agc2_slope1 */
361 29, /* agc2_slope2 */
368 1, /* perform_agc_softsplit */
371 /* PLL Configuration for COFDM BW_MHz = 8.000000
372 * With external clock = 30.000000 */
373 static struct dibx000_bandwidth_config xc3028_bw_config
= {
374 60000, /* internal */
375 30000, /* sampling */
376 1, /* pll_cfg: prediv */
377 8, /* pll_cfg: ratio */
378 3, /* pll_cfg: range */
379 1, /* pll_cfg: reset */
380 0, /* pll_cfg: bypass */
381 0, /* misc: refdiv */
382 0, /* misc: bypclk_div */
383 1, /* misc: IO_CLK_en_core */
384 1, /* misc: ADClkSrc */
385 0, /* misc: modulo */
386 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
387 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
389 30000000 /* xtal_hz */
392 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
393 .output_mpeg2_in_188_bytes
= 1,
394 .hostbus_diversity
= 1,
395 .tuner_is_baseband
= 0,
398 .agc_config_count
= 1,
399 .agc
= &xc3028_agc_config
,
400 .bw
= &xc3028_bw_config
,
402 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
403 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
404 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
410 .output_mode
= OUTMODE_MPEG2_SERIAL
,
413 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
414 .demod_address
= 0x0f,
417 .disable_i2c_gate_ctrl
= 1,
420 static struct stv0900_reg stv0900_ts_regs
[] = {
421 { R0900_TSGENERAL
, 0x00 },
422 { R0900_P1_TSSPEED
, 0x40 },
423 { R0900_P2_TSSPEED
, 0x40 },
424 { R0900_P1_TSCFGM
, 0xc0 },
425 { R0900_P2_TSCFGM
, 0xc0 },
426 { R0900_P1_TSCFGH
, 0xe0 },
427 { R0900_P2_TSCFGH
, 0xe0 },
428 { R0900_P1_TSCFGL
, 0x20 },
429 { R0900_P2_TSCFGL
, 0x20 },
430 { 0xffff, 0xff }, /* terminate */
433 static struct stv0900_config netup_stv0900_config
= {
434 .demod_address
= 0x68,
435 .demod_mode
= 1, /* dual */
437 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
438 .diseqc_mode
= 2,/* 2/3 PWM */
439 .ts_config_regs
= stv0900_ts_regs
,
440 .tun1_maddress
= 0,/* 0x60 */
441 .tun2_maddress
= 3,/* 0x63 */
442 .tun1_adc
= 1,/* 1 Vpp */
443 .tun2_adc
= 1,/* 1 Vpp */
446 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
450 .gain
= 8, /* +16 dB - maximum gain */
453 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
457 .gain
= 8, /* +16 dB - maximum gain */
460 static struct cx24116_config tbs_cx24116_config
= {
461 .demod_address
= 0x55,
464 static struct ds3000_config tevii_ds3000_config
= {
465 .demod_address
= 0x68,
468 static struct ts2020_config tevii_ts2020_config
= {
469 .tuner_address
= 0x60,
473 static struct cx24116_config dvbworld_cx24116_config
= {
474 .demod_address
= 0x05,
477 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
478 .prod
= LGS8GXX_PROD_LGS8GL5
,
479 .demod_address
= 0x19,
483 .if_clk_freq
= 30400, /* 30.4 MHz */
484 .if_freq
= 5380, /* 5.38 MHz */
491 static struct xc5000_config mygica_x8506_xc5000_config
= {
496 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
497 .demod_address
= 0x10,
500 static struct xc5000_config mygica_x8507_xc5000_config
= {
505 static struct stv090x_config prof_8000_stv090x_config
= {
507 .demod_mode
= STV090x_SINGLE
,
508 .clk_mode
= STV090x_CLK_EXT
,
511 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
512 .repeater_level
= STV090x_RPTLEVEL_64
,
513 .adc1_range
= STV090x_ADC_2Vpp
,
514 .diseqc_envelope_mode
= false,
516 .tuner_get_frequency
= stb6100_get_frequency
,
517 .tuner_set_frequency
= stb6100_set_frequency
,
518 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
519 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
522 static struct stb6100_config prof_8000_stb6100_config
= {
523 .tuner_address
= 0x60,
524 .refclock
= 27000000,
527 static int p8000_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
529 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
530 struct cx23885_dev
*dev
= port
->dev
;
532 if (voltage
== SEC_VOLTAGE_18
)
533 cx_write(MC417_RWD
, 0x00001e00);
534 else if (voltage
== SEC_VOLTAGE_13
)
535 cx_write(MC417_RWD
, 0x00001a00);
537 cx_write(MC417_RWD
, 0x00001800);
541 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
543 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
544 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
545 struct cx23885_dev
*dev
= port
->dev
;
547 switch (dev
->board
) {
548 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
549 switch (p
->modulation
) {
551 cx23885_gpio_clear(dev
, GPIO_5
);
556 cx23885_gpio_set(dev
, GPIO_5
);
560 case CX23885_BOARD_MYGICA_X8506
:
561 case CX23885_BOARD_MYGICA_X8507
:
562 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
563 /* Select Digital TV */
564 cx23885_gpio_set(dev
, GPIO_0
);
568 /* Call the real set_frontend */
569 if (port
->set_frontend
)
570 return port
->set_frontend(fe
);
575 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
576 struct dvb_frontend
*fe
)
578 port
->set_frontend
= fe
->ops
.set_frontend
;
579 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
582 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
583 .prod
= LGS8GXX_PROD_LGS8G75
,
584 .demod_address
= 0x19,
588 .if_clk_freq
= 30400, /* 30.4 MHz */
589 .if_freq
= 6500, /* 6.50 MHz */
593 .adc_vpp
= 2, /* 1.6 Vpp */
597 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
602 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
603 .prod
= ATBM8830_PROD_8830
,
604 .demod_address
= 0x44,
606 .ts_sampling_edge
= 1,
608 .osc_clk_freq
= 30400, /* in kHz */
609 .if_freq
= 0, /* zero IF */
616 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
621 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
622 .prod
= ATBM8830_PROD_8830
,
623 .demod_address
= 0x44,
625 .ts_sampling_edge
= 1,
627 .osc_clk_freq
= 30400, /* in kHz */
628 .if_freq
= 0, /* zero IF */
635 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
639 static struct stv0367_config netup_stv0367_config
[] = {
641 .demod_address
= 0x1c,
648 .demod_address
= 0x1d,
657 static struct xc5000_config netup_xc5000_config
[] = {
667 static struct drxk_config terratec_drxk_config
[] = {
677 static struct mt2063_config terratec_mt2063_config
[] = {
679 .tuner_address
= 0x60,
681 .tuner_address
= 0x67,
685 static const struct tda10071_config hauppauge_tda10071_config
= {
686 .demod_i2c_addr
= 0x05,
687 .tuner_i2c_addr
= 0x54,
689 .ts_mode
= TDA10071_TS_SERIAL
,
691 .xtal
= 40444000, /* 40.444 MHz */
692 .pll_multiplier
= 20,
695 static const struct a8293_config hauppauge_a8293_config
= {
699 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
701 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
702 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
705 mem
= cx_read(MC417_RWD
);
707 cx_set(MC417_OEN
, ALT_DATA
);
709 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
711 mem
|= (data
& ALT_DATA
);
721 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
723 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
725 cx_write(MC417_RWD
, mem
); /* start RW cycle */
728 mem
= cx_read(MC417_RWD
);
729 if ((mem
& ALT_RDY
) == 0)
731 if (time_after(jiffies
, timeout
))
736 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
738 return mem
& ALT_DATA
;
743 static int dvb_register(struct cx23885_tsport
*port
)
745 struct cx23885_dev
*dev
= port
->dev
;
746 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
747 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
748 int mfe_shared
= 0; /* bus not shared by default */
751 /* Get the first frontend */
752 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
756 /* init struct videobuf_dvb */
757 fe0
->dvb
.name
= dev
->name
;
759 /* multi-frontend gate control is undefined or defaults to fe0 */
760 port
->frontends
.gate
= 0;
762 /* Sets the gate control callback to be used by i2c command calls */
763 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
766 switch (dev
->board
) {
767 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
768 i2c_bus
= &dev
->i2c_bus
[0];
769 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
770 &hauppauge_generic_config
,
772 if (fe0
->dvb
.frontend
!= NULL
) {
773 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
775 &hauppauge_generic_tunerconfig
, 0);
778 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
779 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
780 i2c_bus
= &dev
->i2c_bus
[0];
781 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
782 &hauppauge_lgdt3305_config
,
784 if (fe0
->dvb
.frontend
!= NULL
) {
785 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
786 0x60, &dev
->i2c_bus
[1].i2c_adap
,
787 &hauppauge_hvr127x_config
);
789 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
790 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
792 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
793 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
794 i2c_bus
= &dev
->i2c_bus
[0];
795 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
798 if (fe0
->dvb
.frontend
!= NULL
) {
799 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
800 0x60, &dev
->i2c_bus
[1].i2c_adap
,
801 &hauppauge_tda18271_config
);
804 tda18271_attach(&dev
->ts1
.analog_fe
,
805 0x60, &dev
->i2c_bus
[1].i2c_adap
,
806 &hauppauge_tda18271_config
);
809 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
810 i2c_bus
= &dev
->i2c_bus
[0];
814 dvb_attach(s5h1409_attach
,
815 &hauppauge_ezqam_config
,
817 if (fe0
->dvb
.frontend
!= NULL
) {
818 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
819 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
821 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
822 0x60, &dev
->i2c_bus
[1].i2c_adap
,
823 &hauppauge_tda18271_config
);
829 dvb_attach(s5h1409_attach
,
830 &hauppauge_generic_config
,
832 if (fe0
->dvb
.frontend
!= NULL
)
833 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
835 &hauppauge_generic_tunerconfig
, 0);
839 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
840 i2c_bus
= &dev
->i2c_bus
[0];
841 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
842 &hauppauge_hvr1800lp_config
,
844 if (fe0
->dvb
.frontend
!= NULL
) {
845 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
847 &hauppauge_generic_tunerconfig
, 0);
850 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
851 i2c_bus
= &dev
->i2c_bus
[0];
852 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
853 &fusionhdtv_5_express
,
855 if (fe0
->dvb
.frontend
!= NULL
) {
856 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
857 &i2c_bus
->i2c_adap
, 0x61,
858 TUNER_LG_TDVS_H06XF
);
861 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
862 i2c_bus
= &dev
->i2c_bus
[1];
863 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
864 &hauppauge_hvr1500q_config
,
865 &dev
->i2c_bus
[0].i2c_adap
);
866 if (fe0
->dvb
.frontend
!= NULL
)
867 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
869 &hauppauge_hvr1500q_tunerconfig
);
871 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
872 i2c_bus
= &dev
->i2c_bus
[1];
873 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
874 &hauppauge_hvr1500_config
,
875 &dev
->i2c_bus
[0].i2c_adap
);
876 if (fe0
->dvb
.frontend
!= NULL
) {
877 struct dvb_frontend
*fe
;
878 struct xc2028_config cfg
= {
879 .i2c_adap
= &i2c_bus
->i2c_adap
,
882 static struct xc2028_ctrl ctl
= {
883 .fname
= XC2028_DEFAULT_FIRMWARE
,
885 .demod
= XC3028_FE_OREN538
,
888 fe
= dvb_attach(xc2028_attach
,
889 fe0
->dvb
.frontend
, &cfg
);
890 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
891 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
894 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
895 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
896 i2c_bus
= &dev
->i2c_bus
[0];
897 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
898 &hauppauge_hvr1200_config
,
900 if (fe0
->dvb
.frontend
!= NULL
) {
901 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
902 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
904 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
905 0x60, &dev
->i2c_bus
[1].i2c_adap
,
906 &hauppauge_hvr1200_tuner_config
);
909 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
910 i2c_bus
= &dev
->i2c_bus
[0];
911 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
912 &hauppauge_hvr1210_config
,
914 if (fe0
->dvb
.frontend
!= NULL
) {
915 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
916 0x60, &dev
->i2c_bus
[1].i2c_adap
,
917 &hauppauge_hvr1210_tuner_config
);
920 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
921 i2c_bus
= &dev
->i2c_bus
[0];
922 fe0
->dvb
.frontend
= dvb_attach(dib7000p_attach
,
924 0x12, &hauppauge_hvr1400_dib7000_config
);
925 if (fe0
->dvb
.frontend
!= NULL
) {
926 struct dvb_frontend
*fe
;
927 struct xc2028_config cfg
= {
928 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
931 static struct xc2028_ctrl ctl
= {
932 .fname
= XC3028L_DEFAULT_FIRMWARE
,
934 .demod
= XC3028_FE_DIBCOM52
,
935 /* This is true for all demods with
937 .type
= XC2028_D2633
,
940 fe
= dvb_attach(xc2028_attach
,
941 fe0
->dvb
.frontend
, &cfg
);
942 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
943 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
946 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
947 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
949 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
950 &dvico_s5h1409_config
,
952 if (fe0
->dvb
.frontend
== NULL
)
953 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
954 &dvico_s5h1411_config
,
956 if (fe0
->dvb
.frontend
!= NULL
)
957 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
959 &dvico_xc5000_tunerconfig
);
961 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
962 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
964 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
965 &dvico_fusionhdtv_xc3028
,
967 if (fe0
->dvb
.frontend
!= NULL
) {
968 struct dvb_frontend
*fe
;
969 struct xc2028_config cfg
= {
970 .i2c_adap
= &i2c_bus
->i2c_adap
,
973 static struct xc2028_ctrl ctl
= {
974 .fname
= XC2028_DEFAULT_FIRMWARE
,
976 .demod
= XC3028_FE_ZARLINK456
,
979 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
981 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
982 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
986 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
987 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
988 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
989 i2c_bus
= &dev
->i2c_bus
[0];
991 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
992 &dvico_fusionhdtv_xc3028
,
994 if (fe0
->dvb
.frontend
!= NULL
) {
995 struct dvb_frontend
*fe
;
996 struct xc2028_config cfg
= {
997 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1000 static struct xc2028_ctrl ctl
= {
1001 .fname
= XC2028_DEFAULT_FIRMWARE
,
1003 .demod
= XC3028_FE_ZARLINK456
,
1006 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1008 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1009 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1012 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1013 i2c_bus
= &dev
->i2c_bus
[0];
1015 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1016 &dvico_fusionhdtv_xc3028
,
1017 &i2c_bus
->i2c_adap
);
1018 if (fe0
->dvb
.frontend
!= NULL
) {
1019 struct dvb_frontend
*fe
;
1020 struct xc4000_config cfg
= {
1021 .i2c_address
= 0x61,
1023 .dvb_amplitude
= 134,
1024 .set_smoothedcvbs
= 1,
1028 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1029 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1031 printk(KERN_ERR
"%s/2: xc4000 attach failed\n",
1033 goto frontend_detach
;
1037 case CX23885_BOARD_TBS_6920
:
1038 i2c_bus
= &dev
->i2c_bus
[1];
1040 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1041 &tbs_cx24116_config
,
1042 &i2c_bus
->i2c_adap
);
1043 if (fe0
->dvb
.frontend
!= NULL
)
1044 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1047 case CX23885_BOARD_TEVII_S470
:
1048 i2c_bus
= &dev
->i2c_bus
[1];
1050 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1051 &tevii_ds3000_config
,
1052 &i2c_bus
->i2c_adap
);
1053 if (fe0
->dvb
.frontend
!= NULL
) {
1054 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1055 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1056 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1060 case CX23885_BOARD_DVBWORLD_2005
:
1061 i2c_bus
= &dev
->i2c_bus
[1];
1063 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1064 &dvbworld_cx24116_config
,
1065 &i2c_bus
->i2c_adap
);
1067 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1068 i2c_bus
= &dev
->i2c_bus
[0];
1072 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1073 &netup_stv0900_config
,
1074 &i2c_bus
->i2c_adap
, 0);
1075 if (fe0
->dvb
.frontend
!= NULL
) {
1076 if (dvb_attach(stv6110_attach
,
1078 &netup_stv6110_tunerconfig_a
,
1079 &i2c_bus
->i2c_adap
)) {
1080 if (!dvb_attach(lnbh24_attach
,
1083 LNBH24_PCL
| LNBH24_TTX
,
1086 "No LNBH24 found!\n");
1093 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1094 &netup_stv0900_config
,
1095 &i2c_bus
->i2c_adap
, 1);
1096 if (fe0
->dvb
.frontend
!= NULL
) {
1097 if (dvb_attach(stv6110_attach
,
1099 &netup_stv6110_tunerconfig_b
,
1100 &i2c_bus
->i2c_adap
)) {
1101 if (!dvb_attach(lnbh24_attach
,
1104 LNBH24_PCL
| LNBH24_TTX
,
1107 "No LNBH24 found!\n");
1114 case CX23885_BOARD_MYGICA_X8506
:
1115 i2c_bus
= &dev
->i2c_bus
[0];
1116 i2c_bus2
= &dev
->i2c_bus
[1];
1117 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1118 &mygica_x8506_lgs8gl5_config
,
1119 &i2c_bus
->i2c_adap
);
1120 if (fe0
->dvb
.frontend
!= NULL
) {
1121 dvb_attach(xc5000_attach
,
1123 &i2c_bus2
->i2c_adap
,
1124 &mygica_x8506_xc5000_config
);
1126 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1128 case CX23885_BOARD_MYGICA_X8507
:
1129 i2c_bus
= &dev
->i2c_bus
[0];
1130 i2c_bus2
= &dev
->i2c_bus
[1];
1131 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1132 &mygica_x8507_mb86a20s_config
,
1133 &i2c_bus
->i2c_adap
);
1134 if (fe0
->dvb
.frontend
!= NULL
) {
1135 dvb_attach(xc5000_attach
,
1137 &i2c_bus2
->i2c_adap
,
1138 &mygica_x8507_xc5000_config
);
1140 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1142 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1143 i2c_bus
= &dev
->i2c_bus
[0];
1144 i2c_bus2
= &dev
->i2c_bus
[1];
1145 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1146 &magicpro_prohdtve2_lgs8g75_config
,
1147 &i2c_bus
->i2c_adap
);
1148 if (fe0
->dvb
.frontend
!= NULL
) {
1149 dvb_attach(xc5000_attach
,
1151 &i2c_bus2
->i2c_adap
,
1152 &magicpro_prohdtve2_xc5000_config
);
1154 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1156 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1157 i2c_bus
= &dev
->i2c_bus
[0];
1158 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1159 &hcw_s5h1411_config
,
1160 &i2c_bus
->i2c_adap
);
1161 if (fe0
->dvb
.frontend
!= NULL
)
1162 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1163 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1164 &hauppauge_tda18271_config
);
1166 tda18271_attach(&dev
->ts1
.analog_fe
,
1167 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1168 &hauppauge_tda18271_config
);
1171 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1172 i2c_bus
= &dev
->i2c_bus
[0];
1173 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1174 &hcw_s5h1411_config
,
1175 &i2c_bus
->i2c_adap
);
1176 if (fe0
->dvb
.frontend
!= NULL
)
1177 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1178 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1179 &hauppauge_tda18271_config
);
1181 case CX23885_BOARD_MYGICA_X8558PRO
:
1185 i2c_bus
= &dev
->i2c_bus
[0];
1186 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1187 &mygica_x8558pro_atbm8830_cfg1
,
1188 &i2c_bus
->i2c_adap
);
1189 if (fe0
->dvb
.frontend
!= NULL
) {
1190 dvb_attach(max2165_attach
,
1193 &mygic_x8558pro_max2165_cfg1
);
1198 i2c_bus
= &dev
->i2c_bus
[1];
1199 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1200 &mygica_x8558pro_atbm8830_cfg2
,
1201 &i2c_bus
->i2c_adap
);
1202 if (fe0
->dvb
.frontend
!= NULL
) {
1203 dvb_attach(max2165_attach
,
1206 &mygic_x8558pro_max2165_cfg2
);
1211 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1212 i2c_bus
= &dev
->i2c_bus
[0];
1213 mfe_shared
= 1;/* MFE */
1214 port
->frontends
.gate
= 0;/* not clear for me yet */
1216 /* MFE frontend 1 DVB-T */
1217 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1218 &netup_stv0367_config
[port
->nr
- 1],
1219 &i2c_bus
->i2c_adap
);
1220 if (fe0
->dvb
.frontend
!= NULL
) {
1221 if (NULL
== dvb_attach(xc5000_attach
,
1224 &netup_xc5000_config
[port
->nr
- 1]))
1225 goto frontend_detach
;
1226 /* load xc5000 firmware */
1227 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1229 /* MFE frontend 2 */
1230 fe1
= videobuf_dvb_get_frontend(&port
->frontends
, 2);
1232 goto frontend_detach
;
1234 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1235 &netup_stv0367_config
[port
->nr
- 1],
1236 &i2c_bus
->i2c_adap
);
1237 if (fe1
->dvb
.frontend
!= NULL
) {
1238 fe1
->dvb
.frontend
->id
= 1;
1239 if (NULL
== dvb_attach(xc5000_attach
,
1242 &netup_xc5000_config
[port
->nr
- 1]))
1243 goto frontend_detach
;
1246 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1247 i2c_bus
= &dev
->i2c_bus
[0];
1248 i2c_bus2
= &dev
->i2c_bus
[1];
1253 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1254 &terratec_drxk_config
[0],
1255 &i2c_bus
->i2c_adap
);
1256 if (fe0
->dvb
.frontend
!= NULL
) {
1257 if (!dvb_attach(mt2063_attach
,
1259 &terratec_mt2063_config
[0],
1260 &i2c_bus2
->i2c_adap
))
1261 goto frontend_detach
;
1266 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1267 &terratec_drxk_config
[1],
1268 &i2c_bus
->i2c_adap
);
1269 if (fe0
->dvb
.frontend
!= NULL
) {
1270 if (!dvb_attach(mt2063_attach
,
1272 &terratec_mt2063_config
[1],
1273 &i2c_bus2
->i2c_adap
))
1274 goto frontend_detach
;
1279 case CX23885_BOARD_TEVII_S471
:
1280 i2c_bus
= &dev
->i2c_bus
[1];
1282 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1283 &tevii_ds3000_config
,
1284 &i2c_bus
->i2c_adap
);
1285 if (fe0
->dvb
.frontend
!= NULL
) {
1286 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1287 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1290 case CX23885_BOARD_PROF_8000
:
1291 i2c_bus
= &dev
->i2c_bus
[0];
1293 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1294 &prof_8000_stv090x_config
,
1296 STV090x_DEMODULATOR_0
);
1297 if (fe0
->dvb
.frontend
!= NULL
) {
1298 if (!dvb_attach(stb6100_attach
,
1300 &prof_8000_stb6100_config
,
1301 &i2c_bus
->i2c_adap
))
1302 goto frontend_detach
;
1304 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1307 case CX23885_BOARD_HAUPPAUGE_HVR4400
:
1308 i2c_bus
= &dev
->i2c_bus
[0];
1309 fe0
->dvb
.frontend
= dvb_attach(tda10071_attach
,
1310 &hauppauge_tda10071_config
,
1311 &i2c_bus
->i2c_adap
);
1312 if (fe0
->dvb
.frontend
!= NULL
) {
1313 dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
1315 &hauppauge_a8293_config
);
1319 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
1320 " isn't supported yet\n",
1325 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
1326 printk(KERN_ERR
"%s: frontend initialization failed\n",
1328 goto frontend_detach
;
1331 /* define general-purpose callback pointer */
1332 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1334 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1336 /* Ensure all frontends negotiate bus access */
1337 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1339 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1342 /* Put the analog decoder in standby to keep it quiet */
1343 call_all(dev
, core
, s_power
, 0);
1345 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
1346 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
1348 /* register everything */
1349 ret
= videobuf_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
1350 &dev
->pci
->dev
, adapter_nr
, mfe_shared
);
1352 goto frontend_detach
;
1355 switch (dev
->board
) {
1356 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1357 static struct netup_card_info cinfo
;
1359 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1360 memcpy(port
->frontends
.adapter
.proposed_mac
,
1361 cinfo
.port
[port
->nr
- 1].mac
, 6);
1362 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1363 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1365 netup_ci_init(port
);
1368 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1369 struct altera_ci_config netup_ci_cfg
= {
1370 .dev
= dev
,/* magic number to identify*/
1371 .adapter
= &port
->frontends
.adapter
,/* for CI */
1372 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1373 .fpga_rw
= netup_altera_fpga_rw
,
1376 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1379 case CX23885_BOARD_TEVII_S470
: {
1380 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1385 /* Read entire EEPROM */
1386 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1387 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1388 printk(KERN_INFO
"TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1389 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1397 port
->gate_ctrl
= NULL
;
1398 videobuf_dvb_dealloc_frontends(&port
->frontends
);
1402 int cx23885_dvb_register(struct cx23885_tsport
*port
)
1405 struct videobuf_dvb_frontend
*fe0
;
1406 struct cx23885_dev
*dev
= port
->dev
;
1409 /* Here we need to allocate the correct number of frontends,
1410 * as reflected in the cards struct. The reality is that currently
1411 * no cx23885 boards support this - yet. But, if we don't modify this
1412 * code then the second frontend would never be allocated (later)
1413 * and fail with error before the attach in dvb_register().
1414 * Without these changes we risk an OOPS later. The changes here
1415 * are for safety, and should provide a good foundation for the
1416 * future addition of any multi-frontend cx23885 based boards.
1418 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
1419 port
->num_frontends
);
1421 for (i
= 1; i
<= port
->num_frontends
; i
++) {
1422 if (videobuf_dvb_alloc_frontend(
1423 &port
->frontends
, i
) == NULL
) {
1424 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1428 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, i
);
1432 dprintk(1, "%s\n", __func__
);
1433 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
1442 /* We have to init the queue for each frontend on a port. */
1443 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
1444 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &dvb_qops
,
1445 &dev
->pci
->dev
, &port
->slock
,
1446 V4L2_BUF_TYPE_VIDEO_CAPTURE
, V4L2_FIELD_TOP
,
1447 sizeof(struct cx23885_buffer
), port
, NULL
);
1449 err
= dvb_register(port
);
1451 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
1457 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
1459 struct videobuf_dvb_frontend
*fe0
;
1461 /* FIXME: in an error condition where the we have
1462 * an expected number of frontends (attach problem)
1463 * then this might not clean up correctly, if 1
1465 * This comment only applies to future boards IF they
1466 * implement MFE support.
1468 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
1469 if (fe0
&& fe0
->dvb
.frontend
)
1470 videobuf_dvb_unregister_bus(&port
->frontends
);
1472 switch (port
->dev
->board
) {
1473 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1474 netup_ci_exit(port
);
1476 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1477 altera_ci_release(port
->dev
, port
->nr
);
1481 port
->gate_ctrl
= NULL
;