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 <media/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_CONTINUOUS_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_CONTINUOUS_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_CONTINUOUS_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_CONTINUOUS_NONINVERTING_CLOCK,
250 static struct mt2131_config hauppauge_generic_tunerconfig = {
254 static struct lgdt330x_config fusionhdtv_5_express = {
255 .demod_chip = LGDT3303,
259 static struct s5h1409_config hauppauge_hvr1500q_config = {
260 .demod_address = 0x32 >> 1,
261 .output_mode = S5H1409_SERIAL_OUTPUT,
262 .gpio = S5H1409_GPIO_ON,
264 .inversion = S5H1409_INVERSION_OFF,
265 .status_mode = S5H1409_DEMODLOCKING,
266 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
269 static struct s5h1409_config dvico_s5h1409_config = {
270 .demod_address = 0x32 >> 1,
271 .output_mode = S5H1409_SERIAL_OUTPUT,
272 .gpio = S5H1409_GPIO_ON,
274 .inversion = S5H1409_INVERSION_OFF,
275 .status_mode = S5H1409_DEMODLOCKING,
276 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
279 static struct s5h1411_config dvico_s5h1411_config = {
280 .output_mode = S5H1411_SERIAL_OUTPUT,
281 .gpio = S5H1411_GPIO_ON,
282 .qam_if = S5H1411_IF_44000,
283 .vsb_if = S5H1411_IF_44000,
284 .inversion = S5H1411_INVERSION_OFF,
285 .status_mode = S5H1411_DEMODLOCKING,
286 .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
289 static struct s5h1411_config hcw_s5h1411_config = {
290 .output_mode = S5H1411_SERIAL_OUTPUT,
291 .gpio = S5H1411_GPIO_OFF,
292 .vsb_if = S5H1411_IF_44000,
293 .qam_if = S5H1411_IF_4000,
294 .inversion = S5H1411_INVERSION_ON,
295 .status_mode = S5H1411_DEMODLOCKING,
296 .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
299 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
304 static struct xc5000_config dvico_xc5000_tunerconfig = {
309 static struct tda829x_config tda829x_no_probe = {
310 .probe_tuner = TDA829X_DONT_PROBE,
313 static struct tda18271_std_map hauppauge_tda18271_std_map = {
314 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
315 .if_lvl = 6, .rfagc_top = 0x37 },
316 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
317 .if_lvl = 6, .rfagc_top = 0x37 },
320 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
321 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
322 .if_lvl = 1, .rfagc_top = 0x37, },
323 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
324 .if_lvl = 1, .rfagc_top = 0x37, },
325 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
326 .if_lvl = 1, .rfagc_top = 0x37, },
329 static struct tda18271_config hauppauge_tda18271_config = {
330 .std_map = &hauppauge_tda18271_std_map,
331 .gate = TDA18271_GATE_ANALOG,
332 .output_opt = TDA18271_OUTPUT_LT_OFF,
335 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
336 .std_map = &hauppauge_hvr1200_tda18271_std_map,
337 .gate = TDA18271_GATE_ANALOG,
338 .output_opt = TDA18271_OUTPUT_LT_OFF,
341 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
342 .gate = TDA18271_GATE_DIGITAL,
343 .output_opt = TDA18271_OUTPUT_LT_OFF,
346 static struct tda18271_config hauppauge_hvr4400_tuner_config = {
347 .gate = TDA18271_GATE_DIGITAL,
348 .output_opt = TDA18271_OUTPUT_LT_OFF,
351 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
352 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
353 .if_lvl = 1, .rfagc_top = 0x58 },
354 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
355 .if_lvl = 1, .rfagc_top = 0x58 },
358 static struct tda18271_config hauppauge_hvr127x_config = {
359 .std_map = &hauppauge_hvr127x_std_map,
360 .output_opt = TDA18271_OUTPUT_LT_OFF,
363 static struct lgdt3305_config hauppauge_lgdt3305_config = {
365 .mpeg_mode = LGDT3305_MPEG_SERIAL,
366 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
367 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
369 .spectral_inversion = 1,
374 static struct dibx000_agc_config xc3028_agc_config = {
375 BAND_VHF | BAND_UHF, /* band_caps */
377 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
378 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
379 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
380 * P_agc_nb_est=2, P_agc_write=0
382 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
383 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
386 21, /* time_stabiliz */
398 39718, /* agc2_max */
407 29, /* agc2_slope1 */
408 29, /* agc2_slope2 */
415 1, /* perform_agc_softsplit */
418 /* PLL Configuration for COFDM BW_MHz = 8.000000
419 * With external clock = 30.000000 */
420 static struct dibx000_bandwidth_config xc3028_bw_config = {
421 60000, /* internal */
422 30000, /* sampling */
423 1, /* pll_cfg: prediv */
424 8, /* pll_cfg: ratio */
425 3, /* pll_cfg: range */
426 1, /* pll_cfg: reset */
427 0, /* pll_cfg: bypass */
428 0, /* misc: refdiv */
429 0, /* misc: bypclk_div */
430 1, /* misc: IO_CLK_en_core */
431 1, /* misc: ADClkSrc */
432 0, /* misc: modulo */
433 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
434 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
436 30000000 /* xtal_hz */
439 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
440 .output_mpeg2_in_188_bytes = 1,
441 .hostbus_diversity = 1,
442 .tuner_is_baseband = 0,
445 .agc_config_count = 1,
446 .agc = &xc3028_agc_config,
447 .bw = &xc3028_bw_config,
449 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
450 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
451 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
457 .output_mode = OUTMODE_MPEG2_SERIAL,
460 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
461 .demod_address = 0x0f,
464 .disable_i2c_gate_ctrl = 1,
467 static struct stv0900_reg stv0900_ts_regs[] = {
468 { R0900_TSGENERAL, 0x00 },
469 { R0900_P1_TSSPEED, 0x40 },
470 { R0900_P2_TSSPEED, 0x40 },
471 { R0900_P1_TSCFGM, 0xc0 },
472 { R0900_P2_TSCFGM, 0xc0 },
473 { R0900_P1_TSCFGH, 0xe0 },
474 { R0900_P2_TSCFGH, 0xe0 },
475 { R0900_P1_TSCFGL, 0x20 },
476 { R0900_P2_TSCFGL, 0x20 },
477 { 0xffff, 0xff }, /* terminate */
480 static struct stv0900_config netup_stv0900_config = {
481 .demod_address = 0x68,
482 .demod_mode = 1, /* dual */
484 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
485 .diseqc_mode = 2,/* 2/3 PWM */
486 .ts_config_regs = stv0900_ts_regs,
487 .tun1_maddress = 0,/* 0x60 */
488 .tun2_maddress = 3,/* 0x63 */
489 .tun1_adc = 1,/* 1 Vpp */
490 .tun2_adc = 1,/* 1 Vpp */
493 static struct stv6110_config netup_stv6110_tunerconfig_a = {
497 .gain = 8, /* +16 dB - maximum gain */
500 static struct stv6110_config netup_stv6110_tunerconfig_b = {
504 .gain = 8, /* +16 dB - maximum gain */
507 static struct cx24116_config tbs_cx24116_config = {
508 .demod_address = 0x55,
511 static struct cx24117_config tbs_cx24117_config = {
512 .demod_address = 0x55,
515 static struct ds3000_config tevii_ds3000_config = {
516 .demod_address = 0x68,
519 static struct ts2020_config tevii_ts2020_config = {
520 .tuner_address = 0x60,
522 .frequency_div = 1146000,
525 static struct cx24116_config dvbworld_cx24116_config = {
526 .demod_address = 0x05,
529 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
530 .prod = LGS8GXX_PROD_LGS8GL5,
531 .demod_address = 0x19,
535 .if_clk_freq = 30400, /* 30.4 MHz */
536 .if_freq = 5380, /* 5.38 MHz */
543 static struct xc5000_config mygica_x8506_xc5000_config = {
548 static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
549 .demod_address = 0x10,
552 static struct xc5000_config mygica_x8507_xc5000_config = {
557 static struct stv090x_config prof_8000_stv090x_config = {
559 .demod_mode = STV090x_SINGLE,
560 .clk_mode = STV090x_CLK_EXT,
563 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
564 .repeater_level = STV090x_RPTLEVEL_64,
565 .adc1_range = STV090x_ADC_2Vpp,
566 .diseqc_envelope_mode = false,
568 .tuner_get_frequency = stb6100_get_frequency,
569 .tuner_set_frequency = stb6100_set_frequency,
570 .tuner_set_bandwidth = stb6100_set_bandwidth,
571 .tuner_get_bandwidth = stb6100_get_bandwidth,
574 static struct stb6100_config prof_8000_stb6100_config = {
575 .tuner_address = 0x60,
576 .refclock = 27000000,
579 static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config = {
583 .deny_i2c_rptr = 1, /* Disabled */
584 .spectral_inversion = 0, /* Disabled */
585 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
586 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
587 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
588 .xtalMHz = 25, /* 24 or 25 */
591 static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config = {
595 .deny_i2c_rptr = 1, /* Disabled */
596 .spectral_inversion = 0, /* Disabled */
597 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
598 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
599 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
600 .xtalMHz = 25, /* 24 or 25 */
603 static int p8000_set_voltage(struct dvb_frontend *fe,
604 enum fe_sec_voltage voltage)
606 struct cx23885_tsport *port = fe->dvb->priv;
607 struct cx23885_dev *dev = port->dev;
609 if (voltage == SEC_VOLTAGE_18)
610 cx_write(MC417_RWD, 0x00001e00);
611 else if (voltage == SEC_VOLTAGE_13)
612 cx_write(MC417_RWD, 0x00001a00);
614 cx_write(MC417_RWD, 0x00001800);
618 static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
619 enum fe_sec_voltage voltage)
621 struct cx23885_tsport *port = fe->dvb->priv;
622 struct cx23885_dev *dev = port->dev;
624 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
628 cx23885_gpio_set(dev, GPIO_1);
629 cx23885_gpio_clear(dev, GPIO_0);
632 cx23885_gpio_set(dev, GPIO_1);
633 cx23885_gpio_set(dev, GPIO_0);
635 case SEC_VOLTAGE_OFF:
636 cx23885_gpio_clear(dev, GPIO_1);
637 cx23885_gpio_clear(dev, GPIO_0);
641 /* call the frontend set_voltage function */
642 port->fe_set_voltage(fe, voltage);
647 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
648 enum fe_sec_voltage voltage)
650 struct cx23885_tsport *port = fe->dvb->priv;
651 struct cx23885_dev *dev = port->dev;
653 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
657 cx23885_gpio_set(dev, GPIO_13);
658 cx23885_gpio_clear(dev, GPIO_12);
661 cx23885_gpio_set(dev, GPIO_13);
662 cx23885_gpio_set(dev, GPIO_12);
664 case SEC_VOLTAGE_OFF:
665 cx23885_gpio_clear(dev, GPIO_13);
666 cx23885_gpio_clear(dev, GPIO_12);
669 /* call the frontend set_voltage function */
670 return port->fe_set_voltage(fe, voltage);
673 static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
677 #define SP2_DATA 0x000000ff
678 #define SP2_WR 0x00008000
679 #define SP2_RD 0x00004000
680 #define SP2_ACK 0x00001000
681 #define SP2_ADHI 0x00000800
682 #define SP2_ADLO 0x00000400
683 #define SP2_CS1 0x00000200
684 #define SP2_CS0 0x00000100
685 #define SP2_EN_ALL 0x00001000
686 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
688 struct cx23885_tsport *port = priv;
689 struct cx23885_dev *dev = port->dev;
692 unsigned long timeout;
694 mutex_lock(&dev->gpio_lock);
697 cx_write(MC417_OEN, SP2_EN_ALL);
698 cx_write(MC417_RWD, SP2_CTRL_OFF |
699 SP2_ADLO | (0xff & addr));
700 cx_clear(MC417_RWD, SP2_ADLO);
701 cx_write(MC417_RWD, SP2_CTRL_OFF |
702 SP2_ADHI | (0xff & (addr >> 8)));
703 cx_clear(MC417_RWD, SP2_ADHI);
707 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
710 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
713 cx_clear(MC417_RWD, SP2_CS0);
716 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
718 /* wait for a maximum of 1 msec */
719 timeout = jiffies + msecs_to_jiffies(1);
720 while (!time_after(jiffies, timeout)) {
721 tmp = cx_read(MC417_RWD);
722 if ((tmp & SP2_ACK) == 0)
724 usleep_range(50, 100);
727 cx_set(MC417_RWD, SP2_CTRL_OFF);
730 mutex_unlock(&dev->gpio_lock);
744 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
746 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
747 struct cx23885_tsport *port = fe->dvb->priv;
748 struct cx23885_dev *dev = port->dev;
750 switch (dev->board) {
751 case CX23885_BOARD_HAUPPAUGE_HVR1275:
752 switch (p->modulation) {
754 cx23885_gpio_clear(dev, GPIO_5);
759 cx23885_gpio_set(dev, GPIO_5);
763 case CX23885_BOARD_MYGICA_X8506:
764 case CX23885_BOARD_MYGICA_X8507:
765 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
766 /* Select Digital TV */
767 cx23885_gpio_set(dev, GPIO_0);
771 /* Call the real set_frontend */
772 if (port->set_frontend)
773 return port->set_frontend(fe);
778 static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
779 struct dvb_frontend *fe)
781 port->set_frontend = fe->ops.set_frontend;
782 fe->ops.set_frontend = cx23885_dvb_set_frontend;
785 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
786 .prod = LGS8GXX_PROD_LGS8G75,
787 .demod_address = 0x19,
791 .if_clk_freq = 30400, /* 30.4 MHz */
792 .if_freq = 6500, /* 6.50 MHz */
796 .adc_vpp = 2, /* 1.6 Vpp */
800 static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
805 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
806 .prod = ATBM8830_PROD_8830,
807 .demod_address = 0x44,
809 .ts_sampling_edge = 1,
811 .osc_clk_freq = 30400, /* in kHz */
812 .if_freq = 0, /* zero IF */
819 static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
824 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
825 .prod = ATBM8830_PROD_8830,
826 .demod_address = 0x44,
828 .ts_sampling_edge = 1,
830 .osc_clk_freq = 30400, /* in kHz */
831 .if_freq = 0, /* zero IF */
838 static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
842 static struct stv0367_config netup_stv0367_config[] = {
844 .demod_address = 0x1c,
851 .demod_address = 0x1d,
860 static struct xc5000_config netup_xc5000_config[] = {
870 static struct drxk_config terratec_drxk_config[] = {
880 static struct mt2063_config terratec_mt2063_config[] = {
882 .tuner_address = 0x60,
884 .tuner_address = 0x67,
888 static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
889 .clk = 40444000, /* 40.444 MHz */
891 .ts_mode = TDA10071_TS_SERIAL,
892 .pll_multiplier = 20,
893 .tuner_i2c_addr = 0x54,
896 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
901 .ts_mode = M88DS3103_TS_PARALLEL,
909 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
914 .ts_mode = M88DS3103_TS_CI,
922 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
926 .ts_mode = M88DS3103_TS_PARALLEL,
932 static struct lgdt3306a_config hauppauge_hvr1265k4_config = {
936 .deny_i2c_rptr = 1, /* Disabled */
937 .spectral_inversion = 0, /* Disabled */
938 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
939 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
940 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
941 .xtalMHz = 25, /* 24 or 25 */
944 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
946 struct cx23885_dev *dev = (struct cx23885_dev *)device;
947 unsigned long timeout = jiffies + msecs_to_jiffies(1);
950 mem = cx_read(MC417_RWD);
952 cx_set(MC417_OEN, ALT_DATA);
954 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
956 mem |= (data & ALT_DATA);
966 mem = (mem & ~ALT_RD) | ALT_WR;
968 mem = (mem & ~ALT_WR) | ALT_RD;
970 cx_write(MC417_RWD, mem); /* start RW cycle */
973 mem = cx_read(MC417_RWD);
974 if ((mem & ALT_RDY) == 0)
976 if (time_after(jiffies, timeout))
981 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
983 return mem & ALT_DATA;
988 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
990 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
992 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
995 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1000 static struct dib0070_config dib7070p_dib0070_config = {
1001 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1002 .reset = dib7070_tuner_reset,
1003 .sleep = dib7070_tuner_sleep,
1005 .freq_offset_khz_vhf = 550,
1006 /* .flip_chip = 1, */
1009 /* DIB7070 generic */
1010 static struct dibx000_agc_config dib7070_agc_config = {
1011 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1014 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
1015 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1016 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1018 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1019 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1021 .time_stabiliz = 10,
1045 .perform_agc_softsplit = 0,
1048 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1058 .IO_CLK_en_core = 1,
1061 /* refsel, sel, freq_15k */
1062 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1063 .ifreq = (0 << 25) | 0,
1065 .xtal_hz = 12000000,
1068 static struct dib7000p_config dib7070p_dib7000p_config = {
1069 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1070 .output_mode = OUTMODE_MPEG2_SERIAL,
1071 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1072 .output_mpeg2_in_188_bytes = 1,
1074 .agc_config_count = 1,
1075 .agc = &dib7070_agc_config,
1076 .bw = &dib7070_bw_config_12_mhz,
1077 .tuner_is_baseband = 1,
1080 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1081 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1082 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1084 .hostbus_diversity = 1,
1087 static int dvb_register_ci_mac(struct cx23885_tsport *port)
1089 struct cx23885_dev *dev = port->dev;
1090 struct i2c_client *client_ci = NULL;
1091 struct vb2_dvb_frontend *fe0;
1093 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1097 switch (dev->board) {
1098 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1099 static struct netup_card_info cinfo;
1101 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1102 memcpy(port->frontends.adapter.proposed_mac,
1103 cinfo.port[port->nr - 1].mac, 6);
1104 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1105 port->nr, port->frontends.adapter.proposed_mac);
1107 netup_ci_init(port);
1110 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1111 struct altera_ci_config netup_ci_cfg = {
1112 .dev = dev,/* magic number to identify*/
1113 .adapter = &port->frontends.adapter,/* for CI */
1114 .demux = &fe0->dvb.demux,/* for hw pid filter */
1115 .fpga_rw = netup_altera_fpga_rw,
1118 altera_ci_init(&netup_ci_cfg, port->nr);
1121 case CX23885_BOARD_TEVII_S470: {
1122 u8 eeprom[256]; /* 24C02 i2c eeprom */
1127 /* Read entire EEPROM */
1128 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1129 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1130 pr_info("TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1131 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1134 case CX23885_BOARD_DVBSKY_T9580:
1135 case CX23885_BOARD_DVBSKY_S950:
1136 case CX23885_BOARD_DVBSKY_S952:
1137 case CX23885_BOARD_DVBSKY_T982: {
1138 u8 eeprom[256]; /* 24C02 i2c eeprom */
1143 /* Read entire EEPROM */
1144 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1145 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1147 pr_info("%s port %d MAC address: %pM\n",
1148 cx23885_boards[dev->board].name, port->nr,
1149 eeprom + 0xc0 + (port->nr-1) * 8);
1150 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1151 (port->nr-1) * 8, 6);
1154 case CX23885_BOARD_DVBSKY_S950C:
1155 case CX23885_BOARD_DVBSKY_T980C:
1156 case CX23885_BOARD_TT_CT2_4500_CI: {
1157 u8 eeprom[256]; /* 24C02 i2c eeprom */
1158 struct sp2_config sp2_config;
1159 struct i2c_board_info info;
1160 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
1163 memset(&sp2_config, 0, sizeof(sp2_config));
1164 sp2_config.dvb_adap = &port->frontends.adapter;
1165 sp2_config.priv = port;
1166 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1167 memset(&info, 0, sizeof(struct i2c_board_info));
1168 strscpy(info.type, "sp2", I2C_NAME_SIZE);
1170 info.platform_data = &sp2_config;
1171 request_module(info.type);
1172 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
1173 if (client_ci == NULL || client_ci->dev.driver == NULL)
1175 if (!try_module_get(client_ci->dev.driver->owner)) {
1176 i2c_unregister_device(client_ci);
1179 port->i2c_client_ci = client_ci;
1184 /* Read entire EEPROM */
1185 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1186 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1188 pr_info("%s MAC address: %pM\n",
1189 cx23885_boards[dev->board].name, eeprom + 0xc0);
1190 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1197 static int dvb_register(struct cx23885_tsport *port)
1199 struct dib7000p_ops dib7000p_ops;
1200 struct cx23885_dev *dev = port->dev;
1201 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
1202 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
1203 struct si2168_config si2168_config;
1204 struct si2165_platform_data si2165_pdata;
1205 struct si2157_config si2157_config;
1206 struct ts2020_config ts2020_config;
1207 struct m88ds3103_platform_data m88ds3103_pdata;
1208 struct m88rs6000t_config m88rs6000t_config = {};
1209 struct a8293_platform_data a8293_pdata = {};
1210 struct i2c_board_info info;
1211 struct i2c_adapter *adapter;
1212 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1213 struct i2c_client *client_sec = 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,
1325 &i2c_bus->i2c_adap);
1326 if (fe0->dvb.frontend == NULL)
1328 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1329 &i2c_bus->i2c_adap, 0x61,
1330 TUNER_LG_TDVS_H06XF);
1332 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1333 i2c_bus = &dev->i2c_bus[1];
1334 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1335 &hauppauge_hvr1500q_config,
1336 &dev->i2c_bus[0].i2c_adap);
1337 if (fe0->dvb.frontend == NULL)
1339 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1341 &hauppauge_hvr1500q_tunerconfig);
1343 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1344 i2c_bus = &dev->i2c_bus[1];
1345 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1346 &hauppauge_hvr1500_config,
1347 &dev->i2c_bus[0].i2c_adap);
1348 if (fe0->dvb.frontend != NULL) {
1349 struct dvb_frontend *fe;
1350 struct xc2028_config cfg = {
1351 .i2c_adap = &i2c_bus->i2c_adap,
1354 static struct xc2028_ctrl ctl = {
1355 .fname = XC2028_DEFAULT_FIRMWARE,
1357 .demod = XC3028_FE_OREN538,
1360 fe = dvb_attach(xc2028_attach,
1361 fe0->dvb.frontend, &cfg);
1362 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1363 fe->ops.tuner_ops.set_config(fe, &ctl);
1366 case CX23885_BOARD_HAUPPAUGE_HVR1200:
1367 case CX23885_BOARD_HAUPPAUGE_HVR1700:
1368 i2c_bus = &dev->i2c_bus[0];
1369 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1370 &hauppauge_hvr1200_config,
1371 &i2c_bus->i2c_adap);
1372 if (fe0->dvb.frontend == NULL)
1374 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1375 &dev->i2c_bus[1].i2c_adap, 0x42,
1377 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1378 0x60, &dev->i2c_bus[1].i2c_adap,
1379 &hauppauge_hvr1200_tuner_config);
1381 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1382 i2c_bus = &dev->i2c_bus[0];
1383 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1384 &hauppauge_hvr1210_config,
1385 &i2c_bus->i2c_adap);
1386 if (fe0->dvb.frontend != NULL) {
1387 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1388 0x60, &dev->i2c_bus[1].i2c_adap,
1389 &hauppauge_hvr1210_tuner_config);
1392 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1393 i2c_bus = &dev->i2c_bus[0];
1395 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1398 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
1399 0x12, &hauppauge_hvr1400_dib7000_config);
1400 if (fe0->dvb.frontend != NULL) {
1401 struct dvb_frontend *fe;
1402 struct xc2028_config cfg = {
1403 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1406 static struct xc2028_ctrl ctl = {
1407 .fname = XC3028L_DEFAULT_FIRMWARE,
1409 .demod = XC3028_FE_DIBCOM52,
1410 /* This is true for all demods with
1412 .type = XC2028_D2633,
1415 fe = dvb_attach(xc2028_attach,
1416 fe0->dvb.frontend, &cfg);
1417 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1418 fe->ops.tuner_ops.set_config(fe, &ctl);
1421 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1422 i2c_bus = &dev->i2c_bus[port->nr - 1];
1424 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1425 &dvico_s5h1409_config,
1426 &i2c_bus->i2c_adap);
1427 if (fe0->dvb.frontend == NULL)
1428 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1429 &dvico_s5h1411_config,
1430 &i2c_bus->i2c_adap);
1431 if (fe0->dvb.frontend != NULL)
1432 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1434 &dvico_xc5000_tunerconfig);
1436 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
1437 i2c_bus = &dev->i2c_bus[port->nr - 1];
1439 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1440 &dvico_fusionhdtv_xc3028,
1441 &i2c_bus->i2c_adap);
1442 if (fe0->dvb.frontend != NULL) {
1443 struct dvb_frontend *fe;
1444 struct xc2028_config cfg = {
1445 .i2c_adap = &i2c_bus->i2c_adap,
1448 static struct xc2028_ctrl ctl = {
1449 .fname = XC2028_DEFAULT_FIRMWARE,
1451 .demod = XC3028_FE_ZARLINK456,
1454 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1456 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1457 fe->ops.tuner_ops.set_config(fe, &ctl);
1461 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
1462 i2c_bus = &dev->i2c_bus[port->nr - 1];
1463 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1464 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1466 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1469 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1470 pr_warn("Unable to enumerate dib7000p\n");
1473 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
1474 if (fe0->dvb.frontend != NULL) {
1475 struct i2c_adapter *tun_i2c;
1477 fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
1478 if (!fe0->dvb.frontend->sec_priv)
1480 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1481 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1486 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1487 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1488 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1489 i2c_bus = &dev->i2c_bus[0];
1491 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1492 &dvico_fusionhdtv_xc3028,
1493 &i2c_bus->i2c_adap);
1494 if (fe0->dvb.frontend != NULL) {
1495 struct dvb_frontend *fe;
1496 struct xc2028_config cfg = {
1497 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1500 static struct xc2028_ctrl ctl = {
1501 .fname = XC2028_DEFAULT_FIRMWARE,
1503 .demod = XC3028_FE_ZARLINK456,
1506 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1508 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1509 fe->ops.tuner_ops.set_config(fe, &ctl);
1512 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1513 i2c_bus = &dev->i2c_bus[0];
1515 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1516 &dvico_fusionhdtv_xc3028,
1517 &i2c_bus->i2c_adap);
1518 if (fe0->dvb.frontend != NULL) {
1519 struct dvb_frontend *fe;
1520 struct xc4000_config cfg = {
1521 .i2c_address = 0x61,
1523 .dvb_amplitude = 134,
1524 .set_smoothedcvbs = 1,
1528 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1529 &dev->i2c_bus[1].i2c_adap, &cfg);
1531 pr_err("%s/2: xc4000 attach failed\n",
1533 goto frontend_detach;
1537 case CX23885_BOARD_TBS_6920:
1538 i2c_bus = &dev->i2c_bus[1];
1540 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1541 &tbs_cx24116_config,
1542 &i2c_bus->i2c_adap);
1543 if (fe0->dvb.frontend != NULL)
1544 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1547 case CX23885_BOARD_TBS_6980:
1548 case CX23885_BOARD_TBS_6981:
1549 i2c_bus = &dev->i2c_bus[1];
1554 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1555 &tbs_cx24117_config,
1556 &i2c_bus->i2c_adap);
1560 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1561 &tbs_cx24117_config,
1562 &i2c_bus->i2c_adap);
1566 case CX23885_BOARD_TEVII_S470:
1567 i2c_bus = &dev->i2c_bus[1];
1569 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1570 &tevii_ds3000_config,
1571 &i2c_bus->i2c_adap);
1572 if (fe0->dvb.frontend != NULL) {
1573 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1574 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1575 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1579 case CX23885_BOARD_DVBWORLD_2005:
1580 i2c_bus = &dev->i2c_bus[1];
1582 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1583 &dvbworld_cx24116_config,
1584 &i2c_bus->i2c_adap);
1586 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1587 i2c_bus = &dev->i2c_bus[0];
1591 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1592 &netup_stv0900_config,
1593 &i2c_bus->i2c_adap, 0);
1594 if (fe0->dvb.frontend != NULL) {
1595 if (dvb_attach(stv6110_attach,
1597 &netup_stv6110_tunerconfig_a,
1598 &i2c_bus->i2c_adap)) {
1599 if (!dvb_attach(lnbh24_attach,
1602 LNBH24_PCL | LNBH24_TTX,
1604 pr_err("No LNBH24 found!\n");
1611 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1612 &netup_stv0900_config,
1613 &i2c_bus->i2c_adap, 1);
1614 if (fe0->dvb.frontend != NULL) {
1615 if (dvb_attach(stv6110_attach,
1617 &netup_stv6110_tunerconfig_b,
1618 &i2c_bus->i2c_adap)) {
1619 if (!dvb_attach(lnbh24_attach,
1622 LNBH24_PCL | LNBH24_TTX,
1624 pr_err("No LNBH24 found!\n");
1631 case CX23885_BOARD_MYGICA_X8506:
1632 i2c_bus = &dev->i2c_bus[0];
1633 i2c_bus2 = &dev->i2c_bus[1];
1634 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1635 &mygica_x8506_lgs8gl5_config,
1636 &i2c_bus->i2c_adap);
1637 if (fe0->dvb.frontend == NULL)
1639 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1640 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1641 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1643 case CX23885_BOARD_MYGICA_X8507:
1644 i2c_bus = &dev->i2c_bus[0];
1645 i2c_bus2 = &dev->i2c_bus[1];
1646 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1647 &mygica_x8507_mb86a20s_config,
1648 &i2c_bus->i2c_adap);
1649 if (fe0->dvb.frontend == NULL)
1652 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1653 &i2c_bus2->i2c_adap,
1654 &mygica_x8507_xc5000_config);
1655 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1657 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1658 i2c_bus = &dev->i2c_bus[0];
1659 i2c_bus2 = &dev->i2c_bus[1];
1660 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1661 &magicpro_prohdtve2_lgs8g75_config,
1662 &i2c_bus->i2c_adap);
1663 if (fe0->dvb.frontend == NULL)
1665 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1666 &i2c_bus2->i2c_adap,
1667 &magicpro_prohdtve2_xc5000_config);
1668 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1670 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1671 i2c_bus = &dev->i2c_bus[0];
1672 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1673 &hcw_s5h1411_config,
1674 &i2c_bus->i2c_adap);
1675 if (fe0->dvb.frontend == NULL)
1677 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1678 0x60, &dev->i2c_bus[0].i2c_adap,
1679 &hauppauge_tda18271_config);
1681 tda18271_attach(&dev->ts1.analog_fe,
1682 0x60, &dev->i2c_bus[1].i2c_adap,
1683 &hauppauge_tda18271_config);
1686 case CX23885_BOARD_HAUPPAUGE_HVR1290:
1687 i2c_bus = &dev->i2c_bus[0];
1688 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1689 &hcw_s5h1411_config,
1690 &i2c_bus->i2c_adap);
1691 if (fe0->dvb.frontend == NULL)
1693 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1694 0x60, &dev->i2c_bus[0].i2c_adap,
1695 &hauppauge_tda18271_config);
1697 case CX23885_BOARD_MYGICA_X8558PRO:
1701 i2c_bus = &dev->i2c_bus[0];
1702 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1703 &mygica_x8558pro_atbm8830_cfg1,
1704 &i2c_bus->i2c_adap);
1705 if (fe0->dvb.frontend == NULL)
1707 dvb_attach(max2165_attach, fe0->dvb.frontend,
1709 &mygic_x8558pro_max2165_cfg1);
1713 i2c_bus = &dev->i2c_bus[1];
1714 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1715 &mygica_x8558pro_atbm8830_cfg2,
1716 &i2c_bus->i2c_adap);
1717 if (fe0->dvb.frontend == NULL)
1719 dvb_attach(max2165_attach, fe0->dvb.frontend,
1721 &mygic_x8558pro_max2165_cfg2);
1724 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1728 i2c_bus = &dev->i2c_bus[0];
1729 mfe_shared = 1;/* MFE */
1730 port->frontends.gate = 0;/* not clear for me yet */
1732 /* MFE frontend 1 DVB-T */
1733 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1734 &netup_stv0367_config[port->nr - 1],
1735 &i2c_bus->i2c_adap);
1736 if (fe0->dvb.frontend == NULL)
1738 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1740 &netup_xc5000_config[port->nr - 1]))
1741 goto frontend_detach;
1742 /* load xc5000 firmware */
1743 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1745 /* MFE frontend 2 */
1746 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1748 goto frontend_detach;
1750 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1751 &netup_stv0367_config[port->nr - 1],
1752 &i2c_bus->i2c_adap);
1753 if (fe1->dvb.frontend == NULL)
1756 fe1->dvb.frontend->id = 1;
1757 if (NULL == dvb_attach(xc5000_attach,
1760 &netup_xc5000_config[port->nr - 1]))
1761 goto frontend_detach;
1763 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1764 i2c_bus = &dev->i2c_bus[0];
1765 i2c_bus2 = &dev->i2c_bus[1];
1770 fe0->dvb.frontend = dvb_attach(drxk_attach,
1771 &terratec_drxk_config[0],
1772 &i2c_bus->i2c_adap);
1773 if (fe0->dvb.frontend == NULL)
1775 if (!dvb_attach(mt2063_attach,
1777 &terratec_mt2063_config[0],
1778 &i2c_bus2->i2c_adap))
1779 goto frontend_detach;
1783 fe0->dvb.frontend = dvb_attach(drxk_attach,
1784 &terratec_drxk_config[1],
1785 &i2c_bus->i2c_adap);
1786 if (fe0->dvb.frontend == NULL)
1788 if (!dvb_attach(mt2063_attach,
1790 &terratec_mt2063_config[1],
1791 &i2c_bus2->i2c_adap))
1792 goto frontend_detach;
1796 case CX23885_BOARD_TEVII_S471:
1797 i2c_bus = &dev->i2c_bus[1];
1799 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1800 &tevii_ds3000_config,
1801 &i2c_bus->i2c_adap);
1802 if (fe0->dvb.frontend == NULL)
1804 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1805 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1807 case CX23885_BOARD_PROF_8000:
1808 i2c_bus = &dev->i2c_bus[0];
1810 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1811 &prof_8000_stv090x_config,
1813 STV090x_DEMODULATOR_0);
1814 if (fe0->dvb.frontend == NULL)
1816 if (!dvb_attach(stb6100_attach,
1818 &prof_8000_stb6100_config,
1819 &i2c_bus->i2c_adap))
1820 goto frontend_detach;
1822 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1824 case CX23885_BOARD_HAUPPAUGE_HVR4400: {
1825 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1826 struct a8293_platform_data a8293_pdata = {};
1828 i2c_bus = &dev->i2c_bus[0];
1829 i2c_bus2 = &dev->i2c_bus[1];
1833 /* attach demod + tuner combo */
1834 memset(&info, 0, sizeof(info));
1835 strscpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1837 info.platform_data = &tda10071_pdata;
1838 request_module("tda10071");
1839 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1840 if (!client_demod || !client_demod->dev.driver)
1841 goto frontend_detach;
1842 if (!try_module_get(client_demod->dev.driver->owner)) {
1843 i2c_unregister_device(client_demod);
1844 goto frontend_detach;
1846 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1847 port->i2c_client_demod = client_demod;
1850 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1851 memset(&info, 0, sizeof(info));
1852 strscpy(info.type, "a8293", I2C_NAME_SIZE);
1854 info.platform_data = &a8293_pdata;
1855 request_module("a8293");
1856 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1857 if (!client_sec || !client_sec->dev.driver)
1858 goto frontend_detach;
1859 if (!try_module_get(client_sec->dev.driver->owner)) {
1860 i2c_unregister_device(client_sec);
1861 goto frontend_detach;
1863 port->i2c_client_sec = client_sec;
1867 /* attach frontend */
1868 memset(&si2165_pdata, 0, sizeof(si2165_pdata));
1869 si2165_pdata.fe = &fe0->dvb.frontend;
1870 si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL;
1871 si2165_pdata.ref_freq_hz = 16000000;
1872 memset(&info, 0, sizeof(struct i2c_board_info));
1873 strscpy(info.type, "si2165", I2C_NAME_SIZE);
1875 info.platform_data = &si2165_pdata;
1876 request_module(info.type);
1877 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1878 if (client_demod == NULL ||
1879 client_demod->dev.driver == NULL)
1880 goto frontend_detach;
1881 if (!try_module_get(client_demod->dev.driver->owner)) {
1882 i2c_unregister_device(client_demod);
1883 goto frontend_detach;
1885 port->i2c_client_demod = client_demod;
1887 if (fe0->dvb.frontend == NULL)
1889 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1890 if (!dvb_attach(tda18271_attach,
1892 0x60, &i2c_bus2->i2c_adap,
1893 &hauppauge_hvr4400_tuner_config))
1894 goto frontend_detach;
1899 case CX23885_BOARD_HAUPPAUGE_STARBURST: {
1900 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1901 struct a8293_platform_data a8293_pdata = {};
1903 i2c_bus = &dev->i2c_bus[0];
1905 /* attach demod + tuner combo */
1906 memset(&info, 0, sizeof(info));
1907 strscpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1909 info.platform_data = &tda10071_pdata;
1910 request_module("tda10071");
1911 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1912 if (!client_demod || !client_demod->dev.driver)
1913 goto frontend_detach;
1914 if (!try_module_get(client_demod->dev.driver->owner)) {
1915 i2c_unregister_device(client_demod);
1916 goto frontend_detach;
1918 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1919 port->i2c_client_demod = client_demod;
1922 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1923 memset(&info, 0, sizeof(info));
1924 strscpy(info.type, "a8293", I2C_NAME_SIZE);
1926 info.platform_data = &a8293_pdata;
1927 request_module("a8293");
1928 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1929 if (!client_sec || !client_sec->dev.driver)
1930 goto frontend_detach;
1931 if (!try_module_get(client_sec->dev.driver->owner)) {
1932 i2c_unregister_device(client_sec);
1933 goto frontend_detach;
1935 port->i2c_client_sec = client_sec;
1938 case CX23885_BOARD_DVBSKY_T9580:
1939 case CX23885_BOARD_DVBSKY_S950:
1940 i2c_bus = &dev->i2c_bus[0];
1941 i2c_bus2 = &dev->i2c_bus[1];
1943 /* port b - satellite */
1945 /* attach frontend */
1946 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1947 &dvbsky_t9580_m88ds3103_config,
1948 &i2c_bus2->i2c_adap, &adapter);
1949 if (fe0->dvb.frontend == NULL)
1953 memset(&ts2020_config, 0, sizeof(ts2020_config));
1954 ts2020_config.fe = fe0->dvb.frontend;
1955 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
1956 memset(&info, 0, sizeof(struct i2c_board_info));
1957 strscpy(info.type, "ts2020", I2C_NAME_SIZE);
1959 info.platform_data = &ts2020_config;
1960 request_module(info.type);
1961 client_tuner = i2c_new_device(adapter, &info);
1962 if (client_tuner == NULL ||
1963 client_tuner->dev.driver == NULL)
1964 goto frontend_detach;
1965 if (!try_module_get(client_tuner->dev.driver->owner)) {
1966 i2c_unregister_device(client_tuner);
1967 goto frontend_detach;
1970 /* delegate signal strength measurement to tuner */
1971 fe0->dvb.frontend->ops.read_signal_strength =
1972 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1975 * for setting the voltage we need to set GPIOs on
1978 port->fe_set_voltage =
1979 fe0->dvb.frontend->ops.set_voltage;
1980 fe0->dvb.frontend->ops.set_voltage =
1981 dvbsky_t9580_set_voltage;
1983 port->i2c_client_tuner = client_tuner;
1986 /* port c - terrestrial/cable */
1988 /* attach frontend */
1989 memset(&si2168_config, 0, sizeof(si2168_config));
1990 si2168_config.i2c_adapter = &adapter;
1991 si2168_config.fe = &fe0->dvb.frontend;
1992 si2168_config.ts_mode = SI2168_TS_SERIAL;
1993 memset(&info, 0, sizeof(struct i2c_board_info));
1994 strscpy(info.type, "si2168", I2C_NAME_SIZE);
1996 info.platform_data = &si2168_config;
1997 request_module(info.type);
1998 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1999 if (client_demod == NULL ||
2000 client_demod->dev.driver == NULL)
2001 goto frontend_detach;
2002 if (!try_module_get(client_demod->dev.driver->owner)) {
2003 i2c_unregister_device(client_demod);
2004 goto frontend_detach;
2006 port->i2c_client_demod = client_demod;
2009 memset(&si2157_config, 0, sizeof(si2157_config));
2010 si2157_config.fe = fe0->dvb.frontend;
2011 si2157_config.if_port = 1;
2012 memset(&info, 0, sizeof(struct i2c_board_info));
2013 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2015 info.platform_data = &si2157_config;
2016 request_module(info.type);
2017 client_tuner = i2c_new_device(adapter, &info);
2018 if (client_tuner == NULL ||
2019 client_tuner->dev.driver == NULL)
2020 goto frontend_detach;
2022 if (!try_module_get(client_tuner->dev.driver->owner)) {
2023 i2c_unregister_device(client_tuner);
2024 goto frontend_detach;
2026 port->i2c_client_tuner = client_tuner;
2030 case CX23885_BOARD_DVBSKY_T980C:
2031 case CX23885_BOARD_TT_CT2_4500_CI:
2032 i2c_bus = &dev->i2c_bus[0];
2033 i2c_bus2 = &dev->i2c_bus[1];
2035 /* attach frontend */
2036 memset(&si2168_config, 0, sizeof(si2168_config));
2037 si2168_config.i2c_adapter = &adapter;
2038 si2168_config.fe = &fe0->dvb.frontend;
2039 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2040 memset(&info, 0, sizeof(struct i2c_board_info));
2041 strscpy(info.type, "si2168", I2C_NAME_SIZE);
2043 info.platform_data = &si2168_config;
2044 request_module(info.type);
2045 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2046 if (client_demod == NULL || client_demod->dev.driver == NULL)
2047 goto frontend_detach;
2048 if (!try_module_get(client_demod->dev.driver->owner)) {
2049 i2c_unregister_device(client_demod);
2050 goto frontend_detach;
2052 port->i2c_client_demod = client_demod;
2055 memset(&si2157_config, 0, sizeof(si2157_config));
2056 si2157_config.fe = fe0->dvb.frontend;
2057 si2157_config.if_port = 1;
2058 memset(&info, 0, sizeof(struct i2c_board_info));
2059 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2061 info.platform_data = &si2157_config;
2062 request_module(info.type);
2063 client_tuner = i2c_new_device(adapter, &info);
2064 if (client_tuner == NULL ||
2065 client_tuner->dev.driver == NULL)
2066 goto frontend_detach;
2067 if (!try_module_get(client_tuner->dev.driver->owner)) {
2068 i2c_unregister_device(client_tuner);
2069 goto frontend_detach;
2071 port->i2c_client_tuner = client_tuner;
2073 case CX23885_BOARD_DVBSKY_S950C:
2074 i2c_bus = &dev->i2c_bus[0];
2075 i2c_bus2 = &dev->i2c_bus[1];
2077 /* attach frontend */
2078 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2079 &dvbsky_s950c_m88ds3103_config,
2080 &i2c_bus2->i2c_adap, &adapter);
2081 if (fe0->dvb.frontend == NULL)
2085 memset(&ts2020_config, 0, sizeof(ts2020_config));
2086 ts2020_config.fe = fe0->dvb.frontend;
2087 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2088 memset(&info, 0, sizeof(struct i2c_board_info));
2089 strscpy(info.type, "ts2020", I2C_NAME_SIZE);
2091 info.platform_data = &ts2020_config;
2092 request_module(info.type);
2093 client_tuner = i2c_new_device(adapter, &info);
2094 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2095 goto frontend_detach;
2096 if (!try_module_get(client_tuner->dev.driver->owner)) {
2097 i2c_unregister_device(client_tuner);
2098 goto frontend_detach;
2101 /* delegate signal strength measurement to tuner */
2102 fe0->dvb.frontend->ops.read_signal_strength =
2103 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2105 port->i2c_client_tuner = client_tuner;
2107 case CX23885_BOARD_DVBSKY_S952:
2108 /* attach frontend */
2109 memset(&m88ds3103_pdata, 0, sizeof(m88ds3103_pdata));
2110 m88ds3103_pdata.clk = 27000000;
2111 m88ds3103_pdata.i2c_wr_max = 33;
2112 m88ds3103_pdata.agc = 0x99;
2113 m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_DISABLED;
2114 m88ds3103_pdata.lnb_en_pol = 1;
2119 i2c_bus = &dev->i2c_bus[1];
2120 m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
2121 m88ds3103_pdata.ts_clk = 16000;
2122 m88ds3103_pdata.ts_clk_pol = 1;
2123 p_set_voltage = dvbsky_t9580_set_voltage;
2127 i2c_bus = &dev->i2c_bus[0];
2128 m88ds3103_pdata.ts_mode = M88DS3103_TS_SERIAL;
2129 m88ds3103_pdata.ts_clk = 96000;
2130 m88ds3103_pdata.ts_clk_pol = 0;
2131 p_set_voltage = dvbsky_s952_portc_set_voltage;
2137 memset(&info, 0, sizeof(info));
2138 strscpy(info.type, "m88ds3103", I2C_NAME_SIZE);
2140 info.platform_data = &m88ds3103_pdata;
2141 request_module(info.type);
2142 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2143 if (client_demod == NULL || client_demod->dev.driver == NULL)
2144 goto frontend_detach;
2145 if (!try_module_get(client_demod->dev.driver->owner)) {
2146 i2c_unregister_device(client_demod);
2147 goto frontend_detach;
2149 port->i2c_client_demod = client_demod;
2150 adapter = m88ds3103_pdata.get_i2c_adapter(client_demod);
2151 fe0->dvb.frontend = m88ds3103_pdata.get_dvb_frontend(client_demod);
2154 memset(&ts2020_config, 0, sizeof(ts2020_config));
2155 ts2020_config.fe = fe0->dvb.frontend;
2156 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2157 memset(&info, 0, sizeof(struct i2c_board_info));
2158 strscpy(info.type, "ts2020", I2C_NAME_SIZE);
2160 info.platform_data = &ts2020_config;
2161 request_module(info.type);
2162 client_tuner = i2c_new_device(adapter, &info);
2163 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2164 goto frontend_detach;
2165 if (!try_module_get(client_tuner->dev.driver->owner)) {
2166 i2c_unregister_device(client_tuner);
2167 goto frontend_detach;
2170 /* delegate signal strength measurement to tuner */
2171 fe0->dvb.frontend->ops.read_signal_strength =
2172 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2175 * for setting the voltage we need to set GPIOs on
2178 port->fe_set_voltage =
2179 fe0->dvb.frontend->ops.set_voltage;
2180 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2182 port->i2c_client_tuner = client_tuner;
2184 case CX23885_BOARD_DVBSKY_T982:
2185 memset(&si2168_config, 0, sizeof(si2168_config));
2189 i2c_bus = &dev->i2c_bus[1];
2190 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2194 i2c_bus = &dev->i2c_bus[0];
2195 si2168_config.ts_mode = SI2168_TS_SERIAL;
2199 /* attach frontend */
2200 si2168_config.i2c_adapter = &adapter;
2201 si2168_config.fe = &fe0->dvb.frontend;
2202 memset(&info, 0, sizeof(struct i2c_board_info));
2203 strscpy(info.type, "si2168", I2C_NAME_SIZE);
2205 info.platform_data = &si2168_config;
2206 request_module(info.type);
2207 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2208 if (client_demod == NULL || client_demod->dev.driver == NULL)
2209 goto frontend_detach;
2210 if (!try_module_get(client_demod->dev.driver->owner)) {
2211 i2c_unregister_device(client_demod);
2212 goto frontend_detach;
2214 port->i2c_client_demod = client_demod;
2217 memset(&si2157_config, 0, sizeof(si2157_config));
2218 si2157_config.fe = fe0->dvb.frontend;
2219 si2157_config.if_port = 1;
2220 memset(&info, 0, sizeof(struct i2c_board_info));
2221 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2223 info.platform_data = &si2157_config;
2224 request_module(info.type);
2225 client_tuner = i2c_new_device(adapter, &info);
2226 if (client_tuner == NULL ||
2227 client_tuner->dev.driver == NULL)
2228 goto frontend_detach;
2229 if (!try_module_get(client_tuner->dev.driver->owner)) {
2230 i2c_unregister_device(client_tuner);
2231 goto frontend_detach;
2233 port->i2c_client_tuner = client_tuner;
2235 case CX23885_BOARD_HAUPPAUGE_STARBURST2:
2236 case CX23885_BOARD_HAUPPAUGE_HVR5525:
2237 i2c_bus = &dev->i2c_bus[0];
2238 i2c_bus2 = &dev->i2c_bus[1];
2242 /* port b - satellite */
2244 /* attach frontend */
2245 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2246 &hauppauge_hvr5525_m88ds3103_config,
2247 &i2c_bus->i2c_adap, &adapter);
2248 if (fe0->dvb.frontend == NULL)
2252 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
2253 memset(&info, 0, sizeof(info));
2254 strscpy(info.type, "a8293", I2C_NAME_SIZE);
2256 info.platform_data = &a8293_pdata;
2257 request_module("a8293");
2258 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
2259 if (!client_sec || !client_sec->dev.driver)
2260 goto frontend_detach;
2261 if (!try_module_get(client_sec->dev.driver->owner)) {
2262 i2c_unregister_device(client_sec);
2263 goto frontend_detach;
2265 port->i2c_client_sec = client_sec;
2268 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2269 m88rs6000t_config.fe = fe0->dvb.frontend;
2270 memset(&info, 0, sizeof(struct i2c_board_info));
2271 strscpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2273 info.platform_data = &m88rs6000t_config;
2274 request_module("%s", info.type);
2275 client_tuner = i2c_new_device(adapter, &info);
2276 if (!client_tuner || !client_tuner->dev.driver)
2277 goto frontend_detach;
2278 if (!try_module_get(client_tuner->dev.driver->owner)) {
2279 i2c_unregister_device(client_tuner);
2280 goto frontend_detach;
2282 port->i2c_client_tuner = client_tuner;
2284 /* delegate signal strength measurement to tuner */
2285 fe0->dvb.frontend->ops.read_signal_strength =
2286 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2288 /* port c - terrestrial/cable */
2290 /* attach frontend */
2291 memset(&si2168_config, 0, sizeof(si2168_config));
2292 si2168_config.i2c_adapter = &adapter;
2293 si2168_config.fe = &fe0->dvb.frontend;
2294 si2168_config.ts_mode = SI2168_TS_SERIAL;
2295 memset(&info, 0, sizeof(struct i2c_board_info));
2296 strscpy(info.type, "si2168", I2C_NAME_SIZE);
2298 info.platform_data = &si2168_config;
2299 request_module("%s", info.type);
2300 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2301 if (!client_demod || !client_demod->dev.driver)
2302 goto frontend_detach;
2303 if (!try_module_get(client_demod->dev.driver->owner)) {
2304 i2c_unregister_device(client_demod);
2305 goto frontend_detach;
2307 port->i2c_client_demod = client_demod;
2310 memset(&si2157_config, 0, sizeof(si2157_config));
2311 si2157_config.fe = fe0->dvb.frontend;
2312 si2157_config.if_port = 1;
2313 memset(&info, 0, sizeof(struct i2c_board_info));
2314 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2316 info.platform_data = &si2157_config;
2317 request_module("%s", info.type);
2318 client_tuner = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2319 if (!client_tuner || !client_tuner->dev.driver) {
2320 module_put(client_demod->dev.driver->owner);
2321 i2c_unregister_device(client_demod);
2322 port->i2c_client_demod = NULL;
2323 goto frontend_detach;
2325 if (!try_module_get(client_tuner->dev.driver->owner)) {
2326 i2c_unregister_device(client_tuner);
2327 module_put(client_demod->dev.driver->owner);
2328 i2c_unregister_device(client_demod);
2329 port->i2c_client_demod = NULL;
2330 goto frontend_detach;
2332 port->i2c_client_tuner = client_tuner;
2336 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
2337 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885:
2338 pr_info("%s(): board=%d port=%d\n", __func__,
2339 dev->board, port->nr);
2341 /* port b - Terrestrial/cable */
2343 /* attach frontend */
2344 memset(&si2168_config, 0, sizeof(si2168_config));
2345 si2168_config.i2c_adapter = &adapter;
2346 si2168_config.fe = &fe0->dvb.frontend;
2347 si2168_config.ts_mode = SI2168_TS_SERIAL;
2348 memset(&info, 0, sizeof(struct i2c_board_info));
2349 strscpy(info.type, "si2168", I2C_NAME_SIZE);
2351 info.platform_data = &si2168_config;
2352 request_module("%s", info.type);
2353 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2354 if (!client_demod || !client_demod->dev.driver)
2355 goto frontend_detach;
2356 if (!try_module_get(client_demod->dev.driver->owner)) {
2357 i2c_unregister_device(client_demod);
2358 goto frontend_detach;
2360 port->i2c_client_demod = client_demod;
2363 memset(&si2157_config, 0, sizeof(si2157_config));
2364 si2157_config.fe = fe0->dvb.frontend;
2365 si2157_config.if_port = 1;
2366 memset(&info, 0, sizeof(struct i2c_board_info));
2367 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2369 info.platform_data = &si2157_config;
2370 request_module("%s", info.type);
2371 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2372 if (!client_tuner || !client_tuner->dev.driver) {
2373 module_put(client_demod->dev.driver->owner);
2374 i2c_unregister_device(client_demod);
2375 port->i2c_client_demod = NULL;
2376 goto frontend_detach;
2378 if (!try_module_get(client_tuner->dev.driver->owner)) {
2379 i2c_unregister_device(client_tuner);
2380 module_put(client_demod->dev.driver->owner);
2381 i2c_unregister_device(client_demod);
2382 port->i2c_client_demod = NULL;
2383 goto frontend_detach;
2385 port->i2c_client_tuner = client_tuner;
2388 /* port c - terrestrial/cable */
2390 /* attach frontend */
2391 memset(&si2168_config, 0, sizeof(si2168_config));
2392 si2168_config.i2c_adapter = &adapter;
2393 si2168_config.fe = &fe0->dvb.frontend;
2394 si2168_config.ts_mode = SI2168_TS_SERIAL;
2395 memset(&info, 0, sizeof(struct i2c_board_info));
2396 strscpy(info.type, "si2168", I2C_NAME_SIZE);
2398 info.platform_data = &si2168_config;
2399 request_module("%s", info.type);
2400 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2401 if (!client_demod || !client_demod->dev.driver)
2402 goto frontend_detach;
2403 if (!try_module_get(client_demod->dev.driver->owner)) {
2404 i2c_unregister_device(client_demod);
2405 goto frontend_detach;
2407 port->i2c_client_demod = client_demod;
2410 memset(&si2157_config, 0, sizeof(si2157_config));
2411 si2157_config.fe = fe0->dvb.frontend;
2412 si2157_config.if_port = 1;
2413 memset(&info, 0, sizeof(struct i2c_board_info));
2414 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2416 info.platform_data = &si2157_config;
2417 request_module("%s", info.type);
2418 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2419 if (!client_tuner || !client_tuner->dev.driver) {
2420 module_put(client_demod->dev.driver->owner);
2421 i2c_unregister_device(client_demod);
2422 port->i2c_client_demod = NULL;
2423 goto frontend_detach;
2425 if (!try_module_get(client_tuner->dev.driver->owner)) {
2426 i2c_unregister_device(client_tuner);
2427 module_put(client_demod->dev.driver->owner);
2428 i2c_unregister_device(client_demod);
2429 port->i2c_client_demod = NULL;
2430 goto frontend_detach;
2432 port->i2c_client_tuner = client_tuner;
2436 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
2437 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885:
2438 pr_info("%s(): board=%d port=%d\n", __func__,
2439 dev->board, port->nr);
2441 /* port b - Terrestrial/cable */
2443 /* attach frontend */
2444 i2c_bus = &dev->i2c_bus[0];
2445 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2446 &hauppauge_quadHD_ATSC_a_config, &i2c_bus->i2c_adap);
2447 if (fe0->dvb.frontend == NULL)
2451 memset(&si2157_config, 0, sizeof(si2157_config));
2452 si2157_config.fe = fe0->dvb.frontend;
2453 si2157_config.if_port = 1;
2454 si2157_config.inversion = 1;
2455 memset(&info, 0, sizeof(struct i2c_board_info));
2456 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2458 info.platform_data = &si2157_config;
2459 request_module("%s", info.type);
2460 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2461 if (!client_tuner || !client_tuner->dev.driver) {
2462 module_put(client_demod->dev.driver->owner);
2463 i2c_unregister_device(client_demod);
2464 port->i2c_client_demod = NULL;
2465 goto frontend_detach;
2467 if (!try_module_get(client_tuner->dev.driver->owner)) {
2468 i2c_unregister_device(client_tuner);
2469 module_put(client_demod->dev.driver->owner);
2470 i2c_unregister_device(client_demod);
2471 port->i2c_client_demod = NULL;
2472 goto frontend_detach;
2474 port->i2c_client_tuner = client_tuner;
2477 /* port c - terrestrial/cable */
2479 /* attach frontend */
2480 i2c_bus = &dev->i2c_bus[0];
2481 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2482 &hauppauge_quadHD_ATSC_b_config, &i2c_bus->i2c_adap);
2483 if (fe0->dvb.frontend == NULL)
2487 memset(&si2157_config, 0, sizeof(si2157_config));
2488 si2157_config.fe = fe0->dvb.frontend;
2489 si2157_config.if_port = 1;
2490 si2157_config.inversion = 1;
2491 memset(&info, 0, sizeof(struct i2c_board_info));
2492 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2494 info.platform_data = &si2157_config;
2495 request_module("%s", info.type);
2496 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2497 if (!client_tuner || !client_tuner->dev.driver) {
2498 module_put(client_demod->dev.driver->owner);
2499 i2c_unregister_device(client_demod);
2500 port->i2c_client_demod = NULL;
2501 goto frontend_detach;
2503 if (!try_module_get(client_tuner->dev.driver->owner)) {
2504 i2c_unregister_device(client_tuner);
2505 module_put(client_demod->dev.driver->owner);
2506 i2c_unregister_device(client_demod);
2507 port->i2c_client_demod = NULL;
2508 goto frontend_detach;
2510 port->i2c_client_tuner = client_tuner;
2514 case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
2516 /* port c - Terrestrial/cable */
2518 /* attach frontend */
2519 i2c_bus = &dev->i2c_bus[0];
2520 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2521 &hauppauge_hvr1265k4_config,
2522 &i2c_bus->i2c_adap);
2523 if (fe0->dvb.frontend == NULL)
2527 memset(&si2157_config, 0, sizeof(si2157_config));
2528 si2157_config.fe = fe0->dvb.frontend;
2529 si2157_config.if_port = 1;
2530 si2157_config.inversion = 1;
2531 memset(&info, 0, sizeof(struct i2c_board_info));
2532 strscpy(info.type, "si2157", I2C_NAME_SIZE);
2534 info.platform_data = &si2157_config;
2535 request_module("%s", info.type);
2536 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2537 if (!client_tuner || !client_tuner->dev.driver)
2538 goto frontend_detach;
2540 if (!try_module_get(client_tuner->dev.driver->owner)) {
2541 i2c_unregister_device(client_tuner);
2542 client_tuner = NULL;
2543 goto frontend_detach;
2545 port->i2c_client_tuner = client_tuner;
2550 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2555 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2556 pr_err("%s: frontend initialization failed\n",
2558 goto frontend_detach;
2561 /* define general-purpose callback pointer */
2562 fe0->dvb.frontend->callback = cx23885_tuner_callback;
2564 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2566 /* Ensure all frontends negotiate bus access */
2567 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2569 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2572 /* Put the tuner in standby to keep it quiet */
2573 call_all(dev, tuner, standby);
2575 if (fe0->dvb.frontend->ops.analog_ops.standby)
2576 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
2578 /* register everything */
2579 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2580 &dev->pci->dev, NULL,
2581 adapter_nr, mfe_shared);
2583 goto frontend_detach;
2585 ret = dvb_register_ci_mac(port);
2587 goto frontend_detach;
2592 /* remove I2C client for SEC */
2593 client_sec = port->i2c_client_sec;
2595 module_put(client_sec->dev.driver->owner);
2596 i2c_unregister_device(client_sec);
2597 port->i2c_client_sec = NULL;
2600 /* remove I2C client for tuner */
2601 client_tuner = port->i2c_client_tuner;
2603 module_put(client_tuner->dev.driver->owner);
2604 i2c_unregister_device(client_tuner);
2605 port->i2c_client_tuner = NULL;
2608 /* remove I2C client for demodulator */
2609 client_demod = port->i2c_client_demod;
2611 module_put(client_demod->dev.driver->owner);
2612 i2c_unregister_device(client_demod);
2613 port->i2c_client_demod = NULL;
2616 port->gate_ctrl = NULL;
2617 vb2_dvb_dealloc_frontends(&port->frontends);
2621 int cx23885_dvb_register(struct cx23885_tsport *port)
2624 struct vb2_dvb_frontend *fe0;
2625 struct cx23885_dev *dev = port->dev;
2628 /* Here we need to allocate the correct number of frontends,
2629 * as reflected in the cards struct. The reality is that currently
2630 * no cx23885 boards support this - yet. But, if we don't modify this
2631 * code then the second frontend would never be allocated (later)
2632 * and fail with error before the attach in dvb_register().
2633 * Without these changes we risk an OOPS later. The changes here
2634 * are for safety, and should provide a good foundation for the
2635 * future addition of any multi-frontend cx23885 based boards.
2637 pr_info("%s() allocating %d frontend(s)\n", __func__,
2638 port->num_frontends);
2640 for (i = 1; i <= port->num_frontends; i++) {
2641 struct vb2_queue *q;
2643 if (vb2_dvb_alloc_frontend(
2644 &port->frontends, i) == NULL) {
2645 pr_err("%s() failed to alloc\n", __func__);
2649 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
2653 dprintk(1, "%s\n", __func__);
2654 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2663 /* We have to init the queue for each frontend on a port. */
2664 pr_info("%s: cx23885 based dvb card\n", dev->name);
2666 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2667 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2668 q->gfp_flags = GFP_DMA32;
2669 q->min_buffers_needed = 2;
2671 q->buf_struct_size = sizeof(struct cx23885_buffer);
2673 q->mem_ops = &vb2_dma_sg_memops;
2674 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2675 q->lock = &dev->lock;
2676 q->dev = &dev->pci->dev;
2678 err = vb2_queue_init(q);
2682 err = dvb_register(port);
2684 pr_err("%s() dvb_register failed err = %d\n",
2690 int cx23885_dvb_unregister(struct cx23885_tsport *port)
2692 struct vb2_dvb_frontend *fe0;
2693 struct i2c_client *client;
2695 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2697 if (fe0 && fe0->dvb.frontend)
2698 vb2_dvb_unregister_bus(&port->frontends);
2700 /* remove I2C client for CI */
2701 client = port->i2c_client_ci;
2703 module_put(client->dev.driver->owner);
2704 i2c_unregister_device(client);
2707 /* remove I2C client for SEC */
2708 client = port->i2c_client_sec;
2710 module_put(client->dev.driver->owner);
2711 i2c_unregister_device(client);
2714 /* remove I2C client for tuner */
2715 client = port->i2c_client_tuner;
2717 module_put(client->dev.driver->owner);
2718 i2c_unregister_device(client);
2721 /* remove I2C client for demodulator */
2722 client = port->i2c_client_demod;
2724 module_put(client->dev.driver->owner);
2725 i2c_unregister_device(client);
2728 switch (port->dev->board) {
2729 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2730 netup_ci_exit(port);
2732 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2733 altera_ci_release(port->dev, port->nr);
2737 port->gate_ctrl = NULL;