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.
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/device.h>
22 #include <linux/kthread.h>
23 #include <linux/file.h>
24 #include <linux/suspend.h>
27 #include <media/v4l2-common.h>
29 #include "dvb_ca_en50221.h"
40 #include "tuner-xc2028.h"
41 #include "tuner-simple.h"
44 #include "dibx000_common.h"
47 #include "stv0900_reg.h"
54 #include "netup-eeprom.h"
55 #include "netup-init.h"
60 #include "cx23885-f300.h"
61 #include "altera-ci.h"
67 #include "stb6100_cfg.h"
75 #include "m88ds3103.h"
76 #include "m88ts2022.h"
77 #include "m88rs6000t.h"
79 static unsigned int debug
;
81 #define dprintk(level, fmt, arg...)\
82 do { if (debug >= level)\
83 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
86 /* ------------------------------------------------------------------ */
88 static unsigned int alt_tuner
;
89 module_param(alt_tuner
, int, 0644);
90 MODULE_PARM_DESC(alt_tuner
, "Enable alternate tuner configuration");
92 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
94 /* ------------------------------------------------------------------ */
96 static int queue_setup(struct vb2_queue
*q
, const struct v4l2_format
*fmt
,
97 unsigned int *num_buffers
, unsigned int *num_planes
,
98 unsigned int sizes
[], void *alloc_ctxs
[])
100 struct cx23885_tsport
*port
= q
->drv_priv
;
102 port
->ts_packet_size
= 188 * 4;
103 port
->ts_packet_count
= 32;
105 sizes
[0] = port
->ts_packet_size
* port
->ts_packet_count
;
106 alloc_ctxs
[0] = port
->dev
->alloc_ctx
;
112 static int buffer_prepare(struct vb2_buffer
*vb
)
114 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
115 struct cx23885_buffer
*buf
=
116 container_of(vb
, struct cx23885_buffer
, vb
);
118 return cx23885_buf_prepare(buf
, port
);
121 static void buffer_finish(struct vb2_buffer
*vb
)
123 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
124 struct cx23885_dev
*dev
= port
->dev
;
125 struct cx23885_buffer
*buf
= container_of(vb
,
126 struct cx23885_buffer
, vb
);
128 cx23885_free_buffer(dev
, buf
);
131 static void buffer_queue(struct vb2_buffer
*vb
)
133 struct cx23885_tsport
*port
= vb
->vb2_queue
->drv_priv
;
134 struct cx23885_buffer
*buf
= container_of(vb
,
135 struct cx23885_buffer
, vb
);
137 cx23885_buf_queue(port
, buf
);
140 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport
*port
, int open
)
142 struct vb2_dvb_frontends
*f
;
143 struct vb2_dvb_frontend
*fe
;
145 f
= &port
->frontends
;
147 if (f
->gate
<= 1) /* undefined or fe0 */
148 fe
= vb2_dvb_get_frontend(f
, 1);
150 fe
= vb2_dvb_get_frontend(f
, f
->gate
);
152 if (fe
&& fe
->dvb
.frontend
&& fe
->dvb
.frontend
->ops
.i2c_gate_ctrl
)
153 fe
->dvb
.frontend
->ops
.i2c_gate_ctrl(fe
->dvb
.frontend
, open
);
156 static int cx23885_start_streaming(struct vb2_queue
*q
, unsigned int count
)
158 struct cx23885_tsport
*port
= q
->drv_priv
;
159 struct cx23885_dmaqueue
*dmaq
= &port
->mpegq
;
160 struct cx23885_buffer
*buf
= list_entry(dmaq
->active
.next
,
161 struct cx23885_buffer
, queue
);
163 cx23885_start_dma(port
, dmaq
, buf
);
167 static void cx23885_stop_streaming(struct vb2_queue
*q
)
169 struct cx23885_tsport
*port
= q
->drv_priv
;
171 cx23885_cancel_buffers(port
);
174 static struct vb2_ops dvb_qops
= {
175 .queue_setup
= queue_setup
,
176 .buf_prepare
= buffer_prepare
,
177 .buf_finish
= buffer_finish
,
178 .buf_queue
= buffer_queue
,
179 .wait_prepare
= vb2_ops_wait_prepare
,
180 .wait_finish
= vb2_ops_wait_finish
,
181 .start_streaming
= cx23885_start_streaming
,
182 .stop_streaming
= cx23885_stop_streaming
,
185 static struct s5h1409_config hauppauge_generic_config
= {
186 .demod_address
= 0x32 >> 1,
187 .output_mode
= S5H1409_SERIAL_OUTPUT
,
188 .gpio
= S5H1409_GPIO_ON
,
190 .inversion
= S5H1409_INVERSION_OFF
,
191 .status_mode
= S5H1409_DEMODLOCKING
,
192 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
195 static struct tda10048_config hauppauge_hvr1200_config
= {
196 .demod_address
= 0x10 >> 1,
197 .output_mode
= TDA10048_SERIAL_OUTPUT
,
198 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
199 .inversion
= TDA10048_INVERSION_ON
,
200 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
201 .dtv7_if_freq_khz
= TDA10048_IF_3800
,
202 .dtv8_if_freq_khz
= TDA10048_IF_4300
,
203 .clk_freq_khz
= TDA10048_CLK_16000
,
206 static struct tda10048_config hauppauge_hvr1210_config
= {
207 .demod_address
= 0x10 >> 1,
208 .output_mode
= TDA10048_SERIAL_OUTPUT
,
209 .fwbulkwritelen
= TDA10048_BULKWRITE_200
,
210 .inversion
= TDA10048_INVERSION_ON
,
211 .dtv6_if_freq_khz
= TDA10048_IF_3300
,
212 .dtv7_if_freq_khz
= TDA10048_IF_3500
,
213 .dtv8_if_freq_khz
= TDA10048_IF_4000
,
214 .clk_freq_khz
= TDA10048_CLK_16000
,
217 static struct s5h1409_config hauppauge_ezqam_config
= {
218 .demod_address
= 0x32 >> 1,
219 .output_mode
= S5H1409_SERIAL_OUTPUT
,
220 .gpio
= S5H1409_GPIO_OFF
,
222 .inversion
= S5H1409_INVERSION_ON
,
223 .status_mode
= S5H1409_DEMODLOCKING
,
224 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
227 static struct s5h1409_config hauppauge_hvr1800lp_config
= {
228 .demod_address
= 0x32 >> 1,
229 .output_mode
= S5H1409_SERIAL_OUTPUT
,
230 .gpio
= S5H1409_GPIO_OFF
,
232 .inversion
= S5H1409_INVERSION_OFF
,
233 .status_mode
= S5H1409_DEMODLOCKING
,
234 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
237 static struct s5h1409_config hauppauge_hvr1500_config
= {
238 .demod_address
= 0x32 >> 1,
239 .output_mode
= S5H1409_SERIAL_OUTPUT
,
240 .gpio
= S5H1409_GPIO_OFF
,
241 .inversion
= S5H1409_INVERSION_OFF
,
242 .status_mode
= S5H1409_DEMODLOCKING
,
243 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
246 static struct mt2131_config hauppauge_generic_tunerconfig
= {
250 static struct lgdt330x_config fusionhdtv_5_express
= {
251 .demod_address
= 0x0e,
252 .demod_chip
= LGDT3303
,
256 static struct s5h1409_config hauppauge_hvr1500q_config
= {
257 .demod_address
= 0x32 >> 1,
258 .output_mode
= S5H1409_SERIAL_OUTPUT
,
259 .gpio
= S5H1409_GPIO_ON
,
261 .inversion
= S5H1409_INVERSION_OFF
,
262 .status_mode
= S5H1409_DEMODLOCKING
,
263 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
266 static struct s5h1409_config dvico_s5h1409_config
= {
267 .demod_address
= 0x32 >> 1,
268 .output_mode
= S5H1409_SERIAL_OUTPUT
,
269 .gpio
= S5H1409_GPIO_ON
,
271 .inversion
= S5H1409_INVERSION_OFF
,
272 .status_mode
= S5H1409_DEMODLOCKING
,
273 .mpeg_timing
= S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
276 static struct s5h1411_config dvico_s5h1411_config
= {
277 .output_mode
= S5H1411_SERIAL_OUTPUT
,
278 .gpio
= S5H1411_GPIO_ON
,
279 .qam_if
= S5H1411_IF_44000
,
280 .vsb_if
= S5H1411_IF_44000
,
281 .inversion
= S5H1411_INVERSION_OFF
,
282 .status_mode
= S5H1411_DEMODLOCKING
,
283 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
286 static struct s5h1411_config hcw_s5h1411_config
= {
287 .output_mode
= S5H1411_SERIAL_OUTPUT
,
288 .gpio
= S5H1411_GPIO_OFF
,
289 .vsb_if
= S5H1411_IF_44000
,
290 .qam_if
= S5H1411_IF_4000
,
291 .inversion
= S5H1411_INVERSION_ON
,
292 .status_mode
= S5H1411_DEMODLOCKING
,
293 .mpeg_timing
= S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
,
296 static struct xc5000_config hauppauge_hvr1500q_tunerconfig
= {
301 static struct xc5000_config dvico_xc5000_tunerconfig
= {
306 static struct tda829x_config tda829x_no_probe
= {
307 .probe_tuner
= TDA829X_DONT_PROBE
,
310 static struct tda18271_std_map hauppauge_tda18271_std_map
= {
311 .atsc_6
= { .if_freq
= 5380, .agc_mode
= 3, .std
= 3,
312 .if_lvl
= 6, .rfagc_top
= 0x37 },
313 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 0,
314 .if_lvl
= 6, .rfagc_top
= 0x37 },
317 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map
= {
318 .dvbt_6
= { .if_freq
= 3300, .agc_mode
= 3, .std
= 4,
319 .if_lvl
= 1, .rfagc_top
= 0x37, },
320 .dvbt_7
= { .if_freq
= 3800, .agc_mode
= 3, .std
= 5,
321 .if_lvl
= 1, .rfagc_top
= 0x37, },
322 .dvbt_8
= { .if_freq
= 4300, .agc_mode
= 3, .std
= 6,
323 .if_lvl
= 1, .rfagc_top
= 0x37, },
326 static struct tda18271_config hauppauge_tda18271_config
= {
327 .std_map
= &hauppauge_tda18271_std_map
,
328 .gate
= TDA18271_GATE_ANALOG
,
329 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
332 static struct tda18271_config hauppauge_hvr1200_tuner_config
= {
333 .std_map
= &hauppauge_hvr1200_tda18271_std_map
,
334 .gate
= TDA18271_GATE_ANALOG
,
335 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
338 static struct tda18271_config hauppauge_hvr1210_tuner_config
= {
339 .gate
= TDA18271_GATE_DIGITAL
,
340 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
343 static struct tda18271_config hauppauge_hvr4400_tuner_config
= {
344 .gate
= TDA18271_GATE_DIGITAL
,
345 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
348 static struct tda18271_std_map hauppauge_hvr127x_std_map
= {
349 .atsc_6
= { .if_freq
= 3250, .agc_mode
= 3, .std
= 4,
350 .if_lvl
= 1, .rfagc_top
= 0x58 },
351 .qam_6
= { .if_freq
= 4000, .agc_mode
= 3, .std
= 5,
352 .if_lvl
= 1, .rfagc_top
= 0x58 },
355 static struct tda18271_config hauppauge_hvr127x_config
= {
356 .std_map
= &hauppauge_hvr127x_std_map
,
357 .output_opt
= TDA18271_OUTPUT_LT_OFF
,
360 static struct lgdt3305_config hauppauge_lgdt3305_config
= {
362 .mpeg_mode
= LGDT3305_MPEG_SERIAL
,
363 .tpclk_edge
= LGDT3305_TPCLK_FALLING_EDGE
,
364 .tpvalid_polarity
= LGDT3305_TP_VALID_HIGH
,
366 .spectral_inversion
= 1,
371 static struct dibx000_agc_config xc3028_agc_config
= {
372 BAND_VHF
| BAND_UHF
, /* band_caps */
374 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
375 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
376 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
377 * P_agc_nb_est=2, P_agc_write=0
379 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
380 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
383 21, /* time_stabiliz */
395 39718, /* agc2_max */
404 29, /* agc2_slope1 */
405 29, /* agc2_slope2 */
412 1, /* perform_agc_softsplit */
415 /* PLL Configuration for COFDM BW_MHz = 8.000000
416 * With external clock = 30.000000 */
417 static struct dibx000_bandwidth_config xc3028_bw_config
= {
418 60000, /* internal */
419 30000, /* sampling */
420 1, /* pll_cfg: prediv */
421 8, /* pll_cfg: ratio */
422 3, /* pll_cfg: range */
423 1, /* pll_cfg: reset */
424 0, /* pll_cfg: bypass */
425 0, /* misc: refdiv */
426 0, /* misc: bypclk_div */
427 1, /* misc: IO_CLK_en_core */
428 1, /* misc: ADClkSrc */
429 0, /* misc: modulo */
430 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
431 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
433 30000000 /* xtal_hz */
436 static struct dib7000p_config hauppauge_hvr1400_dib7000_config
= {
437 .output_mpeg2_in_188_bytes
= 1,
438 .hostbus_diversity
= 1,
439 .tuner_is_baseband
= 0,
442 .agc_config_count
= 1,
443 .agc
= &xc3028_agc_config
,
444 .bw
= &xc3028_bw_config
,
446 .gpio_dir
= DIB7000P_GPIO_DEFAULT_DIRECTIONS
,
447 .gpio_val
= DIB7000P_GPIO_DEFAULT_VALUES
,
448 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
454 .output_mode
= OUTMODE_MPEG2_SERIAL
,
457 static struct zl10353_config dvico_fusionhdtv_xc3028
= {
458 .demod_address
= 0x0f,
461 .disable_i2c_gate_ctrl
= 1,
464 static struct stv0900_reg stv0900_ts_regs
[] = {
465 { R0900_TSGENERAL
, 0x00 },
466 { R0900_P1_TSSPEED
, 0x40 },
467 { R0900_P2_TSSPEED
, 0x40 },
468 { R0900_P1_TSCFGM
, 0xc0 },
469 { R0900_P2_TSCFGM
, 0xc0 },
470 { R0900_P1_TSCFGH
, 0xe0 },
471 { R0900_P2_TSCFGH
, 0xe0 },
472 { R0900_P1_TSCFGL
, 0x20 },
473 { R0900_P2_TSCFGL
, 0x20 },
474 { 0xffff, 0xff }, /* terminate */
477 static struct stv0900_config netup_stv0900_config
= {
478 .demod_address
= 0x68,
479 .demod_mode
= 1, /* dual */
481 .clkmode
= 3,/* 0-CLKI, 2-XTALI, else AUTO */
482 .diseqc_mode
= 2,/* 2/3 PWM */
483 .ts_config_regs
= stv0900_ts_regs
,
484 .tun1_maddress
= 0,/* 0x60 */
485 .tun2_maddress
= 3,/* 0x63 */
486 .tun1_adc
= 1,/* 1 Vpp */
487 .tun2_adc
= 1,/* 1 Vpp */
490 static struct stv6110_config netup_stv6110_tunerconfig_a
= {
494 .gain
= 8, /* +16 dB - maximum gain */
497 static struct stv6110_config netup_stv6110_tunerconfig_b
= {
501 .gain
= 8, /* +16 dB - maximum gain */
504 static struct cx24116_config tbs_cx24116_config
= {
505 .demod_address
= 0x55,
508 static struct cx24117_config tbs_cx24117_config
= {
509 .demod_address
= 0x55,
512 static struct ds3000_config tevii_ds3000_config
= {
513 .demod_address
= 0x68,
516 static struct ts2020_config tevii_ts2020_config
= {
517 .tuner_address
= 0x60,
519 .frequency_div
= 1146000,
522 static struct cx24116_config dvbworld_cx24116_config
= {
523 .demod_address
= 0x05,
526 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config
= {
527 .prod
= LGS8GXX_PROD_LGS8GL5
,
528 .demod_address
= 0x19,
532 .if_clk_freq
= 30400, /* 30.4 MHz */
533 .if_freq
= 5380, /* 5.38 MHz */
540 static struct xc5000_config mygica_x8506_xc5000_config
= {
545 static struct mb86a20s_config mygica_x8507_mb86a20s_config
= {
546 .demod_address
= 0x10,
549 static struct xc5000_config mygica_x8507_xc5000_config
= {
554 static struct stv090x_config prof_8000_stv090x_config
= {
556 .demod_mode
= STV090x_SINGLE
,
557 .clk_mode
= STV090x_CLK_EXT
,
560 .ts1_mode
= STV090x_TSMODE_PARALLEL_PUNCTURED
,
561 .repeater_level
= STV090x_RPTLEVEL_64
,
562 .adc1_range
= STV090x_ADC_2Vpp
,
563 .diseqc_envelope_mode
= false,
565 .tuner_get_frequency
= stb6100_get_frequency
,
566 .tuner_set_frequency
= stb6100_set_frequency
,
567 .tuner_set_bandwidth
= stb6100_set_bandwidth
,
568 .tuner_get_bandwidth
= stb6100_get_bandwidth
,
571 static struct stb6100_config prof_8000_stb6100_config
= {
572 .tuner_address
= 0x60,
573 .refclock
= 27000000,
576 static int p8000_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
578 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
579 struct cx23885_dev
*dev
= port
->dev
;
581 if (voltage
== SEC_VOLTAGE_18
)
582 cx_write(MC417_RWD
, 0x00001e00);
583 else if (voltage
== SEC_VOLTAGE_13
)
584 cx_write(MC417_RWD
, 0x00001a00);
586 cx_write(MC417_RWD
, 0x00001800);
590 static int dvbsky_t9580_set_voltage(struct dvb_frontend
*fe
,
591 fe_sec_voltage_t voltage
)
593 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
594 struct cx23885_dev
*dev
= port
->dev
;
596 cx23885_gpio_enable(dev
, GPIO_0
| GPIO_1
, 1);
600 cx23885_gpio_set(dev
, GPIO_1
);
601 cx23885_gpio_clear(dev
, GPIO_0
);
604 cx23885_gpio_set(dev
, GPIO_1
);
605 cx23885_gpio_set(dev
, GPIO_0
);
607 case SEC_VOLTAGE_OFF
:
608 cx23885_gpio_clear(dev
, GPIO_1
);
609 cx23885_gpio_clear(dev
, GPIO_0
);
613 /* call the frontend set_voltage function */
614 port
->fe_set_voltage(fe
, voltage
);
619 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend
*fe
,
620 fe_sec_voltage_t voltage
)
622 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
623 struct cx23885_dev
*dev
= port
->dev
;
625 cx23885_gpio_enable(dev
, GPIO_12
| GPIO_13
, 1);
629 cx23885_gpio_set(dev
, GPIO_13
);
630 cx23885_gpio_clear(dev
, GPIO_12
);
633 cx23885_gpio_set(dev
, GPIO_13
);
634 cx23885_gpio_set(dev
, GPIO_12
);
636 case SEC_VOLTAGE_OFF
:
637 cx23885_gpio_clear(dev
, GPIO_13
);
638 cx23885_gpio_clear(dev
, GPIO_12
);
641 /* call the frontend set_voltage function */
642 return port
->fe_set_voltage(fe
, voltage
);
645 static int cx23885_sp2_ci_ctrl(void *priv
, u8 read
, int addr
,
649 #define SP2_DATA 0x000000ff
650 #define SP2_WR 0x00008000
651 #define SP2_RD 0x00004000
652 #define SP2_ACK 0x00001000
653 #define SP2_ADHI 0x00000800
654 #define SP2_ADLO 0x00000400
655 #define SP2_CS1 0x00000200
656 #define SP2_CS0 0x00000100
657 #define SP2_EN_ALL 0x00001000
658 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
660 struct cx23885_tsport
*port
= priv
;
661 struct cx23885_dev
*dev
= port
->dev
;
664 unsigned long timeout
;
666 mutex_lock(&dev
->gpio_lock
);
669 cx_write(MC417_OEN
, SP2_EN_ALL
);
670 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
671 SP2_ADLO
| (0xff & addr
));
672 cx_clear(MC417_RWD
, SP2_ADLO
);
673 cx_write(MC417_RWD
, SP2_CTRL_OFF
|
674 SP2_ADHI
| (0xff & (addr
>> 8)));
675 cx_clear(MC417_RWD
, SP2_ADHI
);
679 cx_write(MC417_OEN
, SP2_EN_ALL
| SP2_DATA
);
682 cx_write(MC417_RWD
, SP2_CTRL_OFF
| data
);
685 cx_clear(MC417_RWD
, SP2_CS0
);
688 cx_clear(MC417_RWD
, (read
) ? SP2_RD
: SP2_WR
);
690 /* wait for a maximum of 1 msec */
691 timeout
= jiffies
+ msecs_to_jiffies(1);
692 while (!time_after(jiffies
, timeout
)) {
693 tmp
= cx_read(MC417_RWD
);
694 if ((tmp
& SP2_ACK
) == 0)
696 usleep_range(50, 100);
699 cx_set(MC417_RWD
, SP2_CTRL_OFF
);
702 mutex_unlock(&dev
->gpio_lock
);
716 static int cx23885_dvb_set_frontend(struct dvb_frontend
*fe
)
718 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
719 struct cx23885_tsport
*port
= fe
->dvb
->priv
;
720 struct cx23885_dev
*dev
= port
->dev
;
722 switch (dev
->board
) {
723 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
724 switch (p
->modulation
) {
726 cx23885_gpio_clear(dev
, GPIO_5
);
731 cx23885_gpio_set(dev
, GPIO_5
);
735 case CX23885_BOARD_MYGICA_X8506
:
736 case CX23885_BOARD_MYGICA_X8507
:
737 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
738 /* Select Digital TV */
739 cx23885_gpio_set(dev
, GPIO_0
);
743 /* Call the real set_frontend */
744 if (port
->set_frontend
)
745 return port
->set_frontend(fe
);
750 static void cx23885_set_frontend_hook(struct cx23885_tsport
*port
,
751 struct dvb_frontend
*fe
)
753 port
->set_frontend
= fe
->ops
.set_frontend
;
754 fe
->ops
.set_frontend
= cx23885_dvb_set_frontend
;
757 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config
= {
758 .prod
= LGS8GXX_PROD_LGS8G75
,
759 .demod_address
= 0x19,
763 .if_clk_freq
= 30400, /* 30.4 MHz */
764 .if_freq
= 6500, /* 6.50 MHz */
768 .adc_vpp
= 2, /* 1.6 Vpp */
772 static struct xc5000_config magicpro_prohdtve2_xc5000_config
= {
777 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1
= {
778 .prod
= ATBM8830_PROD_8830
,
779 .demod_address
= 0x44,
781 .ts_sampling_edge
= 1,
783 .osc_clk_freq
= 30400, /* in kHz */
784 .if_freq
= 0, /* zero IF */
791 static struct max2165_config mygic_x8558pro_max2165_cfg1
= {
796 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2
= {
797 .prod
= ATBM8830_PROD_8830
,
798 .demod_address
= 0x44,
800 .ts_sampling_edge
= 1,
802 .osc_clk_freq
= 30400, /* in kHz */
803 .if_freq
= 0, /* zero IF */
810 static struct max2165_config mygic_x8558pro_max2165_cfg2
= {
814 static struct stv0367_config netup_stv0367_config
[] = {
816 .demod_address
= 0x1c,
823 .demod_address
= 0x1d,
832 static struct xc5000_config netup_xc5000_config
[] = {
842 static struct drxk_config terratec_drxk_config
[] = {
852 static struct mt2063_config terratec_mt2063_config
[] = {
854 .tuner_address
= 0x60,
856 .tuner_address
= 0x67,
860 static const struct tda10071_config hauppauge_tda10071_config
= {
861 .demod_i2c_addr
= 0x05,
862 .tuner_i2c_addr
= 0x54,
864 .ts_mode
= TDA10071_TS_SERIAL
,
866 .xtal
= 40444000, /* 40.444 MHz */
867 .pll_multiplier
= 20,
870 static const struct a8293_config hauppauge_a8293_config
= {
874 static const struct si2165_config hauppauge_hvr4400_si2165_config
= {
876 .chip_mode
= SI2165_MODE_PLL_XTAL
,
877 .ref_freq_Hz
= 16000000,
880 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config
= {
885 .ts_mode
= M88DS3103_TS_PARALLEL
,
893 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config
= {
898 .ts_mode
= M88DS3103_TS_CI
,
906 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config
= {
911 .ts_mode
= M88DS3103_TS_SERIAL
,
919 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config
= {
923 .ts_mode
= M88DS3103_TS_PARALLEL
,
929 static int netup_altera_fpga_rw(void *device
, int flag
, int data
, int read
)
931 struct cx23885_dev
*dev
= (struct cx23885_dev
*)device
;
932 unsigned long timeout
= jiffies
+ msecs_to_jiffies(1);
935 mem
= cx_read(MC417_RWD
);
937 cx_set(MC417_OEN
, ALT_DATA
);
939 cx_clear(MC417_OEN
, ALT_DATA
);/* D0-D7 out */
941 mem
|= (data
& ALT_DATA
);
951 mem
= (mem
& ~ALT_RD
) | ALT_WR
;
953 mem
= (mem
& ~ALT_WR
) | ALT_RD
;
955 cx_write(MC417_RWD
, mem
); /* start RW cycle */
958 mem
= cx_read(MC417_RWD
);
959 if ((mem
& ALT_RDY
) == 0)
961 if (time_after(jiffies
, timeout
))
966 cx_set(MC417_RWD
, ALT_RD
| ALT_WR
| ALT_CS
);
968 return mem
& ALT_DATA
;
973 static int dib7070_tuner_reset(struct dvb_frontend
*fe
, int onoff
)
975 struct dib7000p_ops
*dib7000p_ops
= fe
->sec_priv
;
977 return dib7000p_ops
->set_gpio(fe
, 8, 0, !onoff
);
980 static int dib7070_tuner_sleep(struct dvb_frontend
*fe
, int onoff
)
985 static struct dib0070_config dib7070p_dib0070_config
= {
986 .i2c_address
= DEFAULT_DIB0070_I2C_ADDRESS
,
987 .reset
= dib7070_tuner_reset
,
988 .sleep
= dib7070_tuner_sleep
,
990 .freq_offset_khz_vhf
= 550,
991 /* .flip_chip = 1, */
994 /* DIB7070 generic */
995 static struct dibx000_agc_config dib7070_agc_config
= {
996 .band_caps
= BAND_UHF
| BAND_VHF
| BAND_LBAND
| BAND_SBAND
,
999 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1000 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1001 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1003 .setup
= (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1004 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1006 .time_stabiliz
= 10,
1030 .perform_agc_softsplit
= 0,
1033 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz
= {
1043 .IO_CLK_en_core
= 1,
1046 /* refsel, sel, freq_15k */
1047 .sad_cfg
= (3 << 14) | (1 << 12) | (524 << 0),
1048 .ifreq
= (0 << 25) | 0,
1050 .xtal_hz
= 12000000,
1053 static struct dib7000p_config dib7070p_dib7000p_config
= {
1054 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1055 .output_mode
= OUTMODE_MPEG2_SERIAL
,
1056 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1057 .output_mpeg2_in_188_bytes
= 1,
1059 .agc_config_count
= 1,
1060 .agc
= &dib7070_agc_config
,
1061 .bw
= &dib7070_bw_config_12_mhz
,
1062 .tuner_is_baseband
= 1,
1065 .gpio_dir
= 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1066 .gpio_val
= 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1067 .gpio_pwm_pos
= DIB7000P_GPIO_DEFAULT_PWM_POS
,
1069 .hostbus_diversity
= 1,
1072 static int dvb_register(struct cx23885_tsport
*port
)
1074 struct dib7000p_ops dib7000p_ops
;
1075 struct cx23885_dev
*dev
= port
->dev
;
1076 struct cx23885_i2c
*i2c_bus
= NULL
, *i2c_bus2
= NULL
;
1077 struct vb2_dvb_frontend
*fe0
, *fe1
= NULL
;
1078 struct si2168_config si2168_config
;
1079 struct si2157_config si2157_config
;
1080 struct sp2_config sp2_config
;
1081 struct m88ts2022_config m88ts2022_config
;
1082 struct i2c_board_info info
;
1083 struct i2c_adapter
*adapter
;
1084 struct i2c_client
*client_demod
= NULL
, *client_tuner
= NULL
, *client_ci
= NULL
;
1085 const struct m88ds3103_config
*p_m88ds3103_config
= NULL
;
1086 int (*p_set_voltage
)(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
) = NULL
;
1087 int mfe_shared
= 0; /* bus not shared by default */
1090 /* Get the first frontend */
1091 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
1095 /* init struct vb2_dvb */
1096 fe0
->dvb
.name
= dev
->name
;
1098 /* multi-frontend gate control is undefined or defaults to fe0 */
1099 port
->frontends
.gate
= 0;
1101 /* Sets the gate control callback to be used by i2c command calls */
1102 port
->gate_ctrl
= cx23885_dvb_gate_ctrl
;
1105 switch (dev
->board
) {
1106 case CX23885_BOARD_HAUPPAUGE_HVR1250
:
1107 i2c_bus
= &dev
->i2c_bus
[0];
1108 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1109 &hauppauge_generic_config
,
1110 &i2c_bus
->i2c_adap
);
1111 if (fe0
->dvb
.frontend
== NULL
)
1113 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1115 &hauppauge_generic_tunerconfig
, 0);
1117 case CX23885_BOARD_HAUPPAUGE_HVR1270
:
1118 case CX23885_BOARD_HAUPPAUGE_HVR1275
:
1119 i2c_bus
= &dev
->i2c_bus
[0];
1120 fe0
->dvb
.frontend
= dvb_attach(lgdt3305_attach
,
1121 &hauppauge_lgdt3305_config
,
1122 &i2c_bus
->i2c_adap
);
1123 if (fe0
->dvb
.frontend
== NULL
)
1125 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1126 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1127 &hauppauge_hvr127x_config
);
1128 if (dev
->board
== CX23885_BOARD_HAUPPAUGE_HVR1275
)
1129 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1131 case CX23885_BOARD_HAUPPAUGE_HVR1255
:
1132 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111
:
1133 i2c_bus
= &dev
->i2c_bus
[0];
1134 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1135 &hcw_s5h1411_config
,
1136 &i2c_bus
->i2c_adap
);
1137 if (fe0
->dvb
.frontend
== NULL
)
1140 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1141 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1142 &hauppauge_tda18271_config
);
1144 tda18271_attach(&dev
->ts1
.analog_fe
,
1145 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1146 &hauppauge_tda18271_config
);
1149 case CX23885_BOARD_HAUPPAUGE_HVR1800
:
1150 i2c_bus
= &dev
->i2c_bus
[0];
1151 switch (alt_tuner
) {
1154 dvb_attach(s5h1409_attach
,
1155 &hauppauge_ezqam_config
,
1156 &i2c_bus
->i2c_adap
);
1157 if (fe0
->dvb
.frontend
== NULL
)
1160 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1161 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1163 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1164 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1165 &hauppauge_tda18271_config
);
1170 dvb_attach(s5h1409_attach
,
1171 &hauppauge_generic_config
,
1172 &i2c_bus
->i2c_adap
);
1173 if (fe0
->dvb
.frontend
== NULL
)
1175 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1177 &hauppauge_generic_tunerconfig
, 0);
1180 case CX23885_BOARD_HAUPPAUGE_HVR1800lp
:
1181 i2c_bus
= &dev
->i2c_bus
[0];
1182 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1183 &hauppauge_hvr1800lp_config
,
1184 &i2c_bus
->i2c_adap
);
1185 if (fe0
->dvb
.frontend
== NULL
)
1187 dvb_attach(mt2131_attach
, fe0
->dvb
.frontend
,
1189 &hauppauge_generic_tunerconfig
, 0);
1191 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP
:
1192 i2c_bus
= &dev
->i2c_bus
[0];
1193 fe0
->dvb
.frontend
= dvb_attach(lgdt330x_attach
,
1194 &fusionhdtv_5_express
,
1195 &i2c_bus
->i2c_adap
);
1196 if (fe0
->dvb
.frontend
== NULL
)
1198 dvb_attach(simple_tuner_attach
, fe0
->dvb
.frontend
,
1199 &i2c_bus
->i2c_adap
, 0x61,
1200 TUNER_LG_TDVS_H06XF
);
1202 case CX23885_BOARD_HAUPPAUGE_HVR1500Q
:
1203 i2c_bus
= &dev
->i2c_bus
[1];
1204 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1205 &hauppauge_hvr1500q_config
,
1206 &dev
->i2c_bus
[0].i2c_adap
);
1207 if (fe0
->dvb
.frontend
== NULL
)
1209 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1211 &hauppauge_hvr1500q_tunerconfig
);
1213 case CX23885_BOARD_HAUPPAUGE_HVR1500
:
1214 i2c_bus
= &dev
->i2c_bus
[1];
1215 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1216 &hauppauge_hvr1500_config
,
1217 &dev
->i2c_bus
[0].i2c_adap
);
1218 if (fe0
->dvb
.frontend
!= NULL
) {
1219 struct dvb_frontend
*fe
;
1220 struct xc2028_config cfg
= {
1221 .i2c_adap
= &i2c_bus
->i2c_adap
,
1224 static struct xc2028_ctrl ctl
= {
1225 .fname
= XC2028_DEFAULT_FIRMWARE
,
1227 .demod
= XC3028_FE_OREN538
,
1230 fe
= dvb_attach(xc2028_attach
,
1231 fe0
->dvb
.frontend
, &cfg
);
1232 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1233 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1236 case CX23885_BOARD_HAUPPAUGE_HVR1200
:
1237 case CX23885_BOARD_HAUPPAUGE_HVR1700
:
1238 i2c_bus
= &dev
->i2c_bus
[0];
1239 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1240 &hauppauge_hvr1200_config
,
1241 &i2c_bus
->i2c_adap
);
1242 if (fe0
->dvb
.frontend
== NULL
)
1244 dvb_attach(tda829x_attach
, fe0
->dvb
.frontend
,
1245 &dev
->i2c_bus
[1].i2c_adap
, 0x42,
1247 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1248 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1249 &hauppauge_hvr1200_tuner_config
);
1251 case CX23885_BOARD_HAUPPAUGE_HVR1210
:
1252 i2c_bus
= &dev
->i2c_bus
[0];
1253 fe0
->dvb
.frontend
= dvb_attach(tda10048_attach
,
1254 &hauppauge_hvr1210_config
,
1255 &i2c_bus
->i2c_adap
);
1256 if (fe0
->dvb
.frontend
!= NULL
) {
1257 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1258 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1259 &hauppauge_hvr1210_tuner_config
);
1262 case CX23885_BOARD_HAUPPAUGE_HVR1400
:
1263 i2c_bus
= &dev
->i2c_bus
[0];
1265 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1268 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
,
1269 0x12, &hauppauge_hvr1400_dib7000_config
);
1270 if (fe0
->dvb
.frontend
!= NULL
) {
1271 struct dvb_frontend
*fe
;
1272 struct xc2028_config cfg
= {
1273 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1276 static struct xc2028_ctrl ctl
= {
1277 .fname
= XC3028L_DEFAULT_FIRMWARE
,
1279 .demod
= XC3028_FE_DIBCOM52
,
1280 /* This is true for all demods with
1282 .type
= XC2028_D2633
,
1285 fe
= dvb_attach(xc2028_attach
,
1286 fe0
->dvb
.frontend
, &cfg
);
1287 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1288 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1291 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP
:
1292 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1294 fe0
->dvb
.frontend
= dvb_attach(s5h1409_attach
,
1295 &dvico_s5h1409_config
,
1296 &i2c_bus
->i2c_adap
);
1297 if (fe0
->dvb
.frontend
== NULL
)
1298 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1299 &dvico_s5h1411_config
,
1300 &i2c_bus
->i2c_adap
);
1301 if (fe0
->dvb
.frontend
!= NULL
)
1302 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1304 &dvico_xc5000_tunerconfig
);
1306 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP
: {
1307 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1309 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1310 &dvico_fusionhdtv_xc3028
,
1311 &i2c_bus
->i2c_adap
);
1312 if (fe0
->dvb
.frontend
!= NULL
) {
1313 struct dvb_frontend
*fe
;
1314 struct xc2028_config cfg
= {
1315 .i2c_adap
= &i2c_bus
->i2c_adap
,
1318 static struct xc2028_ctrl ctl
= {
1319 .fname
= XC2028_DEFAULT_FIRMWARE
,
1321 .demod
= XC3028_FE_ZARLINK456
,
1324 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1326 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1327 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1331 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2
: {
1332 i2c_bus
= &dev
->i2c_bus
[port
->nr
- 1];
1333 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1334 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1336 if (!dvb_attach(dib7000p_attach
, &dib7000p_ops
))
1339 if (dib7000p_ops
.i2c_enumeration(&i2c_bus
->i2c_adap
, 1, 0x12, &dib7070p_dib7000p_config
) < 0) {
1340 printk(KERN_WARNING
"Unable to enumerate dib7000p\n");
1343 fe0
->dvb
.frontend
= dib7000p_ops
.init(&i2c_bus
->i2c_adap
, 0x80, &dib7070p_dib7000p_config
);
1344 if (fe0
->dvb
.frontend
!= NULL
) {
1345 struct i2c_adapter
*tun_i2c
;
1347 fe0
->dvb
.frontend
->sec_priv
= kmalloc(sizeof(dib7000p_ops
), GFP_KERNEL
);
1348 memcpy(fe0
->dvb
.frontend
->sec_priv
, &dib7000p_ops
, sizeof(dib7000p_ops
));
1349 tun_i2c
= dib7000p_ops
.get_i2c_master(fe0
->dvb
.frontend
, DIBX000_I2C_INTERFACE_TUNER
, 1);
1350 if (!dvb_attach(dib0070_attach
, fe0
->dvb
.frontend
, tun_i2c
, &dib7070p_dib0070_config
))
1355 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H
:
1356 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F
:
1357 case CX23885_BOARD_COMPRO_VIDEOMATE_E800
:
1358 i2c_bus
= &dev
->i2c_bus
[0];
1360 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1361 &dvico_fusionhdtv_xc3028
,
1362 &i2c_bus
->i2c_adap
);
1363 if (fe0
->dvb
.frontend
!= NULL
) {
1364 struct dvb_frontend
*fe
;
1365 struct xc2028_config cfg
= {
1366 .i2c_adap
= &dev
->i2c_bus
[1].i2c_adap
,
1369 static struct xc2028_ctrl ctl
= {
1370 .fname
= XC2028_DEFAULT_FIRMWARE
,
1372 .demod
= XC3028_FE_ZARLINK456
,
1375 fe
= dvb_attach(xc2028_attach
, fe0
->dvb
.frontend
,
1377 if (fe
!= NULL
&& fe
->ops
.tuner_ops
.set_config
!= NULL
)
1378 fe
->ops
.tuner_ops
.set_config(fe
, &ctl
);
1381 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000
:
1382 i2c_bus
= &dev
->i2c_bus
[0];
1384 fe0
->dvb
.frontend
= dvb_attach(zl10353_attach
,
1385 &dvico_fusionhdtv_xc3028
,
1386 &i2c_bus
->i2c_adap
);
1387 if (fe0
->dvb
.frontend
!= NULL
) {
1388 struct dvb_frontend
*fe
;
1389 struct xc4000_config cfg
= {
1390 .i2c_address
= 0x61,
1392 .dvb_amplitude
= 134,
1393 .set_smoothedcvbs
= 1,
1397 fe
= dvb_attach(xc4000_attach
, fe0
->dvb
.frontend
,
1398 &dev
->i2c_bus
[1].i2c_adap
, &cfg
);
1400 printk(KERN_ERR
"%s/2: xc4000 attach failed\n",
1402 goto frontend_detach
;
1406 case CX23885_BOARD_TBS_6920
:
1407 i2c_bus
= &dev
->i2c_bus
[1];
1409 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1410 &tbs_cx24116_config
,
1411 &i2c_bus
->i2c_adap
);
1412 if (fe0
->dvb
.frontend
!= NULL
)
1413 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1416 case CX23885_BOARD_TBS_6980
:
1417 case CX23885_BOARD_TBS_6981
:
1418 i2c_bus
= &dev
->i2c_bus
[1];
1423 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1424 &tbs_cx24117_config
,
1425 &i2c_bus
->i2c_adap
);
1429 fe0
->dvb
.frontend
= dvb_attach(cx24117_attach
,
1430 &tbs_cx24117_config
,
1431 &i2c_bus
->i2c_adap
);
1435 case CX23885_BOARD_TEVII_S470
:
1436 i2c_bus
= &dev
->i2c_bus
[1];
1438 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1439 &tevii_ds3000_config
,
1440 &i2c_bus
->i2c_adap
);
1441 if (fe0
->dvb
.frontend
!= NULL
) {
1442 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1443 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1444 fe0
->dvb
.frontend
->ops
.set_voltage
= f300_set_voltage
;
1448 case CX23885_BOARD_DVBWORLD_2005
:
1449 i2c_bus
= &dev
->i2c_bus
[1];
1451 fe0
->dvb
.frontend
= dvb_attach(cx24116_attach
,
1452 &dvbworld_cx24116_config
,
1453 &i2c_bus
->i2c_adap
);
1455 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
1456 i2c_bus
= &dev
->i2c_bus
[0];
1460 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1461 &netup_stv0900_config
,
1462 &i2c_bus
->i2c_adap
, 0);
1463 if (fe0
->dvb
.frontend
!= NULL
) {
1464 if (dvb_attach(stv6110_attach
,
1466 &netup_stv6110_tunerconfig_a
,
1467 &i2c_bus
->i2c_adap
)) {
1468 if (!dvb_attach(lnbh24_attach
,
1471 LNBH24_PCL
| LNBH24_TTX
,
1474 "No LNBH24 found!\n");
1481 fe0
->dvb
.frontend
= dvb_attach(stv0900_attach
,
1482 &netup_stv0900_config
,
1483 &i2c_bus
->i2c_adap
, 1);
1484 if (fe0
->dvb
.frontend
!= NULL
) {
1485 if (dvb_attach(stv6110_attach
,
1487 &netup_stv6110_tunerconfig_b
,
1488 &i2c_bus
->i2c_adap
)) {
1489 if (!dvb_attach(lnbh24_attach
,
1492 LNBH24_PCL
| LNBH24_TTX
,
1495 "No LNBH24 found!\n");
1502 case CX23885_BOARD_MYGICA_X8506
:
1503 i2c_bus
= &dev
->i2c_bus
[0];
1504 i2c_bus2
= &dev
->i2c_bus
[1];
1505 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1506 &mygica_x8506_lgs8gl5_config
,
1507 &i2c_bus
->i2c_adap
);
1508 if (fe0
->dvb
.frontend
== NULL
)
1510 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1511 &i2c_bus2
->i2c_adap
, &mygica_x8506_xc5000_config
);
1512 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1514 case CX23885_BOARD_MYGICA_X8507
:
1515 i2c_bus
= &dev
->i2c_bus
[0];
1516 i2c_bus2
= &dev
->i2c_bus
[1];
1517 fe0
->dvb
.frontend
= dvb_attach(mb86a20s_attach
,
1518 &mygica_x8507_mb86a20s_config
,
1519 &i2c_bus
->i2c_adap
);
1520 if (fe0
->dvb
.frontend
== NULL
)
1523 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1524 &i2c_bus2
->i2c_adap
,
1525 &mygica_x8507_xc5000_config
);
1526 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1528 case CX23885_BOARD_MAGICPRO_PROHDTVE2
:
1529 i2c_bus
= &dev
->i2c_bus
[0];
1530 i2c_bus2
= &dev
->i2c_bus
[1];
1531 fe0
->dvb
.frontend
= dvb_attach(lgs8gxx_attach
,
1532 &magicpro_prohdtve2_lgs8g75_config
,
1533 &i2c_bus
->i2c_adap
);
1534 if (fe0
->dvb
.frontend
== NULL
)
1536 dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1537 &i2c_bus2
->i2c_adap
,
1538 &magicpro_prohdtve2_xc5000_config
);
1539 cx23885_set_frontend_hook(port
, fe0
->dvb
.frontend
);
1541 case CX23885_BOARD_HAUPPAUGE_HVR1850
:
1542 i2c_bus
= &dev
->i2c_bus
[0];
1543 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1544 &hcw_s5h1411_config
,
1545 &i2c_bus
->i2c_adap
);
1546 if (fe0
->dvb
.frontend
== NULL
)
1548 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1549 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1550 &hauppauge_tda18271_config
);
1552 tda18271_attach(&dev
->ts1
.analog_fe
,
1553 0x60, &dev
->i2c_bus
[1].i2c_adap
,
1554 &hauppauge_tda18271_config
);
1557 case CX23885_BOARD_HAUPPAUGE_HVR1290
:
1558 i2c_bus
= &dev
->i2c_bus
[0];
1559 fe0
->dvb
.frontend
= dvb_attach(s5h1411_attach
,
1560 &hcw_s5h1411_config
,
1561 &i2c_bus
->i2c_adap
);
1562 if (fe0
->dvb
.frontend
== NULL
)
1564 dvb_attach(tda18271_attach
, fe0
->dvb
.frontend
,
1565 0x60, &dev
->i2c_bus
[0].i2c_adap
,
1566 &hauppauge_tda18271_config
);
1568 case CX23885_BOARD_MYGICA_X8558PRO
:
1572 i2c_bus
= &dev
->i2c_bus
[0];
1573 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1574 &mygica_x8558pro_atbm8830_cfg1
,
1575 &i2c_bus
->i2c_adap
);
1576 if (fe0
->dvb
.frontend
== NULL
)
1578 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1580 &mygic_x8558pro_max2165_cfg1
);
1584 i2c_bus
= &dev
->i2c_bus
[1];
1585 fe0
->dvb
.frontend
= dvb_attach(atbm8830_attach
,
1586 &mygica_x8558pro_atbm8830_cfg2
,
1587 &i2c_bus
->i2c_adap
);
1588 if (fe0
->dvb
.frontend
== NULL
)
1590 dvb_attach(max2165_attach
, fe0
->dvb
.frontend
,
1592 &mygic_x8558pro_max2165_cfg2
);
1595 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
1596 i2c_bus
= &dev
->i2c_bus
[0];
1597 mfe_shared
= 1;/* MFE */
1598 port
->frontends
.gate
= 0;/* not clear for me yet */
1600 /* MFE frontend 1 DVB-T */
1601 fe0
->dvb
.frontend
= dvb_attach(stv0367ter_attach
,
1602 &netup_stv0367_config
[port
->nr
- 1],
1603 &i2c_bus
->i2c_adap
);
1604 if (fe0
->dvb
.frontend
== NULL
)
1606 if (NULL
== dvb_attach(xc5000_attach
, fe0
->dvb
.frontend
,
1608 &netup_xc5000_config
[port
->nr
- 1]))
1609 goto frontend_detach
;
1610 /* load xc5000 firmware */
1611 fe0
->dvb
.frontend
->ops
.tuner_ops
.init(fe0
->dvb
.frontend
);
1613 /* MFE frontend 2 */
1614 fe1
= vb2_dvb_get_frontend(&port
->frontends
, 2);
1616 goto frontend_detach
;
1618 fe1
->dvb
.frontend
= dvb_attach(stv0367cab_attach
,
1619 &netup_stv0367_config
[port
->nr
- 1],
1620 &i2c_bus
->i2c_adap
);
1621 if (fe1
->dvb
.frontend
== NULL
)
1624 fe1
->dvb
.frontend
->id
= 1;
1625 if (NULL
== dvb_attach(xc5000_attach
,
1628 &netup_xc5000_config
[port
->nr
- 1]))
1629 goto frontend_detach
;
1631 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL
:
1632 i2c_bus
= &dev
->i2c_bus
[0];
1633 i2c_bus2
= &dev
->i2c_bus
[1];
1638 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1639 &terratec_drxk_config
[0],
1640 &i2c_bus
->i2c_adap
);
1641 if (fe0
->dvb
.frontend
== NULL
)
1643 if (!dvb_attach(mt2063_attach
,
1645 &terratec_mt2063_config
[0],
1646 &i2c_bus2
->i2c_adap
))
1647 goto frontend_detach
;
1651 fe0
->dvb
.frontend
= dvb_attach(drxk_attach
,
1652 &terratec_drxk_config
[1],
1653 &i2c_bus
->i2c_adap
);
1654 if (fe0
->dvb
.frontend
== NULL
)
1656 if (!dvb_attach(mt2063_attach
,
1658 &terratec_mt2063_config
[1],
1659 &i2c_bus2
->i2c_adap
))
1660 goto frontend_detach
;
1664 case CX23885_BOARD_TEVII_S471
:
1665 i2c_bus
= &dev
->i2c_bus
[1];
1667 fe0
->dvb
.frontend
= dvb_attach(ds3000_attach
,
1668 &tevii_ds3000_config
,
1669 &i2c_bus
->i2c_adap
);
1670 if (fe0
->dvb
.frontend
== NULL
)
1672 dvb_attach(ts2020_attach
, fe0
->dvb
.frontend
,
1673 &tevii_ts2020_config
, &i2c_bus
->i2c_adap
);
1675 case CX23885_BOARD_PROF_8000
:
1676 i2c_bus
= &dev
->i2c_bus
[0];
1678 fe0
->dvb
.frontend
= dvb_attach(stv090x_attach
,
1679 &prof_8000_stv090x_config
,
1681 STV090x_DEMODULATOR_0
);
1682 if (fe0
->dvb
.frontend
== NULL
)
1684 if (!dvb_attach(stb6100_attach
,
1686 &prof_8000_stb6100_config
,
1687 &i2c_bus
->i2c_adap
))
1688 goto frontend_detach
;
1690 fe0
->dvb
.frontend
->ops
.set_voltage
= p8000_set_voltage
;
1692 case CX23885_BOARD_HAUPPAUGE_HVR4400
:
1693 i2c_bus
= &dev
->i2c_bus
[0];
1694 i2c_bus2
= &dev
->i2c_bus
[1];
1698 fe0
->dvb
.frontend
= dvb_attach(tda10071_attach
,
1699 &hauppauge_tda10071_config
,
1700 &i2c_bus
->i2c_adap
);
1701 if (fe0
->dvb
.frontend
== NULL
)
1703 if (!dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
1705 &hauppauge_a8293_config
))
1706 goto frontend_detach
;
1710 fe0
->dvb
.frontend
= dvb_attach(si2165_attach
,
1711 &hauppauge_hvr4400_si2165_config
,
1712 &i2c_bus
->i2c_adap
);
1713 if (fe0
->dvb
.frontend
== NULL
)
1715 fe0
->dvb
.frontend
->ops
.i2c_gate_ctrl
= NULL
;
1716 if (!dvb_attach(tda18271_attach
,
1718 0x60, &i2c_bus2
->i2c_adap
,
1719 &hauppauge_hvr4400_tuner_config
))
1720 goto frontend_detach
;
1724 case CX23885_BOARD_HAUPPAUGE_STARBURST
:
1725 i2c_bus
= &dev
->i2c_bus
[0];
1726 fe0
->dvb
.frontend
= dvb_attach(tda10071_attach
,
1727 &hauppauge_tda10071_config
,
1728 &i2c_bus
->i2c_adap
);
1729 if (fe0
->dvb
.frontend
!= NULL
) {
1730 dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
1732 &hauppauge_a8293_config
);
1735 case CX23885_BOARD_DVBSKY_T9580
:
1736 case CX23885_BOARD_DVBSKY_S950
:
1737 i2c_bus
= &dev
->i2c_bus
[0];
1738 i2c_bus2
= &dev
->i2c_bus
[1];
1740 /* port b - satellite */
1742 /* attach frontend */
1743 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1744 &dvbsky_t9580_m88ds3103_config
,
1745 &i2c_bus2
->i2c_adap
, &adapter
);
1746 if (fe0
->dvb
.frontend
== NULL
)
1750 memset(&m88ts2022_config
, 0, sizeof(m88ts2022_config
));
1751 m88ts2022_config
.fe
= fe0
->dvb
.frontend
;
1752 m88ts2022_config
.clock
= 27000000;
1753 memset(&info
, 0, sizeof(struct i2c_board_info
));
1754 strlcpy(info
.type
, "m88ts2022", I2C_NAME_SIZE
);
1756 info
.platform_data
= &m88ts2022_config
;
1757 request_module(info
.type
);
1758 client_tuner
= i2c_new_device(adapter
, &info
);
1759 if (client_tuner
== NULL
||
1760 client_tuner
->dev
.driver
== NULL
)
1761 goto frontend_detach
;
1762 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1763 i2c_unregister_device(client_tuner
);
1764 goto frontend_detach
;
1767 /* delegate signal strength measurement to tuner */
1768 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1769 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1772 * for setting the voltage we need to set GPIOs on
1775 port
->fe_set_voltage
=
1776 fe0
->dvb
.frontend
->ops
.set_voltage
;
1777 fe0
->dvb
.frontend
->ops
.set_voltage
=
1778 dvbsky_t9580_set_voltage
;
1780 port
->i2c_client_tuner
= client_tuner
;
1783 /* port c - terrestrial/cable */
1785 /* attach frontend */
1786 memset(&si2168_config
, 0, sizeof(si2168_config
));
1787 si2168_config
.i2c_adapter
= &adapter
;
1788 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1789 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1790 memset(&info
, 0, sizeof(struct i2c_board_info
));
1791 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1793 info
.platform_data
= &si2168_config
;
1794 request_module(info
.type
);
1795 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1796 if (client_demod
== NULL
||
1797 client_demod
->dev
.driver
== NULL
)
1798 goto frontend_detach
;
1799 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1800 i2c_unregister_device(client_demod
);
1801 goto frontend_detach
;
1803 port
->i2c_client_demod
= client_demod
;
1806 memset(&si2157_config
, 0, sizeof(si2157_config
));
1807 si2157_config
.fe
= fe0
->dvb
.frontend
;
1808 memset(&info
, 0, sizeof(struct i2c_board_info
));
1809 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
1811 info
.platform_data
= &si2157_config
;
1812 request_module(info
.type
);
1813 client_tuner
= i2c_new_device(adapter
, &info
);
1814 if (client_tuner
== NULL
||
1815 client_tuner
->dev
.driver
== NULL
) {
1816 module_put(client_demod
->dev
.driver
->owner
);
1817 i2c_unregister_device(client_demod
);
1818 port
->i2c_client_demod
= NULL
;
1819 goto frontend_detach
;
1821 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1822 i2c_unregister_device(client_tuner
);
1823 module_put(client_demod
->dev
.driver
->owner
);
1824 i2c_unregister_device(client_demod
);
1825 port
->i2c_client_demod
= NULL
;
1826 goto frontend_detach
;
1828 port
->i2c_client_tuner
= client_tuner
;
1832 case CX23885_BOARD_DVBSKY_T980C
:
1833 case CX23885_BOARD_TT_CT2_4500_CI
:
1834 i2c_bus
= &dev
->i2c_bus
[1];
1835 i2c_bus2
= &dev
->i2c_bus
[0];
1837 /* attach frontend */
1838 memset(&si2168_config
, 0, sizeof(si2168_config
));
1839 si2168_config
.i2c_adapter
= &adapter
;
1840 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1841 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
1842 memset(&info
, 0, sizeof(struct i2c_board_info
));
1843 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1845 info
.platform_data
= &si2168_config
;
1846 request_module(info
.type
);
1847 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1848 if (client_demod
== NULL
|| client_demod
->dev
.driver
== NULL
)
1849 goto frontend_detach
;
1850 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1851 i2c_unregister_device(client_demod
);
1852 goto frontend_detach
;
1854 port
->i2c_client_demod
= client_demod
;
1857 memset(&si2157_config
, 0, sizeof(si2157_config
));
1858 si2157_config
.fe
= fe0
->dvb
.frontend
;
1859 memset(&info
, 0, sizeof(struct i2c_board_info
));
1860 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
1862 info
.platform_data
= &si2157_config
;
1863 request_module(info
.type
);
1864 client_tuner
= i2c_new_device(adapter
, &info
);
1865 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
) {
1866 module_put(client_demod
->dev
.driver
->owner
);
1867 i2c_unregister_device(client_demod
);
1868 port
->i2c_client_demod
= NULL
;
1869 goto frontend_detach
;
1871 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1872 i2c_unregister_device(client_tuner
);
1873 module_put(client_demod
->dev
.driver
->owner
);
1874 i2c_unregister_device(client_demod
);
1875 port
->i2c_client_demod
= NULL
;
1876 goto frontend_detach
;
1878 port
->i2c_client_tuner
= client_tuner
;
1880 case CX23885_BOARD_DVBSKY_S950C
:
1881 i2c_bus
= &dev
->i2c_bus
[1];
1882 i2c_bus2
= &dev
->i2c_bus
[0];
1884 /* attach frontend */
1885 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1886 &dvbsky_s950c_m88ds3103_config
,
1887 &i2c_bus
->i2c_adap
, &adapter
);
1888 if (fe0
->dvb
.frontend
== NULL
)
1892 memset(&m88ts2022_config
, 0, sizeof(m88ts2022_config
));
1893 m88ts2022_config
.fe
= fe0
->dvb
.frontend
;
1894 m88ts2022_config
.clock
= 27000000;
1895 memset(&info
, 0, sizeof(struct i2c_board_info
));
1896 strlcpy(info
.type
, "m88ts2022", I2C_NAME_SIZE
);
1898 info
.platform_data
= &m88ts2022_config
;
1899 request_module(info
.type
);
1900 client_tuner
= i2c_new_device(adapter
, &info
);
1901 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
)
1902 goto frontend_detach
;
1903 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1904 i2c_unregister_device(client_tuner
);
1905 goto frontend_detach
;
1908 /* delegate signal strength measurement to tuner */
1909 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1910 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1912 port
->i2c_client_tuner
= client_tuner
;
1914 case CX23885_BOARD_DVBSKY_S952
:
1918 i2c_bus
= &dev
->i2c_bus
[1];
1919 p_m88ds3103_config
= &dvbsky_t9580_m88ds3103_config
;
1920 p_set_voltage
= dvbsky_t9580_set_voltage
;
1924 i2c_bus
= &dev
->i2c_bus
[0];
1925 p_m88ds3103_config
= &dvbsky_s952_portc_m88ds3103_config
;
1926 p_set_voltage
= dvbsky_s952_portc_set_voltage
;
1930 /* attach frontend */
1931 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
1933 &i2c_bus
->i2c_adap
, &adapter
);
1934 if (fe0
->dvb
.frontend
== NULL
)
1938 memset(&m88ts2022_config
, 0, sizeof(m88ts2022_config
));
1939 m88ts2022_config
.fe
= fe0
->dvb
.frontend
;
1940 m88ts2022_config
.clock
= 27000000;
1941 memset(&info
, 0, sizeof(struct i2c_board_info
));
1942 strlcpy(info
.type
, "m88ts2022", I2C_NAME_SIZE
);
1944 info
.platform_data
= &m88ts2022_config
;
1945 request_module(info
.type
);
1946 client_tuner
= i2c_new_device(adapter
, &info
);
1947 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
)
1948 goto frontend_detach
;
1949 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
1950 i2c_unregister_device(client_tuner
);
1951 goto frontend_detach
;
1954 /* delegate signal strength measurement to tuner */
1955 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
1956 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
1959 * for setting the voltage we need to set GPIOs on
1962 port
->fe_set_voltage
=
1963 fe0
->dvb
.frontend
->ops
.set_voltage
;
1964 fe0
->dvb
.frontend
->ops
.set_voltage
= p_set_voltage
;
1966 port
->i2c_client_tuner
= client_tuner
;
1968 case CX23885_BOARD_DVBSKY_T982
:
1969 memset(&si2168_config
, 0, sizeof(si2168_config
));
1973 i2c_bus
= &dev
->i2c_bus
[1];
1974 si2168_config
.ts_mode
= SI2168_TS_PARALLEL
;
1978 i2c_bus
= &dev
->i2c_bus
[0];
1979 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
1983 /* attach frontend */
1984 si2168_config
.i2c_adapter
= &adapter
;
1985 si2168_config
.fe
= &fe0
->dvb
.frontend
;
1986 memset(&info
, 0, sizeof(struct i2c_board_info
));
1987 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
1989 info
.platform_data
= &si2168_config
;
1990 request_module(info
.type
);
1991 client_demod
= i2c_new_device(&i2c_bus
->i2c_adap
, &info
);
1992 if (client_demod
== NULL
|| client_demod
->dev
.driver
== NULL
)
1993 goto frontend_detach
;
1994 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
1995 i2c_unregister_device(client_demod
);
1996 goto frontend_detach
;
1998 port
->i2c_client_demod
= client_demod
;
2001 memset(&si2157_config
, 0, sizeof(si2157_config
));
2002 si2157_config
.fe
= fe0
->dvb
.frontend
;
2003 memset(&info
, 0, sizeof(struct i2c_board_info
));
2004 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2006 info
.platform_data
= &si2157_config
;
2007 request_module(info
.type
);
2008 client_tuner
= i2c_new_device(adapter
, &info
);
2009 if (client_tuner
== NULL
|| client_tuner
->dev
.driver
== NULL
) {
2010 module_put(client_demod
->dev
.driver
->owner
);
2011 i2c_unregister_device(client_demod
);
2012 port
->i2c_client_demod
= NULL
;
2013 goto frontend_detach
;
2015 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2016 i2c_unregister_device(client_tuner
);
2017 module_put(client_demod
->dev
.driver
->owner
);
2018 i2c_unregister_device(client_demod
);
2019 port
->i2c_client_demod
= NULL
;
2020 goto frontend_detach
;
2022 port
->i2c_client_tuner
= client_tuner
;
2024 case CX23885_BOARD_HAUPPAUGE_HVR5525
:
2026 struct m88rs6000t_config m88rs6000t_config
;
2028 /* port b - satellite */
2030 /* attach frontend */
2031 fe0
->dvb
.frontend
= dvb_attach(m88ds3103_attach
,
2032 &hauppauge_hvr5525_m88ds3103_config
,
2033 &dev
->i2c_bus
[0].i2c_adap
, &adapter
);
2034 if (fe0
->dvb
.frontend
== NULL
)
2038 if (!dvb_attach(a8293_attach
, fe0
->dvb
.frontend
,
2039 &dev
->i2c_bus
[0].i2c_adap
,
2040 &hauppauge_a8293_config
))
2041 goto frontend_detach
;
2044 memset(&m88rs6000t_config
, 0, sizeof(m88rs6000t_config
));
2045 m88rs6000t_config
.fe
= fe0
->dvb
.frontend
;
2046 memset(&info
, 0, sizeof(struct i2c_board_info
));
2047 strlcpy(info
.type
, "m88rs6000t", I2C_NAME_SIZE
);
2049 info
.platform_data
= &m88rs6000t_config
;
2050 request_module("%s", info
.type
);
2051 client_tuner
= i2c_new_device(adapter
, &info
);
2052 if (!client_tuner
|| !client_tuner
->dev
.driver
)
2053 goto frontend_detach
;
2054 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2055 i2c_unregister_device(client_tuner
);
2056 goto frontend_detach
;
2058 port
->i2c_client_tuner
= client_tuner
;
2060 /* delegate signal strength measurement to tuner */
2061 fe0
->dvb
.frontend
->ops
.read_signal_strength
=
2062 fe0
->dvb
.frontend
->ops
.tuner_ops
.get_rf_strength
;
2064 /* port c - terrestrial/cable */
2066 /* attach frontend */
2067 memset(&si2168_config
, 0, sizeof(si2168_config
));
2068 si2168_config
.i2c_adapter
= &adapter
;
2069 si2168_config
.fe
= &fe0
->dvb
.frontend
;
2070 si2168_config
.ts_mode
= SI2168_TS_SERIAL
;
2071 memset(&info
, 0, sizeof(struct i2c_board_info
));
2072 strlcpy(info
.type
, "si2168", I2C_NAME_SIZE
);
2074 info
.platform_data
= &si2168_config
;
2075 request_module("%s", info
.type
);
2076 client_demod
= i2c_new_device(&dev
->i2c_bus
[0].i2c_adap
, &info
);
2077 if (!client_demod
|| !client_demod
->dev
.driver
)
2078 goto frontend_detach
;
2079 if (!try_module_get(client_demod
->dev
.driver
->owner
)) {
2080 i2c_unregister_device(client_demod
);
2081 goto frontend_detach
;
2083 port
->i2c_client_demod
= client_demod
;
2086 memset(&si2157_config
, 0, sizeof(si2157_config
));
2087 si2157_config
.fe
= fe0
->dvb
.frontend
;
2088 memset(&info
, 0, sizeof(struct i2c_board_info
));
2089 strlcpy(info
.type
, "si2157", I2C_NAME_SIZE
);
2091 info
.platform_data
= &si2157_config
;
2092 request_module("%s", info
.type
);
2093 client_tuner
= i2c_new_device(&dev
->i2c_bus
[1].i2c_adap
, &info
);
2094 if (!client_tuner
|| !client_tuner
->dev
.driver
) {
2095 module_put(client_demod
->dev
.driver
->owner
);
2096 i2c_unregister_device(client_demod
);
2097 port
->i2c_client_demod
= NULL
;
2098 goto frontend_detach
;
2100 if (!try_module_get(client_tuner
->dev
.driver
->owner
)) {
2101 i2c_unregister_device(client_tuner
);
2102 module_put(client_demod
->dev
.driver
->owner
);
2103 i2c_unregister_device(client_demod
);
2104 port
->i2c_client_demod
= NULL
;
2105 goto frontend_detach
;
2107 port
->i2c_client_tuner
= client_tuner
;
2112 printk(KERN_INFO
"%s: The frontend of your DVB/ATSC card "
2113 " isn't supported yet\n",
2118 if ((NULL
== fe0
->dvb
.frontend
) || (fe1
&& NULL
== fe1
->dvb
.frontend
)) {
2119 printk(KERN_ERR
"%s: frontend initialization failed\n",
2121 goto frontend_detach
;
2124 /* define general-purpose callback pointer */
2125 fe0
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2127 fe1
->dvb
.frontend
->callback
= cx23885_tuner_callback
;
2129 /* Ensure all frontends negotiate bus access */
2130 fe0
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2132 fe1
->dvb
.frontend
->ops
.ts_bus_ctrl
= cx23885_dvb_bus_ctrl
;
2135 /* Put the analog decoder in standby to keep it quiet */
2136 call_all(dev
, core
, s_power
, 0);
2138 if (fe0
->dvb
.frontend
->ops
.analog_ops
.standby
)
2139 fe0
->dvb
.frontend
->ops
.analog_ops
.standby(fe0
->dvb
.frontend
);
2141 /* register everything */
2142 ret
= vb2_dvb_register_bus(&port
->frontends
, THIS_MODULE
, port
,
2143 &dev
->pci
->dev
, adapter_nr
, mfe_shared
);
2145 goto frontend_detach
;
2148 switch (dev
->board
) {
2149 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
: {
2150 static struct netup_card_info cinfo
;
2152 netup_get_card_info(&dev
->i2c_bus
[0].i2c_adap
, &cinfo
);
2153 memcpy(port
->frontends
.adapter
.proposed_mac
,
2154 cinfo
.port
[port
->nr
- 1].mac
, 6);
2155 printk(KERN_INFO
"NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
2156 port
->nr
, port
->frontends
.adapter
.proposed_mac
);
2158 netup_ci_init(port
);
2161 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
: {
2162 struct altera_ci_config netup_ci_cfg
= {
2163 .dev
= dev
,/* magic number to identify*/
2164 .adapter
= &port
->frontends
.adapter
,/* for CI */
2165 .demux
= &fe0
->dvb
.demux
,/* for hw pid filter */
2166 .fpga_rw
= netup_altera_fpga_rw
,
2169 altera_ci_init(&netup_ci_cfg
, port
->nr
);
2172 case CX23885_BOARD_TEVII_S470
: {
2173 u8 eeprom
[256]; /* 24C02 i2c eeprom */
2178 /* Read entire EEPROM */
2179 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
2180 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
, sizeof(eeprom
));
2181 printk(KERN_INFO
"TeVii S470 MAC= %pM\n", eeprom
+ 0xa0);
2182 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xa0, 6);
2185 case CX23885_BOARD_DVBSKY_T9580
:
2186 case CX23885_BOARD_DVBSKY_S950
:
2187 case CX23885_BOARD_DVBSKY_S952
:
2188 case CX23885_BOARD_DVBSKY_T982
: {
2189 u8 eeprom
[256]; /* 24C02 i2c eeprom */
2194 /* Read entire EEPROM */
2195 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
2196 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
2198 printk(KERN_INFO
"%s port %d MAC address: %pM\n",
2199 cx23885_boards
[dev
->board
].name
, port
->nr
,
2200 eeprom
+ 0xc0 + (port
->nr
-1) * 8);
2201 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0 +
2202 (port
->nr
-1) * 8, 6);
2205 case CX23885_BOARD_DVBSKY_S950C
:
2206 case CX23885_BOARD_DVBSKY_T980C
:
2207 case CX23885_BOARD_TT_CT2_4500_CI
: {
2208 u8 eeprom
[256]; /* 24C02 i2c eeprom */
2211 memset(&sp2_config
, 0, sizeof(sp2_config
));
2212 sp2_config
.dvb_adap
= &port
->frontends
.adapter
;
2213 sp2_config
.priv
= port
;
2214 sp2_config
.ci_control
= cx23885_sp2_ci_ctrl
;
2215 memset(&info
, 0, sizeof(struct i2c_board_info
));
2216 strlcpy(info
.type
, "sp2", I2C_NAME_SIZE
);
2218 info
.platform_data
= &sp2_config
;
2219 request_module(info
.type
);
2220 client_ci
= i2c_new_device(&i2c_bus2
->i2c_adap
, &info
);
2221 if (client_ci
== NULL
|| client_ci
->dev
.driver
== NULL
) {
2223 module_put(client_tuner
->dev
.driver
->owner
);
2224 i2c_unregister_device(client_tuner
);
2227 module_put(client_demod
->dev
.driver
->owner
);
2228 i2c_unregister_device(client_demod
);
2230 goto frontend_detach
;
2232 if (!try_module_get(client_ci
->dev
.driver
->owner
)) {
2233 i2c_unregister_device(client_ci
);
2235 module_put(client_tuner
->dev
.driver
->owner
);
2236 i2c_unregister_device(client_tuner
);
2239 module_put(client_demod
->dev
.driver
->owner
);
2240 i2c_unregister_device(client_demod
);
2242 goto frontend_detach
;
2244 port
->i2c_client_ci
= client_ci
;
2249 /* Read entire EEPROM */
2250 dev
->i2c_bus
[0].i2c_client
.addr
= 0xa0 >> 1;
2251 tveeprom_read(&dev
->i2c_bus
[0].i2c_client
, eeprom
,
2253 printk(KERN_INFO
"%s MAC address: %pM\n",
2254 cx23885_boards
[dev
->board
].name
, eeprom
+ 0xc0);
2255 memcpy(port
->frontends
.adapter
.proposed_mac
, eeprom
+ 0xc0, 6);
2263 port
->gate_ctrl
= NULL
;
2264 vb2_dvb_dealloc_frontends(&port
->frontends
);
2268 int cx23885_dvb_register(struct cx23885_tsport
*port
)
2271 struct vb2_dvb_frontend
*fe0
;
2272 struct cx23885_dev
*dev
= port
->dev
;
2275 /* Here we need to allocate the correct number of frontends,
2276 * as reflected in the cards struct. The reality is that currently
2277 * no cx23885 boards support this - yet. But, if we don't modify this
2278 * code then the second frontend would never be allocated (later)
2279 * and fail with error before the attach in dvb_register().
2280 * Without these changes we risk an OOPS later. The changes here
2281 * are for safety, and should provide a good foundation for the
2282 * future addition of any multi-frontend cx23885 based boards.
2284 printk(KERN_INFO
"%s() allocating %d frontend(s)\n", __func__
,
2285 port
->num_frontends
);
2287 for (i
= 1; i
<= port
->num_frontends
; i
++) {
2288 struct vb2_queue
*q
;
2290 if (vb2_dvb_alloc_frontend(
2291 &port
->frontends
, i
) == NULL
) {
2292 printk(KERN_ERR
"%s() failed to alloc\n", __func__
);
2296 fe0
= vb2_dvb_get_frontend(&port
->frontends
, i
);
2300 dprintk(1, "%s\n", __func__
);
2301 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2310 /* We have to init the queue for each frontend on a port. */
2311 printk(KERN_INFO
"%s: cx23885 based dvb card\n", dev
->name
);
2313 q
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
2314 q
->io_modes
= VB2_MMAP
| VB2_USERPTR
| VB2_DMABUF
| VB2_READ
;
2315 q
->gfp_flags
= GFP_DMA32
;
2316 q
->min_buffers_needed
= 2;
2318 q
->buf_struct_size
= sizeof(struct cx23885_buffer
);
2320 q
->mem_ops
= &vb2_dma_sg_memops
;
2321 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
2322 q
->lock
= &dev
->lock
;
2324 err
= vb2_queue_init(q
);
2328 err
= dvb_register(port
);
2330 printk(KERN_ERR
"%s() dvb_register failed err = %d\n",
2336 int cx23885_dvb_unregister(struct cx23885_tsport
*port
)
2338 struct vb2_dvb_frontend
*fe0
;
2339 struct i2c_client
*client
;
2341 /* remove I2C client for CI */
2342 client
= port
->i2c_client_ci
;
2344 module_put(client
->dev
.driver
->owner
);
2345 i2c_unregister_device(client
);
2348 /* remove I2C client for tuner */
2349 client
= port
->i2c_client_tuner
;
2351 module_put(client
->dev
.driver
->owner
);
2352 i2c_unregister_device(client
);
2355 /* remove I2C client for demodulator */
2356 client
= port
->i2c_client_demod
;
2358 module_put(client
->dev
.driver
->owner
);
2359 i2c_unregister_device(client
);
2362 fe0
= vb2_dvb_get_frontend(&port
->frontends
, 1);
2364 if (fe0
&& fe0
->dvb
.frontend
)
2365 vb2_dvb_unregister_bus(&port
->frontends
);
2367 switch (port
->dev
->board
) {
2368 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI
:
2369 netup_ci_exit(port
);
2371 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF
:
2372 altera_ci_release(port
->dev
, port
->nr
);
2376 port
->gate_ctrl
= NULL
;