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"
48 #include "dibx000_common.h"
51 #include "stv0900_reg.h"
58 #include "netup-eeprom.h"
59 #include "netup-init.h"
64 #include "cx23885-f300.h"
65 #include "altera-ci.h"
71 #include "stb6100_cfg.h"
77 static unsigned int debug
;
79 #define dprintk(level, fmt, arg...)\
80 do { if (debug >= level)\
81 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
84 /* ------------------------------------------------------------------ */
86 static unsigned int alt_tuner
;
87 module_param(alt_tuner
, int, 0644);
88 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
90 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
92 /* ------------------------------------------------------------------ */
94 static int dvb_buf_setup(struct videobuf_queue
*q
,
95 unsigned int *count
, unsigned int *size
)
97 struct cx23885_tsport
*port
= q
->priv_data
;
99 port
->ts_packet_size
= 188 * 4;
100 port
->ts_packet_count
= 32;
102 *size
= port
->ts_packet_size
* port
->ts_packet_count
;
107 static int dvb_buf_prepare(struct videobuf_queue
*q
,
108 struct videobuf_buffer
*vb
, enum v4l2_field field
)
110 struct cx23885_tsport
*port
= q
->priv_data
;
111 return cx23885_buf_prepare(q
, port
, (struct cx23885_buffer
*)vb
, field
);
114 static void dvb_buf_queue(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
116 struct cx23885_tsport
*port
= q
->priv_data
;
117 cx23885_buf_queue(port
, (struct cx23885_buffer
*)vb
);
120 static void dvb_buf_release(struct videobuf_queue
*q
,
121 struct videobuf_buffer
*vb
)
123 cx23885_free_buffer(q
, (struct cx23885_buffer
*)vb
);
126 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport
*port
, int open
)
128 struct videobuf_dvb_frontends
*f
;
129 struct videobuf_dvb_frontend
*fe
;
131 f
= &port
->frontends
;
133 if (f
->gate
<= 1) /* undefined or fe0 */
134 fe
= videobuf_dvb_get_frontend(f
, 1);
136 fe
= videobuf_dvb_get_frontend(f
, f
->gate
);
138 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
139 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
142 static struct videobuf_queue_ops dvb_qops
= {
143 .buf_setup
= dvb_buf_setup
,
144 .buf_prepare
= dvb_buf_prepare
,
145 .buf_queue
= dvb_buf_queue
,
146 .buf_release
= dvb_buf_release
,
149 static struct s5h1409_config hauppauge_generic_config
= {
150 .demod_address
= 0x32 >> 1,
151 .output_mode
= S5H1409_SERIAL_OUTPUT
,
152 .gpio
= S5H1409_GPIO_ON
,
154 .inversion
= S5H1409_INVERSION_OFF
,
155 .status_mode
= S5H1409_DEMODLOCKING
,
156 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
159 static struct tda10048_config hauppauge_hvr1200_config
= {
160 .demod_address
= 0x10 >> 1,
161 .output_mode
= TDA10048_SERIAL_OUTPUT
,
162 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
163 .inversion
= TDA10048_INVERSION_ON
,
164 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
165 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
166 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
167 .clk_freq_khz
= TDA10048_CLK_16000
,
170 static struct tda10048_config hauppauge_hvr1210_config
= {
171 .demod_address
= 0x10 >> 1,
172 .output_mode
= TDA10048_SERIAL_OUTPUT
,
173 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
174 .inversion
= TDA10048_INVERSION_ON
,
175 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
176 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
177 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
178 .clk_freq_khz
= TDA10048_CLK_16000
,
181 static struct s5h1409_config hauppauge_ezqam_config
= {
182 .demod_address
= 0x32 >> 1,
183 .output_mode
= S5H1409_SERIAL_OUTPUT
,
184 .gpio
= S5H1409_GPIO_OFF
,
186 .inversion
= S5H1409_INVERSION_ON
,
187 .status_mode
= S5H1409_DEMODLOCKING
,
188 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
191 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
192 .demod_address
= 0x32 >> 1,
193 .output_mode
= S5H1409_SERIAL_OUTPUT
,
194 .gpio
= S5H1409_GPIO_OFF
,
196 .inversion
= S5H1409_INVERSION_OFF
,
197 .status_mode
= S5H1409_DEMODLOCKING
,
198 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
201 static struct s5h1409_config hauppauge_hvr1500_config
= {
202 .demod_address
= 0x32 >> 1,
203 .output_mode
= S5H1409_SERIAL_OUTPUT
,
204 .gpio
= S5H1409_GPIO_OFF
,
205 .inversion
= S5H1409_INVERSION_OFF
,
206 .status_mode
= S5H1409_DEMODLOCKING
,
207 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
210 static struct mt2131_config hauppauge_generic_tunerconfig
= {
214 static struct lgdt330x_config fusionhdtv_5_express
= {
215 .demod_address
= 0x0e,
216 .demod_chip
= LGDT3303
,
220 static struct s5h1409_config hauppauge_hvr1500q_config
= {
221 .demod_address
= 0x32 >> 1,
222 .output_mode
= S5H1409_SERIAL_OUTPUT
,
223 .gpio
= S5H1409_GPIO_ON
,
225 .inversion
= S5H1409_INVERSION_OFF
,
226 .status_mode
= S5H1409_DEMODLOCKING
,
227 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
230 static struct s5h1409_config dvico_s5h1409_config
= {
231 .demod_address
= 0x32 >> 1,
232 .output_mode
= S5H1409_SERIAL_OUTPUT
,
233 .gpio
= S5H1409_GPIO_ON
,
235 .inversion
= S5H1409_INVERSION_OFF
,
236 .status_mode
= S5H1409_DEMODLOCKING
,
237 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
240 static struct s5h1411_config dvico_s5h1411_config
= {
241 .output_mode
= S5H1411_SERIAL_OUTPUT
,
242 .gpio
= S5H1411_GPIO_ON
,
243 .qam_if
= S5H1411_IF_44000
,
244 .vsb_if
= S5H1411_IF_44000
,
245 .inversion
= S5H1411_INVERSION_OFF
,
246 .status_mode
= S5H1411_DEMODLOCKING
,
247 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
250 static struct s5h1411_config hcw_s5h1411_config
= {
251 .output_mode
= S5H1411_SERIAL_OUTPUT
,
252 .gpio
= S5H1411_GPIO_OFF
,
253 .vsb_if
= S5H1411_IF_44000
,
254 .qam_if
= S5H1411_IF_4000
,
255 .inversion
= S5H1411_INVERSION_ON
,
256 .status_mode
= S5H1411_DEMODLOCKING
,
257 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
260 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
265 static struct xc5000_config dvico_xc5000_tunerconfig
= {
270 static struct tda829x_config tda829x_no_probe
= {
271 .probe_tuner
= TDA829X_DONT_PROBE
,
274 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
275 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
276 .if_lvl
= 6, .rfagc_top
= 0x37 },
277 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
278 .if_lvl
= 6, .rfagc_top
= 0x37 },
281 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
282 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
283 .if_lvl
= 1, .rfagc_top
= 0x37, },
284 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
285 .if_lvl
= 1, .rfagc_top
= 0x37, },
286 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
287 .if_lvl
= 1, .rfagc_top
= 0x37, },
290 static struct tda18271_config hauppauge_tda18271_config
= {
291 .std_map
= &hauppauge_tda18271_std_map
,
292 .gate
= TDA18271_GATE_ANALOG
,
293 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
296 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
297 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
298 .gate
= TDA18271_GATE_ANALOG
,
299 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
302 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
303 .gate
= TDA18271_GATE_DIGITAL
,
304 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
307 static struct tda18271_config hauppauge_hvr4400_tuner_config
= {
308 .gate
= TDA18271_GATE_DIGITAL
,
309 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
312 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
313 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
314 .if_lvl
= 1, .rfagc_top
= 0x58 },
315 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
316 .if_lvl
= 1, .rfagc_top
= 0x58 },
319 static struct tda18271_config hauppauge_hvr127x_config
= {
320 .std_map
= &hauppauge_hvr127x_std_map
,
321 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
324 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
326 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
327 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
328 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
330 .spectral_inversion
= 1,
335 static struct dibx000_agc_config xc3028_agc_config
= {
336 BAND_VHF
| BAND_UHF
, /* band_caps */
338 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
339 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
340 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
341 * P_agc_nb_est=2, P_agc_write=0
343 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
344 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
347 21, /* time_stabiliz */
359 39718, /* agc2_max */
368 29, /* agc2_slope1 */
369 29, /* agc2_slope2 */
376 1, /* perform_agc_softsplit */
379 /* PLL Configuration for COFDM BW_MHz = 8.000000
380 * With external clock = 30.000000 */
381 static struct dibx000_bandwidth_config xc3028_bw_config
= {
382 60000, /* internal */
383 30000, /* sampling */
384 1, /* pll_cfg: prediv */
385 8, /* pll_cfg: ratio */
386 3, /* pll_cfg: range */
387 1, /* pll_cfg: reset */
388 0, /* pll_cfg: bypass */
389 0, /* misc: refdiv */
390 0, /* misc: bypclk_div */
391 1, /* misc: IO_CLK_en_core */
392 1, /* misc: ADClkSrc */
393 0, /* misc: modulo */
394 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
395 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
397 30000000 /* xtal_hz */
400 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
401 .output_mpeg2_in_188_bytes
= 1,
402 .hostbus_diversity
= 1,
403 .tuner_is_baseband
= 0,
406 .agc_config_count
= 1,
407 .agc
= &xc3028_agc_config
,
408 .bw
= &xc3028_bw_config
,
410 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
411 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
412 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
418 .output_mode
= OUTMODE_MPEG2_SERIAL
,
421 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
422 .demod_address
= 0x0f,
425 .disable_i2c_gate_ctrl
= 1,
428 static struct stv0900_reg stv0900_ts_regs
[] = {
429 { R0900_TSGENERAL
, 0x00 },
430 { R0900_P1_TSSPEED
, 0x40 },
431 { R0900_P2_TSSPEED
, 0x40 },
432 { R0900_P1_TSCFGM
, 0xc0 },
433 { R0900_P2_TSCFGM
, 0xc0 },
434 { R0900_P1_TSCFGH
, 0xe0 },
435 { R0900_P2_TSCFGH
, 0xe0 },
436 { R0900_P1_TSCFGL
, 0x20 },
437 { R0900_P2_TSCFGL
, 0x20 },
438 { 0xffff, 0xff }, /* terminate */
441 static struct stv0900_config netup_stv0900_config
= {
442 .demod_address
= 0x68,
443 .demod_mode
= 1, /* dual */
445 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
446 .diseqc_mode
= 2,/* 2/3 PWM */
447 .ts_config_regs
= stv0900_ts_regs
,
448 .tun1_maddress
= 0,/* 0x60 */
449 .tun2_maddress
= 3,/* 0x63 */
450 .tun1_adc
= 1,/* 1 Vpp */
451 .tun2_adc
= 1,/* 1 Vpp */
454 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
458 .gain
= 8, /* +16 dB - maximum gain */
461 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
465 .gain
= 8, /* +16 dB - maximum gain */
468 static struct cx24116_config tbs_cx24116_config
= {
469 .demod_address
= 0x55,
472 static struct cx24117_config tbs_cx24117_config
= {
473 .demod_address
= 0x55,
476 static struct ds3000_config tevii_ds3000_config
= {
477 .demod_address
= 0x68,
480 static struct ts2020_config tevii_ts2020_config
= {
481 .tuner_address
= 0x60,
483 .frequency_div
= 1146000,
486 static struct cx24116_config dvbworld_cx24116_config
= {
487 .demod_address
= 0x05,
490 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
491 .prod
= LGS8GXX_PROD_LGS8GL5
,
492 .demod_address
= 0x19,
496 .if_clk_freq
= 30400, /* 30.4 MHz */
497 .if_freq
= 5380, /* 5.38 MHz */
504 static struct xc5000_config mygica_x8506_xc5000_config
= {
509 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
510 .demod_address
= 0x10,
513 static struct xc5000_config mygica_x8507_xc5000_config
= {
518 static struct stv090x_config prof_8000_stv090x_config
= {
520 .demod_mode
= STV090x_SINGLE
,
521 .clk_mode
= STV090x_CLK_EXT
,
524 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
525 .repeater_level
= STV090x_RPTLEVEL_64
,
526 .adc1_range
= STV090x_ADC_2Vpp
,
527 .diseqc_envelope_mode
= false,
529 .tuner_get_frequency
= stb6100_get_frequency
,
530 .tuner_set_frequency
= stb6100_set_frequency
,
531 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
532 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
535 static struct stb6100_config prof_8000_stb6100_config
= {
536 .tuner_address
= 0x60,
537 .refclock
= 27000000,
540 static int p8000_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
542 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
543 struct cx23885_dev
*dev
= port
->dev
;
545 if (voltage
== SEC_VOLTAGE_18
)
546 cx_write(MC417_RWD
, 0x00001e00);
547 else if (voltage
== SEC_VOLTAGE_13
)
548 cx_write(MC417_RWD
, 0x00001a00);
550 cx_write(MC417_RWD
, 0x00001800);
554 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
556 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
557 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
558 struct cx23885_dev
*dev
= port
->dev
;
560 switch (dev
->board
) {
561 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
562 switch (p
->modulation
) {
564 cx23885_gpio_clear(dev
, GPIO_5
);
569 cx23885_gpio_set(dev
, GPIO_5
);
573 case CX23885_BOARD_MYGICA_X8506
:
574 case CX23885_BOARD_MYGICA_X8507
:
575 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
576 /* Select Digital TV */
577 cx23885_gpio_set(dev
, GPIO_0
);
581 /* Call the real set_frontend */
582 if (port
->set_frontend
)
583 return port
->set_frontend(fe
);
588 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
589 struct dvb_frontend
*fe
)
591 port
->set_frontend
= fe
->ops
.set_frontend
;
592 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
595 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
596 .prod
= LGS8GXX_PROD_LGS8G75
,
597 .demod_address
= 0x19,
601 .if_clk_freq
= 30400, /* 30.4 MHz */
602 .if_freq
= 6500, /* 6.50 MHz */
606 .adc_vpp
= 2, /* 1.6 Vpp */
610 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
615 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
616 .prod
= ATBM8830_PROD_8830
,
617 .demod_address
= 0x44,
619 .ts_sampling_edge
= 1,
621 .osc_clk_freq
= 30400, /* in kHz */
622 .if_freq
= 0, /* zero IF */
629 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
634 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
635 .prod
= ATBM8830_PROD_8830
,
636 .demod_address
= 0x44,
638 .ts_sampling_edge
= 1,
640 .osc_clk_freq
= 30400, /* in kHz */
641 .if_freq
= 0, /* zero IF */
648 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
652 static struct stv0367_config netup_stv0367_config
[] = {
654 .demod_address
= 0x1c,
661 .demod_address
= 0x1d,
670 static struct xc5000_config netup_xc5000_config
[] = {
680 static struct drxk_config terratec_drxk_config
[] = {
690 static struct mt2063_config terratec_mt2063_config
[] = {
692 .tuner_address
= 0x60,
694 .tuner_address
= 0x67,
698 static const struct tda10071_config hauppauge_tda10071_config
= {
699 .demod_i2c_addr
= 0x05,
700 .tuner_i2c_addr
= 0x54,
702 .ts_mode
= TDA10071_TS_SERIAL
,
704 .xtal
= 40444000, /* 40.444 MHz */
705 .pll_multiplier
= 20,
708 static const struct a8293_config hauppauge_a8293_config
= {
712 static const struct si2165_config hauppauge_hvr4400_si2165_config
= {
714 .chip_mode
= SI2165_MODE_PLL_XTAL
,
715 .ref_freq_Hz
= 16000000,
718 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
720 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
721 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
724 mem
= cx_read(MC417_RWD
);
726 cx_set(MC417_OEN
, ALT_DATA
);
728 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
730 mem
|= (data
& ALT_DATA
);
740 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
742 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
744 cx_write(MC417_RWD
, mem
); /* start RW cycle */
747 mem
= cx_read(MC417_RWD
);
748 if ((mem
& ALT_RDY
) == 0)
750 if (time_after(jiffies
, timeout
))
755 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
757 return mem
& ALT_DATA
;
762 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
764 struct dib7000p_ops
*dib7000p_ops
= fe
->sec_priv
;
766 return dib7000p_ops
->set_gpio(fe
, 8, 0, !onoff
);
769 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
774 static struct dib0070_config dib7070p_dib0070_config
= {
775 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
776 .reset
= dib7070_tuner_reset
,
777 .sleep
= dib7070_tuner_sleep
,
779 .freq_offset_khz_vhf
= 550,
780 /* .flip_chip = 1, */
783 /* DIB7070 generic */
784 static struct dibx000_agc_config dib7070_agc_config
= {
785 .band_caps
= BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
788 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
789 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
790 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
792 .setup
= (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
793 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
819 .perform_agc_softsplit
= 0,
822 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
835 /* refsel, sel, freq_15k */
836 .sad_cfg
= (3 << 14) | (1 << 12) | (524 << 0),
837 .ifreq
= (0 << 25) | 0,
842 static struct dib7000p_config dib7070p_dib7000p_config
= {
843 /* .output_mode = OUTMODE_MPEG2_FIFO, */
844 .output_mode
= OUTMODE_MPEG2_SERIAL
,
845 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
846 .output_mpeg2_in_188_bytes
= 1,
848 .agc_config_count
= 1,
849 .agc
= &dib7070_agc_config
,
850 .bw
= &dib7070_bw_config_12_mhz
,
851 .tuner_is_baseband
= 1,
854 .gpio_dir
= 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
855 .gpio_val
= 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
856 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
858 .hostbus_diversity
= 1,
861 static int dvb_register(struct cx23885_tsport
*port
)
863 struct dib7000p_ops dib7000p_ops
;
864 struct cx23885_dev
*dev
= port
->dev
;
865 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
866 struct videobuf_dvb_frontend
*fe0
, *fe1
= NULL
;
867 int mfe_shared
= 0; /* bus not shared by default */
870 /* Get the first frontend */
871 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
875 /* init struct videobuf_dvb */
876 fe0
->dvb
.name
= dev
->name
;
878 /* multi-frontend gate control is undefined or defaults to fe0 */
879 port
->frontends
.gate
= 0;
881 /* Sets the gate control callback to be used by i2c command calls */
882 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
885 switch (dev
->board
) {
886 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
887 i2c_bus
= &dev
->i2c_bus
[0];
888 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
889 &hauppauge_generic_config
,
891 if (fe0
->dvb
.frontend
!= NULL
) {
892 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
894 &hauppauge_generic_tunerconfig
, 0);
897 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
898 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
899 i2c_bus
= &dev
->i2c_bus
[0];
900 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
901 &hauppauge_lgdt3305_config
,
903 if (fe0
->dvb
.frontend
!= NULL
) {
904 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
905 0x60, &dev
->i2c_bus
[1].i2c_adap
,
906 &hauppauge_hvr127x_config
);
908 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
909 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
911 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
912 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
913 i2c_bus
= &dev
->i2c_bus
[0];
914 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
917 if (fe0
->dvb
.frontend
!= NULL
) {
918 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
919 0x60, &dev
->i2c_bus
[1].i2c_adap
,
920 &hauppauge_tda18271_config
);
923 tda18271_attach(&dev
->ts1
.analog_fe
,
924 0x60, &dev
->i2c_bus
[1].i2c_adap
,
925 &hauppauge_tda18271_config
);
928 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
929 i2c_bus
= &dev
->i2c_bus
[0];
933 dvb_attach(s5h1409_attach
,
934 &hauppauge_ezqam_config
,
936 if (fe0
->dvb
.frontend
!= NULL
) {
937 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
938 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
940 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
941 0x60, &dev
->i2c_bus
[1].i2c_adap
,
942 &hauppauge_tda18271_config
);
948 dvb_attach(s5h1409_attach
,
949 &hauppauge_generic_config
,
951 if (fe0
->dvb
.frontend
!= NULL
)
952 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
954 &hauppauge_generic_tunerconfig
, 0);
958 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
959 i2c_bus
= &dev
->i2c_bus
[0];
960 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
961 &hauppauge_hvr1800lp_config
,
963 if (fe0
->dvb
.frontend
!= NULL
) {
964 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
966 &hauppauge_generic_tunerconfig
, 0);
969 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
970 i2c_bus
= &dev
->i2c_bus
[0];
971 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
972 &fusionhdtv_5_express
,
974 if (fe0
->dvb
.frontend
!= NULL
) {
975 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
976 &i2c_bus
->i2c_adap
, 0x61,
977 TUNER_LG_TDVS_H06XF
);
980 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
981 i2c_bus
= &dev
->i2c_bus
[1];
982 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
983 &hauppauge_hvr1500q_config
,
984 &dev
->i2c_bus
[0].i2c_adap
);
985 if (fe0
->dvb
.frontend
!= NULL
)
986 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
988 &hauppauge_hvr1500q_tunerconfig
);
990 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
991 i2c_bus
= &dev
->i2c_bus
[1];
992 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
993 &hauppauge_hvr1500_config
,
994 &dev
->i2c_bus
[0].i2c_adap
);
995 if (fe0
->dvb
.frontend
!= NULL
) {
996 struct dvb_frontend
*fe
;
997 struct xc2028_config cfg
= {
998 .i2c_adap
= &i2c_bus
->i2c_adap
,
1001 static struct xc2028_ctrl ctl
= {
1002 .fname
= XC2028_DEFAULT_FIRMWARE
,
1004 .demod
= XC3028_FE_OREN538
,
1007 fe
= dvb_attach(xc2028_attach
,
1008 fe0
->dvb
.frontend
, &cfg
);
1009 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1010 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1013 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
1014 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
1015 i2c_bus
= &dev
->i2c_bus
[0];
1016 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1017 &hauppauge_hvr1200_config
,
1018 &i2c_bus
->i2c_adap
);
1019 if (fe0
->dvb
.frontend
!= NULL
) {
1020 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1021 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1023 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1024 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1025 &hauppauge_hvr1200_tuner_config
);
1028 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
1029 i2c_bus
= &dev
->i2c_bus
[0];
1030 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1031 &hauppauge_hvr1210_config
,
1032 &i2c_bus
->i2c_adap
);
1033 if (fe0
->dvb
.frontend
!= NULL
) {
1034 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1035 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1036 &hauppauge_hvr1210_tuner_config
);
1039 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
1040 i2c_bus
= &dev
->i2c_bus
[0];
1042 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1045 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
,
1046 0x12, &hauppauge_hvr1400_dib7000_config
);
1047 if (fe0
->dvb
.frontend
!= NULL
) {
1048 struct dvb_frontend
*fe
;
1049 struct xc2028_config cfg
= {
1050 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1053 static struct xc2028_ctrl ctl
= {
1054 .fname
= XC3028L_DEFAULT_FIRMWARE
,
1056 .demod
= XC3028_FE_DIBCOM52
,
1057 /* This is true for all demods with
1059 .type
= XC2028_D2633
,
1062 fe
= dvb_attach(xc2028_attach
,
1063 fe0
->dvb
.frontend
, &cfg
);
1064 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1065 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1068 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
1069 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1071 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1072 &dvico_s5h1409_config
,
1073 &i2c_bus
->i2c_adap
);
1074 if (fe0
->dvb
.frontend
== NULL
)
1075 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1076 &dvico_s5h1411_config
,
1077 &i2c_bus
->i2c_adap
);
1078 if (fe0
->dvb
.frontend
!= NULL
)
1079 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1081 &dvico_xc5000_tunerconfig
);
1083 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
1084 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1086 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1087 &dvico_fusionhdtv_xc3028
,
1088 &i2c_bus
->i2c_adap
);
1089 if (fe0
->dvb
.frontend
!= NULL
) {
1090 struct dvb_frontend
*fe
;
1091 struct xc2028_config cfg
= {
1092 .i2c_adap
= &i2c_bus
->i2c_adap
,
1095 static struct xc2028_ctrl ctl
= {
1096 .fname
= XC2028_DEFAULT_FIRMWARE
,
1098 .demod
= XC3028_FE_ZARLINK456
,
1101 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1103 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1104 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1108 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2
: {
1109 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1110 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1111 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1113 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1116 if (dib7000p_ops
.i2c_enumeration(&i2c_bus
->i2c_adap
, 1, 0x12, &dib7070p_dib7000p_config
) < 0) {
1117 printk(KERN_WARNING
"Unable to enumerate dib7000p\n");
1120 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
, 0x80, &dib7070p_dib7000p_config
);
1121 if (fe0
->dvb
.frontend
!= NULL
) {
1122 struct i2c_adapter
*tun_i2c
;
1124 fe0
->dvb
.frontend
->sec_priv
= kmalloc(sizeof(dib7000p_ops
), GFP_KERNEL
);
1125 memcpy(fe0
->dvb
.frontend
->sec_priv
, &dib7000p_ops
, sizeof(dib7000p_ops
));
1126 tun_i2c
= dib7000p_ops
.get_i2c_master(fe0
->dvb
.frontend
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1127 if (!dvb_attach(dib0070_attach
, fe0
->dvb
.frontend
, tun_i2c
, &dib7070p_dib0070_config
))
1132 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
1133 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
1134 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
1135 i2c_bus
= &dev
->i2c_bus
[0];
1137 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1138 &dvico_fusionhdtv_xc3028
,
1139 &i2c_bus
->i2c_adap
);
1140 if (fe0
->dvb
.frontend
!= NULL
) {
1141 struct dvb_frontend
*fe
;
1142 struct xc2028_config cfg
= {
1143 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1146 static struct xc2028_ctrl ctl
= {
1147 .fname
= XC2028_DEFAULT_FIRMWARE
,
1149 .demod
= XC3028_FE_ZARLINK456
,
1152 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1154 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1155 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1158 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1159 i2c_bus
= &dev
->i2c_bus
[0];
1161 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1162 &dvico_fusionhdtv_xc3028
,
1163 &i2c_bus
->i2c_adap
);
1164 if (fe0
->dvb
.frontend
!= NULL
) {
1165 struct dvb_frontend
*fe
;
1166 struct xc4000_config cfg
= {
1167 .i2c_address
= 0x61,
1169 .dvb_amplitude
= 134,
1170 .set_smoothedcvbs
= 1,
1174 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1175 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1177 printk(KERN_ERR
"%s/2: xc4000 attach failed\n",
1179 goto frontend_detach
;
1183 case CX23885_BOARD_TBS_6920
:
1184 i2c_bus
= &dev
->i2c_bus
[1];
1186 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1187 &tbs_cx24116_config
,
1188 &i2c_bus
->i2c_adap
);
1189 if (fe0
->dvb
.frontend
!= NULL
)
1190 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1193 case CX23885_BOARD_TBS_6980
:
1194 case CX23885_BOARD_TBS_6981
:
1195 i2c_bus
= &dev
->i2c_bus
[1];
1200 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1201 &tbs_cx24117_config
,
1202 &i2c_bus
->i2c_adap
);
1206 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1207 &tbs_cx24117_config
,
1208 &i2c_bus
->i2c_adap
);
1212 case CX23885_BOARD_TEVII_S470
:
1213 i2c_bus
= &dev
->i2c_bus
[1];
1215 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1216 &tevii_ds3000_config
,
1217 &i2c_bus
->i2c_adap
);
1218 if (fe0
->dvb
.frontend
!= NULL
) {
1219 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1220 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1221 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1225 case CX23885_BOARD_DVBWORLD_2005
:
1226 i2c_bus
= &dev
->i2c_bus
[1];
1228 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1229 &dvbworld_cx24116_config
,
1230 &i2c_bus
->i2c_adap
);
1232 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1233 i2c_bus
= &dev
->i2c_bus
[0];
1237 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1238 &netup_stv0900_config
,
1239 &i2c_bus
->i2c_adap
, 0);
1240 if (fe0
->dvb
.frontend
!= NULL
) {
1241 if (dvb_attach(stv6110_attach
,
1243 &netup_stv6110_tunerconfig_a
,
1244 &i2c_bus
->i2c_adap
)) {
1245 if (!dvb_attach(lnbh24_attach
,
1248 LNBH24_PCL
| LNBH24_TTX
,
1251 "No LNBH24 found!\n");
1258 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1259 &netup_stv0900_config
,
1260 &i2c_bus
->i2c_adap
, 1);
1261 if (fe0
->dvb
.frontend
!= NULL
) {
1262 if (dvb_attach(stv6110_attach
,
1264 &netup_stv6110_tunerconfig_b
,
1265 &i2c_bus
->i2c_adap
)) {
1266 if (!dvb_attach(lnbh24_attach
,
1269 LNBH24_PCL
| LNBH24_TTX
,
1272 "No LNBH24 found!\n");
1279 case CX23885_BOARD_MYGICA_X8506
:
1280 i2c_bus
= &dev
->i2c_bus
[0];
1281 i2c_bus2
= &dev
->i2c_bus
[1];
1282 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1283 &mygica_x8506_lgs8gl5_config
,
1284 &i2c_bus
->i2c_adap
);
1285 if (fe0
->dvb
.frontend
!= NULL
) {
1286 dvb_attach(xc5000_attach
,
1288 &i2c_bus2
->i2c_adap
,
1289 &mygica_x8506_xc5000_config
);
1291 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1293 case CX23885_BOARD_MYGICA_X8507
:
1294 i2c_bus
= &dev
->i2c_bus
[0];
1295 i2c_bus2
= &dev
->i2c_bus
[1];
1296 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1297 &mygica_x8507_mb86a20s_config
,
1298 &i2c_bus
->i2c_adap
);
1299 if (fe0
->dvb
.frontend
!= NULL
) {
1300 dvb_attach(xc5000_attach
,
1302 &i2c_bus2
->i2c_adap
,
1303 &mygica_x8507_xc5000_config
);
1305 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1307 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1308 i2c_bus
= &dev
->i2c_bus
[0];
1309 i2c_bus2
= &dev
->i2c_bus
[1];
1310 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1311 &magicpro_prohdtve2_lgs8g75_config
,
1312 &i2c_bus
->i2c_adap
);
1313 if (fe0
->dvb
.frontend
!= NULL
) {
1314 dvb_attach(xc5000_attach
,
1316 &i2c_bus2
->i2c_adap
,
1317 &magicpro_prohdtve2_xc5000_config
);
1319 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1321 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1322 i2c_bus
= &dev
->i2c_bus
[0];
1323 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1324 &hcw_s5h1411_config
,
1325 &i2c_bus
->i2c_adap
);
1326 if (fe0
->dvb
.frontend
!= NULL
)
1327 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1328 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1329 &hauppauge_tda18271_config
);
1331 tda18271_attach(&dev
->ts1
.analog_fe
,
1332 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1333 &hauppauge_tda18271_config
);
1336 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1337 i2c_bus
= &dev
->i2c_bus
[0];
1338 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1339 &hcw_s5h1411_config
,
1340 &i2c_bus
->i2c_adap
);
1341 if (fe0
->dvb
.frontend
!= NULL
)
1342 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1343 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1344 &hauppauge_tda18271_config
);
1346 case CX23885_BOARD_MYGICA_X8558PRO
:
1350 i2c_bus
= &dev
->i2c_bus
[0];
1351 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1352 &mygica_x8558pro_atbm8830_cfg1
,
1353 &i2c_bus
->i2c_adap
);
1354 if (fe0
->dvb
.frontend
!= NULL
) {
1355 dvb_attach(max2165_attach
,
1358 &mygic_x8558pro_max2165_cfg1
);
1363 i2c_bus
= &dev
->i2c_bus
[1];
1364 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1365 &mygica_x8558pro_atbm8830_cfg2
,
1366 &i2c_bus
->i2c_adap
);
1367 if (fe0
->dvb
.frontend
!= NULL
) {
1368 dvb_attach(max2165_attach
,
1371 &mygic_x8558pro_max2165_cfg2
);
1376 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1377 i2c_bus
= &dev
->i2c_bus
[0];
1378 mfe_shared
= 1;/* MFE */
1379 port
->frontends
.gate
= 0;/* not clear for me yet */
1381 /* MFE frontend 1 DVB-T */
1382 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1383 &netup_stv0367_config
[port
->nr
- 1],
1384 &i2c_bus
->i2c_adap
);
1385 if (fe0
->dvb
.frontend
!= NULL
) {
1386 if (NULL
== dvb_attach(xc5000_attach
,
1389 &netup_xc5000_config
[port
->nr
- 1]))
1390 goto frontend_detach
;
1391 /* load xc5000 firmware */
1392 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1394 /* MFE frontend 2 */
1395 fe1
= videobuf_dvb_get_frontend(&port
->frontends
, 2);
1397 goto frontend_detach
;
1399 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1400 &netup_stv0367_config
[port
->nr
- 1],
1401 &i2c_bus
->i2c_adap
);
1402 if (fe1
->dvb
.frontend
!= NULL
) {
1403 fe1
->dvb
.frontend
->id
= 1;
1404 if (NULL
== dvb_attach(xc5000_attach
,
1407 &netup_xc5000_config
[port
->nr
- 1]))
1408 goto frontend_detach
;
1411 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1412 i2c_bus
= &dev
->i2c_bus
[0];
1413 i2c_bus2
= &dev
->i2c_bus
[1];
1418 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1419 &terratec_drxk_config
[0],
1420 &i2c_bus
->i2c_adap
);
1421 if (fe0
->dvb
.frontend
!= NULL
) {
1422 if (!dvb_attach(mt2063_attach
,
1424 &terratec_mt2063_config
[0],
1425 &i2c_bus2
->i2c_adap
))
1426 goto frontend_detach
;
1431 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1432 &terratec_drxk_config
[1],
1433 &i2c_bus
->i2c_adap
);
1434 if (fe0
->dvb
.frontend
!= NULL
) {
1435 if (!dvb_attach(mt2063_attach
,
1437 &terratec_mt2063_config
[1],
1438 &i2c_bus2
->i2c_adap
))
1439 goto frontend_detach
;
1444 case CX23885_BOARD_TEVII_S471
:
1445 i2c_bus
= &dev
->i2c_bus
[1];
1447 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1448 &tevii_ds3000_config
,
1449 &i2c_bus
->i2c_adap
);
1450 if (fe0
->dvb
.frontend
!= NULL
) {
1451 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1452 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1455 case CX23885_BOARD_PROF_8000
:
1456 i2c_bus
= &dev
->i2c_bus
[0];
1458 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1459 &prof_8000_stv090x_config
,
1461 STV090x_DEMODULATOR_0
);
1462 if (fe0
->dvb
.frontend
!= NULL
) {
1463 if (!dvb_attach(stb6100_attach
,
1465 &prof_8000_stb6100_config
,
1466 &i2c_bus
->i2c_adap
))
1467 goto frontend_detach
;
1469 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1472 case CX23885_BOARD_HAUPPAUGE_HVR4400
:
1473 i2c_bus
= &dev
->i2c_bus
[0];
1474 i2c_bus2
= &dev
->i2c_bus
[1];
1478 fe0
->dvb
.frontend
= dvb_attach(tda10071_attach
,
1479 &hauppauge_tda10071_config
,
1480 &i2c_bus
->i2c_adap
);
1481 if (fe0
->dvb
.frontend
!= NULL
) {
1482 if (!dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
1484 &hauppauge_a8293_config
))
1485 goto frontend_detach
;
1490 fe0
->dvb
.frontend
= dvb_attach(si2165_attach
,
1491 &hauppauge_hvr4400_si2165_config
,
1492 &i2c_bus
->i2c_adap
);
1493 if (fe0
->dvb
.frontend
!= NULL
) {
1494 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= 0;
1495 if (!dvb_attach(tda18271_attach
,
1497 0x60, &i2c_bus2
->i2c_adap
,
1498 &hauppauge_hvr4400_tuner_config
))
1499 goto frontend_detach
;
1505 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
1506 " isn't supported yet\n",
1511 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
1512 printk(KERN_ERR
"%s: frontend initialization failed\n",
1514 goto frontend_detach
;
1517 /* define general-purpose callback pointer */
1518 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1520 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
1522 /* Ensure all frontends negotiate bus access */
1523 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1525 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
1528 /* Put the analog decoder in standby to keep it quiet */
1529 call_all(dev
, core
, s_power
, 0);
1531 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
1532 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
1534 /* register everything */
1535 ret
= videobuf_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
1536 &dev
->pci
->dev
, adapter_nr
, mfe_shared
);
1538 goto frontend_detach
;
1541 switch (dev
->board
) {
1542 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1543 static struct netup_card_info cinfo
;
1545 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1546 memcpy(port
->frontends
.adapter
.proposed_mac
,
1547 cinfo
.port
[port
->nr
- 1].mac
, 6);
1548 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1549 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1551 netup_ci_init(port
);
1554 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1555 struct altera_ci_config netup_ci_cfg
= {
1556 .dev
= dev
,/* magic number to identify*/
1557 .adapter
= &port
->frontends
.adapter
,/* for CI */
1558 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1559 .fpga_rw
= netup_altera_fpga_rw
,
1562 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1565 case CX23885_BOARD_TEVII_S470
: {
1566 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1571 /* Read entire EEPROM */
1572 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1573 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1574 printk(KERN_INFO
"TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1575 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1583 port
->gate_ctrl
= NULL
;
1584 videobuf_dvb_dealloc_frontends(&port
->frontends
);
1588 int cx23885_dvb_register(struct cx23885_tsport
*port
)
1591 struct videobuf_dvb_frontend
*fe0
;
1592 struct cx23885_dev
*dev
= port
->dev
;
1595 /* Here we need to allocate the correct number of frontends,
1596 * as reflected in the cards struct. The reality is that currently
1597 * no cx23885 boards support this - yet. But, if we don't modify this
1598 * code then the second frontend would never be allocated (later)
1599 * and fail with error before the attach in dvb_register().
1600 * Without these changes we risk an OOPS later. The changes here
1601 * are for safety, and should provide a good foundation for the
1602 * future addition of any multi-frontend cx23885 based boards.
1604 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
1605 port
->num_frontends
);
1607 for (i
= 1; i
<= port
->num_frontends
; i
++) {
1608 if (videobuf_dvb_alloc_frontend(
1609 &port
->frontends
, i
) == NULL
) {
1610 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
1614 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, i
);
1618 dprintk(1, "%s\n", __func__
);
1619 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
1628 /* We have to init the queue for each frontend on a port. */
1629 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
1630 videobuf_queue_sg_init(&fe0
->dvb
.dvbq
, &dvb_qops
,
1631 &dev
->pci
->dev
, &port
->slock
,
1632 V4L2_BUF_TYPE_VIDEO_CAPTURE
, V4L2_FIELD_TOP
,
1633 sizeof(struct cx23885_buffer
), port
, NULL
);
1635 err
= dvb_register(port
);
1637 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
1643 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
1645 struct videobuf_dvb_frontend
*fe0
;
1647 /* FIXME: in an error condition where the we have
1648 * an expected number of frontends (attach problem)
1649 * then this might not clean up correctly, if 1
1651 * This comment only applies to future boards IF they
1652 * implement MFE support.
1654 fe0
= videobuf_dvb_get_frontend(&port
->frontends
, 1);
1655 if (fe0
&& fe0
->dvb
.frontend
)
1656 videobuf_dvb_unregister_bus(&port
->frontends
);
1658 switch (port
->dev
->board
) {
1659 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1660 netup_ci_exit(port
);
1662 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1663 altera_ci_release(port
->dev
, port
->nr
);
1667 port
->gate_ctrl
= NULL
;