1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for the Conexant CX23885 PCIe bridge
5 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/device.h>
14 #include <linux/kthread.h>
15 #include <linux/file.h>
16 #include <linux/suspend.h>
18 #include <media/v4l2-common.h>
20 #include <media/dvb_ca_en50221.h>
31 #include "tuner-xc2028.h"
32 #include "tuner-simple.h"
35 #include "dibx000_common.h"
38 #include "stv0900_reg.h"
45 #include "netup-eeprom.h"
46 #include "netup-init.h"
51 #include "cx23885-f300.h"
52 #include "altera-ci.h"
58 #include "stb6100_cfg.h"
66 #include "m88ds3103.h"
67 #include "m88rs6000t.h"
68 #include "lgdt3306a.h"
70 static unsigned int debug
;
72 #define dprintk(level, fmt, arg...)\
73 do { if (debug >= level)\
74 printk(KERN_DEBUG pr_fmt("%s dvb: " fmt), \
78 /* ------------------------------------------------------------------ */
80 static unsigned int alt_tuner
;
81 module_param(alt_tuner
, int, 0644);
82 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
84 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
86 /* ------------------------------------------------------------------ */
88 static int queue_setup(struct vb2_queue
*q
,
89 unsigned int *num_buffers
, unsigned int *num_planes
,
90 unsigned int sizes
[], struct device
*alloc_devs
[])
92 struct cx23885_tsport
*port
= q
->drv_priv
;
94 port
->ts_packet_size
= 188 * 4;
95 port
->ts_packet_count
= 32;
97 sizes
[0] = port
->ts_packet_size
* port
->ts_packet_count
;
103 static int buffer_prepare(struct vb2_buffer
*vb
)
105 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
106 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
107 struct cx23885_buffer
*buf
=
108 container_of(vbuf
, struct cx23885_buffer
, vb
);
110 return cx23885_buf_prepare(buf
, port
);
113 static void buffer_finish(struct vb2_buffer
*vb
)
115 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
116 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
117 struct cx23885_dev
*dev
= port
->dev
;
118 struct cx23885_buffer
*buf
= container_of(vbuf
,
119 struct cx23885_buffer
, vb
);
121 cx23885_free_buffer(dev
, buf
);
124 static void buffer_queue(struct vb2_buffer
*vb
)
126 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
127 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
128 struct cx23885_buffer
*buf
= container_of(vbuf
,
129 struct cx23885_buffer
, vb
);
131 cx23885_buf_queue(port
, buf
);
134 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport
*port
, int open
)
136 struct vb2_dvb_frontends
*f
;
137 struct vb2_dvb_frontend
*fe
;
139 f
= &port
->frontends
;
141 if (f
->gate
<= 1) /* undefined or fe0 */
142 fe
= vb2_dvb_get_frontend(f
, 1);
144 fe
= vb2_dvb_get_frontend(f
, f
->gate
);
146 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
147 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
150 static int cx23885_start_streaming(struct vb2_queue
*q
, unsigned int count
)
152 struct cx23885_tsport
*port
= q
->drv_priv
;
153 struct cx23885_dmaqueue
*dmaq
= &port
->mpegq
;
154 struct cx23885_buffer
*buf
= list_entry(dmaq
->active
.next
,
155 struct cx23885_buffer
, queue
);
157 cx23885_start_dma(port
, dmaq
, buf
);
161 static void cx23885_stop_streaming(struct vb2_queue
*q
)
163 struct cx23885_tsport
*port
= q
->drv_priv
;
165 cx23885_cancel_buffers(port
);
168 static const struct vb2_ops dvb_qops
= {
169 .queue_setup
= queue_setup
,
170 .buf_prepare
= buffer_prepare
,
171 .buf_finish
= buffer_finish
,
172 .buf_queue
= buffer_queue
,
173 .wait_prepare
= vb2_ops_wait_prepare
,
174 .wait_finish
= vb2_ops_wait_finish
,
175 .start_streaming
= cx23885_start_streaming
,
176 .stop_streaming
= cx23885_stop_streaming
,
179 static struct s5h1409_config hauppauge_generic_config
= {
180 .demod_address
= 0x32 >> 1,
181 .output_mode
= S5H1409_SERIAL_OUTPUT
,
182 .gpio
= S5H1409_GPIO_ON
,
184 .inversion
= S5H1409_INVERSION_OFF
,
185 .status_mode
= S5H1409_DEMODLOCKING
,
186 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
189 static struct tda10048_config hauppauge_hvr1200_config
= {
190 .demod_address
= 0x10 >> 1,
191 .output_mode
= TDA10048_SERIAL_OUTPUT
,
192 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
193 .inversion
= TDA10048_INVERSION_ON
,
194 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
195 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
196 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
197 .clk_freq_khz
= TDA10048_CLK_16000
,
200 static struct tda10048_config hauppauge_hvr1210_config
= {
201 .demod_address
= 0x10 >> 1,
202 .output_mode
= TDA10048_SERIAL_OUTPUT
,
203 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
204 .inversion
= TDA10048_INVERSION_ON
,
205 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
206 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
207 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
208 .clk_freq_khz
= TDA10048_CLK_16000
,
211 static struct s5h1409_config hauppauge_ezqam_config
= {
212 .demod_address
= 0x32 >> 1,
213 .output_mode
= S5H1409_SERIAL_OUTPUT
,
214 .gpio
= S5H1409_GPIO_OFF
,
216 .inversion
= S5H1409_INVERSION_ON
,
217 .status_mode
= S5H1409_DEMODLOCKING
,
218 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
221 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
222 .demod_address
= 0x32 >> 1,
223 .output_mode
= S5H1409_SERIAL_OUTPUT
,
224 .gpio
= S5H1409_GPIO_OFF
,
226 .inversion
= S5H1409_INVERSION_OFF
,
227 .status_mode
= S5H1409_DEMODLOCKING
,
228 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
231 static struct s5h1409_config hauppauge_hvr1500_config
= {
232 .demod_address
= 0x32 >> 1,
233 .output_mode
= S5H1409_SERIAL_OUTPUT
,
234 .gpio
= S5H1409_GPIO_OFF
,
235 .inversion
= S5H1409_INVERSION_OFF
,
236 .status_mode
= S5H1409_DEMODLOCKING
,
237 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
240 static struct mt2131_config hauppauge_generic_tunerconfig
= {
244 static struct lgdt330x_config fusionhdtv_5_express
= {
245 .demod_chip
= LGDT3303
,
249 static struct s5h1409_config hauppauge_hvr1500q_config
= {
250 .demod_address
= 0x32 >> 1,
251 .output_mode
= S5H1409_SERIAL_OUTPUT
,
252 .gpio
= S5H1409_GPIO_ON
,
254 .inversion
= S5H1409_INVERSION_OFF
,
255 .status_mode
= S5H1409_DEMODLOCKING
,
256 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
259 static struct s5h1409_config dvico_s5h1409_config
= {
260 .demod_address
= 0x32 >> 1,
261 .output_mode
= S5H1409_SERIAL_OUTPUT
,
262 .gpio
= S5H1409_GPIO_ON
,
264 .inversion
= S5H1409_INVERSION_OFF
,
265 .status_mode
= S5H1409_DEMODLOCKING
,
266 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
269 static struct s5h1411_config dvico_s5h1411_config
= {
270 .output_mode
= S5H1411_SERIAL_OUTPUT
,
271 .gpio
= S5H1411_GPIO_ON
,
272 .qam_if
= S5H1411_IF_44000
,
273 .vsb_if
= S5H1411_IF_44000
,
274 .inversion
= S5H1411_INVERSION_OFF
,
275 .status_mode
= S5H1411_DEMODLOCKING
,
276 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
279 static struct s5h1411_config hcw_s5h1411_config
= {
280 .output_mode
= S5H1411_SERIAL_OUTPUT
,
281 .gpio
= S5H1411_GPIO_OFF
,
282 .vsb_if
= S5H1411_IF_44000
,
283 .qam_if
= S5H1411_IF_4000
,
284 .inversion
= S5H1411_INVERSION_ON
,
285 .status_mode
= S5H1411_DEMODLOCKING
,
286 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
289 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
294 static struct xc5000_config dvico_xc5000_tunerconfig
= {
299 static struct tda829x_config tda829x_no_probe
= {
300 .probe_tuner
= TDA829X_DONT_PROBE
,
303 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
304 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
305 .if_lvl
= 6, .rfagc_top
= 0x37 },
306 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
307 .if_lvl
= 6, .rfagc_top
= 0x37 },
310 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
311 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
312 .if_lvl
= 1, .rfagc_top
= 0x37, },
313 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
314 .if_lvl
= 1, .rfagc_top
= 0x37, },
315 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
316 .if_lvl
= 1, .rfagc_top
= 0x37, },
319 static struct tda18271_config hauppauge_tda18271_config
= {
320 .std_map
= &hauppauge_tda18271_std_map
,
321 .gate
= TDA18271_GATE_ANALOG
,
322 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
325 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
326 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
327 .gate
= TDA18271_GATE_ANALOG
,
328 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
331 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
332 .gate
= TDA18271_GATE_DIGITAL
,
333 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
336 static struct tda18271_config hauppauge_hvr4400_tuner_config
= {
337 .gate
= TDA18271_GATE_DIGITAL
,
338 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
341 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
342 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
343 .if_lvl
= 1, .rfagc_top
= 0x58 },
344 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
345 .if_lvl
= 1, .rfagc_top
= 0x58 },
348 static struct tda18271_config hauppauge_hvr127x_config
= {
349 .std_map
= &hauppauge_hvr127x_std_map
,
350 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
353 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
355 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
356 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
357 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
359 .spectral_inversion
= 1,
364 static struct dibx000_agc_config xc3028_agc_config
= {
365 BAND_VHF
| BAND_UHF
, /* band_caps */
367 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
368 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
369 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
370 * P_agc_nb_est=2, P_agc_write=0
372 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
373 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
376 21, /* time_stabiliz */
388 39718, /* agc2_max */
397 29, /* agc2_slope1 */
398 29, /* agc2_slope2 */
405 1, /* perform_agc_softsplit */
408 /* PLL Configuration for COFDM BW_MHz = 8.000000
409 * With external clock = 30.000000 */
410 static struct dibx000_bandwidth_config xc3028_bw_config
= {
411 60000, /* internal */
412 30000, /* sampling */
413 1, /* pll_cfg: prediv */
414 8, /* pll_cfg: ratio */
415 3, /* pll_cfg: range */
416 1, /* pll_cfg: reset */
417 0, /* pll_cfg: bypass */
418 0, /* misc: refdiv */
419 0, /* misc: bypclk_div */
420 1, /* misc: IO_CLK_en_core */
421 1, /* misc: ADClkSrc */
422 0, /* misc: modulo */
423 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
424 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
426 30000000 /* xtal_hz */
429 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
430 .output_mpeg2_in_188_bytes
= 1,
431 .hostbus_diversity
= 1,
432 .tuner_is_baseband
= 0,
435 .agc_config_count
= 1,
436 .agc
= &xc3028_agc_config
,
437 .bw
= &xc3028_bw_config
,
439 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
440 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
441 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
447 .output_mode
= OUTMODE_MPEG2_SERIAL
,
450 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
451 .demod_address
= 0x0f,
454 .disable_i2c_gate_ctrl
= 1,
457 static struct stv0900_reg stv0900_ts_regs
[] = {
458 { R0900_TSGENERAL
, 0x00 },
459 { R0900_P1_TSSPEED
, 0x40 },
460 { R0900_P2_TSSPEED
, 0x40 },
461 { R0900_P1_TSCFGM
, 0xc0 },
462 { R0900_P2_TSCFGM
, 0xc0 },
463 { R0900_P1_TSCFGH
, 0xe0 },
464 { R0900_P2_TSCFGH
, 0xe0 },
465 { R0900_P1_TSCFGL
, 0x20 },
466 { R0900_P2_TSCFGL
, 0x20 },
467 { 0xffff, 0xff }, /* terminate */
470 static struct stv0900_config netup_stv0900_config
= {
471 .demod_address
= 0x68,
472 .demod_mode
= 1, /* dual */
474 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
475 .diseqc_mode
= 2,/* 2/3 PWM */
476 .ts_config_regs
= stv0900_ts_regs
,
477 .tun1_maddress
= 0,/* 0x60 */
478 .tun2_maddress
= 3,/* 0x63 */
479 .tun1_adc
= 1,/* 1 Vpp */
480 .tun2_adc
= 1,/* 1 Vpp */
483 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
487 .gain
= 8, /* +16 dB - maximum gain */
490 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
494 .gain
= 8, /* +16 dB - maximum gain */
497 static struct cx24116_config tbs_cx24116_config
= {
498 .demod_address
= 0x55,
501 static struct cx24117_config tbs_cx24117_config
= {
502 .demod_address
= 0x55,
505 static struct ds3000_config tevii_ds3000_config
= {
506 .demod_address
= 0x68,
509 static struct ts2020_config tevii_ts2020_config
= {
510 .tuner_address
= 0x60,
512 .frequency_div
= 1146000,
515 static struct cx24116_config dvbworld_cx24116_config
= {
516 .demod_address
= 0x05,
519 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
520 .prod
= LGS8GXX_PROD_LGS8GL5
,
521 .demod_address
= 0x19,
525 .if_clk_freq
= 30400, /* 30.4 MHz */
526 .if_freq
= 5380, /* 5.38 MHz */
533 static struct xc5000_config mygica_x8506_xc5000_config
= {
538 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
539 .demod_address
= 0x10,
542 static struct xc5000_config mygica_x8507_xc5000_config
= {
547 static struct stv090x_config prof_8000_stv090x_config
= {
549 .demod_mode
= STV090x_SINGLE
,
550 .clk_mode
= STV090x_CLK_EXT
,
553 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
554 .repeater_level
= STV090x_RPTLEVEL_64
,
555 .adc1_range
= STV090x_ADC_2Vpp
,
556 .diseqc_envelope_mode
= false,
558 .tuner_get_frequency
= stb6100_get_frequency
,
559 .tuner_set_frequency
= stb6100_set_frequency
,
560 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
561 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
564 static struct stb6100_config prof_8000_stb6100_config
= {
565 .tuner_address
= 0x60,
566 .refclock
= 27000000,
569 static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config
= {
573 .deny_i2c_rptr
= 1, /* Disabled */
574 .spectral_inversion
= 0, /* Disabled */
575 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
576 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
577 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
578 .xtalMHz
= 25, /* 24 or 25 */
581 static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config
= {
585 .deny_i2c_rptr
= 1, /* Disabled */
586 .spectral_inversion
= 0, /* Disabled */
587 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
588 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
589 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
590 .xtalMHz
= 25, /* 24 or 25 */
593 static int p8000_set_voltage(struct dvb_frontend
*fe
,
594 enum fe_sec_voltage voltage
)
596 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
597 struct cx23885_dev
*dev
= port
->dev
;
599 if (voltage
== SEC_VOLTAGE_18
)
600 cx_write(MC417_RWD
, 0x00001e00);
601 else if (voltage
== SEC_VOLTAGE_13
)
602 cx_write(MC417_RWD
, 0x00001a00);
604 cx_write(MC417_RWD
, 0x00001800);
608 static int dvbsky_t9580_set_voltage(struct dvb_frontend
*fe
,
609 enum fe_sec_voltage voltage
)
611 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
612 struct cx23885_dev
*dev
= port
->dev
;
614 cx23885_gpio_enable(dev
, GPIO_0
| GPIO_1
, 1);
618 cx23885_gpio_set(dev
, GPIO_1
);
619 cx23885_gpio_clear(dev
, GPIO_0
);
622 cx23885_gpio_set(dev
, GPIO_1
);
623 cx23885_gpio_set(dev
, GPIO_0
);
625 case SEC_VOLTAGE_OFF
:
626 cx23885_gpio_clear(dev
, GPIO_1
);
627 cx23885_gpio_clear(dev
, GPIO_0
);
631 /* call the frontend set_voltage function */
632 port
->fe_set_voltage(fe
, voltage
);
637 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend
*fe
,
638 enum fe_sec_voltage voltage
)
640 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
641 struct cx23885_dev
*dev
= port
->dev
;
643 cx23885_gpio_enable(dev
, GPIO_12
| GPIO_13
, 1);
647 cx23885_gpio_set(dev
, GPIO_13
);
648 cx23885_gpio_clear(dev
, GPIO_12
);
651 cx23885_gpio_set(dev
, GPIO_13
);
652 cx23885_gpio_set(dev
, GPIO_12
);
654 case SEC_VOLTAGE_OFF
:
655 cx23885_gpio_clear(dev
, GPIO_13
);
656 cx23885_gpio_clear(dev
, GPIO_12
);
659 /* call the frontend set_voltage function */
660 return port
->fe_set_voltage(fe
, voltage
);
663 static int cx23885_sp2_ci_ctrl(void *priv
, u8 read
, int addr
,
667 #define SP2_DATA 0x000000ff
668 #define SP2_WR 0x00008000
669 #define SP2_RD 0x00004000
670 #define SP2_ACK 0x00001000
671 #define SP2_ADHI 0x00000800
672 #define SP2_ADLO 0x00000400
673 #define SP2_CS1 0x00000200
674 #define SP2_CS0 0x00000100
675 #define SP2_EN_ALL 0x00001000
676 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
678 struct cx23885_tsport
*port
= priv
;
679 struct cx23885_dev
*dev
= port
->dev
;
682 unsigned long timeout
;
684 mutex_lock(&dev
->gpio_lock
);
687 cx_write(MC417_OEN
, SP2_EN_ALL
);
688 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
689 SP2_ADLO
| (0xff & addr
));
690 cx_clear(MC417_RWD
, SP2_ADLO
);
691 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
692 SP2_ADHI
| (0xff & (addr
>> 8)));
693 cx_clear(MC417_RWD
, SP2_ADHI
);
697 cx_write(MC417_OEN
, SP2_EN_ALL
| SP2_DATA
);
700 cx_write(MC417_RWD
, SP2_CTRL_OFF
| data
);
703 cx_clear(MC417_RWD
, SP2_CS0
);
706 cx_clear(MC417_RWD
, (read
) ? SP2_RD
: SP2_WR
);
708 /* wait for a maximum of 1 msec */
709 timeout
= jiffies
+ msecs_to_jiffies(1);
710 while (!time_after(jiffies
, timeout
)) {
711 tmp
= cx_read(MC417_RWD
);
712 if ((tmp
& SP2_ACK
) == 0)
714 usleep_range(50, 100);
717 cx_set(MC417_RWD
, SP2_CTRL_OFF
);
720 mutex_unlock(&dev
->gpio_lock
);
734 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
736 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
737 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
738 struct cx23885_dev
*dev
= port
->dev
;
740 switch (dev
->board
) {
741 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
742 switch (p
->modulation
) {
744 cx23885_gpio_clear(dev
, GPIO_5
);
749 cx23885_gpio_set(dev
, GPIO_5
);
753 case CX23885_BOARD_MYGICA_X8506
:
754 case CX23885_BOARD_MYGICA_X8507
:
755 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
756 /* Select Digital TV */
757 cx23885_gpio_set(dev
, GPIO_0
);
761 /* Call the real set_frontend */
762 if (port
->set_frontend
)
763 return port
->set_frontend(fe
);
768 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
769 struct dvb_frontend
*fe
)
771 port
->set_frontend
= fe
->ops
.set_frontend
;
772 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
775 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
776 .prod
= LGS8GXX_PROD_LGS8G75
,
777 .demod_address
= 0x19,
781 .if_clk_freq
= 30400, /* 30.4 MHz */
782 .if_freq
= 6500, /* 6.50 MHz */
786 .adc_vpp
= 2, /* 1.6 Vpp */
790 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
795 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
796 .prod
= ATBM8830_PROD_8830
,
797 .demod_address
= 0x44,
799 .ts_sampling_edge
= 1,
801 .osc_clk_freq
= 30400, /* in kHz */
802 .if_freq
= 0, /* zero IF */
809 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
814 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
815 .prod
= ATBM8830_PROD_8830
,
816 .demod_address
= 0x44,
818 .ts_sampling_edge
= 1,
820 .osc_clk_freq
= 30400, /* in kHz */
821 .if_freq
= 0, /* zero IF */
828 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
832 static struct stv0367_config netup_stv0367_config
[] = {
834 .demod_address
= 0x1c,
841 .demod_address
= 0x1d,
850 static struct xc5000_config netup_xc5000_config
[] = {
860 static struct drxk_config terratec_drxk_config
[] = {
870 static struct mt2063_config terratec_mt2063_config
[] = {
872 .tuner_address
= 0x60,
874 .tuner_address
= 0x67,
878 static const struct tda10071_platform_data hauppauge_tda10071_pdata
= {
879 .clk
= 40444000, /* 40.444 MHz */
881 .ts_mode
= TDA10071_TS_SERIAL
,
882 .pll_multiplier
= 20,
883 .tuner_i2c_addr
= 0x54,
886 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config
= {
891 .ts_mode
= M88DS3103_TS_PARALLEL
,
899 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config
= {
904 .ts_mode
= M88DS3103_TS_CI
,
912 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config
= {
916 .ts_mode
= M88DS3103_TS_PARALLEL
,
922 static struct lgdt3306a_config hauppauge_hvr1265k4_config
= {
926 .deny_i2c_rptr
= 1, /* Disabled */
927 .spectral_inversion
= 0, /* Disabled */
928 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
929 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
930 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
931 .xtalMHz
= 25, /* 24 or 25 */
934 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
936 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
937 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
940 mem
= cx_read(MC417_RWD
);
942 cx_set(MC417_OEN
, ALT_DATA
);
944 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
946 mem
|= (data
& ALT_DATA
);
956 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
958 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
960 cx_write(MC417_RWD
, mem
); /* start RW cycle */
963 mem
= cx_read(MC417_RWD
);
964 if ((mem
& ALT_RDY
) == 0)
966 if (time_after(jiffies
, timeout
))
971 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
973 return mem
& ALT_DATA
;
978 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
980 struct dib7000p_ops
*dib7000p_ops
= fe
->sec_priv
;
982 return dib7000p_ops
->set_gpio(fe
, 8, 0, !onoff
);
985 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
990 static struct dib0070_config dib7070p_dib0070_config
= {
991 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
992 .reset
= dib7070_tuner_reset
,
993 .sleep
= dib7070_tuner_sleep
,
995 .freq_offset_khz_vhf
= 550,
996 /* .flip_chip = 1, */
999 /* DIB7070 generic */
1000 static struct dibx000_agc_config dib7070_agc_config
= {
1001 .band_caps
= BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
1004 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1005 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1006 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1008 .setup
= (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1009 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1011 .time_stabiliz
= 10,
1035 .perform_agc_softsplit
= 0,
1038 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
1048 .IO_CLK_en_core
= 1,
1051 /* refsel, sel, freq_15k */
1052 .sad_cfg
= (3 << 14) | (1 << 12) | (524 << 0),
1053 .ifreq
= (0 << 25) | 0,
1055 .xtal_hz
= 12000000,
1058 static struct dib7000p_config dib7070p_dib7000p_config
= {
1059 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1060 .output_mode
= OUTMODE_MPEG2_SERIAL
,
1061 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1062 .output_mpeg2_in_188_bytes
= 1,
1064 .agc_config_count
= 1,
1065 .agc
= &dib7070_agc_config
,
1066 .bw
= &dib7070_bw_config_12_mhz
,
1067 .tuner_is_baseband
= 1,
1070 .gpio_dir
= 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1071 .gpio_val
= 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1072 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1074 .hostbus_diversity
= 1,
1077 static int dvb_register_ci_mac(struct cx23885_tsport
*port
)
1079 struct cx23885_dev
*dev
= port
->dev
;
1080 struct i2c_client
*client_ci
= NULL
;
1081 struct vb2_dvb_frontend
*fe0
;
1083 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1087 switch (dev
->board
) {
1088 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1089 static struct netup_card_info cinfo
;
1091 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1092 memcpy(port
->frontends
.adapter
.proposed_mac
,
1093 cinfo
.port
[port
->nr
- 1].mac
, 6);
1094 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1095 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1097 netup_ci_init(port
);
1100 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1101 struct altera_ci_config netup_ci_cfg
= {
1102 .dev
= dev
,/* magic number to identify*/
1103 .adapter
= &port
->frontends
.adapter
,/* for CI */
1104 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1105 .fpga_rw
= netup_altera_fpga_rw
,
1108 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1111 case CX23885_BOARD_TEVII_S470
: {
1112 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1117 /* Read entire EEPROM */
1118 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1119 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1120 pr_info("TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1121 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1124 case CX23885_BOARD_DVBSKY_T9580
:
1125 case CX23885_BOARD_DVBSKY_S950
:
1126 case CX23885_BOARD_DVBSKY_S952
:
1127 case CX23885_BOARD_DVBSKY_T982
: {
1128 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1133 /* Read entire EEPROM */
1134 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1135 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1137 pr_info("%s port %d MAC address: %pM\n",
1138 cx23885_boards
[dev
->board
].name
, port
->nr
,
1139 eeprom
+ 0xc0 + (port
->nr
-1) * 8);
1140 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0 +
1141 (port
->nr
-1) * 8, 6);
1144 case CX23885_BOARD_DVBSKY_S950C
:
1145 case CX23885_BOARD_DVBSKY_T980C
:
1146 case CX23885_BOARD_TT_CT2_4500_CI
: {
1147 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1148 struct sp2_config sp2_config
;
1149 struct i2c_board_info info
;
1150 struct cx23885_i2c
*i2c_bus
= &dev
->i2c_bus
[0];
1153 memset(&sp2_config
, 0, sizeof(sp2_config
));
1154 sp2_config
.dvb_adap
= &port
->frontends
.adapter
;
1155 sp2_config
.priv
= port
;
1156 sp2_config
.ci_control
= cx23885_sp2_ci_ctrl
;
1157 memset(&info
, 0, sizeof(struct i2c_board_info
));
1158 strscpy(info
.type
, "sp2", I2C_NAME_SIZE
);
1160 info
.platform_data
= &sp2_config
;
1161 request_module(info
.type
);
1162 client_ci
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1163 if (!i2c_client_has_driver(client_ci
))
1165 if (!try_module_get(client_ci
->dev
.driver
->owner
)) {
1166 i2c_unregister_device(client_ci
);
1169 port
->i2c_client_ci
= client_ci
;
1174 /* Read entire EEPROM */
1175 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1176 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1178 pr_info("%s MAC address: %pM\n",
1179 cx23885_boards
[dev
->board
].name
, eeprom
+ 0xc0);
1180 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0, 6);
1187 static int dvb_register(struct cx23885_tsport
*port
)
1189 struct dib7000p_ops dib7000p_ops
;
1190 struct cx23885_dev
*dev
= port
->dev
;
1191 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
1192 struct vb2_dvb_frontend
*fe0
, *fe1
= NULL
;
1193 struct si2168_config si2168_config
;
1194 struct si2165_platform_data si2165_pdata
;
1195 struct si2157_config si2157_config
;
1196 struct ts2020_config ts2020_config
;
1197 struct m88ds3103_platform_data m88ds3103_pdata
;
1198 struct m88rs6000t_config m88rs6000t_config
= {};
1199 struct a8293_platform_data a8293_pdata
= {};
1200 struct i2c_board_info info
;
1201 struct i2c_adapter
*adapter
;
1202 struct i2c_client
*client_demod
= NULL
, *client_tuner
= NULL
;
1203 struct i2c_client
*client_sec
= NULL
;
1204 int (*p_set_voltage
)(struct dvb_frontend
*fe
,
1205 enum fe_sec_voltage voltage
) = NULL
;
1206 int mfe_shared
= 0; /* bus not shared by default */
1209 /* Get the first frontend */
1210 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1214 /* init struct vb2_dvb */
1215 fe0
->dvb
.name
= dev
->name
;
1217 /* multi-frontend gate control is undefined or defaults to fe0 */
1218 port
->frontends
.gate
= 0;
1220 /* Sets the gate control callback to be used by i2c command calls */
1221 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
1224 switch (dev
->board
) {
1225 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
1226 i2c_bus
= &dev
->i2c_bus
[0];
1227 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1228 &hauppauge_generic_config
,
1229 &i2c_bus
->i2c_adap
);
1230 if (fe0
->dvb
.frontend
== NULL
)
1232 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1234 &hauppauge_generic_tunerconfig
, 0);
1236 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
1237 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
1238 i2c_bus
= &dev
->i2c_bus
[0];
1239 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1240 &hauppauge_lgdt3305_config
,
1241 &i2c_bus
->i2c_adap
);
1242 if (fe0
->dvb
.frontend
== NULL
)
1244 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1245 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1246 &hauppauge_hvr127x_config
);
1247 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
1248 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1250 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
1251 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
1252 i2c_bus
= &dev
->i2c_bus
[0];
1253 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1254 &hcw_s5h1411_config
,
1255 &i2c_bus
->i2c_adap
);
1256 if (fe0
->dvb
.frontend
== NULL
)
1259 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1260 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1261 &hauppauge_tda18271_config
);
1263 tda18271_attach(&dev
->ts1
.analog_fe
,
1264 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1265 &hauppauge_tda18271_config
);
1268 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
1269 i2c_bus
= &dev
->i2c_bus
[0];
1270 switch (alt_tuner
) {
1273 dvb_attach(s5h1409_attach
,
1274 &hauppauge_ezqam_config
,
1275 &i2c_bus
->i2c_adap
);
1276 if (fe0
->dvb
.frontend
== NULL
)
1279 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1280 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1282 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1283 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1284 &hauppauge_tda18271_config
);
1289 dvb_attach(s5h1409_attach
,
1290 &hauppauge_generic_config
,
1291 &i2c_bus
->i2c_adap
);
1292 if (fe0
->dvb
.frontend
== NULL
)
1294 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1296 &hauppauge_generic_tunerconfig
, 0);
1299 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
1300 i2c_bus
= &dev
->i2c_bus
[0];
1301 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1302 &hauppauge_hvr1800lp_config
,
1303 &i2c_bus
->i2c_adap
);
1304 if (fe0
->dvb
.frontend
== NULL
)
1306 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1308 &hauppauge_generic_tunerconfig
, 0);
1310 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
1311 i2c_bus
= &dev
->i2c_bus
[0];
1312 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1313 &fusionhdtv_5_express
,
1315 &i2c_bus
->i2c_adap
);
1316 if (fe0
->dvb
.frontend
== NULL
)
1318 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1319 &i2c_bus
->i2c_adap
, 0x61,
1320 TUNER_LG_TDVS_H06XF
);
1322 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
1323 i2c_bus
= &dev
->i2c_bus
[1];
1324 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1325 &hauppauge_hvr1500q_config
,
1326 &dev
->i2c_bus
[0].i2c_adap
);
1327 if (fe0
->dvb
.frontend
== NULL
)
1329 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1331 &hauppauge_hvr1500q_tunerconfig
);
1333 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
1334 i2c_bus
= &dev
->i2c_bus
[1];
1335 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1336 &hauppauge_hvr1500_config
,
1337 &dev
->i2c_bus
[0].i2c_adap
);
1338 if (fe0
->dvb
.frontend
!= NULL
) {
1339 struct dvb_frontend
*fe
;
1340 struct xc2028_config cfg
= {
1341 .i2c_adap
= &i2c_bus
->i2c_adap
,
1344 static struct xc2028_ctrl ctl
= {
1345 .fname
= XC2028_DEFAULT_FIRMWARE
,
1347 .demod
= XC3028_FE_OREN538
,
1350 fe
= dvb_attach(xc2028_attach
,
1351 fe0
->dvb
.frontend
, &cfg
);
1352 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1353 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1356 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
1357 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
1358 i2c_bus
= &dev
->i2c_bus
[0];
1359 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1360 &hauppauge_hvr1200_config
,
1361 &i2c_bus
->i2c_adap
);
1362 if (fe0
->dvb
.frontend
== NULL
)
1364 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1365 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1367 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1368 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1369 &hauppauge_hvr1200_tuner_config
);
1371 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
1372 i2c_bus
= &dev
->i2c_bus
[0];
1373 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1374 &hauppauge_hvr1210_config
,
1375 &i2c_bus
->i2c_adap
);
1376 if (fe0
->dvb
.frontend
!= NULL
) {
1377 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1378 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1379 &hauppauge_hvr1210_tuner_config
);
1382 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
1383 i2c_bus
= &dev
->i2c_bus
[0];
1385 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1388 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
,
1389 0x12, &hauppauge_hvr1400_dib7000_config
);
1390 if (fe0
->dvb
.frontend
!= NULL
) {
1391 struct dvb_frontend
*fe
;
1392 struct xc2028_config cfg
= {
1393 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1396 static struct xc2028_ctrl ctl
= {
1397 .fname
= XC3028L_DEFAULT_FIRMWARE
,
1399 .demod
= XC3028_FE_DIBCOM52
,
1400 /* This is true for all demods with
1402 .type
= XC2028_D2633
,
1405 fe
= dvb_attach(xc2028_attach
,
1406 fe0
->dvb
.frontend
, &cfg
);
1407 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1408 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1411 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
1412 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1414 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1415 &dvico_s5h1409_config
,
1416 &i2c_bus
->i2c_adap
);
1417 if (fe0
->dvb
.frontend
== NULL
)
1418 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1419 &dvico_s5h1411_config
,
1420 &i2c_bus
->i2c_adap
);
1421 if (fe0
->dvb
.frontend
!= NULL
)
1422 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1424 &dvico_xc5000_tunerconfig
);
1426 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
1427 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1429 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1430 &dvico_fusionhdtv_xc3028
,
1431 &i2c_bus
->i2c_adap
);
1432 if (fe0
->dvb
.frontend
!= NULL
) {
1433 struct dvb_frontend
*fe
;
1434 struct xc2028_config cfg
= {
1435 .i2c_adap
= &i2c_bus
->i2c_adap
,
1438 static struct xc2028_ctrl ctl
= {
1439 .fname
= XC2028_DEFAULT_FIRMWARE
,
1441 .demod
= XC3028_FE_ZARLINK456
,
1444 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1446 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1447 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1451 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2
: {
1452 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1453 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1454 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1456 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1459 if (dib7000p_ops
.i2c_enumeration(&i2c_bus
->i2c_adap
, 1, 0x12, &dib7070p_dib7000p_config
) < 0) {
1460 pr_warn("Unable to enumerate dib7000p\n");
1463 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
, 0x80, &dib7070p_dib7000p_config
);
1464 if (fe0
->dvb
.frontend
!= NULL
) {
1465 struct i2c_adapter
*tun_i2c
;
1467 fe0
->dvb
.frontend
->sec_priv
= kmemdup(&dib7000p_ops
, sizeof(dib7000p_ops
), GFP_KERNEL
);
1468 if (!fe0
->dvb
.frontend
->sec_priv
)
1470 tun_i2c
= dib7000p_ops
.get_i2c_master(fe0
->dvb
.frontend
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1471 if (!dvb_attach(dib0070_attach
, fe0
->dvb
.frontend
, tun_i2c
, &dib7070p_dib0070_config
))
1476 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
1477 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
1478 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
1479 i2c_bus
= &dev
->i2c_bus
[0];
1481 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1482 &dvico_fusionhdtv_xc3028
,
1483 &i2c_bus
->i2c_adap
);
1484 if (fe0
->dvb
.frontend
!= NULL
) {
1485 struct dvb_frontend
*fe
;
1486 struct xc2028_config cfg
= {
1487 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1490 static struct xc2028_ctrl ctl
= {
1491 .fname
= XC2028_DEFAULT_FIRMWARE
,
1493 .demod
= XC3028_FE_ZARLINK456
,
1496 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1498 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1499 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1502 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1503 i2c_bus
= &dev
->i2c_bus
[0];
1505 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1506 &dvico_fusionhdtv_xc3028
,
1507 &i2c_bus
->i2c_adap
);
1508 if (fe0
->dvb
.frontend
!= NULL
) {
1509 struct dvb_frontend
*fe
;
1510 struct xc4000_config cfg
= {
1511 .i2c_address
= 0x61,
1513 .dvb_amplitude
= 134,
1514 .set_smoothedcvbs
= 1,
1518 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1519 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1521 pr_err("%s/2: xc4000 attach failed\n",
1523 goto frontend_detach
;
1527 case CX23885_BOARD_TBS_6920
:
1528 i2c_bus
= &dev
->i2c_bus
[1];
1530 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1531 &tbs_cx24116_config
,
1532 &i2c_bus
->i2c_adap
);
1533 if (fe0
->dvb
.frontend
!= NULL
)
1534 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1537 case CX23885_BOARD_TBS_6980
:
1538 case CX23885_BOARD_TBS_6981
:
1539 i2c_bus
= &dev
->i2c_bus
[1];
1544 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1545 &tbs_cx24117_config
,
1546 &i2c_bus
->i2c_adap
);
1550 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1551 &tbs_cx24117_config
,
1552 &i2c_bus
->i2c_adap
);
1556 case CX23885_BOARD_TEVII_S470
:
1557 i2c_bus
= &dev
->i2c_bus
[1];
1559 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1560 &tevii_ds3000_config
,
1561 &i2c_bus
->i2c_adap
);
1562 if (fe0
->dvb
.frontend
!= NULL
) {
1563 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1564 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1565 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1569 case CX23885_BOARD_DVBWORLD_2005
:
1570 i2c_bus
= &dev
->i2c_bus
[1];
1572 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1573 &dvbworld_cx24116_config
,
1574 &i2c_bus
->i2c_adap
);
1576 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1577 i2c_bus
= &dev
->i2c_bus
[0];
1581 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1582 &netup_stv0900_config
,
1583 &i2c_bus
->i2c_adap
, 0);
1584 if (fe0
->dvb
.frontend
!= NULL
) {
1585 if (dvb_attach(stv6110_attach
,
1587 &netup_stv6110_tunerconfig_a
,
1588 &i2c_bus
->i2c_adap
)) {
1589 if (!dvb_attach(lnbh24_attach
,
1592 LNBH24_PCL
| LNBH24_TTX
,
1594 pr_err("No LNBH24 found!\n");
1601 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1602 &netup_stv0900_config
,
1603 &i2c_bus
->i2c_adap
, 1);
1604 if (fe0
->dvb
.frontend
!= NULL
) {
1605 if (dvb_attach(stv6110_attach
,
1607 &netup_stv6110_tunerconfig_b
,
1608 &i2c_bus
->i2c_adap
)) {
1609 if (!dvb_attach(lnbh24_attach
,
1612 LNBH24_PCL
| LNBH24_TTX
,
1614 pr_err("No LNBH24 found!\n");
1621 case CX23885_BOARD_MYGICA_X8506
:
1622 i2c_bus
= &dev
->i2c_bus
[0];
1623 i2c_bus2
= &dev
->i2c_bus
[1];
1624 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1625 &mygica_x8506_lgs8gl5_config
,
1626 &i2c_bus
->i2c_adap
);
1627 if (fe0
->dvb
.frontend
== NULL
)
1629 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1630 &i2c_bus2
->i2c_adap
, &mygica_x8506_xc5000_config
);
1631 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1633 case CX23885_BOARD_MYGICA_X8507
:
1634 i2c_bus
= &dev
->i2c_bus
[0];
1635 i2c_bus2
= &dev
->i2c_bus
[1];
1636 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1637 &mygica_x8507_mb86a20s_config
,
1638 &i2c_bus
->i2c_adap
);
1639 if (fe0
->dvb
.frontend
== NULL
)
1642 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1643 &i2c_bus2
->i2c_adap
,
1644 &mygica_x8507_xc5000_config
);
1645 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1647 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1648 i2c_bus
= &dev
->i2c_bus
[0];
1649 i2c_bus2
= &dev
->i2c_bus
[1];
1650 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1651 &magicpro_prohdtve2_lgs8g75_config
,
1652 &i2c_bus
->i2c_adap
);
1653 if (fe0
->dvb
.frontend
== NULL
)
1655 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1656 &i2c_bus2
->i2c_adap
,
1657 &magicpro_prohdtve2_xc5000_config
);
1658 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1660 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1661 i2c_bus
= &dev
->i2c_bus
[0];
1662 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1663 &hcw_s5h1411_config
,
1664 &i2c_bus
->i2c_adap
);
1665 if (fe0
->dvb
.frontend
== NULL
)
1667 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1668 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1669 &hauppauge_tda18271_config
);
1671 tda18271_attach(&dev
->ts1
.analog_fe
,
1672 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1673 &hauppauge_tda18271_config
);
1676 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1677 i2c_bus
= &dev
->i2c_bus
[0];
1678 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1679 &hcw_s5h1411_config
,
1680 &i2c_bus
->i2c_adap
);
1681 if (fe0
->dvb
.frontend
== NULL
)
1683 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1684 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1685 &hauppauge_tda18271_config
);
1687 case CX23885_BOARD_MYGICA_X8558PRO
:
1691 i2c_bus
= &dev
->i2c_bus
[0];
1692 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1693 &mygica_x8558pro_atbm8830_cfg1
,
1694 &i2c_bus
->i2c_adap
);
1695 if (fe0
->dvb
.frontend
== NULL
)
1697 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1699 &mygic_x8558pro_max2165_cfg1
);
1703 i2c_bus
= &dev
->i2c_bus
[1];
1704 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1705 &mygica_x8558pro_atbm8830_cfg2
,
1706 &i2c_bus
->i2c_adap
);
1707 if (fe0
->dvb
.frontend
== NULL
)
1709 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1711 &mygic_x8558pro_max2165_cfg2
);
1714 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1718 i2c_bus
= &dev
->i2c_bus
[0];
1719 mfe_shared
= 1;/* MFE */
1720 port
->frontends
.gate
= 0;/* not clear for me yet */
1722 /* MFE frontend 1 DVB-T */
1723 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1724 &netup_stv0367_config
[port
->nr
- 1],
1725 &i2c_bus
->i2c_adap
);
1726 if (fe0
->dvb
.frontend
== NULL
)
1728 if (NULL
== dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1730 &netup_xc5000_config
[port
->nr
- 1]))
1731 goto frontend_detach
;
1732 /* load xc5000 firmware */
1733 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1735 /* MFE frontend 2 */
1736 fe1
= vb2_dvb_get_frontend(&port
->frontends
, 2);
1738 goto frontend_detach
;
1740 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1741 &netup_stv0367_config
[port
->nr
- 1],
1742 &i2c_bus
->i2c_adap
);
1743 if (fe1
->dvb
.frontend
== NULL
)
1746 fe1
->dvb
.frontend
->id
= 1;
1747 if (NULL
== dvb_attach(xc5000_attach
,
1750 &netup_xc5000_config
[port
->nr
- 1]))
1751 goto frontend_detach
;
1753 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1754 i2c_bus
= &dev
->i2c_bus
[0];
1755 i2c_bus2
= &dev
->i2c_bus
[1];
1760 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1761 &terratec_drxk_config
[0],
1762 &i2c_bus
->i2c_adap
);
1763 if (fe0
->dvb
.frontend
== NULL
)
1765 if (!dvb_attach(mt2063_attach
,
1767 &terratec_mt2063_config
[0],
1768 &i2c_bus2
->i2c_adap
))
1769 goto frontend_detach
;
1773 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1774 &terratec_drxk_config
[1],
1775 &i2c_bus
->i2c_adap
);
1776 if (fe0
->dvb
.frontend
== NULL
)
1778 if (!dvb_attach(mt2063_attach
,
1780 &terratec_mt2063_config
[1],
1781 &i2c_bus2
->i2c_adap
))
1782 goto frontend_detach
;
1786 case CX23885_BOARD_TEVII_S471
:
1787 i2c_bus
= &dev
->i2c_bus
[1];
1789 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1790 &tevii_ds3000_config
,
1791 &i2c_bus
->i2c_adap
);
1792 if (fe0
->dvb
.frontend
== NULL
)
1794 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1795 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1797 case CX23885_BOARD_PROF_8000
:
1798 i2c_bus
= &dev
->i2c_bus
[0];
1800 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1801 &prof_8000_stv090x_config
,
1803 STV090x_DEMODULATOR_0
);
1804 if (fe0
->dvb
.frontend
== NULL
)
1806 if (!dvb_attach(stb6100_attach
,
1808 &prof_8000_stb6100_config
,
1809 &i2c_bus
->i2c_adap
))
1810 goto frontend_detach
;
1812 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1814 case CX23885_BOARD_HAUPPAUGE_HVR4400
: {
1815 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1816 struct a8293_platform_data a8293_pdata
= {};
1818 i2c_bus
= &dev
->i2c_bus
[0];
1819 i2c_bus2
= &dev
->i2c_bus
[1];
1823 /* attach demod + tuner combo */
1824 memset(&info
, 0, sizeof(info
));
1825 strscpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1827 info
.platform_data
= &tda10071_pdata
;
1828 request_module("tda10071");
1829 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1830 if (!i2c_client_has_driver(client_demod
))
1831 goto frontend_detach
;
1832 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1833 i2c_unregister_device(client_demod
);
1834 goto frontend_detach
;
1836 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1837 port
->i2c_client_demod
= client_demod
;
1840 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1841 memset(&info
, 0, sizeof(info
));
1842 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1844 info
.platform_data
= &a8293_pdata
;
1845 request_module("a8293");
1846 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1847 if (!i2c_client_has_driver(client_sec
))
1848 goto frontend_detach
;
1849 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1850 i2c_unregister_device(client_sec
);
1851 goto frontend_detach
;
1853 port
->i2c_client_sec
= client_sec
;
1857 /* attach frontend */
1858 memset(&si2165_pdata
, 0, sizeof(si2165_pdata
));
1859 si2165_pdata
.fe
= &fe0
->dvb
.frontend
;
1860 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
;
1861 si2165_pdata
.ref_freq_hz
= 16000000;
1862 memset(&info
, 0, sizeof(struct i2c_board_info
));
1863 strscpy(info
.type
, "si2165", I2C_NAME_SIZE
);
1865 info
.platform_data
= &si2165_pdata
;
1866 request_module(info
.type
);
1867 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1868 if (!i2c_client_has_driver(client_demod
))
1869 goto frontend_detach
;
1870 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1871 i2c_unregister_device(client_demod
);
1872 goto frontend_detach
;
1874 port
->i2c_client_demod
= client_demod
;
1876 if (fe0
->dvb
.frontend
== NULL
)
1878 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1879 if (!dvb_attach(tda18271_attach
,
1881 0x60, &i2c_bus2
->i2c_adap
,
1882 &hauppauge_hvr4400_tuner_config
))
1883 goto frontend_detach
;
1888 case CX23885_BOARD_HAUPPAUGE_STARBURST
: {
1889 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1890 struct a8293_platform_data a8293_pdata
= {};
1892 i2c_bus
= &dev
->i2c_bus
[0];
1894 /* attach demod + tuner combo */
1895 memset(&info
, 0, sizeof(info
));
1896 strscpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1898 info
.platform_data
= &tda10071_pdata
;
1899 request_module("tda10071");
1900 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1901 if (!i2c_client_has_driver(client_demod
))
1902 goto frontend_detach
;
1903 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1904 i2c_unregister_device(client_demod
);
1905 goto frontend_detach
;
1907 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1908 port
->i2c_client_demod
= client_demod
;
1911 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1912 memset(&info
, 0, sizeof(info
));
1913 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1915 info
.platform_data
= &a8293_pdata
;
1916 request_module("a8293");
1917 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1918 if (!i2c_client_has_driver(client_sec
))
1919 goto frontend_detach
;
1920 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1921 i2c_unregister_device(client_sec
);
1922 goto frontend_detach
;
1924 port
->i2c_client_sec
= client_sec
;
1927 case CX23885_BOARD_DVBSKY_T9580
:
1928 case CX23885_BOARD_DVBSKY_S950
:
1929 i2c_bus
= &dev
->i2c_bus
[0];
1930 i2c_bus2
= &dev
->i2c_bus
[1];
1932 /* port b - satellite */
1934 /* attach frontend */
1935 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1936 &dvbsky_t9580_m88ds3103_config
,
1937 &i2c_bus2
->i2c_adap
, &adapter
);
1938 if (fe0
->dvb
.frontend
== NULL
)
1942 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
1943 ts2020_config
.fe
= fe0
->dvb
.frontend
;
1944 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
1945 memset(&info
, 0, sizeof(struct i2c_board_info
));
1946 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
1948 info
.platform_data
= &ts2020_config
;
1949 request_module(info
.type
);
1950 client_tuner
= i2c_new_client_device(adapter
, &info
);
1951 if (!i2c_client_has_driver(client_tuner
))
1952 goto frontend_detach
;
1953 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1954 i2c_unregister_device(client_tuner
);
1955 goto frontend_detach
;
1958 /* delegate signal strength measurement to tuner */
1959 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1960 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1963 * for setting the voltage we need to set GPIOs on
1966 port
->fe_set_voltage
=
1967 fe0
->dvb
.frontend
->ops
.set_voltage
;
1968 fe0
->dvb
.frontend
->ops
.set_voltage
=
1969 dvbsky_t9580_set_voltage
;
1971 port
->i2c_client_tuner
= client_tuner
;
1974 /* port c - terrestrial/cable */
1976 /* attach frontend */
1977 memset(&si2168_config
, 0, sizeof(si2168_config
));
1978 si2168_config
.i2c_adapter
= &adapter
;
1979 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1980 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1981 memset(&info
, 0, sizeof(struct i2c_board_info
));
1982 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1984 info
.platform_data
= &si2168_config
;
1985 request_module(info
.type
);
1986 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1987 if (!i2c_client_has_driver(client_demod
))
1988 goto frontend_detach
;
1989 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1990 i2c_unregister_device(client_demod
);
1991 goto frontend_detach
;
1993 port
->i2c_client_demod
= client_demod
;
1996 memset(&si2157_config
, 0, sizeof(si2157_config
));
1997 si2157_config
.fe
= fe0
->dvb
.frontend
;
1998 si2157_config
.if_port
= 1;
1999 memset(&info
, 0, sizeof(struct i2c_board_info
));
2000 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2002 info
.platform_data
= &si2157_config
;
2003 request_module(info
.type
);
2004 client_tuner
= i2c_new_client_device(adapter
, &info
);
2005 if (!i2c_client_has_driver(client_tuner
))
2006 goto frontend_detach
;
2008 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2009 i2c_unregister_device(client_tuner
);
2010 goto frontend_detach
;
2012 port
->i2c_client_tuner
= client_tuner
;
2016 case CX23885_BOARD_DVBSKY_T980C
:
2017 case CX23885_BOARD_TT_CT2_4500_CI
:
2018 i2c_bus
= &dev
->i2c_bus
[0];
2019 i2c_bus2
= &dev
->i2c_bus
[1];
2021 /* attach frontend */
2022 memset(&si2168_config
, 0, sizeof(si2168_config
));
2023 si2168_config
.i2c_adapter
= &adapter
;
2024 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2025 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2026 memset(&info
, 0, sizeof(struct i2c_board_info
));
2027 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2029 info
.platform_data
= &si2168_config
;
2030 request_module(info
.type
);
2031 client_demod
= i2c_new_client_device(&i2c_bus2
->i2c_adap
, &info
);
2032 if (!i2c_client_has_driver(client_demod
))
2033 goto frontend_detach
;
2034 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2035 i2c_unregister_device(client_demod
);
2036 goto frontend_detach
;
2038 port
->i2c_client_demod
= client_demod
;
2041 memset(&si2157_config
, 0, sizeof(si2157_config
));
2042 si2157_config
.fe
= fe0
->dvb
.frontend
;
2043 si2157_config
.if_port
= 1;
2044 memset(&info
, 0, sizeof(struct i2c_board_info
));
2045 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2047 info
.platform_data
= &si2157_config
;
2048 request_module(info
.type
);
2049 client_tuner
= i2c_new_client_device(adapter
, &info
);
2050 if (!i2c_client_has_driver(client_tuner
))
2051 goto frontend_detach
;
2052 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2053 i2c_unregister_device(client_tuner
);
2054 goto frontend_detach
;
2056 port
->i2c_client_tuner
= client_tuner
;
2058 case CX23885_BOARD_DVBSKY_S950C
:
2059 i2c_bus
= &dev
->i2c_bus
[0];
2060 i2c_bus2
= &dev
->i2c_bus
[1];
2062 /* attach frontend */
2063 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2064 &dvbsky_s950c_m88ds3103_config
,
2065 &i2c_bus2
->i2c_adap
, &adapter
);
2066 if (fe0
->dvb
.frontend
== NULL
)
2070 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2071 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2072 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2073 memset(&info
, 0, sizeof(struct i2c_board_info
));
2074 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2076 info
.platform_data
= &ts2020_config
;
2077 request_module(info
.type
);
2078 client_tuner
= i2c_new_client_device(adapter
, &info
);
2079 if (!i2c_client_has_driver(client_tuner
))
2080 goto frontend_detach
;
2081 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2082 i2c_unregister_device(client_tuner
);
2083 goto frontend_detach
;
2086 /* delegate signal strength measurement to tuner */
2087 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2088 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2090 port
->i2c_client_tuner
= client_tuner
;
2092 case CX23885_BOARD_DVBSKY_S952
:
2093 /* attach frontend */
2094 memset(&m88ds3103_pdata
, 0, sizeof(m88ds3103_pdata
));
2095 m88ds3103_pdata
.clk
= 27000000;
2096 m88ds3103_pdata
.i2c_wr_max
= 33;
2097 m88ds3103_pdata
.agc
= 0x99;
2098 m88ds3103_pdata
.clk_out
= M88DS3103_CLOCK_OUT_DISABLED
;
2099 m88ds3103_pdata
.lnb_en_pol
= 1;
2104 i2c_bus
= &dev
->i2c_bus
[1];
2105 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_PARALLEL
;
2106 m88ds3103_pdata
.ts_clk
= 16000;
2107 m88ds3103_pdata
.ts_clk_pol
= 1;
2108 p_set_voltage
= dvbsky_t9580_set_voltage
;
2112 i2c_bus
= &dev
->i2c_bus
[0];
2113 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_SERIAL
;
2114 m88ds3103_pdata
.ts_clk
= 96000;
2115 m88ds3103_pdata
.ts_clk_pol
= 0;
2116 p_set_voltage
= dvbsky_s952_portc_set_voltage
;
2122 memset(&info
, 0, sizeof(info
));
2123 strscpy(info
.type
, "m88ds3103", I2C_NAME_SIZE
);
2125 info
.platform_data
= &m88ds3103_pdata
;
2126 request_module(info
.type
);
2127 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2128 if (!i2c_client_has_driver(client_demod
))
2129 goto frontend_detach
;
2130 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2131 i2c_unregister_device(client_demod
);
2132 goto frontend_detach
;
2134 port
->i2c_client_demod
= client_demod
;
2135 adapter
= m88ds3103_pdata
.get_i2c_adapter(client_demod
);
2136 fe0
->dvb
.frontend
= m88ds3103_pdata
.get_dvb_frontend(client_demod
);
2139 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2140 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2141 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2142 memset(&info
, 0, sizeof(struct i2c_board_info
));
2143 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2145 info
.platform_data
= &ts2020_config
;
2146 request_module(info
.type
);
2147 client_tuner
= i2c_new_client_device(adapter
, &info
);
2148 if (!i2c_client_has_driver(client_tuner
))
2149 goto frontend_detach
;
2150 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2151 i2c_unregister_device(client_tuner
);
2152 goto frontend_detach
;
2155 /* delegate signal strength measurement to tuner */
2156 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2157 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2160 * for setting the voltage we need to set GPIOs on
2163 port
->fe_set_voltage
=
2164 fe0
->dvb
.frontend
->ops
.set_voltage
;
2165 fe0
->dvb
.frontend
->ops
.set_voltage
= p_set_voltage
;
2167 port
->i2c_client_tuner
= client_tuner
;
2169 case CX23885_BOARD_DVBSKY_T982
:
2170 memset(&si2168_config
, 0, sizeof(si2168_config
));
2174 i2c_bus
= &dev
->i2c_bus
[1];
2175 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2179 i2c_bus
= &dev
->i2c_bus
[0];
2180 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2184 /* attach frontend */
2185 si2168_config
.i2c_adapter
= &adapter
;
2186 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2187 memset(&info
, 0, sizeof(struct i2c_board_info
));
2188 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2190 info
.platform_data
= &si2168_config
;
2191 request_module(info
.type
);
2192 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2193 if (!i2c_client_has_driver(client_demod
))
2194 goto frontend_detach
;
2195 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2196 i2c_unregister_device(client_demod
);
2197 goto frontend_detach
;
2199 port
->i2c_client_demod
= client_demod
;
2202 memset(&si2157_config
, 0, sizeof(si2157_config
));
2203 si2157_config
.fe
= fe0
->dvb
.frontend
;
2204 si2157_config
.if_port
= 1;
2205 memset(&info
, 0, sizeof(struct i2c_board_info
));
2206 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2208 info
.platform_data
= &si2157_config
;
2209 request_module(info
.type
);
2210 client_tuner
= i2c_new_client_device(adapter
, &info
);
2211 if (!i2c_client_has_driver(client_tuner
))
2212 goto frontend_detach
;
2213 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2214 i2c_unregister_device(client_tuner
);
2215 goto frontend_detach
;
2217 port
->i2c_client_tuner
= client_tuner
;
2219 case CX23885_BOARD_HAUPPAUGE_STARBURST2
:
2220 case CX23885_BOARD_HAUPPAUGE_HVR5525
:
2221 i2c_bus
= &dev
->i2c_bus
[0];
2222 i2c_bus2
= &dev
->i2c_bus
[1];
2226 /* port b - satellite */
2228 /* attach frontend */
2229 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2230 &hauppauge_hvr5525_m88ds3103_config
,
2231 &i2c_bus
->i2c_adap
, &adapter
);
2232 if (fe0
->dvb
.frontend
== NULL
)
2236 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
2237 memset(&info
, 0, sizeof(info
));
2238 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
2240 info
.platform_data
= &a8293_pdata
;
2241 request_module("a8293");
2242 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2243 if (!i2c_client_has_driver(client_sec
))
2244 goto frontend_detach
;
2245 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
2246 i2c_unregister_device(client_sec
);
2247 goto frontend_detach
;
2249 port
->i2c_client_sec
= client_sec
;
2252 memset(&m88rs6000t_config
, 0, sizeof(m88rs6000t_config
));
2253 m88rs6000t_config
.fe
= fe0
->dvb
.frontend
;
2254 memset(&info
, 0, sizeof(struct i2c_board_info
));
2255 strscpy(info
.type
, "m88rs6000t", I2C_NAME_SIZE
);
2257 info
.platform_data
= &m88rs6000t_config
;
2258 request_module("%s", info
.type
);
2259 client_tuner
= i2c_new_client_device(adapter
, &info
);
2260 if (!i2c_client_has_driver(client_tuner
))
2261 goto frontend_detach
;
2262 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2263 i2c_unregister_device(client_tuner
);
2264 goto frontend_detach
;
2266 port
->i2c_client_tuner
= client_tuner
;
2268 /* delegate signal strength measurement to tuner */
2269 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2270 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2272 /* port c - terrestrial/cable */
2274 /* attach frontend */
2275 memset(&si2168_config
, 0, sizeof(si2168_config
));
2276 si2168_config
.i2c_adapter
= &adapter
;
2277 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2278 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2279 memset(&info
, 0, sizeof(struct i2c_board_info
));
2280 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2282 info
.platform_data
= &si2168_config
;
2283 request_module("%s", info
.type
);
2284 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2285 if (!i2c_client_has_driver(client_demod
))
2286 goto frontend_detach
;
2287 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2288 i2c_unregister_device(client_demod
);
2289 goto frontend_detach
;
2291 port
->i2c_client_demod
= client_demod
;
2294 memset(&si2157_config
, 0, sizeof(si2157_config
));
2295 si2157_config
.fe
= fe0
->dvb
.frontend
;
2296 si2157_config
.if_port
= 1;
2297 memset(&info
, 0, sizeof(struct i2c_board_info
));
2298 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2300 info
.platform_data
= &si2157_config
;
2301 request_module("%s", info
.type
);
2302 client_tuner
= i2c_new_client_device(&i2c_bus2
->i2c_adap
, &info
);
2303 if (!i2c_client_has_driver(client_tuner
)) {
2304 module_put(client_demod
->dev
.driver
->owner
);
2305 i2c_unregister_device(client_demod
);
2306 port
->i2c_client_demod
= NULL
;
2307 goto frontend_detach
;
2309 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2310 i2c_unregister_device(client_tuner
);
2311 module_put(client_demod
->dev
.driver
->owner
);
2312 i2c_unregister_device(client_demod
);
2313 port
->i2c_client_demod
= NULL
;
2314 goto frontend_detach
;
2316 port
->i2c_client_tuner
= client_tuner
;
2320 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB
:
2321 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885
:
2322 pr_info("%s(): board=%d port=%d\n", __func__
,
2323 dev
->board
, port
->nr
);
2325 /* port b - Terrestrial/cable */
2327 /* attach frontend */
2328 memset(&si2168_config
, 0, sizeof(si2168_config
));
2329 si2168_config
.i2c_adapter
= &adapter
;
2330 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2331 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2332 memset(&info
, 0, sizeof(struct i2c_board_info
));
2333 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2335 info
.platform_data
= &si2168_config
;
2336 request_module("%s", info
.type
);
2337 client_demod
= i2c_new_client_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2338 if (!i2c_client_has_driver(client_demod
))
2339 goto frontend_detach
;
2340 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2341 i2c_unregister_device(client_demod
);
2342 goto frontend_detach
;
2344 port
->i2c_client_demod
= client_demod
;
2347 memset(&si2157_config
, 0, sizeof(si2157_config
));
2348 si2157_config
.fe
= fe0
->dvb
.frontend
;
2349 si2157_config
.if_port
= 1;
2350 memset(&info
, 0, sizeof(struct i2c_board_info
));
2351 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2353 info
.platform_data
= &si2157_config
;
2354 request_module("%s", info
.type
);
2355 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2356 if (!i2c_client_has_driver(client_tuner
)) {
2357 module_put(client_demod
->dev
.driver
->owner
);
2358 i2c_unregister_device(client_demod
);
2359 port
->i2c_client_demod
= NULL
;
2360 goto frontend_detach
;
2362 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2363 i2c_unregister_device(client_tuner
);
2364 module_put(client_demod
->dev
.driver
->owner
);
2365 i2c_unregister_device(client_demod
);
2366 port
->i2c_client_demod
= NULL
;
2367 goto frontend_detach
;
2369 port
->i2c_client_tuner
= client_tuner
;
2372 /* port c - terrestrial/cable */
2374 /* attach frontend */
2375 memset(&si2168_config
, 0, sizeof(si2168_config
));
2376 si2168_config
.i2c_adapter
= &adapter
;
2377 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2378 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2379 memset(&info
, 0, sizeof(struct i2c_board_info
));
2380 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2382 info
.platform_data
= &si2168_config
;
2383 request_module("%s", info
.type
);
2384 client_demod
= i2c_new_client_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2385 if (!i2c_client_has_driver(client_demod
))
2386 goto frontend_detach
;
2387 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2388 i2c_unregister_device(client_demod
);
2389 goto frontend_detach
;
2391 port
->i2c_client_demod
= client_demod
;
2394 memset(&si2157_config
, 0, sizeof(si2157_config
));
2395 si2157_config
.fe
= fe0
->dvb
.frontend
;
2396 si2157_config
.if_port
= 1;
2397 memset(&info
, 0, sizeof(struct i2c_board_info
));
2398 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2400 info
.platform_data
= &si2157_config
;
2401 request_module("%s", info
.type
);
2402 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2403 if (!i2c_client_has_driver(client_tuner
)) {
2404 module_put(client_demod
->dev
.driver
->owner
);
2405 i2c_unregister_device(client_demod
);
2406 port
->i2c_client_demod
= NULL
;
2407 goto frontend_detach
;
2409 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2410 i2c_unregister_device(client_tuner
);
2411 module_put(client_demod
->dev
.driver
->owner
);
2412 i2c_unregister_device(client_demod
);
2413 port
->i2c_client_demod
= NULL
;
2414 goto frontend_detach
;
2416 port
->i2c_client_tuner
= client_tuner
;
2420 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC
:
2421 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885
:
2422 pr_info("%s(): board=%d port=%d\n", __func__
,
2423 dev
->board
, port
->nr
);
2425 /* port b - Terrestrial/cable */
2427 /* attach frontend */
2428 i2c_bus
= &dev
->i2c_bus
[0];
2429 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2430 &hauppauge_quadHD_ATSC_a_config
, &i2c_bus
->i2c_adap
);
2431 if (fe0
->dvb
.frontend
== NULL
)
2435 memset(&si2157_config
, 0, sizeof(si2157_config
));
2436 si2157_config
.fe
= fe0
->dvb
.frontend
;
2437 si2157_config
.if_port
= 1;
2438 si2157_config
.inversion
= 1;
2439 memset(&info
, 0, sizeof(struct i2c_board_info
));
2440 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2442 info
.platform_data
= &si2157_config
;
2443 request_module("%s", info
.type
);
2444 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2445 if (!i2c_client_has_driver(client_tuner
)) {
2446 module_put(client_demod
->dev
.driver
->owner
);
2447 i2c_unregister_device(client_demod
);
2448 port
->i2c_client_demod
= NULL
;
2449 goto frontend_detach
;
2451 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2452 i2c_unregister_device(client_tuner
);
2453 module_put(client_demod
->dev
.driver
->owner
);
2454 i2c_unregister_device(client_demod
);
2455 port
->i2c_client_demod
= NULL
;
2456 goto frontend_detach
;
2458 port
->i2c_client_tuner
= client_tuner
;
2461 /* port c - terrestrial/cable */
2463 /* attach frontend */
2464 i2c_bus
= &dev
->i2c_bus
[0];
2465 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2466 &hauppauge_quadHD_ATSC_b_config
, &i2c_bus
->i2c_adap
);
2467 if (fe0
->dvb
.frontend
== NULL
)
2471 memset(&si2157_config
, 0, sizeof(si2157_config
));
2472 si2157_config
.fe
= fe0
->dvb
.frontend
;
2473 si2157_config
.if_port
= 1;
2474 si2157_config
.inversion
= 1;
2475 memset(&info
, 0, sizeof(struct i2c_board_info
));
2476 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2478 info
.platform_data
= &si2157_config
;
2479 request_module("%s", info
.type
);
2480 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2481 if (!i2c_client_has_driver(client_tuner
)) {
2482 module_put(client_demod
->dev
.driver
->owner
);
2483 i2c_unregister_device(client_demod
);
2484 port
->i2c_client_demod
= NULL
;
2485 goto frontend_detach
;
2487 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2488 i2c_unregister_device(client_tuner
);
2489 module_put(client_demod
->dev
.driver
->owner
);
2490 i2c_unregister_device(client_demod
);
2491 port
->i2c_client_demod
= NULL
;
2492 goto frontend_detach
;
2494 port
->i2c_client_tuner
= client_tuner
;
2498 case CX23885_BOARD_HAUPPAUGE_HVR1265_K4
:
2500 /* port c - Terrestrial/cable */
2502 /* attach frontend */
2503 i2c_bus
= &dev
->i2c_bus
[0];
2504 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2505 &hauppauge_hvr1265k4_config
,
2506 &i2c_bus
->i2c_adap
);
2507 if (fe0
->dvb
.frontend
== NULL
)
2511 memset(&si2157_config
, 0, sizeof(si2157_config
));
2512 si2157_config
.fe
= fe0
->dvb
.frontend
;
2513 si2157_config
.if_port
= 1;
2514 si2157_config
.inversion
= 1;
2515 memset(&info
, 0, sizeof(struct i2c_board_info
));
2516 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2518 info
.platform_data
= &si2157_config
;
2519 request_module("%s", info
.type
);
2520 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2521 if (!i2c_client_has_driver(client_tuner
))
2522 goto frontend_detach
;
2524 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2525 i2c_unregister_device(client_tuner
);
2526 client_tuner
= NULL
;
2527 goto frontend_detach
;
2529 port
->i2c_client_tuner
= client_tuner
;
2534 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2539 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
2540 pr_err("%s: frontend initialization failed\n",
2542 goto frontend_detach
;
2545 /* define general-purpose callback pointer */
2546 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2548 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2550 /* Ensure all frontends negotiate bus access */
2551 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2553 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2556 /* Put the tuner in standby to keep it quiet */
2557 call_all(dev
, tuner
, standby
);
2559 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
2560 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
2562 /* register everything */
2563 ret
= vb2_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
2564 &dev
->pci
->dev
, NULL
,
2565 adapter_nr
, mfe_shared
);
2567 goto frontend_detach
;
2569 ret
= dvb_register_ci_mac(port
);
2571 goto frontend_detach
;
2576 /* remove I2C client for SEC */
2577 client_sec
= port
->i2c_client_sec
;
2579 module_put(client_sec
->dev
.driver
->owner
);
2580 i2c_unregister_device(client_sec
);
2581 port
->i2c_client_sec
= NULL
;
2584 /* remove I2C client for tuner */
2585 client_tuner
= port
->i2c_client_tuner
;
2587 module_put(client_tuner
->dev
.driver
->owner
);
2588 i2c_unregister_device(client_tuner
);
2589 port
->i2c_client_tuner
= NULL
;
2592 /* remove I2C client for demodulator */
2593 client_demod
= port
->i2c_client_demod
;
2595 module_put(client_demod
->dev
.driver
->owner
);
2596 i2c_unregister_device(client_demod
);
2597 port
->i2c_client_demod
= NULL
;
2600 port
->gate_ctrl
= NULL
;
2601 vb2_dvb_dealloc_frontends(&port
->frontends
);
2605 int cx23885_dvb_register(struct cx23885_tsport
*port
)
2608 struct vb2_dvb_frontend
*fe0
;
2609 struct cx23885_dev
*dev
= port
->dev
;
2612 /* Here we need to allocate the correct number of frontends,
2613 * as reflected in the cards struct. The reality is that currently
2614 * no cx23885 boards support this - yet. But, if we don't modify this
2615 * code then the second frontend would never be allocated (later)
2616 * and fail with error before the attach in dvb_register().
2617 * Without these changes we risk an OOPS later. The changes here
2618 * are for safety, and should provide a good foundation for the
2619 * future addition of any multi-frontend cx23885 based boards.
2621 pr_info("%s() allocating %d frontend(s)\n", __func__
,
2622 port
->num_frontends
);
2624 for (i
= 1; i
<= port
->num_frontends
; i
++) {
2625 struct vb2_queue
*q
;
2627 if (vb2_dvb_alloc_frontend(
2628 &port
->frontends
, i
) == NULL
) {
2629 pr_err("%s() failed to alloc\n", __func__
);
2633 fe0
= vb2_dvb_get_frontend(&port
->frontends
, i
);
2637 dprintk(1, "%s\n", __func__
);
2638 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2645 /* We have to init the queue for each frontend on a port. */
2646 pr_info("%s: cx23885 based dvb card\n", dev
->name
);
2648 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
2649 q
->io_modes
= VB2_MMAP
| VB2_USERPTR
| VB2_DMABUF
| VB2_READ
;
2650 q
->gfp_flags
= GFP_DMA32
;
2651 q
->min_buffers_needed
= 2;
2653 q
->buf_struct_size
= sizeof(struct cx23885_buffer
);
2655 q
->mem_ops
= &vb2_dma_sg_memops
;
2656 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
2657 q
->lock
= &dev
->lock
;
2658 q
->dev
= &dev
->pci
->dev
;
2660 err
= vb2_queue_init(q
);
2664 err
= dvb_register(port
);
2666 pr_err("%s() dvb_register failed err = %d\n",
2672 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
2674 struct vb2_dvb_frontend
*fe0
;
2675 struct i2c_client
*client
;
2677 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
2679 if (fe0
&& fe0
->dvb
.frontend
)
2680 vb2_dvb_unregister_bus(&port
->frontends
);
2682 /* remove I2C client for CI */
2683 client
= port
->i2c_client_ci
;
2685 module_put(client
->dev
.driver
->owner
);
2686 i2c_unregister_device(client
);
2689 /* remove I2C client for SEC */
2690 client
= port
->i2c_client_sec
;
2692 module_put(client
->dev
.driver
->owner
);
2693 i2c_unregister_device(client
);
2696 /* remove I2C client for tuner */
2697 client
= port
->i2c_client_tuner
;
2699 module_put(client
->dev
.driver
->owner
);
2700 i2c_unregister_device(client
);
2703 /* remove I2C client for demodulator */
2704 client
= port
->i2c_client_demod
;
2706 module_put(client
->dev
.driver
->owner
);
2707 i2c_unregister_device(client
);
2710 switch (port
->dev
->board
) {
2711 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
2712 netup_ci_exit(port
);
2714 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
2715 altera_ci_release(port
->dev
, port
->nr
);
2719 port
->gate_ctrl
= NULL
;