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>
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 .start_streaming
= cx23885_start_streaming
,
174 .stop_streaming
= cx23885_stop_streaming
,
177 static struct s5h1409_config hauppauge_generic_config
= {
178 .demod_address
= 0x32 >> 1,
179 .output_mode
= S5H1409_SERIAL_OUTPUT
,
180 .gpio
= S5H1409_GPIO_ON
,
182 .inversion
= S5H1409_INVERSION_OFF
,
183 .status_mode
= S5H1409_DEMODLOCKING
,
184 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
187 static struct tda10048_config hauppauge_hvr1200_config
= {
188 .demod_address
= 0x10 >> 1,
189 .output_mode
= TDA10048_SERIAL_OUTPUT
,
190 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
191 .inversion
= TDA10048_INVERSION_ON
,
192 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
193 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
194 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
195 .clk_freq_khz
= TDA10048_CLK_16000
,
198 static struct tda10048_config hauppauge_hvr1210_config
= {
199 .demod_address
= 0x10 >> 1,
200 .output_mode
= TDA10048_SERIAL_OUTPUT
,
201 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
202 .inversion
= TDA10048_INVERSION_ON
,
203 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
204 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
205 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
206 .clk_freq_khz
= TDA10048_CLK_16000
,
209 static struct s5h1409_config hauppauge_ezqam_config
= {
210 .demod_address
= 0x32 >> 1,
211 .output_mode
= S5H1409_SERIAL_OUTPUT
,
212 .gpio
= S5H1409_GPIO_OFF
,
214 .inversion
= S5H1409_INVERSION_ON
,
215 .status_mode
= S5H1409_DEMODLOCKING
,
216 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
219 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
220 .demod_address
= 0x32 >> 1,
221 .output_mode
= S5H1409_SERIAL_OUTPUT
,
222 .gpio
= S5H1409_GPIO_OFF
,
224 .inversion
= S5H1409_INVERSION_OFF
,
225 .status_mode
= S5H1409_DEMODLOCKING
,
226 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
229 static struct s5h1409_config hauppauge_hvr1500_config
= {
230 .demod_address
= 0x32 >> 1,
231 .output_mode
= S5H1409_SERIAL_OUTPUT
,
232 .gpio
= S5H1409_GPIO_OFF
,
233 .inversion
= S5H1409_INVERSION_OFF
,
234 .status_mode
= S5H1409_DEMODLOCKING
,
235 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
238 static struct mt2131_config hauppauge_generic_tunerconfig
= {
242 static struct lgdt330x_config fusionhdtv_5_express
= {
243 .demod_chip
= LGDT3303
,
247 static struct s5h1409_config hauppauge_hvr1500q_config
= {
248 .demod_address
= 0x32 >> 1,
249 .output_mode
= S5H1409_SERIAL_OUTPUT
,
250 .gpio
= S5H1409_GPIO_ON
,
252 .inversion
= S5H1409_INVERSION_OFF
,
253 .status_mode
= S5H1409_DEMODLOCKING
,
254 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
257 static struct s5h1409_config dvico_s5h1409_config
= {
258 .demod_address
= 0x32 >> 1,
259 .output_mode
= S5H1409_SERIAL_OUTPUT
,
260 .gpio
= S5H1409_GPIO_ON
,
262 .inversion
= S5H1409_INVERSION_OFF
,
263 .status_mode
= S5H1409_DEMODLOCKING
,
264 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
267 static struct s5h1411_config dvico_s5h1411_config
= {
268 .output_mode
= S5H1411_SERIAL_OUTPUT
,
269 .gpio
= S5H1411_GPIO_ON
,
270 .qam_if
= S5H1411_IF_44000
,
271 .vsb_if
= S5H1411_IF_44000
,
272 .inversion
= S5H1411_INVERSION_OFF
,
273 .status_mode
= S5H1411_DEMODLOCKING
,
274 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
277 static struct s5h1411_config hcw_s5h1411_config
= {
278 .output_mode
= S5H1411_SERIAL_OUTPUT
,
279 .gpio
= S5H1411_GPIO_OFF
,
280 .vsb_if
= S5H1411_IF_44000
,
281 .qam_if
= S5H1411_IF_4000
,
282 .inversion
= S5H1411_INVERSION_ON
,
283 .status_mode
= S5H1411_DEMODLOCKING
,
284 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK
,
287 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
292 static struct xc5000_config dvico_xc5000_tunerconfig
= {
297 static struct tda829x_config tda829x_no_probe
= {
298 .probe_tuner
= TDA829X_DONT_PROBE
,
301 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
302 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
303 .if_lvl
= 6, .rfagc_top
= 0x37 },
304 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
305 .if_lvl
= 6, .rfagc_top
= 0x37 },
308 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
309 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
310 .if_lvl
= 1, .rfagc_top
= 0x37, },
311 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
312 .if_lvl
= 1, .rfagc_top
= 0x37, },
313 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
314 .if_lvl
= 1, .rfagc_top
= 0x37, },
317 static struct tda18271_config hauppauge_tda18271_config
= {
318 .std_map
= &hauppauge_tda18271_std_map
,
319 .gate
= TDA18271_GATE_ANALOG
,
320 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
323 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
324 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
325 .gate
= TDA18271_GATE_ANALOG
,
326 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
329 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
330 .gate
= TDA18271_GATE_DIGITAL
,
331 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
334 static struct tda18271_config hauppauge_hvr4400_tuner_config
= {
335 .gate
= TDA18271_GATE_DIGITAL
,
336 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
339 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
340 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
341 .if_lvl
= 1, .rfagc_top
= 0x58 },
342 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
343 .if_lvl
= 1, .rfagc_top
= 0x58 },
346 static struct tda18271_config hauppauge_hvr127x_config
= {
347 .std_map
= &hauppauge_hvr127x_std_map
,
348 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
351 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
353 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
354 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
355 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
357 .spectral_inversion
= 1,
362 static struct dibx000_agc_config xc3028_agc_config
= {
363 BAND_VHF
| BAND_UHF
, /* band_caps */
365 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
366 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
367 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
368 * P_agc_nb_est=2, P_agc_write=0
370 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
371 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
374 21, /* time_stabiliz */
386 39718, /* agc2_max */
395 29, /* agc2_slope1 */
396 29, /* agc2_slope2 */
403 1, /* perform_agc_softsplit */
406 /* PLL Configuration for COFDM BW_MHz = 8.000000
407 * With external clock = 30.000000 */
408 static struct dibx000_bandwidth_config xc3028_bw_config
= {
409 60000, /* internal */
410 30000, /* sampling */
411 1, /* pll_cfg: prediv */
412 8, /* pll_cfg: ratio */
413 3, /* pll_cfg: range */
414 1, /* pll_cfg: reset */
415 0, /* pll_cfg: bypass */
416 0, /* misc: refdiv */
417 0, /* misc: bypclk_div */
418 1, /* misc: IO_CLK_en_core */
419 1, /* misc: ADClkSrc */
420 0, /* misc: modulo */
421 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
422 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
424 30000000 /* xtal_hz */
427 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
428 .output_mpeg2_in_188_bytes
= 1,
429 .hostbus_diversity
= 1,
430 .tuner_is_baseband
= 0,
433 .agc_config_count
= 1,
434 .agc
= &xc3028_agc_config
,
435 .bw
= &xc3028_bw_config
,
437 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
438 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
439 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
445 .output_mode
= OUTMODE_MPEG2_SERIAL
,
448 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
449 .demod_address
= 0x0f,
452 .disable_i2c_gate_ctrl
= 1,
455 static struct stv0900_reg stv0900_ts_regs
[] = {
456 { R0900_TSGENERAL
, 0x00 },
457 { R0900_P1_TSSPEED
, 0x40 },
458 { R0900_P2_TSSPEED
, 0x40 },
459 { R0900_P1_TSCFGM
, 0xc0 },
460 { R0900_P2_TSCFGM
, 0xc0 },
461 { R0900_P1_TSCFGH
, 0xe0 },
462 { R0900_P2_TSCFGH
, 0xe0 },
463 { R0900_P1_TSCFGL
, 0x20 },
464 { R0900_P2_TSCFGL
, 0x20 },
465 { 0xffff, 0xff }, /* terminate */
468 static struct stv0900_config netup_stv0900_config
= {
469 .demod_address
= 0x68,
470 .demod_mode
= 1, /* dual */
472 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
473 .diseqc_mode
= 2,/* 2/3 PWM */
474 .ts_config_regs
= stv0900_ts_regs
,
475 .tun1_maddress
= 0,/* 0x60 */
476 .tun2_maddress
= 3,/* 0x63 */
477 .tun1_adc
= 1,/* 1 Vpp */
478 .tun2_adc
= 1,/* 1 Vpp */
481 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
485 .gain
= 8, /* +16 dB - maximum gain */
488 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
492 .gain
= 8, /* +16 dB - maximum gain */
495 static struct cx24116_config tbs_cx24116_config
= {
496 .demod_address
= 0x55,
499 static struct cx24117_config tbs_cx24117_config
= {
500 .demod_address
= 0x55,
503 static struct ds3000_config tevii_ds3000_config
= {
504 .demod_address
= 0x68,
507 static struct ts2020_config tevii_ts2020_config
= {
508 .tuner_address
= 0x60,
510 .frequency_div
= 1146000,
513 static struct cx24116_config dvbworld_cx24116_config
= {
514 .demod_address
= 0x05,
517 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
518 .prod
= LGS8GXX_PROD_LGS8GL5
,
519 .demod_address
= 0x19,
523 .if_clk_freq
= 30400, /* 30.4 MHz */
524 .if_freq
= 5380, /* 5.38 MHz */
531 static struct xc5000_config mygica_x8506_xc5000_config
= {
536 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
537 .demod_address
= 0x10,
540 static struct xc5000_config mygica_x8507_xc5000_config
= {
545 static struct stv090x_config prof_8000_stv090x_config
= {
547 .demod_mode
= STV090x_SINGLE
,
548 .clk_mode
= STV090x_CLK_EXT
,
551 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
552 .repeater_level
= STV090x_RPTLEVEL_64
,
553 .adc1_range
= STV090x_ADC_2Vpp
,
554 .diseqc_envelope_mode
= false,
556 .tuner_get_frequency
= stb6100_get_frequency
,
557 .tuner_set_frequency
= stb6100_set_frequency
,
558 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
559 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
562 static struct stb6100_config prof_8000_stb6100_config
= {
563 .tuner_address
= 0x60,
564 .refclock
= 27000000,
567 static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config
= {
571 .deny_i2c_rptr
= 1, /* Disabled */
572 .spectral_inversion
= 0, /* Disabled */
573 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
574 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
575 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
576 .xtalMHz
= 25, /* 24 or 25 */
579 static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config
= {
583 .deny_i2c_rptr
= 1, /* Disabled */
584 .spectral_inversion
= 0, /* Disabled */
585 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
586 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
587 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
588 .xtalMHz
= 25, /* 24 or 25 */
591 static int p8000_set_voltage(struct dvb_frontend
*fe
,
592 enum fe_sec_voltage voltage
)
594 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
595 struct cx23885_dev
*dev
= port
->dev
;
597 if (voltage
== SEC_VOLTAGE_18
)
598 cx_write(MC417_RWD
, 0x00001e00);
599 else if (voltage
== SEC_VOLTAGE_13
)
600 cx_write(MC417_RWD
, 0x00001a00);
602 cx_write(MC417_RWD
, 0x00001800);
606 static int dvbsky_t9580_set_voltage(struct dvb_frontend
*fe
,
607 enum fe_sec_voltage voltage
)
609 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
610 struct cx23885_dev
*dev
= port
->dev
;
612 cx23885_gpio_enable(dev
, GPIO_0
| GPIO_1
, 1);
616 cx23885_gpio_set(dev
, GPIO_1
);
617 cx23885_gpio_clear(dev
, GPIO_0
);
620 cx23885_gpio_set(dev
, GPIO_1
);
621 cx23885_gpio_set(dev
, GPIO_0
);
623 case SEC_VOLTAGE_OFF
:
624 cx23885_gpio_clear(dev
, GPIO_1
);
625 cx23885_gpio_clear(dev
, GPIO_0
);
629 /* call the frontend set_voltage function */
630 port
->fe_set_voltage(fe
, voltage
);
635 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend
*fe
,
636 enum fe_sec_voltage voltage
)
638 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
639 struct cx23885_dev
*dev
= port
->dev
;
641 cx23885_gpio_enable(dev
, GPIO_12
| GPIO_13
, 1);
645 cx23885_gpio_set(dev
, GPIO_13
);
646 cx23885_gpio_clear(dev
, GPIO_12
);
649 cx23885_gpio_set(dev
, GPIO_13
);
650 cx23885_gpio_set(dev
, GPIO_12
);
652 case SEC_VOLTAGE_OFF
:
653 cx23885_gpio_clear(dev
, GPIO_13
);
654 cx23885_gpio_clear(dev
, GPIO_12
);
657 /* call the frontend set_voltage function */
658 return port
->fe_set_voltage(fe
, voltage
);
661 static int cx23885_sp2_ci_ctrl(void *priv
, u8 read
, int addr
,
665 #define SP2_DATA 0x000000ff
666 #define SP2_WR 0x00008000
667 #define SP2_RD 0x00004000
668 #define SP2_ACK 0x00001000
669 #define SP2_ADHI 0x00000800
670 #define SP2_ADLO 0x00000400
671 #define SP2_CS1 0x00000200
672 #define SP2_CS0 0x00000100
673 #define SP2_EN_ALL 0x00001000
674 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
676 struct cx23885_tsport
*port
= priv
;
677 struct cx23885_dev
*dev
= port
->dev
;
680 unsigned long timeout
;
682 mutex_lock(&dev
->gpio_lock
);
685 cx_write(MC417_OEN
, SP2_EN_ALL
);
686 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
687 SP2_ADLO
| (0xff & addr
));
688 cx_clear(MC417_RWD
, SP2_ADLO
);
689 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
690 SP2_ADHI
| (0xff & (addr
>> 8)));
691 cx_clear(MC417_RWD
, SP2_ADHI
);
695 cx_write(MC417_OEN
, SP2_EN_ALL
| SP2_DATA
);
698 cx_write(MC417_RWD
, SP2_CTRL_OFF
| data
);
701 cx_clear(MC417_RWD
, SP2_CS0
);
704 cx_clear(MC417_RWD
, (read
) ? SP2_RD
: SP2_WR
);
706 /* wait for a maximum of 1 msec */
707 timeout
= jiffies
+ msecs_to_jiffies(1);
708 while (!time_after(jiffies
, timeout
)) {
709 tmp
= cx_read(MC417_RWD
);
710 if ((tmp
& SP2_ACK
) == 0)
712 usleep_range(50, 100);
715 cx_set(MC417_RWD
, SP2_CTRL_OFF
);
718 mutex_unlock(&dev
->gpio_lock
);
732 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
734 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
735 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
736 struct cx23885_dev
*dev
= port
->dev
;
738 switch (dev
->board
) {
739 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
740 switch (p
->modulation
) {
742 cx23885_gpio_clear(dev
, GPIO_5
);
747 cx23885_gpio_set(dev
, GPIO_5
);
751 case CX23885_BOARD_MYGICA_X8506
:
752 case CX23885_BOARD_MYGICA_X8507
:
753 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
754 /* Select Digital TV */
755 cx23885_gpio_set(dev
, GPIO_0
);
759 /* Call the real set_frontend */
760 if (port
->set_frontend
)
761 return port
->set_frontend(fe
);
766 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
767 struct dvb_frontend
*fe
)
769 port
->set_frontend
= fe
->ops
.set_frontend
;
770 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
773 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
774 .prod
= LGS8GXX_PROD_LGS8G75
,
775 .demod_address
= 0x19,
779 .if_clk_freq
= 30400, /* 30.4 MHz */
780 .if_freq
= 6500, /* 6.50 MHz */
784 .adc_vpp
= 2, /* 1.6 Vpp */
788 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
793 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
794 .prod
= ATBM8830_PROD_8830
,
795 .demod_address
= 0x44,
797 .ts_sampling_edge
= 1,
799 .osc_clk_freq
= 30400, /* in kHz */
800 .if_freq
= 0, /* zero IF */
807 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
812 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
813 .prod
= ATBM8830_PROD_8830
,
814 .demod_address
= 0x44,
816 .ts_sampling_edge
= 1,
818 .osc_clk_freq
= 30400, /* in kHz */
819 .if_freq
= 0, /* zero IF */
826 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
830 static struct stv0367_config netup_stv0367_config
[] = {
832 .demod_address
= 0x1c,
839 .demod_address
= 0x1d,
848 static struct xc5000_config netup_xc5000_config
[] = {
858 static struct drxk_config terratec_drxk_config
[] = {
868 static struct mt2063_config terratec_mt2063_config
[] = {
870 .tuner_address
= 0x60,
872 .tuner_address
= 0x67,
876 static const struct tda10071_platform_data hauppauge_tda10071_pdata
= {
877 .clk
= 40444000, /* 40.444 MHz */
879 .ts_mode
= TDA10071_TS_SERIAL
,
880 .pll_multiplier
= 20,
881 .tuner_i2c_addr
= 0x54,
884 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config
= {
889 .ts_mode
= M88DS3103_TS_PARALLEL
,
897 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config
= {
902 .ts_mode
= M88DS3103_TS_CI
,
910 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config
= {
914 .ts_mode
= M88DS3103_TS_PARALLEL
,
920 static struct lgdt3306a_config hauppauge_hvr1265k4_config
= {
924 .deny_i2c_rptr
= 1, /* Disabled */
925 .spectral_inversion
= 0, /* Disabled */
926 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
927 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
928 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
929 .xtalMHz
= 25, /* 24 or 25 */
932 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
934 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
935 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
938 mem
= cx_read(MC417_RWD
);
940 cx_set(MC417_OEN
, ALT_DATA
);
942 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
944 mem
|= (data
& ALT_DATA
);
954 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
956 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
958 cx_write(MC417_RWD
, mem
); /* start RW cycle */
961 mem
= cx_read(MC417_RWD
);
962 if ((mem
& ALT_RDY
) == 0)
964 if (time_after(jiffies
, timeout
))
969 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
971 return mem
& ALT_DATA
;
976 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
978 struct dib7000p_ops
*dib7000p_ops
= fe
->sec_priv
;
980 return dib7000p_ops
->set_gpio(fe
, 8, 0, !onoff
);
983 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
988 static struct dib0070_config dib7070p_dib0070_config
= {
989 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
990 .reset
= dib7070_tuner_reset
,
991 .sleep
= dib7070_tuner_sleep
,
993 .freq_offset_khz_vhf
= 550,
994 /* .flip_chip = 1, */
997 /* DIB7070 generic */
998 static struct dibx000_agc_config dib7070_agc_config
= {
999 .band_caps
= BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
1002 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1003 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1004 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1006 .setup
= (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1007 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1009 .time_stabiliz
= 10,
1033 .perform_agc_softsplit
= 0,
1036 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
1046 .IO_CLK_en_core
= 1,
1049 /* refsel, sel, freq_15k */
1050 .sad_cfg
= (3 << 14) | (1 << 12) | (524 << 0),
1051 .ifreq
= (0 << 25) | 0,
1053 .xtal_hz
= 12000000,
1056 static struct dib7000p_config dib7070p_dib7000p_config
= {
1057 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1058 .output_mode
= OUTMODE_MPEG2_SERIAL
,
1059 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1060 .output_mpeg2_in_188_bytes
= 1,
1062 .agc_config_count
= 1,
1063 .agc
= &dib7070_agc_config
,
1064 .bw
= &dib7070_bw_config_12_mhz
,
1065 .tuner_is_baseband
= 1,
1068 .gpio_dir
= 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1069 .gpio_val
= 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1070 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1072 .hostbus_diversity
= 1,
1075 static int dvb_register_ci_mac(struct cx23885_tsport
*port
)
1077 struct cx23885_dev
*dev
= port
->dev
;
1078 struct i2c_client
*client_ci
= NULL
;
1079 struct vb2_dvb_frontend
*fe0
;
1081 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1085 switch (dev
->board
) {
1086 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1087 static struct netup_card_info cinfo
;
1089 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1090 memcpy(port
->frontends
.adapter
.proposed_mac
,
1091 cinfo
.port
[port
->nr
- 1].mac
, 6);
1092 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1093 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1095 netup_ci_init(port
);
1098 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1099 struct altera_ci_config netup_ci_cfg
= {
1100 .dev
= dev
,/* magic number to identify*/
1101 .adapter
= &port
->frontends
.adapter
,/* for CI */
1102 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1103 .fpga_rw
= netup_altera_fpga_rw
,
1106 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1109 case CX23885_BOARD_TEVII_S470
: {
1110 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1115 /* Read entire EEPROM */
1116 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1117 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1118 pr_info("TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1119 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1122 case CX23885_BOARD_DVBSKY_T9580
:
1123 case CX23885_BOARD_DVBSKY_S950
:
1124 case CX23885_BOARD_DVBSKY_S952
:
1125 case CX23885_BOARD_DVBSKY_T982
: {
1126 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1131 /* Read entire EEPROM */
1132 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1133 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1135 pr_info("%s port %d MAC address: %pM\n",
1136 cx23885_boards
[dev
->board
].name
, port
->nr
,
1137 eeprom
+ 0xc0 + (port
->nr
-1) * 8);
1138 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0 +
1139 (port
->nr
-1) * 8, 6);
1142 case CX23885_BOARD_DVBSKY_S950C
:
1143 case CX23885_BOARD_DVBSKY_T980C
:
1144 case CX23885_BOARD_TT_CT2_4500_CI
: {
1145 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1146 struct sp2_config sp2_config
;
1147 struct i2c_board_info info
;
1148 struct cx23885_i2c
*i2c_bus
= &dev
->i2c_bus
[0];
1151 memset(&sp2_config
, 0, sizeof(sp2_config
));
1152 sp2_config
.dvb_adap
= &port
->frontends
.adapter
;
1153 sp2_config
.priv
= port
;
1154 sp2_config
.ci_control
= cx23885_sp2_ci_ctrl
;
1155 memset(&info
, 0, sizeof(struct i2c_board_info
));
1156 strscpy(info
.type
, "sp2", I2C_NAME_SIZE
);
1158 info
.platform_data
= &sp2_config
;
1159 request_module(info
.type
);
1160 client_ci
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1161 if (!i2c_client_has_driver(client_ci
))
1163 if (!try_module_get(client_ci
->dev
.driver
->owner
)) {
1164 i2c_unregister_device(client_ci
);
1167 port
->i2c_client_ci
= client_ci
;
1172 /* Read entire EEPROM */
1173 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1174 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1176 pr_info("%s MAC address: %pM\n",
1177 cx23885_boards
[dev
->board
].name
, eeprom
+ 0xc0);
1178 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0, 6);
1185 static int dvb_register(struct cx23885_tsport
*port
)
1187 struct dib7000p_ops dib7000p_ops
;
1188 struct cx23885_dev
*dev
= port
->dev
;
1189 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
1190 struct vb2_dvb_frontend
*fe0
, *fe1
= NULL
;
1191 struct si2168_config si2168_config
;
1192 struct si2165_platform_data si2165_pdata
;
1193 struct si2157_config si2157_config
;
1194 struct ts2020_config ts2020_config
;
1195 struct m88ds3103_platform_data m88ds3103_pdata
;
1196 struct m88rs6000t_config m88rs6000t_config
= {};
1197 struct a8293_platform_data a8293_pdata
= {};
1198 struct i2c_board_info info
;
1199 struct i2c_adapter
*adapter
;
1200 struct i2c_client
*client_demod
= NULL
, *client_tuner
= NULL
;
1201 struct i2c_client
*client_sec
= NULL
;
1202 int (*p_set_voltage
)(struct dvb_frontend
*fe
,
1203 enum fe_sec_voltage voltage
) = NULL
;
1204 int mfe_shared
= 0; /* bus not shared by default */
1207 /* Get the first frontend */
1208 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1212 /* init struct vb2_dvb */
1213 fe0
->dvb
.name
= dev
->name
;
1215 /* multi-frontend gate control is undefined or defaults to fe0 */
1216 port
->frontends
.gate
= 0;
1218 /* Sets the gate control callback to be used by i2c command calls */
1219 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
1222 switch (dev
->board
) {
1223 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
1224 i2c_bus
= &dev
->i2c_bus
[0];
1225 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1226 &hauppauge_generic_config
,
1227 &i2c_bus
->i2c_adap
);
1228 if (fe0
->dvb
.frontend
== NULL
)
1230 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1232 &hauppauge_generic_tunerconfig
, 0);
1234 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
1235 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
1236 i2c_bus
= &dev
->i2c_bus
[0];
1237 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1238 &hauppauge_lgdt3305_config
,
1239 &i2c_bus
->i2c_adap
);
1240 if (fe0
->dvb
.frontend
== NULL
)
1242 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1243 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1244 &hauppauge_hvr127x_config
);
1245 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
1246 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1248 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
1249 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
1250 i2c_bus
= &dev
->i2c_bus
[0];
1251 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1252 &hcw_s5h1411_config
,
1253 &i2c_bus
->i2c_adap
);
1254 if (fe0
->dvb
.frontend
== NULL
)
1257 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1258 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1259 &hauppauge_tda18271_config
);
1261 tda18271_attach(&dev
->ts1
.analog_fe
,
1262 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1263 &hauppauge_tda18271_config
);
1266 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
1267 i2c_bus
= &dev
->i2c_bus
[0];
1268 switch (alt_tuner
) {
1271 dvb_attach(s5h1409_attach
,
1272 &hauppauge_ezqam_config
,
1273 &i2c_bus
->i2c_adap
);
1274 if (fe0
->dvb
.frontend
== NULL
)
1277 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1278 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1280 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1281 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1282 &hauppauge_tda18271_config
);
1287 dvb_attach(s5h1409_attach
,
1288 &hauppauge_generic_config
,
1289 &i2c_bus
->i2c_adap
);
1290 if (fe0
->dvb
.frontend
== NULL
)
1292 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1294 &hauppauge_generic_tunerconfig
, 0);
1297 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
1298 i2c_bus
= &dev
->i2c_bus
[0];
1299 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1300 &hauppauge_hvr1800lp_config
,
1301 &i2c_bus
->i2c_adap
);
1302 if (fe0
->dvb
.frontend
== NULL
)
1304 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1306 &hauppauge_generic_tunerconfig
, 0);
1308 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
1309 i2c_bus
= &dev
->i2c_bus
[0];
1310 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1311 &fusionhdtv_5_express
,
1313 &i2c_bus
->i2c_adap
);
1314 if (fe0
->dvb
.frontend
== NULL
)
1316 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1317 &i2c_bus
->i2c_adap
, 0x61,
1318 TUNER_LG_TDVS_H06XF
);
1320 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
1321 i2c_bus
= &dev
->i2c_bus
[1];
1322 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1323 &hauppauge_hvr1500q_config
,
1324 &dev
->i2c_bus
[0].i2c_adap
);
1325 if (fe0
->dvb
.frontend
== NULL
)
1327 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1329 &hauppauge_hvr1500q_tunerconfig
);
1331 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
1332 i2c_bus
= &dev
->i2c_bus
[1];
1333 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1334 &hauppauge_hvr1500_config
,
1335 &dev
->i2c_bus
[0].i2c_adap
);
1336 if (fe0
->dvb
.frontend
!= NULL
) {
1337 struct dvb_frontend
*fe
;
1338 struct xc2028_config cfg
= {
1339 .i2c_adap
= &i2c_bus
->i2c_adap
,
1342 static struct xc2028_ctrl ctl
= {
1343 .fname
= XC2028_DEFAULT_FIRMWARE
,
1345 .demod
= XC3028_FE_OREN538
,
1348 fe
= dvb_attach(xc2028_attach
,
1349 fe0
->dvb
.frontend
, &cfg
);
1350 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1351 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1354 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
1355 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
1356 i2c_bus
= &dev
->i2c_bus
[0];
1357 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1358 &hauppauge_hvr1200_config
,
1359 &i2c_bus
->i2c_adap
);
1360 if (fe0
->dvb
.frontend
== NULL
)
1362 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1363 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1365 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1366 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1367 &hauppauge_hvr1200_tuner_config
);
1369 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
1370 i2c_bus
= &dev
->i2c_bus
[0];
1371 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1372 &hauppauge_hvr1210_config
,
1373 &i2c_bus
->i2c_adap
);
1374 if (fe0
->dvb
.frontend
!= NULL
) {
1375 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1376 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1377 &hauppauge_hvr1210_tuner_config
);
1380 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
1381 i2c_bus
= &dev
->i2c_bus
[0];
1383 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1386 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
,
1387 0x12, &hauppauge_hvr1400_dib7000_config
);
1388 if (fe0
->dvb
.frontend
!= NULL
) {
1389 struct dvb_frontend
*fe
;
1390 struct xc2028_config cfg
= {
1391 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1394 static struct xc2028_ctrl ctl
= {
1395 .fname
= XC3028L_DEFAULT_FIRMWARE
,
1397 .demod
= XC3028_FE_DIBCOM52
,
1398 /* This is true for all demods with
1400 .type
= XC2028_D2633
,
1403 fe
= dvb_attach(xc2028_attach
,
1404 fe0
->dvb
.frontend
, &cfg
);
1405 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1406 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1409 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
1410 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1412 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1413 &dvico_s5h1409_config
,
1414 &i2c_bus
->i2c_adap
);
1415 if (fe0
->dvb
.frontend
== NULL
)
1416 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1417 &dvico_s5h1411_config
,
1418 &i2c_bus
->i2c_adap
);
1419 if (fe0
->dvb
.frontend
!= NULL
)
1420 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1422 &dvico_xc5000_tunerconfig
);
1424 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
1425 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1427 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1428 &dvico_fusionhdtv_xc3028
,
1429 &i2c_bus
->i2c_adap
);
1430 if (fe0
->dvb
.frontend
!= NULL
) {
1431 struct dvb_frontend
*fe
;
1432 struct xc2028_config cfg
= {
1433 .i2c_adap
= &i2c_bus
->i2c_adap
,
1436 static struct xc2028_ctrl ctl
= {
1437 .fname
= XC2028_DEFAULT_FIRMWARE
,
1439 .demod
= XC3028_FE_ZARLINK456
,
1442 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1444 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1445 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1449 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2
: {
1450 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1451 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1452 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1454 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1457 if (dib7000p_ops
.i2c_enumeration(&i2c_bus
->i2c_adap
, 1, 0x12, &dib7070p_dib7000p_config
) < 0) {
1458 pr_warn("Unable to enumerate dib7000p\n");
1461 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
, 0x80, &dib7070p_dib7000p_config
);
1462 if (fe0
->dvb
.frontend
!= NULL
) {
1463 struct i2c_adapter
*tun_i2c
;
1465 fe0
->dvb
.frontend
->sec_priv
= kmemdup(&dib7000p_ops
, sizeof(dib7000p_ops
), GFP_KERNEL
);
1466 if (!fe0
->dvb
.frontend
->sec_priv
)
1468 tun_i2c
= dib7000p_ops
.get_i2c_master(fe0
->dvb
.frontend
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1469 if (!dvb_attach(dib0070_attach
, fe0
->dvb
.frontend
, tun_i2c
, &dib7070p_dib0070_config
))
1474 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
1475 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
1476 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
1477 i2c_bus
= &dev
->i2c_bus
[0];
1479 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1480 &dvico_fusionhdtv_xc3028
,
1481 &i2c_bus
->i2c_adap
);
1482 if (fe0
->dvb
.frontend
!= NULL
) {
1483 struct dvb_frontend
*fe
;
1484 struct xc2028_config cfg
= {
1485 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1488 static struct xc2028_ctrl ctl
= {
1489 .fname
= XC2028_DEFAULT_FIRMWARE
,
1491 .demod
= XC3028_FE_ZARLINK456
,
1494 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1496 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1497 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1500 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1501 i2c_bus
= &dev
->i2c_bus
[0];
1503 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1504 &dvico_fusionhdtv_xc3028
,
1505 &i2c_bus
->i2c_adap
);
1506 if (fe0
->dvb
.frontend
!= NULL
) {
1507 struct dvb_frontend
*fe
;
1508 struct xc4000_config cfg
= {
1509 .i2c_address
= 0x61,
1511 .dvb_amplitude
= 134,
1512 .set_smoothedcvbs
= 1,
1516 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1517 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1519 pr_err("%s/2: xc4000 attach failed\n",
1521 goto frontend_detach
;
1525 case CX23885_BOARD_TBS_6920
:
1526 i2c_bus
= &dev
->i2c_bus
[1];
1528 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1529 &tbs_cx24116_config
,
1530 &i2c_bus
->i2c_adap
);
1531 if (fe0
->dvb
.frontend
!= NULL
)
1532 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1535 case CX23885_BOARD_TBS_6980
:
1536 case CX23885_BOARD_TBS_6981
:
1537 i2c_bus
= &dev
->i2c_bus
[1];
1542 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1543 &tbs_cx24117_config
,
1544 &i2c_bus
->i2c_adap
);
1548 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1549 &tbs_cx24117_config
,
1550 &i2c_bus
->i2c_adap
);
1554 case CX23885_BOARD_TEVII_S470
:
1555 i2c_bus
= &dev
->i2c_bus
[1];
1557 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1558 &tevii_ds3000_config
,
1559 &i2c_bus
->i2c_adap
);
1560 if (fe0
->dvb
.frontend
!= NULL
) {
1561 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1562 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1563 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1567 case CX23885_BOARD_DVBWORLD_2005
:
1568 i2c_bus
= &dev
->i2c_bus
[1];
1570 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1571 &dvbworld_cx24116_config
,
1572 &i2c_bus
->i2c_adap
);
1574 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1575 i2c_bus
= &dev
->i2c_bus
[0];
1579 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1580 &netup_stv0900_config
,
1581 &i2c_bus
->i2c_adap
, 0);
1582 if (fe0
->dvb
.frontend
!= NULL
) {
1583 if (dvb_attach(stv6110_attach
,
1585 &netup_stv6110_tunerconfig_a
,
1586 &i2c_bus
->i2c_adap
)) {
1587 if (!dvb_attach(lnbh24_attach
,
1590 LNBH24_PCL
| LNBH24_TTX
,
1592 pr_err("No LNBH24 found!\n");
1599 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1600 &netup_stv0900_config
,
1601 &i2c_bus
->i2c_adap
, 1);
1602 if (fe0
->dvb
.frontend
!= NULL
) {
1603 if (dvb_attach(stv6110_attach
,
1605 &netup_stv6110_tunerconfig_b
,
1606 &i2c_bus
->i2c_adap
)) {
1607 if (!dvb_attach(lnbh24_attach
,
1610 LNBH24_PCL
| LNBH24_TTX
,
1612 pr_err("No LNBH24 found!\n");
1619 case CX23885_BOARD_MYGICA_X8506
:
1620 i2c_bus
= &dev
->i2c_bus
[0];
1621 i2c_bus2
= &dev
->i2c_bus
[1];
1622 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1623 &mygica_x8506_lgs8gl5_config
,
1624 &i2c_bus
->i2c_adap
);
1625 if (fe0
->dvb
.frontend
== NULL
)
1627 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1628 &i2c_bus2
->i2c_adap
, &mygica_x8506_xc5000_config
);
1629 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1631 case CX23885_BOARD_MYGICA_X8507
:
1632 i2c_bus
= &dev
->i2c_bus
[0];
1633 i2c_bus2
= &dev
->i2c_bus
[1];
1634 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1635 &mygica_x8507_mb86a20s_config
,
1636 &i2c_bus
->i2c_adap
);
1637 if (fe0
->dvb
.frontend
== NULL
)
1640 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1641 &i2c_bus2
->i2c_adap
,
1642 &mygica_x8507_xc5000_config
);
1643 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1645 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1646 i2c_bus
= &dev
->i2c_bus
[0];
1647 i2c_bus2
= &dev
->i2c_bus
[1];
1648 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1649 &magicpro_prohdtve2_lgs8g75_config
,
1650 &i2c_bus
->i2c_adap
);
1651 if (fe0
->dvb
.frontend
== NULL
)
1653 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1654 &i2c_bus2
->i2c_adap
,
1655 &magicpro_prohdtve2_xc5000_config
);
1656 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1658 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1659 i2c_bus
= &dev
->i2c_bus
[0];
1660 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1661 &hcw_s5h1411_config
,
1662 &i2c_bus
->i2c_adap
);
1663 if (fe0
->dvb
.frontend
== NULL
)
1665 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1666 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1667 &hauppauge_tda18271_config
);
1669 tda18271_attach(&dev
->ts1
.analog_fe
,
1670 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1671 &hauppauge_tda18271_config
);
1674 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1675 i2c_bus
= &dev
->i2c_bus
[0];
1676 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1677 &hcw_s5h1411_config
,
1678 &i2c_bus
->i2c_adap
);
1679 if (fe0
->dvb
.frontend
== NULL
)
1681 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1682 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1683 &hauppauge_tda18271_config
);
1685 case CX23885_BOARD_MYGICA_X8558PRO
:
1689 i2c_bus
= &dev
->i2c_bus
[0];
1690 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1691 &mygica_x8558pro_atbm8830_cfg1
,
1692 &i2c_bus
->i2c_adap
);
1693 if (fe0
->dvb
.frontend
== NULL
)
1695 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1697 &mygic_x8558pro_max2165_cfg1
);
1701 i2c_bus
= &dev
->i2c_bus
[1];
1702 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1703 &mygica_x8558pro_atbm8830_cfg2
,
1704 &i2c_bus
->i2c_adap
);
1705 if (fe0
->dvb
.frontend
== NULL
)
1707 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1709 &mygic_x8558pro_max2165_cfg2
);
1712 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1716 i2c_bus
= &dev
->i2c_bus
[0];
1717 mfe_shared
= 1;/* MFE */
1718 port
->frontends
.gate
= 0;/* not clear for me yet */
1720 /* MFE frontend 1 DVB-T */
1721 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1722 &netup_stv0367_config
[port
->nr
- 1],
1723 &i2c_bus
->i2c_adap
);
1724 if (fe0
->dvb
.frontend
== NULL
)
1726 if (NULL
== dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1728 &netup_xc5000_config
[port
->nr
- 1]))
1729 goto frontend_detach
;
1730 /* load xc5000 firmware */
1731 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1733 /* MFE frontend 2 */
1734 fe1
= vb2_dvb_get_frontend(&port
->frontends
, 2);
1736 goto frontend_detach
;
1738 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1739 &netup_stv0367_config
[port
->nr
- 1],
1740 &i2c_bus
->i2c_adap
);
1741 if (fe1
->dvb
.frontend
== NULL
)
1744 fe1
->dvb
.frontend
->id
= 1;
1745 if (NULL
== dvb_attach(xc5000_attach
,
1748 &netup_xc5000_config
[port
->nr
- 1]))
1749 goto frontend_detach
;
1751 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1752 i2c_bus
= &dev
->i2c_bus
[0];
1753 i2c_bus2
= &dev
->i2c_bus
[1];
1758 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1759 &terratec_drxk_config
[0],
1760 &i2c_bus
->i2c_adap
);
1761 if (fe0
->dvb
.frontend
== NULL
)
1763 if (!dvb_attach(mt2063_attach
,
1765 &terratec_mt2063_config
[0],
1766 &i2c_bus2
->i2c_adap
))
1767 goto frontend_detach
;
1771 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1772 &terratec_drxk_config
[1],
1773 &i2c_bus
->i2c_adap
);
1774 if (fe0
->dvb
.frontend
== NULL
)
1776 if (!dvb_attach(mt2063_attach
,
1778 &terratec_mt2063_config
[1],
1779 &i2c_bus2
->i2c_adap
))
1780 goto frontend_detach
;
1784 case CX23885_BOARD_TEVII_S471
:
1785 i2c_bus
= &dev
->i2c_bus
[1];
1787 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1788 &tevii_ds3000_config
,
1789 &i2c_bus
->i2c_adap
);
1790 if (fe0
->dvb
.frontend
== NULL
)
1792 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1793 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1795 case CX23885_BOARD_PROF_8000
:
1796 i2c_bus
= &dev
->i2c_bus
[0];
1798 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1799 &prof_8000_stv090x_config
,
1801 STV090x_DEMODULATOR_0
);
1802 if (fe0
->dvb
.frontend
== NULL
)
1804 if (!dvb_attach(stb6100_attach
,
1806 &prof_8000_stb6100_config
,
1807 &i2c_bus
->i2c_adap
))
1808 goto frontend_detach
;
1810 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1812 case CX23885_BOARD_HAUPPAUGE_HVR4400
: {
1813 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1814 struct a8293_platform_data a8293_pdata
= {};
1816 i2c_bus
= &dev
->i2c_bus
[0];
1817 i2c_bus2
= &dev
->i2c_bus
[1];
1821 /* attach demod + tuner combo */
1822 memset(&info
, 0, sizeof(info
));
1823 strscpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1825 info
.platform_data
= &tda10071_pdata
;
1826 request_module("tda10071");
1827 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1828 if (!i2c_client_has_driver(client_demod
))
1829 goto frontend_detach
;
1830 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1831 i2c_unregister_device(client_demod
);
1832 goto frontend_detach
;
1834 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1835 port
->i2c_client_demod
= client_demod
;
1838 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1839 memset(&info
, 0, sizeof(info
));
1840 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1842 info
.platform_data
= &a8293_pdata
;
1843 request_module("a8293");
1844 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1845 if (!i2c_client_has_driver(client_sec
))
1846 goto frontend_detach
;
1847 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1848 i2c_unregister_device(client_sec
);
1849 goto frontend_detach
;
1851 port
->i2c_client_sec
= client_sec
;
1855 /* attach frontend */
1856 memset(&si2165_pdata
, 0, sizeof(si2165_pdata
));
1857 si2165_pdata
.fe
= &fe0
->dvb
.frontend
;
1858 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
;
1859 si2165_pdata
.ref_freq_hz
= 16000000;
1860 memset(&info
, 0, sizeof(struct i2c_board_info
));
1861 strscpy(info
.type
, "si2165", I2C_NAME_SIZE
);
1863 info
.platform_data
= &si2165_pdata
;
1864 request_module(info
.type
);
1865 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1866 if (!i2c_client_has_driver(client_demod
))
1867 goto frontend_detach
;
1868 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1869 i2c_unregister_device(client_demod
);
1870 goto frontend_detach
;
1872 port
->i2c_client_demod
= client_demod
;
1874 if (fe0
->dvb
.frontend
== NULL
)
1876 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1877 if (!dvb_attach(tda18271_attach
,
1879 0x60, &i2c_bus2
->i2c_adap
,
1880 &hauppauge_hvr4400_tuner_config
))
1881 goto frontend_detach
;
1886 case CX23885_BOARD_HAUPPAUGE_STARBURST
: {
1887 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1888 struct a8293_platform_data a8293_pdata
= {};
1890 i2c_bus
= &dev
->i2c_bus
[0];
1892 /* attach demod + tuner combo */
1893 memset(&info
, 0, sizeof(info
));
1894 strscpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1896 info
.platform_data
= &tda10071_pdata
;
1897 request_module("tda10071");
1898 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1899 if (!i2c_client_has_driver(client_demod
))
1900 goto frontend_detach
;
1901 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1902 i2c_unregister_device(client_demod
);
1903 goto frontend_detach
;
1905 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1906 port
->i2c_client_demod
= client_demod
;
1909 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1910 memset(&info
, 0, sizeof(info
));
1911 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1913 info
.platform_data
= &a8293_pdata
;
1914 request_module("a8293");
1915 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1916 if (!i2c_client_has_driver(client_sec
))
1917 goto frontend_detach
;
1918 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1919 i2c_unregister_device(client_sec
);
1920 goto frontend_detach
;
1922 port
->i2c_client_sec
= client_sec
;
1925 case CX23885_BOARD_DVBSKY_T9580
:
1926 case CX23885_BOARD_DVBSKY_S950
:
1927 i2c_bus
= &dev
->i2c_bus
[0];
1928 i2c_bus2
= &dev
->i2c_bus
[1];
1930 /* port b - satellite */
1932 /* attach frontend */
1933 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1934 &dvbsky_t9580_m88ds3103_config
,
1935 &i2c_bus2
->i2c_adap
, &adapter
);
1936 if (fe0
->dvb
.frontend
== NULL
)
1940 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
1941 ts2020_config
.fe
= fe0
->dvb
.frontend
;
1942 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
1943 memset(&info
, 0, sizeof(struct i2c_board_info
));
1944 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
1946 info
.platform_data
= &ts2020_config
;
1947 request_module(info
.type
);
1948 client_tuner
= i2c_new_client_device(adapter
, &info
);
1949 if (!i2c_client_has_driver(client_tuner
))
1950 goto frontend_detach
;
1951 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1952 i2c_unregister_device(client_tuner
);
1953 goto frontend_detach
;
1956 /* delegate signal strength measurement to tuner */
1957 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1958 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1961 * for setting the voltage we need to set GPIOs on
1964 port
->fe_set_voltage
=
1965 fe0
->dvb
.frontend
->ops
.set_voltage
;
1966 fe0
->dvb
.frontend
->ops
.set_voltage
=
1967 dvbsky_t9580_set_voltage
;
1969 port
->i2c_client_tuner
= client_tuner
;
1972 /* port c - terrestrial/cable */
1974 /* attach frontend */
1975 memset(&si2168_config
, 0, sizeof(si2168_config
));
1976 si2168_config
.i2c_adapter
= &adapter
;
1977 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1978 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1979 memset(&info
, 0, sizeof(struct i2c_board_info
));
1980 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1982 info
.platform_data
= &si2168_config
;
1983 request_module(info
.type
);
1984 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
1985 if (!i2c_client_has_driver(client_demod
))
1986 goto frontend_detach
;
1987 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1988 i2c_unregister_device(client_demod
);
1989 goto frontend_detach
;
1991 port
->i2c_client_demod
= client_demod
;
1994 memset(&si2157_config
, 0, sizeof(si2157_config
));
1995 si2157_config
.fe
= fe0
->dvb
.frontend
;
1996 si2157_config
.if_port
= 1;
1997 memset(&info
, 0, sizeof(struct i2c_board_info
));
1998 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2000 info
.platform_data
= &si2157_config
;
2001 request_module(info
.type
);
2002 client_tuner
= i2c_new_client_device(adapter
, &info
);
2003 if (!i2c_client_has_driver(client_tuner
))
2004 goto frontend_detach
;
2006 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2007 i2c_unregister_device(client_tuner
);
2008 goto frontend_detach
;
2010 port
->i2c_client_tuner
= client_tuner
;
2014 case CX23885_BOARD_DVBSKY_T980C
:
2015 case CX23885_BOARD_TT_CT2_4500_CI
:
2016 i2c_bus
= &dev
->i2c_bus
[0];
2017 i2c_bus2
= &dev
->i2c_bus
[1];
2019 /* attach frontend */
2020 memset(&si2168_config
, 0, sizeof(si2168_config
));
2021 si2168_config
.i2c_adapter
= &adapter
;
2022 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2023 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2024 memset(&info
, 0, sizeof(struct i2c_board_info
));
2025 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2027 info
.platform_data
= &si2168_config
;
2028 request_module(info
.type
);
2029 client_demod
= i2c_new_client_device(&i2c_bus2
->i2c_adap
, &info
);
2030 if (!i2c_client_has_driver(client_demod
))
2031 goto frontend_detach
;
2032 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2033 i2c_unregister_device(client_demod
);
2034 goto frontend_detach
;
2036 port
->i2c_client_demod
= client_demod
;
2039 memset(&si2157_config
, 0, sizeof(si2157_config
));
2040 si2157_config
.fe
= fe0
->dvb
.frontend
;
2041 si2157_config
.if_port
= 1;
2042 memset(&info
, 0, sizeof(struct i2c_board_info
));
2043 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2045 info
.platform_data
= &si2157_config
;
2046 request_module(info
.type
);
2047 client_tuner
= i2c_new_client_device(adapter
, &info
);
2048 if (!i2c_client_has_driver(client_tuner
))
2049 goto frontend_detach
;
2050 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2051 i2c_unregister_device(client_tuner
);
2052 goto frontend_detach
;
2054 port
->i2c_client_tuner
= client_tuner
;
2056 case CX23885_BOARD_DVBSKY_S950C
:
2057 i2c_bus
= &dev
->i2c_bus
[0];
2058 i2c_bus2
= &dev
->i2c_bus
[1];
2060 /* attach frontend */
2061 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2062 &dvbsky_s950c_m88ds3103_config
,
2063 &i2c_bus2
->i2c_adap
, &adapter
);
2064 if (fe0
->dvb
.frontend
== NULL
)
2068 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2069 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2070 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2071 memset(&info
, 0, sizeof(struct i2c_board_info
));
2072 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2074 info
.platform_data
= &ts2020_config
;
2075 request_module(info
.type
);
2076 client_tuner
= i2c_new_client_device(adapter
, &info
);
2077 if (!i2c_client_has_driver(client_tuner
))
2078 goto frontend_detach
;
2079 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2080 i2c_unregister_device(client_tuner
);
2081 goto frontend_detach
;
2084 /* delegate signal strength measurement to tuner */
2085 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2086 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2088 port
->i2c_client_tuner
= client_tuner
;
2090 case CX23885_BOARD_DVBSKY_S952
:
2091 /* attach frontend */
2092 memset(&m88ds3103_pdata
, 0, sizeof(m88ds3103_pdata
));
2093 m88ds3103_pdata
.clk
= 27000000;
2094 m88ds3103_pdata
.i2c_wr_max
= 33;
2095 m88ds3103_pdata
.agc
= 0x99;
2096 m88ds3103_pdata
.clk_out
= M88DS3103_CLOCK_OUT_DISABLED
;
2097 m88ds3103_pdata
.lnb_en_pol
= 1;
2102 i2c_bus
= &dev
->i2c_bus
[1];
2103 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_PARALLEL
;
2104 m88ds3103_pdata
.ts_clk
= 16000;
2105 m88ds3103_pdata
.ts_clk_pol
= 1;
2106 p_set_voltage
= dvbsky_t9580_set_voltage
;
2110 i2c_bus
= &dev
->i2c_bus
[0];
2111 m88ds3103_pdata
.ts_mode
= M88DS3103_TS_SERIAL
;
2112 m88ds3103_pdata
.ts_clk
= 96000;
2113 m88ds3103_pdata
.ts_clk_pol
= 0;
2114 p_set_voltage
= dvbsky_s952_portc_set_voltage
;
2120 memset(&info
, 0, sizeof(info
));
2121 strscpy(info
.type
, "m88ds3103", I2C_NAME_SIZE
);
2123 info
.platform_data
= &m88ds3103_pdata
;
2124 request_module(info
.type
);
2125 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2126 if (!i2c_client_has_driver(client_demod
))
2127 goto frontend_detach
;
2128 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2129 i2c_unregister_device(client_demod
);
2130 goto frontend_detach
;
2132 port
->i2c_client_demod
= client_demod
;
2133 adapter
= m88ds3103_pdata
.get_i2c_adapter(client_demod
);
2134 fe0
->dvb
.frontend
= m88ds3103_pdata
.get_dvb_frontend(client_demod
);
2137 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2138 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2139 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2140 memset(&info
, 0, sizeof(struct i2c_board_info
));
2141 strscpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2143 info
.platform_data
= &ts2020_config
;
2144 request_module(info
.type
);
2145 client_tuner
= i2c_new_client_device(adapter
, &info
);
2146 if (!i2c_client_has_driver(client_tuner
))
2147 goto frontend_detach
;
2148 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2149 i2c_unregister_device(client_tuner
);
2150 goto frontend_detach
;
2153 /* delegate signal strength measurement to tuner */
2154 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2155 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2158 * for setting the voltage we need to set GPIOs on
2161 port
->fe_set_voltage
=
2162 fe0
->dvb
.frontend
->ops
.set_voltage
;
2163 fe0
->dvb
.frontend
->ops
.set_voltage
= p_set_voltage
;
2165 port
->i2c_client_tuner
= client_tuner
;
2167 case CX23885_BOARD_DVBSKY_T982
:
2168 memset(&si2168_config
, 0, sizeof(si2168_config
));
2172 i2c_bus
= &dev
->i2c_bus
[1];
2173 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2177 i2c_bus
= &dev
->i2c_bus
[0];
2178 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2182 /* attach frontend */
2183 si2168_config
.i2c_adapter
= &adapter
;
2184 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2185 memset(&info
, 0, sizeof(struct i2c_board_info
));
2186 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2188 info
.platform_data
= &si2168_config
;
2189 request_module(info
.type
);
2190 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2191 if (!i2c_client_has_driver(client_demod
))
2192 goto frontend_detach
;
2193 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2194 i2c_unregister_device(client_demod
);
2195 goto frontend_detach
;
2197 port
->i2c_client_demod
= client_demod
;
2200 memset(&si2157_config
, 0, sizeof(si2157_config
));
2201 si2157_config
.fe
= fe0
->dvb
.frontend
;
2202 si2157_config
.if_port
= 1;
2203 memset(&info
, 0, sizeof(struct i2c_board_info
));
2204 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2206 info
.platform_data
= &si2157_config
;
2207 request_module(info
.type
);
2208 client_tuner
= i2c_new_client_device(adapter
, &info
);
2209 if (!i2c_client_has_driver(client_tuner
))
2210 goto frontend_detach
;
2211 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2212 i2c_unregister_device(client_tuner
);
2213 goto frontend_detach
;
2215 port
->i2c_client_tuner
= client_tuner
;
2217 case CX23885_BOARD_HAUPPAUGE_STARBURST2
:
2218 case CX23885_BOARD_HAUPPAUGE_HVR5525
:
2219 i2c_bus
= &dev
->i2c_bus
[0];
2220 i2c_bus2
= &dev
->i2c_bus
[1];
2224 /* port b - satellite */
2226 /* attach frontend */
2227 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2228 &hauppauge_hvr5525_m88ds3103_config
,
2229 &i2c_bus
->i2c_adap
, &adapter
);
2230 if (fe0
->dvb
.frontend
== NULL
)
2234 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
2235 memset(&info
, 0, sizeof(info
));
2236 strscpy(info
.type
, "a8293", I2C_NAME_SIZE
);
2238 info
.platform_data
= &a8293_pdata
;
2239 request_module("a8293");
2240 client_sec
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2241 if (!i2c_client_has_driver(client_sec
))
2242 goto frontend_detach
;
2243 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
2244 i2c_unregister_device(client_sec
);
2245 goto frontend_detach
;
2247 port
->i2c_client_sec
= client_sec
;
2250 memset(&m88rs6000t_config
, 0, sizeof(m88rs6000t_config
));
2251 m88rs6000t_config
.fe
= fe0
->dvb
.frontend
;
2252 memset(&info
, 0, sizeof(struct i2c_board_info
));
2253 strscpy(info
.type
, "m88rs6000t", I2C_NAME_SIZE
);
2255 info
.platform_data
= &m88rs6000t_config
;
2256 request_module("%s", info
.type
);
2257 client_tuner
= i2c_new_client_device(adapter
, &info
);
2258 if (!i2c_client_has_driver(client_tuner
))
2259 goto frontend_detach
;
2260 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2261 i2c_unregister_device(client_tuner
);
2262 goto frontend_detach
;
2264 port
->i2c_client_tuner
= client_tuner
;
2266 /* delegate signal strength measurement to tuner */
2267 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2268 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2270 /* port c - terrestrial/cable */
2272 /* attach frontend */
2273 memset(&si2168_config
, 0, sizeof(si2168_config
));
2274 si2168_config
.i2c_adapter
= &adapter
;
2275 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2276 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2277 memset(&info
, 0, sizeof(struct i2c_board_info
));
2278 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2280 info
.platform_data
= &si2168_config
;
2281 request_module("%s", info
.type
);
2282 client_demod
= i2c_new_client_device(&i2c_bus
->i2c_adap
, &info
);
2283 if (!i2c_client_has_driver(client_demod
))
2284 goto frontend_detach
;
2285 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2286 i2c_unregister_device(client_demod
);
2287 goto frontend_detach
;
2289 port
->i2c_client_demod
= client_demod
;
2292 memset(&si2157_config
, 0, sizeof(si2157_config
));
2293 si2157_config
.fe
= fe0
->dvb
.frontend
;
2294 si2157_config
.if_port
= 1;
2295 memset(&info
, 0, sizeof(struct i2c_board_info
));
2296 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2298 info
.platform_data
= &si2157_config
;
2299 request_module("%s", info
.type
);
2300 client_tuner
= i2c_new_client_device(&i2c_bus2
->i2c_adap
, &info
);
2301 if (!i2c_client_has_driver(client_tuner
)) {
2302 module_put(client_demod
->dev
.driver
->owner
);
2303 i2c_unregister_device(client_demod
);
2304 port
->i2c_client_demod
= NULL
;
2305 goto frontend_detach
;
2307 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2308 i2c_unregister_device(client_tuner
);
2309 module_put(client_demod
->dev
.driver
->owner
);
2310 i2c_unregister_device(client_demod
);
2311 port
->i2c_client_demod
= NULL
;
2312 goto frontend_detach
;
2314 port
->i2c_client_tuner
= client_tuner
;
2316 dev
->ts1
.analog_fe
.tuner_priv
= client_tuner
;
2317 memcpy(&dev
->ts1
.analog_fe
.ops
.tuner_ops
,
2318 &fe0
->dvb
.frontend
->ops
.tuner_ops
,
2319 sizeof(struct dvb_tuner_ops
));
2324 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB
:
2325 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885
:
2326 pr_info("%s(): board=%d port=%d\n", __func__
,
2327 dev
->board
, port
->nr
);
2329 /* port b - Terrestrial/cable */
2331 /* attach frontend */
2332 memset(&si2168_config
, 0, sizeof(si2168_config
));
2333 si2168_config
.i2c_adapter
= &adapter
;
2334 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2335 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2336 memset(&info
, 0, sizeof(struct i2c_board_info
));
2337 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2339 info
.platform_data
= &si2168_config
;
2340 request_module("%s", info
.type
);
2341 client_demod
= i2c_new_client_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2342 if (!i2c_client_has_driver(client_demod
))
2343 goto frontend_detach
;
2344 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2345 i2c_unregister_device(client_demod
);
2346 goto frontend_detach
;
2348 port
->i2c_client_demod
= client_demod
;
2351 memset(&si2157_config
, 0, sizeof(si2157_config
));
2352 si2157_config
.fe
= fe0
->dvb
.frontend
;
2353 si2157_config
.if_port
= 1;
2354 memset(&info
, 0, sizeof(struct i2c_board_info
));
2355 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2357 info
.platform_data
= &si2157_config
;
2358 request_module("%s", info
.type
);
2359 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2360 if (!i2c_client_has_driver(client_tuner
)) {
2361 module_put(client_demod
->dev
.driver
->owner
);
2362 i2c_unregister_device(client_demod
);
2363 port
->i2c_client_demod
= NULL
;
2364 goto frontend_detach
;
2366 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2367 i2c_unregister_device(client_tuner
);
2368 module_put(client_demod
->dev
.driver
->owner
);
2369 i2c_unregister_device(client_demod
);
2370 port
->i2c_client_demod
= NULL
;
2371 goto frontend_detach
;
2373 port
->i2c_client_tuner
= client_tuner
;
2375 /* we only attach tuner for analog on the 888 version */
2376 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_QUADHD_DVB
) {
2377 pr_info("%s(): QUADHD_DVB analog setup\n",
2379 dev
->ts1
.analog_fe
.tuner_priv
= client_tuner
;
2380 memcpy(&dev
->ts1
.analog_fe
.ops
.tuner_ops
,
2381 &fe0
->dvb
.frontend
->ops
.tuner_ops
,
2382 sizeof(struct dvb_tuner_ops
));
2386 /* port c - terrestrial/cable */
2388 /* attach frontend */
2389 memset(&si2168_config
, 0, sizeof(si2168_config
));
2390 si2168_config
.i2c_adapter
= &adapter
;
2391 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2392 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2393 memset(&info
, 0, sizeof(struct i2c_board_info
));
2394 strscpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2396 info
.platform_data
= &si2168_config
;
2397 request_module("%s", info
.type
);
2398 client_demod
= i2c_new_client_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2399 if (!i2c_client_has_driver(client_demod
))
2400 goto frontend_detach
;
2401 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2402 i2c_unregister_device(client_demod
);
2403 goto frontend_detach
;
2405 port
->i2c_client_demod
= client_demod
;
2408 memset(&si2157_config
, 0, sizeof(si2157_config
));
2409 si2157_config
.fe
= fe0
->dvb
.frontend
;
2410 si2157_config
.if_port
= 1;
2411 memset(&info
, 0, sizeof(struct i2c_board_info
));
2412 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2414 info
.platform_data
= &si2157_config
;
2415 request_module("%s", info
.type
);
2416 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2417 if (!i2c_client_has_driver(client_tuner
)) {
2418 module_put(client_demod
->dev
.driver
->owner
);
2419 i2c_unregister_device(client_demod
);
2420 port
->i2c_client_demod
= NULL
;
2421 goto frontend_detach
;
2423 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2424 i2c_unregister_device(client_tuner
);
2425 module_put(client_demod
->dev
.driver
->owner
);
2426 i2c_unregister_device(client_demod
);
2427 port
->i2c_client_demod
= NULL
;
2428 goto frontend_detach
;
2430 port
->i2c_client_tuner
= client_tuner
;
2434 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC
:
2435 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885
:
2436 pr_info("%s(): board=%d port=%d\n", __func__
,
2437 dev
->board
, port
->nr
);
2439 /* port b - Terrestrial/cable */
2441 /* attach frontend */
2442 i2c_bus
= &dev
->i2c_bus
[0];
2443 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2444 &hauppauge_quadHD_ATSC_a_config
, &i2c_bus
->i2c_adap
);
2445 if (fe0
->dvb
.frontend
== NULL
)
2449 memset(&si2157_config
, 0, sizeof(si2157_config
));
2450 si2157_config
.fe
= fe0
->dvb
.frontend
;
2451 si2157_config
.if_port
= 1;
2452 si2157_config
.inversion
= 1;
2453 memset(&info
, 0, sizeof(struct i2c_board_info
));
2454 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2456 info
.platform_data
= &si2157_config
;
2457 request_module("%s", info
.type
);
2458 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2459 if (!i2c_client_has_driver(client_tuner
)) {
2460 goto frontend_detach
;
2462 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2463 i2c_unregister_device(client_tuner
);
2464 goto frontend_detach
;
2466 port
->i2c_client_tuner
= client_tuner
;
2468 /* we only attach tuner for analog on the 888 version */
2469 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC
) {
2470 pr_info("%s(): QUADHD_ATSC analog setup\n",
2472 dev
->ts1
.analog_fe
.tuner_priv
= client_tuner
;
2473 memcpy(&dev
->ts1
.analog_fe
.ops
.tuner_ops
,
2474 &fe0
->dvb
.frontend
->ops
.tuner_ops
,
2475 sizeof(struct dvb_tuner_ops
));
2479 /* port c - terrestrial/cable */
2481 /* attach frontend */
2482 i2c_bus
= &dev
->i2c_bus
[0];
2483 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2484 &hauppauge_quadHD_ATSC_b_config
, &i2c_bus
->i2c_adap
);
2485 if (fe0
->dvb
.frontend
== NULL
)
2489 memset(&si2157_config
, 0, sizeof(si2157_config
));
2490 si2157_config
.fe
= fe0
->dvb
.frontend
;
2491 si2157_config
.if_port
= 1;
2492 si2157_config
.inversion
= 1;
2493 memset(&info
, 0, sizeof(struct i2c_board_info
));
2494 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2496 info
.platform_data
= &si2157_config
;
2497 request_module("%s", info
.type
);
2498 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2499 if (!i2c_client_has_driver(client_tuner
)) {
2500 goto frontend_detach
;
2502 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2503 i2c_unregister_device(client_tuner
);
2504 goto frontend_detach
;
2506 port
->i2c_client_tuner
= client_tuner
;
2510 case CX23885_BOARD_HAUPPAUGE_HVR1265_K4
:
2512 /* port c - Terrestrial/cable */
2514 /* attach frontend */
2515 i2c_bus
= &dev
->i2c_bus
[0];
2516 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2517 &hauppauge_hvr1265k4_config
,
2518 &i2c_bus
->i2c_adap
);
2519 if (fe0
->dvb
.frontend
== NULL
)
2523 memset(&si2157_config
, 0, sizeof(si2157_config
));
2524 si2157_config
.fe
= fe0
->dvb
.frontend
;
2525 si2157_config
.if_port
= 1;
2526 si2157_config
.inversion
= 1;
2527 memset(&info
, 0, sizeof(struct i2c_board_info
));
2528 strscpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2530 info
.platform_data
= &si2157_config
;
2531 request_module("%s", info
.type
);
2532 client_tuner
= i2c_new_client_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2533 if (!i2c_client_has_driver(client_tuner
))
2534 goto frontend_detach
;
2536 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2537 i2c_unregister_device(client_tuner
);
2538 client_tuner
= NULL
;
2539 goto frontend_detach
;
2541 port
->i2c_client_tuner
= client_tuner
;
2543 dev
->ts1
.analog_fe
.tuner_priv
= client_tuner
;
2544 memcpy(&dev
->ts1
.analog_fe
.ops
.tuner_ops
,
2545 &fe0
->dvb
.frontend
->ops
.tuner_ops
,
2546 sizeof(struct dvb_tuner_ops
));
2551 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2556 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
2557 pr_err("%s: frontend initialization failed\n",
2559 goto frontend_detach
;
2562 /* define general-purpose callback pointer */
2563 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2565 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2567 /* Ensure all frontends negotiate bus access */
2568 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2570 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2573 /* Put the tuner in standby to keep it quiet */
2574 call_all(dev
, tuner
, standby
);
2576 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
2577 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
2579 /* register everything */
2580 ret
= vb2_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
2581 &dev
->pci
->dev
, NULL
,
2582 adapter_nr
, mfe_shared
);
2584 goto frontend_detach
;
2586 ret
= dvb_register_ci_mac(port
);
2588 goto frontend_detach
;
2593 /* remove I2C client for SEC */
2594 client_sec
= port
->i2c_client_sec
;
2596 module_put(client_sec
->dev
.driver
->owner
);
2597 i2c_unregister_device(client_sec
);
2598 port
->i2c_client_sec
= NULL
;
2601 /* remove I2C client for tuner */
2602 client_tuner
= port
->i2c_client_tuner
;
2604 module_put(client_tuner
->dev
.driver
->owner
);
2605 i2c_unregister_device(client_tuner
);
2606 port
->i2c_client_tuner
= NULL
;
2609 /* remove I2C client for demodulator */
2610 client_demod
= port
->i2c_client_demod
;
2612 module_put(client_demod
->dev
.driver
->owner
);
2613 i2c_unregister_device(client_demod
);
2614 port
->i2c_client_demod
= NULL
;
2617 port
->gate_ctrl
= NULL
;
2618 vb2_dvb_dealloc_frontends(&port
->frontends
);
2622 int cx23885_dvb_register(struct cx23885_tsport
*port
)
2625 struct vb2_dvb_frontend
*fe0
;
2626 struct cx23885_dev
*dev
= port
->dev
;
2629 /* Here we need to allocate the correct number of frontends,
2630 * as reflected in the cards struct. The reality is that currently
2631 * no cx23885 boards support this - yet. But, if we don't modify this
2632 * code then the second frontend would never be allocated (later)
2633 * and fail with error before the attach in dvb_register().
2634 * Without these changes we risk an OOPS later. The changes here
2635 * are for safety, and should provide a good foundation for the
2636 * future addition of any multi-frontend cx23885 based boards.
2638 pr_info("%s() allocating %d frontend(s)\n", __func__
,
2639 port
->num_frontends
);
2641 for (i
= 1; i
<= port
->num_frontends
; i
++) {
2642 struct vb2_queue
*q
;
2644 if (vb2_dvb_alloc_frontend(
2645 &port
->frontends
, i
) == NULL
) {
2646 pr_err("%s() failed to alloc\n", __func__
);
2650 fe0
= vb2_dvb_get_frontend(&port
->frontends
, i
);
2654 dprintk(1, "%s\n", __func__
);
2655 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2662 /* We have to init the queue for each frontend on a port. */
2663 pr_info("%s: cx23885 based dvb card\n", dev
->name
);
2665 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
2666 q
->io_modes
= VB2_MMAP
| VB2_USERPTR
| VB2_DMABUF
| VB2_READ
;
2667 q
->gfp_flags
= GFP_DMA32
;
2668 q
->min_queued_buffers
= 2;
2670 q
->buf_struct_size
= sizeof(struct cx23885_buffer
);
2672 q
->mem_ops
= &vb2_dma_sg_memops
;
2673 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
2674 q
->lock
= &dev
->lock
;
2675 q
->dev
= &dev
->pci
->dev
;
2677 err
= vb2_queue_init(q
);
2681 err
= dvb_register(port
);
2683 pr_err("%s() dvb_register failed err = %d\n",
2689 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
2691 struct vb2_dvb_frontend
*fe0
;
2692 struct i2c_client
*client
;
2694 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
2696 if (fe0
&& fe0
->dvb
.frontend
)
2697 vb2_dvb_unregister_bus(&port
->frontends
);
2699 /* remove I2C client for CI */
2700 client
= port
->i2c_client_ci
;
2702 module_put(client
->dev
.driver
->owner
);
2703 i2c_unregister_device(client
);
2706 /* remove I2C client for SEC */
2707 client
= port
->i2c_client_sec
;
2709 module_put(client
->dev
.driver
->owner
);
2710 i2c_unregister_device(client
);
2713 /* remove I2C client for tuner */
2714 client
= port
->i2c_client_tuner
;
2716 module_put(client
->dev
.driver
->owner
);
2717 i2c_unregister_device(client
);
2720 /* remove I2C client for demodulator */
2721 client
= port
->i2c_client_demod
;
2723 module_put(client
->dev
.driver
->owner
);
2724 i2c_unregister_device(client
);
2727 switch (port
->dev
->board
) {
2728 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
2729 netup_ci_exit(port
);
2731 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
2732 altera_ci_release(port
->dev
, port
->nr
);
2736 port
->gate_ctrl
= NULL
;