2 * Driver for the Conexant CX23885 PCIe bridge
4 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/device.h>
24 #include <linux/kthread.h>
25 #include <linux/file.h>
26 #include <linux/suspend.h>
28 #include <media/v4l2-common.h>
30 #include "dvb_ca_en50221.h"
41 #include "tuner-xc2028.h"
42 #include "tuner-simple.h"
45 #include "dibx000_common.h"
48 #include "stv0900_reg.h"
55 #include "netup-eeprom.h"
56 #include "netup-init.h"
61 #include "cx23885-f300.h"
62 #include "altera-ci.h"
68 #include "stb6100_cfg.h"
76 #include "m88ds3103.h"
77 #include "m88rs6000t.h"
78 #include "lgdt3306a.h"
80 static unsigned int debug
;
82 #define dprintk(level, fmt, arg...)\
83 do { if (debug >= level)\
84 printk(KERN_DEBUG pr_fmt("%s dvb: " fmt), \
88 /* ------------------------------------------------------------------ */
90 static unsigned int alt_tuner
;
91 module_param(alt_tuner
, int, 0644);
92 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
94 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
96 /* ------------------------------------------------------------------ */
98 static int queue_setup(struct vb2_queue
*q
,
99 unsigned int *num_buffers
, unsigned int *num_planes
,
100 unsigned int sizes
[], struct device
*alloc_devs
[])
102 struct cx23885_tsport
*port
= q
->drv_priv
;
104 port
->ts_packet_size
= 188 * 4;
105 port
->ts_packet_count
= 32;
107 sizes
[0] = port
->ts_packet_size
* port
->ts_packet_count
;
113 static int buffer_prepare(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_buffer
*buf
=
118 container_of(vbuf
, struct cx23885_buffer
, vb
);
120 return cx23885_buf_prepare(buf
, port
);
123 static void buffer_finish(struct vb2_buffer
*vb
)
125 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
126 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
127 struct cx23885_dev
*dev
= port
->dev
;
128 struct cx23885_buffer
*buf
= container_of(vbuf
,
129 struct cx23885_buffer
, vb
);
131 cx23885_free_buffer(dev
, buf
);
134 static void buffer_queue(struct vb2_buffer
*vb
)
136 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
137 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
138 struct cx23885_buffer
*buf
= container_of(vbuf
,
139 struct cx23885_buffer
, vb
);
141 cx23885_buf_queue(port
, buf
);
144 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport
*port
, int open
)
146 struct vb2_dvb_frontends
*f
;
147 struct vb2_dvb_frontend
*fe
;
149 f
= &port
->frontends
;
151 if (f
->gate
<= 1) /* undefined or fe0 */
152 fe
= vb2_dvb_get_frontend(f
, 1);
154 fe
= vb2_dvb_get_frontend(f
, f
->gate
);
156 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
157 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
160 static int cx23885_start_streaming(struct vb2_queue
*q
, unsigned int count
)
162 struct cx23885_tsport
*port
= q
->drv_priv
;
163 struct cx23885_dmaqueue
*dmaq
= &port
->mpegq
;
164 struct cx23885_buffer
*buf
= list_entry(dmaq
->active
.next
,
165 struct cx23885_buffer
, queue
);
167 cx23885_start_dma(port
, dmaq
, buf
);
171 static void cx23885_stop_streaming(struct vb2_queue
*q
)
173 struct cx23885_tsport
*port
= q
->drv_priv
;
175 cx23885_cancel_buffers(port
);
178 static const struct vb2_ops dvb_qops
= {
179 .queue_setup
= queue_setup
,
180 .buf_prepare
= buffer_prepare
,
181 .buf_finish
= buffer_finish
,
182 .buf_queue
= buffer_queue
,
183 .wait_prepare
= vb2_ops_wait_prepare
,
184 .wait_finish
= vb2_ops_wait_finish
,
185 .start_streaming
= cx23885_start_streaming
,
186 .stop_streaming
= cx23885_stop_streaming
,
189 static struct s5h1409_config hauppauge_generic_config
= {
190 .demod_address
= 0x32 >> 1,
191 .output_mode
= S5H1409_SERIAL_OUTPUT
,
192 .gpio
= S5H1409_GPIO_ON
,
194 .inversion
= S5H1409_INVERSION_OFF
,
195 .status_mode
= S5H1409_DEMODLOCKING
,
196 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
199 static struct tda10048_config hauppauge_hvr1200_config
= {
200 .demod_address
= 0x10 >> 1,
201 .output_mode
= TDA10048_SERIAL_OUTPUT
,
202 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
203 .inversion
= TDA10048_INVERSION_ON
,
204 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
205 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
206 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
207 .clk_freq_khz
= TDA10048_CLK_16000
,
210 static struct tda10048_config hauppauge_hvr1210_config
= {
211 .demod_address
= 0x10 >> 1,
212 .output_mode
= TDA10048_SERIAL_OUTPUT
,
213 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
214 .inversion
= TDA10048_INVERSION_ON
,
215 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
216 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
217 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
218 .clk_freq_khz
= TDA10048_CLK_16000
,
221 static struct s5h1409_config hauppauge_ezqam_config
= {
222 .demod_address
= 0x32 >> 1,
223 .output_mode
= S5H1409_SERIAL_OUTPUT
,
224 .gpio
= S5H1409_GPIO_OFF
,
226 .inversion
= S5H1409_INVERSION_ON
,
227 .status_mode
= S5H1409_DEMODLOCKING
,
228 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
231 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
232 .demod_address
= 0x32 >> 1,
233 .output_mode
= S5H1409_SERIAL_OUTPUT
,
234 .gpio
= S5H1409_GPIO_OFF
,
236 .inversion
= S5H1409_INVERSION_OFF
,
237 .status_mode
= S5H1409_DEMODLOCKING
,
238 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
241 static struct s5h1409_config hauppauge_hvr1500_config
= {
242 .demod_address
= 0x32 >> 1,
243 .output_mode
= S5H1409_SERIAL_OUTPUT
,
244 .gpio
= S5H1409_GPIO_OFF
,
245 .inversion
= S5H1409_INVERSION_OFF
,
246 .status_mode
= S5H1409_DEMODLOCKING
,
247 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
250 static struct mt2131_config hauppauge_generic_tunerconfig
= {
254 static struct lgdt330x_config fusionhdtv_5_express
= {
255 .demod_address
= 0x0e,
256 .demod_chip
= LGDT3303
,
260 static struct s5h1409_config hauppauge_hvr1500q_config
= {
261 .demod_address
= 0x32 >> 1,
262 .output_mode
= S5H1409_SERIAL_OUTPUT
,
263 .gpio
= S5H1409_GPIO_ON
,
265 .inversion
= S5H1409_INVERSION_OFF
,
266 .status_mode
= S5H1409_DEMODLOCKING
,
267 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
270 static struct s5h1409_config dvico_s5h1409_config
= {
271 .demod_address
= 0x32 >> 1,
272 .output_mode
= S5H1409_SERIAL_OUTPUT
,
273 .gpio
= S5H1409_GPIO_ON
,
275 .inversion
= S5H1409_INVERSION_OFF
,
276 .status_mode
= S5H1409_DEMODLOCKING
,
277 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
280 static struct s5h1411_config dvico_s5h1411_config
= {
281 .output_mode
= S5H1411_SERIAL_OUTPUT
,
282 .gpio
= S5H1411_GPIO_ON
,
283 .qam_if
= S5H1411_IF_44000
,
284 .vsb_if
= S5H1411_IF_44000
,
285 .inversion
= S5H1411_INVERSION_OFF
,
286 .status_mode
= S5H1411_DEMODLOCKING
,
287 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
290 static struct s5h1411_config hcw_s5h1411_config
= {
291 .output_mode
= S5H1411_SERIAL_OUTPUT
,
292 .gpio
= S5H1411_GPIO_OFF
,
293 .vsb_if
= S5H1411_IF_44000
,
294 .qam_if
= S5H1411_IF_4000
,
295 .inversion
= S5H1411_INVERSION_ON
,
296 .status_mode
= S5H1411_DEMODLOCKING
,
297 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
300 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
305 static struct xc5000_config dvico_xc5000_tunerconfig
= {
310 static struct tda829x_config tda829x_no_probe
= {
311 .probe_tuner
= TDA829X_DONT_PROBE
,
314 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
315 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
316 .if_lvl
= 6, .rfagc_top
= 0x37 },
317 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
318 .if_lvl
= 6, .rfagc_top
= 0x37 },
321 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
322 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
323 .if_lvl
= 1, .rfagc_top
= 0x37, },
324 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
325 .if_lvl
= 1, .rfagc_top
= 0x37, },
326 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
327 .if_lvl
= 1, .rfagc_top
= 0x37, },
330 static struct tda18271_config hauppauge_tda18271_config
= {
331 .std_map
= &hauppauge_tda18271_std_map
,
332 .gate
= TDA18271_GATE_ANALOG
,
333 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
336 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
337 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
338 .gate
= TDA18271_GATE_ANALOG
,
339 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
342 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
343 .gate
= TDA18271_GATE_DIGITAL
,
344 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
347 static struct tda18271_config hauppauge_hvr4400_tuner_config
= {
348 .gate
= TDA18271_GATE_DIGITAL
,
349 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
352 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
353 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
354 .if_lvl
= 1, .rfagc_top
= 0x58 },
355 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
356 .if_lvl
= 1, .rfagc_top
= 0x58 },
359 static struct tda18271_config hauppauge_hvr127x_config
= {
360 .std_map
= &hauppauge_hvr127x_std_map
,
361 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
364 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
366 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
367 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
368 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
370 .spectral_inversion
= 1,
375 static struct dibx000_agc_config xc3028_agc_config
= {
376 BAND_VHF
| BAND_UHF
, /* band_caps */
378 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
379 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
380 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
381 * P_agc_nb_est=2, P_agc_write=0
383 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
384 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
387 21, /* time_stabiliz */
399 39718, /* agc2_max */
408 29, /* agc2_slope1 */
409 29, /* agc2_slope2 */
416 1, /* perform_agc_softsplit */
419 /* PLL Configuration for COFDM BW_MHz = 8.000000
420 * With external clock = 30.000000 */
421 static struct dibx000_bandwidth_config xc3028_bw_config
= {
422 60000, /* internal */
423 30000, /* sampling */
424 1, /* pll_cfg: prediv */
425 8, /* pll_cfg: ratio */
426 3, /* pll_cfg: range */
427 1, /* pll_cfg: reset */
428 0, /* pll_cfg: bypass */
429 0, /* misc: refdiv */
430 0, /* misc: bypclk_div */
431 1, /* misc: IO_CLK_en_core */
432 1, /* misc: ADClkSrc */
433 0, /* misc: modulo */
434 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
435 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
437 30000000 /* xtal_hz */
440 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
441 .output_mpeg2_in_188_bytes
= 1,
442 .hostbus_diversity
= 1,
443 .tuner_is_baseband
= 0,
446 .agc_config_count
= 1,
447 .agc
= &xc3028_agc_config
,
448 .bw
= &xc3028_bw_config
,
450 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
451 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
452 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
458 .output_mode
= OUTMODE_MPEG2_SERIAL
,
461 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
462 .demod_address
= 0x0f,
465 .disable_i2c_gate_ctrl
= 1,
468 static struct stv0900_reg stv0900_ts_regs
[] = {
469 { R0900_TSGENERAL
, 0x00 },
470 { R0900_P1_TSSPEED
, 0x40 },
471 { R0900_P2_TSSPEED
, 0x40 },
472 { R0900_P1_TSCFGM
, 0xc0 },
473 { R0900_P2_TSCFGM
, 0xc0 },
474 { R0900_P1_TSCFGH
, 0xe0 },
475 { R0900_P2_TSCFGH
, 0xe0 },
476 { R0900_P1_TSCFGL
, 0x20 },
477 { R0900_P2_TSCFGL
, 0x20 },
478 { 0xffff, 0xff }, /* terminate */
481 static struct stv0900_config netup_stv0900_config
= {
482 .demod_address
= 0x68,
483 .demod_mode
= 1, /* dual */
485 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
486 .diseqc_mode
= 2,/* 2/3 PWM */
487 .ts_config_regs
= stv0900_ts_regs
,
488 .tun1_maddress
= 0,/* 0x60 */
489 .tun2_maddress
= 3,/* 0x63 */
490 .tun1_adc
= 1,/* 1 Vpp */
491 .tun2_adc
= 1,/* 1 Vpp */
494 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
498 .gain
= 8, /* +16 dB - maximum gain */
501 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
505 .gain
= 8, /* +16 dB - maximum gain */
508 static struct cx24116_config tbs_cx24116_config
= {
509 .demod_address
= 0x55,
512 static struct cx24117_config tbs_cx24117_config
= {
513 .demod_address
= 0x55,
516 static struct ds3000_config tevii_ds3000_config
= {
517 .demod_address
= 0x68,
520 static struct ts2020_config tevii_ts2020_config
= {
521 .tuner_address
= 0x60,
523 .frequency_div
= 1146000,
526 static struct cx24116_config dvbworld_cx24116_config
= {
527 .demod_address
= 0x05,
530 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
531 .prod
= LGS8GXX_PROD_LGS8GL5
,
532 .demod_address
= 0x19,
536 .if_clk_freq
= 30400, /* 30.4 MHz */
537 .if_freq
= 5380, /* 5.38 MHz */
544 static struct xc5000_config mygica_x8506_xc5000_config
= {
549 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
550 .demod_address
= 0x10,
553 static struct xc5000_config mygica_x8507_xc5000_config
= {
558 static struct stv090x_config prof_8000_stv090x_config
= {
560 .demod_mode
= STV090x_SINGLE
,
561 .clk_mode
= STV090x_CLK_EXT
,
564 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
565 .repeater_level
= STV090x_RPTLEVEL_64
,
566 .adc1_range
= STV090x_ADC_2Vpp
,
567 .diseqc_envelope_mode
= false,
569 .tuner_get_frequency
= stb6100_get_frequency
,
570 .tuner_set_frequency
= stb6100_set_frequency
,
571 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
572 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
575 static struct stb6100_config prof_8000_stb6100_config
= {
576 .tuner_address
= 0x60,
577 .refclock
= 27000000,
580 static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config
= {
584 .deny_i2c_rptr
= 1, /* Disabled */
585 .spectral_inversion
= 0, /* Disabled */
586 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
587 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
588 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
589 .xtalMHz
= 25, /* 24 or 25 */
592 static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config
= {
596 .deny_i2c_rptr
= 1, /* Disabled */
597 .spectral_inversion
= 0, /* Disabled */
598 .mpeg_mode
= LGDT3306A_MPEG_SERIAL
,
599 .tpclk_edge
= LGDT3306A_TPCLK_RISING_EDGE
,
600 .tpvalid_polarity
= LGDT3306A_TP_VALID_HIGH
,
601 .xtalMHz
= 25, /* 24 or 25 */
604 static int p8000_set_voltage(struct dvb_frontend
*fe
,
605 enum fe_sec_voltage voltage
)
607 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
608 struct cx23885_dev
*dev
= port
->dev
;
610 if (voltage
== SEC_VOLTAGE_18
)
611 cx_write(MC417_RWD
, 0x00001e00);
612 else if (voltage
== SEC_VOLTAGE_13
)
613 cx_write(MC417_RWD
, 0x00001a00);
615 cx_write(MC417_RWD
, 0x00001800);
619 static int dvbsky_t9580_set_voltage(struct dvb_frontend
*fe
,
620 enum fe_sec_voltage voltage
)
622 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
623 struct cx23885_dev
*dev
= port
->dev
;
625 cx23885_gpio_enable(dev
, GPIO_0
| GPIO_1
, 1);
629 cx23885_gpio_set(dev
, GPIO_1
);
630 cx23885_gpio_clear(dev
, GPIO_0
);
633 cx23885_gpio_set(dev
, GPIO_1
);
634 cx23885_gpio_set(dev
, GPIO_0
);
636 case SEC_VOLTAGE_OFF
:
637 cx23885_gpio_clear(dev
, GPIO_1
);
638 cx23885_gpio_clear(dev
, GPIO_0
);
642 /* call the frontend set_voltage function */
643 port
->fe_set_voltage(fe
, voltage
);
648 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend
*fe
,
649 enum fe_sec_voltage voltage
)
651 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
652 struct cx23885_dev
*dev
= port
->dev
;
654 cx23885_gpio_enable(dev
, GPIO_12
| GPIO_13
, 1);
658 cx23885_gpio_set(dev
, GPIO_13
);
659 cx23885_gpio_clear(dev
, GPIO_12
);
662 cx23885_gpio_set(dev
, GPIO_13
);
663 cx23885_gpio_set(dev
, GPIO_12
);
665 case SEC_VOLTAGE_OFF
:
666 cx23885_gpio_clear(dev
, GPIO_13
);
667 cx23885_gpio_clear(dev
, GPIO_12
);
670 /* call the frontend set_voltage function */
671 return port
->fe_set_voltage(fe
, voltage
);
674 static int cx23885_sp2_ci_ctrl(void *priv
, u8 read
, int addr
,
678 #define SP2_DATA 0x000000ff
679 #define SP2_WR 0x00008000
680 #define SP2_RD 0x00004000
681 #define SP2_ACK 0x00001000
682 #define SP2_ADHI 0x00000800
683 #define SP2_ADLO 0x00000400
684 #define SP2_CS1 0x00000200
685 #define SP2_CS0 0x00000100
686 #define SP2_EN_ALL 0x00001000
687 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
689 struct cx23885_tsport
*port
= priv
;
690 struct cx23885_dev
*dev
= port
->dev
;
693 unsigned long timeout
;
695 mutex_lock(&dev
->gpio_lock
);
698 cx_write(MC417_OEN
, SP2_EN_ALL
);
699 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
700 SP2_ADLO
| (0xff & addr
));
701 cx_clear(MC417_RWD
, SP2_ADLO
);
702 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
703 SP2_ADHI
| (0xff & (addr
>> 8)));
704 cx_clear(MC417_RWD
, SP2_ADHI
);
708 cx_write(MC417_OEN
, SP2_EN_ALL
| SP2_DATA
);
711 cx_write(MC417_RWD
, SP2_CTRL_OFF
| data
);
714 cx_clear(MC417_RWD
, SP2_CS0
);
717 cx_clear(MC417_RWD
, (read
) ? SP2_RD
: SP2_WR
);
719 /* wait for a maximum of 1 msec */
720 timeout
= jiffies
+ msecs_to_jiffies(1);
721 while (!time_after(jiffies
, timeout
)) {
722 tmp
= cx_read(MC417_RWD
);
723 if ((tmp
& SP2_ACK
) == 0)
725 usleep_range(50, 100);
728 cx_set(MC417_RWD
, SP2_CTRL_OFF
);
731 mutex_unlock(&dev
->gpio_lock
);
745 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
747 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
748 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
749 struct cx23885_dev
*dev
= port
->dev
;
751 switch (dev
->board
) {
752 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
753 switch (p
->modulation
) {
755 cx23885_gpio_clear(dev
, GPIO_5
);
760 cx23885_gpio_set(dev
, GPIO_5
);
764 case CX23885_BOARD_MYGICA_X8506
:
765 case CX23885_BOARD_MYGICA_X8507
:
766 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
767 /* Select Digital TV */
768 cx23885_gpio_set(dev
, GPIO_0
);
772 /* Call the real set_frontend */
773 if (port
->set_frontend
)
774 return port
->set_frontend(fe
);
779 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
780 struct dvb_frontend
*fe
)
782 port
->set_frontend
= fe
->ops
.set_frontend
;
783 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
786 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
787 .prod
= LGS8GXX_PROD_LGS8G75
,
788 .demod_address
= 0x19,
792 .if_clk_freq
= 30400, /* 30.4 MHz */
793 .if_freq
= 6500, /* 6.50 MHz */
797 .adc_vpp
= 2, /* 1.6 Vpp */
801 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
806 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
807 .prod
= ATBM8830_PROD_8830
,
808 .demod_address
= 0x44,
810 .ts_sampling_edge
= 1,
812 .osc_clk_freq
= 30400, /* in kHz */
813 .if_freq
= 0, /* zero IF */
820 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
825 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
826 .prod
= ATBM8830_PROD_8830
,
827 .demod_address
= 0x44,
829 .ts_sampling_edge
= 1,
831 .osc_clk_freq
= 30400, /* in kHz */
832 .if_freq
= 0, /* zero IF */
839 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
843 static struct stv0367_config netup_stv0367_config
[] = {
845 .demod_address
= 0x1c,
852 .demod_address
= 0x1d,
861 static struct xc5000_config netup_xc5000_config
[] = {
871 static struct drxk_config terratec_drxk_config
[] = {
881 static struct mt2063_config terratec_mt2063_config
[] = {
883 .tuner_address
= 0x60,
885 .tuner_address
= 0x67,
889 static const struct tda10071_platform_data hauppauge_tda10071_pdata
= {
890 .clk
= 40444000, /* 40.444 MHz */
892 .ts_mode
= TDA10071_TS_SERIAL
,
893 .pll_multiplier
= 20,
894 .tuner_i2c_addr
= 0x54,
897 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config
= {
902 .ts_mode
= M88DS3103_TS_PARALLEL
,
910 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config
= {
915 .ts_mode
= M88DS3103_TS_CI
,
923 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config
= {
928 .ts_mode
= M88DS3103_TS_SERIAL
,
936 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config
= {
940 .ts_mode
= M88DS3103_TS_PARALLEL
,
946 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
948 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
949 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
952 mem
= cx_read(MC417_RWD
);
954 cx_set(MC417_OEN
, ALT_DATA
);
956 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
958 mem
|= (data
& ALT_DATA
);
968 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
970 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
972 cx_write(MC417_RWD
, mem
); /* start RW cycle */
975 mem
= cx_read(MC417_RWD
);
976 if ((mem
& ALT_RDY
) == 0)
978 if (time_after(jiffies
, timeout
))
983 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
985 return mem
& ALT_DATA
;
990 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
992 struct dib7000p_ops
*dib7000p_ops
= fe
->sec_priv
;
994 return dib7000p_ops
->set_gpio(fe
, 8, 0, !onoff
);
997 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
1002 static struct dib0070_config dib7070p_dib0070_config
= {
1003 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
1004 .reset
= dib7070_tuner_reset
,
1005 .sleep
= dib7070_tuner_sleep
,
1007 .freq_offset_khz_vhf
= 550,
1008 /* .flip_chip = 1, */
1011 /* DIB7070 generic */
1012 static struct dibx000_agc_config dib7070_agc_config
= {
1013 .band_caps
= BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
1016 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1017 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1018 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1020 .setup
= (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1021 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1023 .time_stabiliz
= 10,
1047 .perform_agc_softsplit
= 0,
1050 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
1060 .IO_CLK_en_core
= 1,
1063 /* refsel, sel, freq_15k */
1064 .sad_cfg
= (3 << 14) | (1 << 12) | (524 << 0),
1065 .ifreq
= (0 << 25) | 0,
1067 .xtal_hz
= 12000000,
1070 static struct dib7000p_config dib7070p_dib7000p_config
= {
1071 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1072 .output_mode
= OUTMODE_MPEG2_SERIAL
,
1073 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1074 .output_mpeg2_in_188_bytes
= 1,
1076 .agc_config_count
= 1,
1077 .agc
= &dib7070_agc_config
,
1078 .bw
= &dib7070_bw_config_12_mhz
,
1079 .tuner_is_baseband
= 1,
1082 .gpio_dir
= 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1083 .gpio_val
= 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1084 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1086 .hostbus_diversity
= 1,
1089 static int dvb_register_ci_mac(struct cx23885_tsport
*port
)
1091 struct cx23885_dev
*dev
= port
->dev
;
1092 struct i2c_client
*client_ci
= NULL
;
1093 struct vb2_dvb_frontend
*fe0
;
1095 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1099 switch (dev
->board
) {
1100 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
1101 static struct netup_card_info cinfo
;
1103 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
1104 memcpy(port
->frontends
.adapter
.proposed_mac
,
1105 cinfo
.port
[port
->nr
- 1].mac
, 6);
1106 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1107 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
1109 netup_ci_init(port
);
1112 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
1113 struct altera_ci_config netup_ci_cfg
= {
1114 .dev
= dev
,/* magic number to identify*/
1115 .adapter
= &port
->frontends
.adapter
,/* for CI */
1116 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
1117 .fpga_rw
= netup_altera_fpga_rw
,
1120 altera_ci_init(&netup_ci_cfg
, port
->nr
);
1123 case CX23885_BOARD_TEVII_S470
: {
1124 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1129 /* Read entire EEPROM */
1130 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1131 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
1132 pr_info("TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
1133 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
1136 case CX23885_BOARD_DVBSKY_T9580
:
1137 case CX23885_BOARD_DVBSKY_S950
:
1138 case CX23885_BOARD_DVBSKY_S952
:
1139 case CX23885_BOARD_DVBSKY_T982
: {
1140 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1145 /* Read entire EEPROM */
1146 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1147 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1149 pr_info("%s port %d MAC address: %pM\n",
1150 cx23885_boards
[dev
->board
].name
, port
->nr
,
1151 eeprom
+ 0xc0 + (port
->nr
-1) * 8);
1152 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0 +
1153 (port
->nr
-1) * 8, 6);
1156 case CX23885_BOARD_DVBSKY_S950C
:
1157 case CX23885_BOARD_DVBSKY_T980C
:
1158 case CX23885_BOARD_TT_CT2_4500_CI
: {
1159 u8 eeprom
[256]; /* 24C02 i2c eeprom */
1160 struct sp2_config sp2_config
;
1161 struct i2c_board_info info
;
1162 struct cx23885_i2c
*i2c_bus
= &dev
->i2c_bus
[0];
1165 memset(&sp2_config
, 0, sizeof(sp2_config
));
1166 sp2_config
.dvb_adap
= &port
->frontends
.adapter
;
1167 sp2_config
.priv
= port
;
1168 sp2_config
.ci_control
= cx23885_sp2_ci_ctrl
;
1169 memset(&info
, 0, sizeof(struct i2c_board_info
));
1170 strlcpy(info
.type
, "sp2", I2C_NAME_SIZE
);
1172 info
.platform_data
= &sp2_config
;
1173 request_module(info
.type
);
1174 client_ci
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1175 if (client_ci
== NULL
|| client_ci
->dev
.driver
== NULL
)
1177 if (!try_module_get(client_ci
->dev
.driver
->owner
)) {
1178 i2c_unregister_device(client_ci
);
1181 port
->i2c_client_ci
= client_ci
;
1186 /* Read entire EEPROM */
1187 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
1188 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
1190 pr_info("%s MAC address: %pM\n",
1191 cx23885_boards
[dev
->board
].name
, eeprom
+ 0xc0);
1192 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0, 6);
1199 static int dvb_register(struct cx23885_tsport
*port
)
1201 struct dib7000p_ops dib7000p_ops
;
1202 struct cx23885_dev
*dev
= port
->dev
;
1203 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
1204 struct vb2_dvb_frontend
*fe0
, *fe1
= NULL
;
1205 struct si2168_config si2168_config
;
1206 struct si2165_platform_data si2165_pdata
;
1207 struct si2157_config si2157_config
;
1208 struct ts2020_config ts2020_config
;
1209 struct i2c_board_info info
;
1210 struct i2c_adapter
*adapter
;
1211 struct i2c_client
*client_demod
= NULL
, *client_tuner
= NULL
;
1212 struct i2c_client
*client_sec
= NULL
;
1213 const struct m88ds3103_config
*p_m88ds3103_config
= NULL
;
1214 int (*p_set_voltage
)(struct dvb_frontend
*fe
,
1215 enum fe_sec_voltage voltage
) = NULL
;
1216 int mfe_shared
= 0; /* bus not shared by default */
1219 /* Get the first frontend */
1220 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1224 /* init struct vb2_dvb */
1225 fe0
->dvb
.name
= dev
->name
;
1227 /* multi-frontend gate control is undefined or defaults to fe0 */
1228 port
->frontends
.gate
= 0;
1230 /* Sets the gate control callback to be used by i2c command calls */
1231 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
1234 switch (dev
->board
) {
1235 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
1236 i2c_bus
= &dev
->i2c_bus
[0];
1237 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1238 &hauppauge_generic_config
,
1239 &i2c_bus
->i2c_adap
);
1240 if (fe0
->dvb
.frontend
== NULL
)
1242 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1244 &hauppauge_generic_tunerconfig
, 0);
1246 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
1247 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
1248 i2c_bus
= &dev
->i2c_bus
[0];
1249 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1250 &hauppauge_lgdt3305_config
,
1251 &i2c_bus
->i2c_adap
);
1252 if (fe0
->dvb
.frontend
== NULL
)
1254 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1255 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1256 &hauppauge_hvr127x_config
);
1257 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
1258 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1260 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
1261 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
1262 i2c_bus
= &dev
->i2c_bus
[0];
1263 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1264 &hcw_s5h1411_config
,
1265 &i2c_bus
->i2c_adap
);
1266 if (fe0
->dvb
.frontend
== NULL
)
1269 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1270 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1271 &hauppauge_tda18271_config
);
1273 tda18271_attach(&dev
->ts1
.analog_fe
,
1274 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1275 &hauppauge_tda18271_config
);
1278 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
1279 i2c_bus
= &dev
->i2c_bus
[0];
1280 switch (alt_tuner
) {
1283 dvb_attach(s5h1409_attach
,
1284 &hauppauge_ezqam_config
,
1285 &i2c_bus
->i2c_adap
);
1286 if (fe0
->dvb
.frontend
== NULL
)
1289 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1290 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1292 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1293 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1294 &hauppauge_tda18271_config
);
1299 dvb_attach(s5h1409_attach
,
1300 &hauppauge_generic_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);
1309 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
1310 i2c_bus
= &dev
->i2c_bus
[0];
1311 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1312 &hauppauge_hvr1800lp_config
,
1313 &i2c_bus
->i2c_adap
);
1314 if (fe0
->dvb
.frontend
== NULL
)
1316 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1318 &hauppauge_generic_tunerconfig
, 0);
1320 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
1321 i2c_bus
= &dev
->i2c_bus
[0];
1322 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1323 &fusionhdtv_5_express
,
1324 &i2c_bus
->i2c_adap
);
1325 if (fe0
->dvb
.frontend
== NULL
)
1327 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1328 &i2c_bus
->i2c_adap
, 0x61,
1329 TUNER_LG_TDVS_H06XF
);
1331 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
1332 i2c_bus
= &dev
->i2c_bus
[1];
1333 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1334 &hauppauge_hvr1500q_config
,
1335 &dev
->i2c_bus
[0].i2c_adap
);
1336 if (fe0
->dvb
.frontend
== NULL
)
1338 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1340 &hauppauge_hvr1500q_tunerconfig
);
1342 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
1343 i2c_bus
= &dev
->i2c_bus
[1];
1344 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1345 &hauppauge_hvr1500_config
,
1346 &dev
->i2c_bus
[0].i2c_adap
);
1347 if (fe0
->dvb
.frontend
!= NULL
) {
1348 struct dvb_frontend
*fe
;
1349 struct xc2028_config cfg
= {
1350 .i2c_adap
= &i2c_bus
->i2c_adap
,
1353 static struct xc2028_ctrl ctl
= {
1354 .fname
= XC2028_DEFAULT_FIRMWARE
,
1356 .demod
= XC3028_FE_OREN538
,
1359 fe
= dvb_attach(xc2028_attach
,
1360 fe0
->dvb
.frontend
, &cfg
);
1361 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1362 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1365 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
1366 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
1367 i2c_bus
= &dev
->i2c_bus
[0];
1368 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1369 &hauppauge_hvr1200_config
,
1370 &i2c_bus
->i2c_adap
);
1371 if (fe0
->dvb
.frontend
== NULL
)
1373 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1374 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1376 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1377 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1378 &hauppauge_hvr1200_tuner_config
);
1380 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
1381 i2c_bus
= &dev
->i2c_bus
[0];
1382 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1383 &hauppauge_hvr1210_config
,
1384 &i2c_bus
->i2c_adap
);
1385 if (fe0
->dvb
.frontend
!= NULL
) {
1386 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1387 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1388 &hauppauge_hvr1210_tuner_config
);
1391 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
1392 i2c_bus
= &dev
->i2c_bus
[0];
1394 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1397 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
,
1398 0x12, &hauppauge_hvr1400_dib7000_config
);
1399 if (fe0
->dvb
.frontend
!= NULL
) {
1400 struct dvb_frontend
*fe
;
1401 struct xc2028_config cfg
= {
1402 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1405 static struct xc2028_ctrl ctl
= {
1406 .fname
= XC3028L_DEFAULT_FIRMWARE
,
1408 .demod
= XC3028_FE_DIBCOM52
,
1409 /* This is true for all demods with
1411 .type
= XC2028_D2633
,
1414 fe
= dvb_attach(xc2028_attach
,
1415 fe0
->dvb
.frontend
, &cfg
);
1416 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1417 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1420 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
1421 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1423 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1424 &dvico_s5h1409_config
,
1425 &i2c_bus
->i2c_adap
);
1426 if (fe0
->dvb
.frontend
== NULL
)
1427 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1428 &dvico_s5h1411_config
,
1429 &i2c_bus
->i2c_adap
);
1430 if (fe0
->dvb
.frontend
!= NULL
)
1431 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1433 &dvico_xc5000_tunerconfig
);
1435 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
1436 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1438 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1439 &dvico_fusionhdtv_xc3028
,
1440 &i2c_bus
->i2c_adap
);
1441 if (fe0
->dvb
.frontend
!= NULL
) {
1442 struct dvb_frontend
*fe
;
1443 struct xc2028_config cfg
= {
1444 .i2c_adap
= &i2c_bus
->i2c_adap
,
1447 static struct xc2028_ctrl ctl
= {
1448 .fname
= XC2028_DEFAULT_FIRMWARE
,
1450 .demod
= XC3028_FE_ZARLINK456
,
1453 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1455 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1456 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1460 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2
: {
1461 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1462 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1463 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1465 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1468 if (dib7000p_ops
.i2c_enumeration(&i2c_bus
->i2c_adap
, 1, 0x12, &dib7070p_dib7000p_config
) < 0) {
1469 pr_warn("Unable to enumerate dib7000p\n");
1472 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
, 0x80, &dib7070p_dib7000p_config
);
1473 if (fe0
->dvb
.frontend
!= NULL
) {
1474 struct i2c_adapter
*tun_i2c
;
1476 fe0
->dvb
.frontend
->sec_priv
= kmalloc(sizeof(dib7000p_ops
), GFP_KERNEL
);
1477 memcpy(fe0
->dvb
.frontend
->sec_priv
, &dib7000p_ops
, sizeof(dib7000p_ops
));
1478 tun_i2c
= dib7000p_ops
.get_i2c_master(fe0
->dvb
.frontend
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1479 if (!dvb_attach(dib0070_attach
, fe0
->dvb
.frontend
, tun_i2c
, &dib7070p_dib0070_config
))
1484 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
1485 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
1486 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
1487 i2c_bus
= &dev
->i2c_bus
[0];
1489 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1490 &dvico_fusionhdtv_xc3028
,
1491 &i2c_bus
->i2c_adap
);
1492 if (fe0
->dvb
.frontend
!= NULL
) {
1493 struct dvb_frontend
*fe
;
1494 struct xc2028_config cfg
= {
1495 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1498 static struct xc2028_ctrl ctl
= {
1499 .fname
= XC2028_DEFAULT_FIRMWARE
,
1501 .demod
= XC3028_FE_ZARLINK456
,
1504 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1506 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1507 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1510 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1511 i2c_bus
= &dev
->i2c_bus
[0];
1513 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1514 &dvico_fusionhdtv_xc3028
,
1515 &i2c_bus
->i2c_adap
);
1516 if (fe0
->dvb
.frontend
!= NULL
) {
1517 struct dvb_frontend
*fe
;
1518 struct xc4000_config cfg
= {
1519 .i2c_address
= 0x61,
1521 .dvb_amplitude
= 134,
1522 .set_smoothedcvbs
= 1,
1526 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1527 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1529 pr_err("%s/2: xc4000 attach failed\n",
1531 goto frontend_detach
;
1535 case CX23885_BOARD_TBS_6920
:
1536 i2c_bus
= &dev
->i2c_bus
[1];
1538 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1539 &tbs_cx24116_config
,
1540 &i2c_bus
->i2c_adap
);
1541 if (fe0
->dvb
.frontend
!= NULL
)
1542 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1545 case CX23885_BOARD_TBS_6980
:
1546 case CX23885_BOARD_TBS_6981
:
1547 i2c_bus
= &dev
->i2c_bus
[1];
1552 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1553 &tbs_cx24117_config
,
1554 &i2c_bus
->i2c_adap
);
1558 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1559 &tbs_cx24117_config
,
1560 &i2c_bus
->i2c_adap
);
1564 case CX23885_BOARD_TEVII_S470
:
1565 i2c_bus
= &dev
->i2c_bus
[1];
1567 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1568 &tevii_ds3000_config
,
1569 &i2c_bus
->i2c_adap
);
1570 if (fe0
->dvb
.frontend
!= NULL
) {
1571 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1572 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1573 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1577 case CX23885_BOARD_DVBWORLD_2005
:
1578 i2c_bus
= &dev
->i2c_bus
[1];
1580 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1581 &dvbworld_cx24116_config
,
1582 &i2c_bus
->i2c_adap
);
1584 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1585 i2c_bus
= &dev
->i2c_bus
[0];
1589 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1590 &netup_stv0900_config
,
1591 &i2c_bus
->i2c_adap
, 0);
1592 if (fe0
->dvb
.frontend
!= NULL
) {
1593 if (dvb_attach(stv6110_attach
,
1595 &netup_stv6110_tunerconfig_a
,
1596 &i2c_bus
->i2c_adap
)) {
1597 if (!dvb_attach(lnbh24_attach
,
1600 LNBH24_PCL
| LNBH24_TTX
,
1602 pr_err("No LNBH24 found!\n");
1609 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1610 &netup_stv0900_config
,
1611 &i2c_bus
->i2c_adap
, 1);
1612 if (fe0
->dvb
.frontend
!= NULL
) {
1613 if (dvb_attach(stv6110_attach
,
1615 &netup_stv6110_tunerconfig_b
,
1616 &i2c_bus
->i2c_adap
)) {
1617 if (!dvb_attach(lnbh24_attach
,
1620 LNBH24_PCL
| LNBH24_TTX
,
1622 pr_err("No LNBH24 found!\n");
1629 case CX23885_BOARD_MYGICA_X8506
:
1630 i2c_bus
= &dev
->i2c_bus
[0];
1631 i2c_bus2
= &dev
->i2c_bus
[1];
1632 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1633 &mygica_x8506_lgs8gl5_config
,
1634 &i2c_bus
->i2c_adap
);
1635 if (fe0
->dvb
.frontend
== NULL
)
1637 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1638 &i2c_bus2
->i2c_adap
, &mygica_x8506_xc5000_config
);
1639 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1641 case CX23885_BOARD_MYGICA_X8507
:
1642 i2c_bus
= &dev
->i2c_bus
[0];
1643 i2c_bus2
= &dev
->i2c_bus
[1];
1644 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1645 &mygica_x8507_mb86a20s_config
,
1646 &i2c_bus
->i2c_adap
);
1647 if (fe0
->dvb
.frontend
== NULL
)
1650 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1651 &i2c_bus2
->i2c_adap
,
1652 &mygica_x8507_xc5000_config
);
1653 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1655 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1656 i2c_bus
= &dev
->i2c_bus
[0];
1657 i2c_bus2
= &dev
->i2c_bus
[1];
1658 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1659 &magicpro_prohdtve2_lgs8g75_config
,
1660 &i2c_bus
->i2c_adap
);
1661 if (fe0
->dvb
.frontend
== NULL
)
1663 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1664 &i2c_bus2
->i2c_adap
,
1665 &magicpro_prohdtve2_xc5000_config
);
1666 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1668 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1669 i2c_bus
= &dev
->i2c_bus
[0];
1670 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1671 &hcw_s5h1411_config
,
1672 &i2c_bus
->i2c_adap
);
1673 if (fe0
->dvb
.frontend
== NULL
)
1675 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1676 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1677 &hauppauge_tda18271_config
);
1679 tda18271_attach(&dev
->ts1
.analog_fe
,
1680 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1681 &hauppauge_tda18271_config
);
1684 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1685 i2c_bus
= &dev
->i2c_bus
[0];
1686 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1687 &hcw_s5h1411_config
,
1688 &i2c_bus
->i2c_adap
);
1689 if (fe0
->dvb
.frontend
== NULL
)
1691 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1692 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1693 &hauppauge_tda18271_config
);
1695 case CX23885_BOARD_MYGICA_X8558PRO
:
1699 i2c_bus
= &dev
->i2c_bus
[0];
1700 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1701 &mygica_x8558pro_atbm8830_cfg1
,
1702 &i2c_bus
->i2c_adap
);
1703 if (fe0
->dvb
.frontend
== NULL
)
1705 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1707 &mygic_x8558pro_max2165_cfg1
);
1711 i2c_bus
= &dev
->i2c_bus
[1];
1712 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1713 &mygica_x8558pro_atbm8830_cfg2
,
1714 &i2c_bus
->i2c_adap
);
1715 if (fe0
->dvb
.frontend
== NULL
)
1717 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1719 &mygic_x8558pro_max2165_cfg2
);
1722 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1726 i2c_bus
= &dev
->i2c_bus
[0];
1727 mfe_shared
= 1;/* MFE */
1728 port
->frontends
.gate
= 0;/* not clear for me yet */
1730 /* MFE frontend 1 DVB-T */
1731 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1732 &netup_stv0367_config
[port
->nr
- 1],
1733 &i2c_bus
->i2c_adap
);
1734 if (fe0
->dvb
.frontend
== NULL
)
1736 if (NULL
== dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1738 &netup_xc5000_config
[port
->nr
- 1]))
1739 goto frontend_detach
;
1740 /* load xc5000 firmware */
1741 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1743 /* MFE frontend 2 */
1744 fe1
= vb2_dvb_get_frontend(&port
->frontends
, 2);
1746 goto frontend_detach
;
1748 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1749 &netup_stv0367_config
[port
->nr
- 1],
1750 &i2c_bus
->i2c_adap
);
1751 if (fe1
->dvb
.frontend
== NULL
)
1754 fe1
->dvb
.frontend
->id
= 1;
1755 if (NULL
== dvb_attach(xc5000_attach
,
1758 &netup_xc5000_config
[port
->nr
- 1]))
1759 goto frontend_detach
;
1761 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1762 i2c_bus
= &dev
->i2c_bus
[0];
1763 i2c_bus2
= &dev
->i2c_bus
[1];
1768 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1769 &terratec_drxk_config
[0],
1770 &i2c_bus
->i2c_adap
);
1771 if (fe0
->dvb
.frontend
== NULL
)
1773 if (!dvb_attach(mt2063_attach
,
1775 &terratec_mt2063_config
[0],
1776 &i2c_bus2
->i2c_adap
))
1777 goto frontend_detach
;
1781 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1782 &terratec_drxk_config
[1],
1783 &i2c_bus
->i2c_adap
);
1784 if (fe0
->dvb
.frontend
== NULL
)
1786 if (!dvb_attach(mt2063_attach
,
1788 &terratec_mt2063_config
[1],
1789 &i2c_bus2
->i2c_adap
))
1790 goto frontend_detach
;
1794 case CX23885_BOARD_TEVII_S471
:
1795 i2c_bus
= &dev
->i2c_bus
[1];
1797 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1798 &tevii_ds3000_config
,
1799 &i2c_bus
->i2c_adap
);
1800 if (fe0
->dvb
.frontend
== NULL
)
1802 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1803 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1805 case CX23885_BOARD_PROF_8000
:
1806 i2c_bus
= &dev
->i2c_bus
[0];
1808 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1809 &prof_8000_stv090x_config
,
1811 STV090x_DEMODULATOR_0
);
1812 if (fe0
->dvb
.frontend
== NULL
)
1814 if (!dvb_attach(stb6100_attach
,
1816 &prof_8000_stb6100_config
,
1817 &i2c_bus
->i2c_adap
))
1818 goto frontend_detach
;
1820 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1822 case CX23885_BOARD_HAUPPAUGE_HVR4400
: {
1823 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1824 struct a8293_platform_data a8293_pdata
= {};
1826 i2c_bus
= &dev
->i2c_bus
[0];
1827 i2c_bus2
= &dev
->i2c_bus
[1];
1831 /* attach demod + tuner combo */
1832 memset(&info
, 0, sizeof(info
));
1833 strlcpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1835 info
.platform_data
= &tda10071_pdata
;
1836 request_module("tda10071");
1837 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1838 if (!client_demod
|| !client_demod
->dev
.driver
)
1839 goto frontend_detach
;
1840 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1841 i2c_unregister_device(client_demod
);
1842 goto frontend_detach
;
1844 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1845 port
->i2c_client_demod
= client_demod
;
1848 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1849 memset(&info
, 0, sizeof(info
));
1850 strlcpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1852 info
.platform_data
= &a8293_pdata
;
1853 request_module("a8293");
1854 client_sec
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1855 if (!client_sec
|| !client_sec
->dev
.driver
)
1856 goto frontend_detach
;
1857 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1858 i2c_unregister_device(client_sec
);
1859 goto frontend_detach
;
1861 port
->i2c_client_sec
= client_sec
;
1865 /* attach frontend */
1866 memset(&si2165_pdata
, 0, sizeof(si2165_pdata
));
1867 si2165_pdata
.fe
= &fe0
->dvb
.frontend
;
1868 si2165_pdata
.chip_mode
= SI2165_MODE_PLL_XTAL
,
1869 si2165_pdata
.ref_freq_Hz
= 16000000,
1870 memset(&info
, 0, sizeof(struct i2c_board_info
));
1871 strlcpy(info
.type
, "si2165", I2C_NAME_SIZE
);
1873 info
.platform_data
= &si2165_pdata
;
1874 request_module(info
.type
);
1875 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1876 if (client_demod
== NULL
||
1877 client_demod
->dev
.driver
== NULL
)
1878 goto frontend_detach
;
1879 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1880 i2c_unregister_device(client_demod
);
1881 goto frontend_detach
;
1883 port
->i2c_client_demod
= client_demod
;
1885 if (fe0
->dvb
.frontend
== NULL
)
1887 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1888 if (!dvb_attach(tda18271_attach
,
1890 0x60, &i2c_bus2
->i2c_adap
,
1891 &hauppauge_hvr4400_tuner_config
))
1892 goto frontend_detach
;
1897 case CX23885_BOARD_HAUPPAUGE_STARBURST
: {
1898 struct tda10071_platform_data tda10071_pdata
= hauppauge_tda10071_pdata
;
1899 struct a8293_platform_data a8293_pdata
= {};
1901 i2c_bus
= &dev
->i2c_bus
[0];
1903 /* attach demod + tuner combo */
1904 memset(&info
, 0, sizeof(info
));
1905 strlcpy(info
.type
, "tda10071_cx24118", I2C_NAME_SIZE
);
1907 info
.platform_data
= &tda10071_pdata
;
1908 request_module("tda10071");
1909 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1910 if (!client_demod
|| !client_demod
->dev
.driver
)
1911 goto frontend_detach
;
1912 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1913 i2c_unregister_device(client_demod
);
1914 goto frontend_detach
;
1916 fe0
->dvb
.frontend
= tda10071_pdata
.get_dvb_frontend(client_demod
);
1917 port
->i2c_client_demod
= client_demod
;
1920 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
1921 memset(&info
, 0, sizeof(info
));
1922 strlcpy(info
.type
, "a8293", I2C_NAME_SIZE
);
1924 info
.platform_data
= &a8293_pdata
;
1925 request_module("a8293");
1926 client_sec
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1927 if (!client_sec
|| !client_sec
->dev
.driver
)
1928 goto frontend_detach
;
1929 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
1930 i2c_unregister_device(client_sec
);
1931 goto frontend_detach
;
1933 port
->i2c_client_sec
= client_sec
;
1936 case CX23885_BOARD_DVBSKY_T9580
:
1937 case CX23885_BOARD_DVBSKY_S950
:
1938 i2c_bus
= &dev
->i2c_bus
[0];
1939 i2c_bus2
= &dev
->i2c_bus
[1];
1941 /* port b - satellite */
1943 /* attach frontend */
1944 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1945 &dvbsky_t9580_m88ds3103_config
,
1946 &i2c_bus2
->i2c_adap
, &adapter
);
1947 if (fe0
->dvb
.frontend
== NULL
)
1951 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
1952 ts2020_config
.fe
= fe0
->dvb
.frontend
;
1953 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
1954 memset(&info
, 0, sizeof(struct i2c_board_info
));
1955 strlcpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
1957 info
.platform_data
= &ts2020_config
;
1958 request_module(info
.type
);
1959 client_tuner
= i2c_new_device(adapter
, &info
);
1960 if (client_tuner
== NULL
||
1961 client_tuner
->dev
.driver
== NULL
)
1962 goto frontend_detach
;
1963 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1964 i2c_unregister_device(client_tuner
);
1965 goto frontend_detach
;
1968 /* delegate signal strength measurement to tuner */
1969 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1970 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1973 * for setting the voltage we need to set GPIOs on
1976 port
->fe_set_voltage
=
1977 fe0
->dvb
.frontend
->ops
.set_voltage
;
1978 fe0
->dvb
.frontend
->ops
.set_voltage
=
1979 dvbsky_t9580_set_voltage
;
1981 port
->i2c_client_tuner
= client_tuner
;
1984 /* port c - terrestrial/cable */
1986 /* attach frontend */
1987 memset(&si2168_config
, 0, sizeof(si2168_config
));
1988 si2168_config
.i2c_adapter
= &adapter
;
1989 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1990 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1991 memset(&info
, 0, sizeof(struct i2c_board_info
));
1992 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1994 info
.platform_data
= &si2168_config
;
1995 request_module(info
.type
);
1996 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1997 if (client_demod
== NULL
||
1998 client_demod
->dev
.driver
== NULL
)
1999 goto frontend_detach
;
2000 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2001 i2c_unregister_device(client_demod
);
2002 goto frontend_detach
;
2004 port
->i2c_client_demod
= client_demod
;
2007 memset(&si2157_config
, 0, sizeof(si2157_config
));
2008 si2157_config
.fe
= fe0
->dvb
.frontend
;
2009 si2157_config
.if_port
= 1;
2010 memset(&info
, 0, sizeof(struct i2c_board_info
));
2011 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2013 info
.platform_data
= &si2157_config
;
2014 request_module(info
.type
);
2015 client_tuner
= i2c_new_device(adapter
, &info
);
2016 if (client_tuner
== NULL
||
2017 client_tuner
->dev
.driver
== NULL
)
2018 goto frontend_detach
;
2020 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2021 i2c_unregister_device(client_tuner
);
2022 goto frontend_detach
;
2024 port
->i2c_client_tuner
= client_tuner
;
2028 case CX23885_BOARD_DVBSKY_T980C
:
2029 case CX23885_BOARD_TT_CT2_4500_CI
:
2030 i2c_bus
= &dev
->i2c_bus
[0];
2031 i2c_bus2
= &dev
->i2c_bus
[1];
2033 /* attach frontend */
2034 memset(&si2168_config
, 0, sizeof(si2168_config
));
2035 si2168_config
.i2c_adapter
= &adapter
;
2036 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2037 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2038 memset(&info
, 0, sizeof(struct i2c_board_info
));
2039 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2041 info
.platform_data
= &si2168_config
;
2042 request_module(info
.type
);
2043 client_demod
= i2c_new_device(&i2c_bus2
->i2c_adap
, &info
);
2044 if (client_demod
== NULL
|| client_demod
->dev
.driver
== NULL
)
2045 goto frontend_detach
;
2046 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2047 i2c_unregister_device(client_demod
);
2048 goto frontend_detach
;
2050 port
->i2c_client_demod
= client_demod
;
2053 memset(&si2157_config
, 0, sizeof(si2157_config
));
2054 si2157_config
.fe
= fe0
->dvb
.frontend
;
2055 si2157_config
.if_port
= 1;
2056 memset(&info
, 0, sizeof(struct i2c_board_info
));
2057 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2059 info
.platform_data
= &si2157_config
;
2060 request_module(info
.type
);
2061 client_tuner
= i2c_new_device(adapter
, &info
);
2062 if (client_tuner
== NULL
||
2063 client_tuner
->dev
.driver
== NULL
)
2064 goto frontend_detach
;
2065 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2066 i2c_unregister_device(client_tuner
);
2067 goto frontend_detach
;
2069 port
->i2c_client_tuner
= client_tuner
;
2071 case CX23885_BOARD_DVBSKY_S950C
:
2072 i2c_bus
= &dev
->i2c_bus
[0];
2073 i2c_bus2
= &dev
->i2c_bus
[1];
2075 /* attach frontend */
2076 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2077 &dvbsky_s950c_m88ds3103_config
,
2078 &i2c_bus2
->i2c_adap
, &adapter
);
2079 if (fe0
->dvb
.frontend
== NULL
)
2083 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2084 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2085 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2086 memset(&info
, 0, sizeof(struct i2c_board_info
));
2087 strlcpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2089 info
.platform_data
= &ts2020_config
;
2090 request_module(info
.type
);
2091 client_tuner
= i2c_new_device(adapter
, &info
);
2092 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
)
2093 goto frontend_detach
;
2094 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2095 i2c_unregister_device(client_tuner
);
2096 goto frontend_detach
;
2099 /* delegate signal strength measurement to tuner */
2100 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2101 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2103 port
->i2c_client_tuner
= client_tuner
;
2105 case CX23885_BOARD_DVBSKY_S952
:
2109 i2c_bus
= &dev
->i2c_bus
[1];
2110 p_m88ds3103_config
= &dvbsky_t9580_m88ds3103_config
;
2111 p_set_voltage
= dvbsky_t9580_set_voltage
;
2115 i2c_bus
= &dev
->i2c_bus
[0];
2116 p_m88ds3103_config
= &dvbsky_s952_portc_m88ds3103_config
;
2117 p_set_voltage
= dvbsky_s952_portc_set_voltage
;
2121 /* attach frontend */
2122 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2124 &i2c_bus
->i2c_adap
, &adapter
);
2125 if (fe0
->dvb
.frontend
== NULL
)
2129 memset(&ts2020_config
, 0, sizeof(ts2020_config
));
2130 ts2020_config
.fe
= fe0
->dvb
.frontend
;
2131 ts2020_config
.get_agc_pwm
= m88ds3103_get_agc_pwm
;
2132 memset(&info
, 0, sizeof(struct i2c_board_info
));
2133 strlcpy(info
.type
, "ts2020", I2C_NAME_SIZE
);
2135 info
.platform_data
= &ts2020_config
;
2136 request_module(info
.type
);
2137 client_tuner
= i2c_new_device(adapter
, &info
);
2138 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
)
2139 goto frontend_detach
;
2140 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2141 i2c_unregister_device(client_tuner
);
2142 goto frontend_detach
;
2145 /* delegate signal strength measurement to tuner */
2146 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2147 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2150 * for setting the voltage we need to set GPIOs on
2153 port
->fe_set_voltage
=
2154 fe0
->dvb
.frontend
->ops
.set_voltage
;
2155 fe0
->dvb
.frontend
->ops
.set_voltage
= p_set_voltage
;
2157 port
->i2c_client_tuner
= client_tuner
;
2159 case CX23885_BOARD_DVBSKY_T982
:
2160 memset(&si2168_config
, 0, sizeof(si2168_config
));
2164 i2c_bus
= &dev
->i2c_bus
[1];
2165 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
2169 i2c_bus
= &dev
->i2c_bus
[0];
2170 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2174 /* attach frontend */
2175 si2168_config
.i2c_adapter
= &adapter
;
2176 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2177 memset(&info
, 0, sizeof(struct i2c_board_info
));
2178 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2180 info
.platform_data
= &si2168_config
;
2181 request_module(info
.type
);
2182 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
2183 if (client_demod
== NULL
|| client_demod
->dev
.driver
== NULL
)
2184 goto frontend_detach
;
2185 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2186 i2c_unregister_device(client_demod
);
2187 goto frontend_detach
;
2189 port
->i2c_client_demod
= client_demod
;
2192 memset(&si2157_config
, 0, sizeof(si2157_config
));
2193 si2157_config
.fe
= fe0
->dvb
.frontend
;
2194 si2157_config
.if_port
= 1;
2195 memset(&info
, 0, sizeof(struct i2c_board_info
));
2196 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2198 info
.platform_data
= &si2157_config
;
2199 request_module(info
.type
);
2200 client_tuner
= i2c_new_device(adapter
, &info
);
2201 if (client_tuner
== NULL
||
2202 client_tuner
->dev
.driver
== NULL
)
2203 goto frontend_detach
;
2204 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2205 i2c_unregister_device(client_tuner
);
2206 goto frontend_detach
;
2208 port
->i2c_client_tuner
= client_tuner
;
2210 case CX23885_BOARD_HAUPPAUGE_HVR5525
: {
2211 struct m88rs6000t_config m88rs6000t_config
;
2212 struct a8293_platform_data a8293_pdata
= {};
2216 /* port b - satellite */
2218 /* attach frontend */
2219 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2220 &hauppauge_hvr5525_m88ds3103_config
,
2221 &dev
->i2c_bus
[0].i2c_adap
, &adapter
);
2222 if (fe0
->dvb
.frontend
== NULL
)
2226 a8293_pdata
.dvb_frontend
= fe0
->dvb
.frontend
;
2227 memset(&info
, 0, sizeof(info
));
2228 strlcpy(info
.type
, "a8293", I2C_NAME_SIZE
);
2230 info
.platform_data
= &a8293_pdata
;
2231 request_module("a8293");
2232 client_sec
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2233 if (!client_sec
|| !client_sec
->dev
.driver
)
2234 goto frontend_detach
;
2235 if (!try_module_get(client_sec
->dev
.driver
->owner
)) {
2236 i2c_unregister_device(client_sec
);
2237 goto frontend_detach
;
2239 port
->i2c_client_sec
= client_sec
;
2242 memset(&m88rs6000t_config
, 0, sizeof(m88rs6000t_config
));
2243 m88rs6000t_config
.fe
= fe0
->dvb
.frontend
;
2244 memset(&info
, 0, sizeof(struct i2c_board_info
));
2245 strlcpy(info
.type
, "m88rs6000t", I2C_NAME_SIZE
);
2247 info
.platform_data
= &m88rs6000t_config
;
2248 request_module("%s", info
.type
);
2249 client_tuner
= i2c_new_device(adapter
, &info
);
2250 if (!client_tuner
|| !client_tuner
->dev
.driver
)
2251 goto frontend_detach
;
2252 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2253 i2c_unregister_device(client_tuner
);
2254 goto frontend_detach
;
2256 port
->i2c_client_tuner
= client_tuner
;
2258 /* delegate signal strength measurement to tuner */
2259 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2260 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2262 /* port c - terrestrial/cable */
2264 /* attach frontend */
2265 memset(&si2168_config
, 0, sizeof(si2168_config
));
2266 si2168_config
.i2c_adapter
= &adapter
;
2267 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2268 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2269 memset(&info
, 0, sizeof(struct i2c_board_info
));
2270 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2272 info
.platform_data
= &si2168_config
;
2273 request_module("%s", info
.type
);
2274 client_demod
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2275 if (!client_demod
|| !client_demod
->dev
.driver
)
2276 goto frontend_detach
;
2277 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2278 i2c_unregister_device(client_demod
);
2279 goto frontend_detach
;
2281 port
->i2c_client_demod
= client_demod
;
2284 memset(&si2157_config
, 0, sizeof(si2157_config
));
2285 si2157_config
.fe
= fe0
->dvb
.frontend
;
2286 si2157_config
.if_port
= 1;
2287 memset(&info
, 0, sizeof(struct i2c_board_info
));
2288 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2290 info
.platform_data
= &si2157_config
;
2291 request_module("%s", info
.type
);
2292 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2293 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2294 module_put(client_demod
->dev
.driver
->owner
);
2295 i2c_unregister_device(client_demod
);
2296 port
->i2c_client_demod
= NULL
;
2297 goto frontend_detach
;
2299 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2300 i2c_unregister_device(client_tuner
);
2301 module_put(client_demod
->dev
.driver
->owner
);
2302 i2c_unregister_device(client_demod
);
2303 port
->i2c_client_demod
= NULL
;
2304 goto frontend_detach
;
2306 port
->i2c_client_tuner
= client_tuner
;
2311 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB
:
2313 /* port b - Terrestrial/cable */
2315 /* attach frontend */
2316 memset(&si2168_config
, 0, sizeof(si2168_config
));
2317 si2168_config
.i2c_adapter
= &adapter
;
2318 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2319 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2320 memset(&info
, 0, sizeof(struct i2c_board_info
));
2321 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2323 info
.platform_data
= &si2168_config
;
2324 request_module("%s", info
.type
);
2325 client_demod
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2326 if (!client_demod
|| !client_demod
->dev
.driver
)
2327 goto frontend_detach
;
2328 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2329 i2c_unregister_device(client_demod
);
2330 goto frontend_detach
;
2332 port
->i2c_client_demod
= client_demod
;
2335 memset(&si2157_config
, 0, sizeof(si2157_config
));
2336 si2157_config
.fe
= fe0
->dvb
.frontend
;
2337 si2157_config
.if_port
= 1;
2338 memset(&info
, 0, sizeof(struct i2c_board_info
));
2339 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2341 info
.platform_data
= &si2157_config
;
2342 request_module("%s", info
.type
);
2343 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2344 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2345 module_put(client_demod
->dev
.driver
->owner
);
2346 i2c_unregister_device(client_demod
);
2347 port
->i2c_client_demod
= NULL
;
2348 goto frontend_detach
;
2350 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2351 i2c_unregister_device(client_tuner
);
2352 module_put(client_demod
->dev
.driver
->owner
);
2353 i2c_unregister_device(client_demod
);
2354 port
->i2c_client_demod
= NULL
;
2355 goto frontend_detach
;
2357 port
->i2c_client_tuner
= client_tuner
;
2360 /* port c - terrestrial/cable */
2362 /* attach frontend */
2363 memset(&si2168_config
, 0, sizeof(si2168_config
));
2364 si2168_config
.i2c_adapter
= &adapter
;
2365 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2366 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2367 memset(&info
, 0, sizeof(struct i2c_board_info
));
2368 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2370 info
.platform_data
= &si2168_config
;
2371 request_module("%s", info
.type
);
2372 client_demod
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2373 if (!client_demod
|| !client_demod
->dev
.driver
)
2374 goto frontend_detach
;
2375 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2376 i2c_unregister_device(client_demod
);
2377 goto frontend_detach
;
2379 port
->i2c_client_demod
= client_demod
;
2382 memset(&si2157_config
, 0, sizeof(si2157_config
));
2383 si2157_config
.fe
= fe0
->dvb
.frontend
;
2384 si2157_config
.if_port
= 1;
2385 memset(&info
, 0, sizeof(struct i2c_board_info
));
2386 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2388 info
.platform_data
= &si2157_config
;
2389 request_module("%s", info
.type
);
2390 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2391 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2392 module_put(client_demod
->dev
.driver
->owner
);
2393 i2c_unregister_device(client_demod
);
2394 port
->i2c_client_demod
= NULL
;
2395 goto frontend_detach
;
2397 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2398 i2c_unregister_device(client_tuner
);
2399 module_put(client_demod
->dev
.driver
->owner
);
2400 i2c_unregister_device(client_demod
);
2401 port
->i2c_client_demod
= NULL
;
2402 goto frontend_detach
;
2404 port
->i2c_client_tuner
= client_tuner
;
2408 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC
:
2410 /* port b - Terrestrial/cable */
2412 /* attach frontend */
2413 i2c_bus
= &dev
->i2c_bus
[0];
2414 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2415 &hauppauge_quadHD_ATSC_a_config
, &i2c_bus
->i2c_adap
);
2416 if (fe0
->dvb
.frontend
== NULL
)
2420 memset(&si2157_config
, 0, sizeof(si2157_config
));
2421 si2157_config
.fe
= fe0
->dvb
.frontend
;
2422 si2157_config
.if_port
= 1;
2423 si2157_config
.inversion
= 1;
2424 memset(&info
, 0, sizeof(struct i2c_board_info
));
2425 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2427 info
.platform_data
= &si2157_config
;
2428 request_module("%s", info
.type
);
2429 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2430 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2431 module_put(client_demod
->dev
.driver
->owner
);
2432 i2c_unregister_device(client_demod
);
2433 port
->i2c_client_demod
= NULL
;
2434 goto frontend_detach
;
2436 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2437 i2c_unregister_device(client_tuner
);
2438 module_put(client_demod
->dev
.driver
->owner
);
2439 i2c_unregister_device(client_demod
);
2440 port
->i2c_client_demod
= NULL
;
2441 goto frontend_detach
;
2443 port
->i2c_client_tuner
= client_tuner
;
2446 /* port c - terrestrial/cable */
2448 /* attach frontend */
2449 i2c_bus
= &dev
->i2c_bus
[0];
2450 fe0
->dvb
.frontend
= dvb_attach(lgdt3306a_attach
,
2451 &hauppauge_quadHD_ATSC_b_config
, &i2c_bus
->i2c_adap
);
2452 if (fe0
->dvb
.frontend
== NULL
)
2456 memset(&si2157_config
, 0, sizeof(si2157_config
));
2457 si2157_config
.fe
= fe0
->dvb
.frontend
;
2458 si2157_config
.if_port
= 1;
2459 si2157_config
.inversion
= 1;
2460 memset(&info
, 0, sizeof(struct i2c_board_info
));
2461 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2463 info
.platform_data
= &si2157_config
;
2464 request_module("%s", info
.type
);
2465 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2466 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2467 module_put(client_demod
->dev
.driver
->owner
);
2468 i2c_unregister_device(client_demod
);
2469 port
->i2c_client_demod
= NULL
;
2470 goto frontend_detach
;
2472 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2473 i2c_unregister_device(client_tuner
);
2474 module_put(client_demod
->dev
.driver
->owner
);
2475 i2c_unregister_device(client_demod
);
2476 port
->i2c_client_demod
= NULL
;
2477 goto frontend_detach
;
2479 port
->i2c_client_tuner
= client_tuner
;
2485 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2490 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
2491 pr_err("%s: frontend initialization failed\n",
2493 goto frontend_detach
;
2496 /* define general-purpose callback pointer */
2497 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2499 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2501 /* Ensure all frontends negotiate bus access */
2502 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2504 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2507 /* Put the analog decoder in standby to keep it quiet */
2508 call_all(dev
, core
, s_power
, 0);
2510 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
2511 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
2513 /* register everything */
2514 ret
= vb2_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
2515 &dev
->pci
->dev
, NULL
,
2516 adapter_nr
, mfe_shared
);
2518 goto frontend_detach
;
2520 ret
= dvb_register_ci_mac(port
);
2522 goto frontend_detach
;
2527 /* remove I2C client for SEC */
2528 client_sec
= port
->i2c_client_sec
;
2530 module_put(client_sec
->dev
.driver
->owner
);
2531 i2c_unregister_device(client_sec
);
2532 port
->i2c_client_sec
= NULL
;
2535 /* remove I2C client for tuner */
2536 client_tuner
= port
->i2c_client_tuner
;
2538 module_put(client_tuner
->dev
.driver
->owner
);
2539 i2c_unregister_device(client_tuner
);
2540 port
->i2c_client_tuner
= NULL
;
2543 /* remove I2C client for demodulator */
2544 client_demod
= port
->i2c_client_demod
;
2546 module_put(client_demod
->dev
.driver
->owner
);
2547 i2c_unregister_device(client_demod
);
2548 port
->i2c_client_demod
= NULL
;
2551 port
->gate_ctrl
= NULL
;
2552 vb2_dvb_dealloc_frontends(&port
->frontends
);
2556 int cx23885_dvb_register(struct cx23885_tsport
*port
)
2559 struct vb2_dvb_frontend
*fe0
;
2560 struct cx23885_dev
*dev
= port
->dev
;
2563 /* Here we need to allocate the correct number of frontends,
2564 * as reflected in the cards struct. The reality is that currently
2565 * no cx23885 boards support this - yet. But, if we don't modify this
2566 * code then the second frontend would never be allocated (later)
2567 * and fail with error before the attach in dvb_register().
2568 * Without these changes we risk an OOPS later. The changes here
2569 * are for safety, and should provide a good foundation for the
2570 * future addition of any multi-frontend cx23885 based boards.
2572 pr_info("%s() allocating %d frontend(s)\n", __func__
,
2573 port
->num_frontends
);
2575 for (i
= 1; i
<= port
->num_frontends
; i
++) {
2576 struct vb2_queue
*q
;
2578 if (vb2_dvb_alloc_frontend(
2579 &port
->frontends
, i
) == NULL
) {
2580 pr_err("%s() failed to alloc\n", __func__
);
2584 fe0
= vb2_dvb_get_frontend(&port
->frontends
, i
);
2588 dprintk(1, "%s\n", __func__
);
2589 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2598 /* We have to init the queue for each frontend on a port. */
2599 pr_info("%s: cx23885 based dvb card\n", dev
->name
);
2601 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
2602 q
->io_modes
= VB2_MMAP
| VB2_USERPTR
| VB2_DMABUF
| VB2_READ
;
2603 q
->gfp_flags
= GFP_DMA32
;
2604 q
->min_buffers_needed
= 2;
2606 q
->buf_struct_size
= sizeof(struct cx23885_buffer
);
2608 q
->mem_ops
= &vb2_dma_sg_memops
;
2609 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
2610 q
->lock
= &dev
->lock
;
2611 q
->dev
= &dev
->pci
->dev
;
2613 err
= vb2_queue_init(q
);
2617 err
= dvb_register(port
);
2619 pr_err("%s() dvb_register failed err = %d\n",
2625 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
2627 struct vb2_dvb_frontend
*fe0
;
2628 struct i2c_client
*client
;
2630 /* remove I2C client for CI */
2631 client
= port
->i2c_client_ci
;
2633 module_put(client
->dev
.driver
->owner
);
2634 i2c_unregister_device(client
);
2637 /* remove I2C client for SEC */
2638 client
= port
->i2c_client_sec
;
2640 module_put(client
->dev
.driver
->owner
);
2641 i2c_unregister_device(client
);
2644 /* remove I2C client for tuner */
2645 client
= port
->i2c_client_tuner
;
2647 module_put(client
->dev
.driver
->owner
);
2648 i2c_unregister_device(client
);
2651 /* remove I2C client for demodulator */
2652 client
= port
->i2c_client_demod
;
2654 module_put(client
->dev
.driver
->owner
);
2655 i2c_unregister_device(client
);
2658 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
2660 if (fe0
&& fe0
->dvb
.frontend
)
2661 vb2_dvb_unregister_bus(&port
->frontends
);
2663 switch (port
->dev
->board
) {
2664 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
2665 netup_ci_exit(port
);
2667 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
2668 altera_ci_release(port
->dev
, port
->nr
);
2672 port
->gate_ctrl
= NULL
;