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 "m88rs6000t.h"
78 static unsigned int debug;
80 #define dprintk(level, fmt, arg...)\
81 do { if (debug >= level)\
82 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
85 /* ------------------------------------------------------------------ */
87 static unsigned int alt_tuner;
88 module_param(alt_tuner, int, 0644);
89 MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
91 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
93 /* ------------------------------------------------------------------ */
95 static int queue_setup(struct vb2_queue *q, const void *parg,
96 unsigned int *num_buffers, unsigned int *num_planes,
97 unsigned int sizes[], void *alloc_ctxs[])
99 struct cx23885_tsport *port = q->drv_priv;
101 port->ts_packet_size = 188 * 4;
102 port->ts_packet_count = 32;
104 sizes[0] = port->ts_packet_size * port->ts_packet_count;
105 alloc_ctxs[0] = port->dev->alloc_ctx;
111 static int buffer_prepare(struct vb2_buffer *vb)
113 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
114 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
115 struct cx23885_buffer *buf =
116 container_of(vbuf, struct cx23885_buffer, vb);
118 return cx23885_buf_prepare(buf, port);
121 static void buffer_finish(struct vb2_buffer *vb)
123 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
124 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
125 struct cx23885_dev *dev = port->dev;
126 struct cx23885_buffer *buf = container_of(vbuf,
127 struct cx23885_buffer, vb);
129 cx23885_free_buffer(dev, buf);
132 static void buffer_queue(struct vb2_buffer *vb)
134 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
135 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
136 struct cx23885_buffer *buf = container_of(vbuf,
137 struct cx23885_buffer, vb);
139 cx23885_buf_queue(port, buf);
142 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
144 struct vb2_dvb_frontends *f;
145 struct vb2_dvb_frontend *fe;
147 f = &port->frontends;
149 if (f->gate <= 1) /* undefined or fe0 */
150 fe = vb2_dvb_get_frontend(f, 1);
152 fe = vb2_dvb_get_frontend(f, f->gate);
154 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
155 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
158 static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
160 struct cx23885_tsport *port = q->drv_priv;
161 struct cx23885_dmaqueue *dmaq = &port->mpegq;
162 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
163 struct cx23885_buffer, queue);
165 cx23885_start_dma(port, dmaq, buf);
169 static void cx23885_stop_streaming(struct vb2_queue *q)
171 struct cx23885_tsport *port = q->drv_priv;
173 cx23885_cancel_buffers(port);
176 static struct vb2_ops dvb_qops = {
177 .queue_setup = queue_setup,
178 .buf_prepare = buffer_prepare,
179 .buf_finish = buffer_finish,
180 .buf_queue = buffer_queue,
181 .wait_prepare = vb2_ops_wait_prepare,
182 .wait_finish = vb2_ops_wait_finish,
183 .start_streaming = cx23885_start_streaming,
184 .stop_streaming = cx23885_stop_streaming,
187 static struct s5h1409_config hauppauge_generic_config = {
188 .demod_address = 0x32 >> 1,
189 .output_mode = S5H1409_SERIAL_OUTPUT,
190 .gpio = S5H1409_GPIO_ON,
192 .inversion = S5H1409_INVERSION_OFF,
193 .status_mode = S5H1409_DEMODLOCKING,
194 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
197 static struct tda10048_config hauppauge_hvr1200_config = {
198 .demod_address = 0x10 >> 1,
199 .output_mode = TDA10048_SERIAL_OUTPUT,
200 .fwbulkwritelen = TDA10048_BULKWRITE_200,
201 .inversion = TDA10048_INVERSION_ON,
202 .dtv6_if_freq_khz = TDA10048_IF_3300,
203 .dtv7_if_freq_khz = TDA10048_IF_3800,
204 .dtv8_if_freq_khz = TDA10048_IF_4300,
205 .clk_freq_khz = TDA10048_CLK_16000,
208 static struct tda10048_config hauppauge_hvr1210_config = {
209 .demod_address = 0x10 >> 1,
210 .output_mode = TDA10048_SERIAL_OUTPUT,
211 .fwbulkwritelen = TDA10048_BULKWRITE_200,
212 .inversion = TDA10048_INVERSION_ON,
213 .dtv6_if_freq_khz = TDA10048_IF_3300,
214 .dtv7_if_freq_khz = TDA10048_IF_3500,
215 .dtv8_if_freq_khz = TDA10048_IF_4000,
216 .clk_freq_khz = TDA10048_CLK_16000,
219 static struct s5h1409_config hauppauge_ezqam_config = {
220 .demod_address = 0x32 >> 1,
221 .output_mode = S5H1409_SERIAL_OUTPUT,
222 .gpio = S5H1409_GPIO_OFF,
224 .inversion = S5H1409_INVERSION_ON,
225 .status_mode = S5H1409_DEMODLOCKING,
226 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
229 static struct s5h1409_config hauppauge_hvr1800lp_config = {
230 .demod_address = 0x32 >> 1,
231 .output_mode = S5H1409_SERIAL_OUTPUT,
232 .gpio = S5H1409_GPIO_OFF,
234 .inversion = S5H1409_INVERSION_OFF,
235 .status_mode = S5H1409_DEMODLOCKING,
236 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
239 static struct s5h1409_config hauppauge_hvr1500_config = {
240 .demod_address = 0x32 >> 1,
241 .output_mode = S5H1409_SERIAL_OUTPUT,
242 .gpio = S5H1409_GPIO_OFF,
243 .inversion = S5H1409_INVERSION_OFF,
244 .status_mode = S5H1409_DEMODLOCKING,
245 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
248 static struct mt2131_config hauppauge_generic_tunerconfig = {
252 static struct lgdt330x_config fusionhdtv_5_express = {
253 .demod_address = 0x0e,
254 .demod_chip = LGDT3303,
258 static struct s5h1409_config hauppauge_hvr1500q_config = {
259 .demod_address = 0x32 >> 1,
260 .output_mode = S5H1409_SERIAL_OUTPUT,
261 .gpio = S5H1409_GPIO_ON,
263 .inversion = S5H1409_INVERSION_OFF,
264 .status_mode = S5H1409_DEMODLOCKING,
265 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
268 static struct s5h1409_config dvico_s5h1409_config = {
269 .demod_address = 0x32 >> 1,
270 .output_mode = S5H1409_SERIAL_OUTPUT,
271 .gpio = S5H1409_GPIO_ON,
273 .inversion = S5H1409_INVERSION_OFF,
274 .status_mode = S5H1409_DEMODLOCKING,
275 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
278 static struct s5h1411_config dvico_s5h1411_config = {
279 .output_mode = S5H1411_SERIAL_OUTPUT,
280 .gpio = S5H1411_GPIO_ON,
281 .qam_if = S5H1411_IF_44000,
282 .vsb_if = S5H1411_IF_44000,
283 .inversion = S5H1411_INVERSION_OFF,
284 .status_mode = S5H1411_DEMODLOCKING,
285 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
288 static struct s5h1411_config hcw_s5h1411_config = {
289 .output_mode = S5H1411_SERIAL_OUTPUT,
290 .gpio = S5H1411_GPIO_OFF,
291 .vsb_if = S5H1411_IF_44000,
292 .qam_if = S5H1411_IF_4000,
293 .inversion = S5H1411_INVERSION_ON,
294 .status_mode = S5H1411_DEMODLOCKING,
295 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
298 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
303 static struct xc5000_config dvico_xc5000_tunerconfig = {
308 static struct tda829x_config tda829x_no_probe = {
309 .probe_tuner = TDA829X_DONT_PROBE,
312 static struct tda18271_std_map hauppauge_tda18271_std_map = {
313 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
314 .if_lvl = 6, .rfagc_top = 0x37 },
315 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
316 .if_lvl = 6, .rfagc_top = 0x37 },
319 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
320 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
321 .if_lvl = 1, .rfagc_top = 0x37, },
322 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
323 .if_lvl = 1, .rfagc_top = 0x37, },
324 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
325 .if_lvl = 1, .rfagc_top = 0x37, },
328 static struct tda18271_config hauppauge_tda18271_config = {
329 .std_map = &hauppauge_tda18271_std_map,
330 .gate = TDA18271_GATE_ANALOG,
331 .output_opt = TDA18271_OUTPUT_LT_OFF,
334 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
335 .std_map = &hauppauge_hvr1200_tda18271_std_map,
336 .gate = TDA18271_GATE_ANALOG,
337 .output_opt = TDA18271_OUTPUT_LT_OFF,
340 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
341 .gate = TDA18271_GATE_DIGITAL,
342 .output_opt = TDA18271_OUTPUT_LT_OFF,
345 static struct tda18271_config hauppauge_hvr4400_tuner_config = {
346 .gate = TDA18271_GATE_DIGITAL,
347 .output_opt = TDA18271_OUTPUT_LT_OFF,
350 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
351 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
352 .if_lvl = 1, .rfagc_top = 0x58 },
353 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
354 .if_lvl = 1, .rfagc_top = 0x58 },
357 static struct tda18271_config hauppauge_hvr127x_config = {
358 .std_map = &hauppauge_hvr127x_std_map,
359 .output_opt = TDA18271_OUTPUT_LT_OFF,
362 static struct lgdt3305_config hauppauge_lgdt3305_config = {
364 .mpeg_mode = LGDT3305_MPEG_SERIAL,
365 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
366 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
368 .spectral_inversion = 1,
373 static struct dibx000_agc_config xc3028_agc_config = {
374 BAND_VHF | BAND_UHF, /* band_caps */
376 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
377 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
378 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
379 * P_agc_nb_est=2, P_agc_write=0
381 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
382 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
385 21, /* time_stabiliz */
397 39718, /* agc2_max */
406 29, /* agc2_slope1 */
407 29, /* agc2_slope2 */
414 1, /* perform_agc_softsplit */
417 /* PLL Configuration for COFDM BW_MHz = 8.000000
418 * With external clock = 30.000000 */
419 static struct dibx000_bandwidth_config xc3028_bw_config = {
420 60000, /* internal */
421 30000, /* sampling */
422 1, /* pll_cfg: prediv */
423 8, /* pll_cfg: ratio */
424 3, /* pll_cfg: range */
425 1, /* pll_cfg: reset */
426 0, /* pll_cfg: bypass */
427 0, /* misc: refdiv */
428 0, /* misc: bypclk_div */
429 1, /* misc: IO_CLK_en_core */
430 1, /* misc: ADClkSrc */
431 0, /* misc: modulo */
432 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
433 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
435 30000000 /* xtal_hz */
438 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
439 .output_mpeg2_in_188_bytes = 1,
440 .hostbus_diversity = 1,
441 .tuner_is_baseband = 0,
444 .agc_config_count = 1,
445 .agc = &xc3028_agc_config,
446 .bw = &xc3028_bw_config,
448 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
449 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
450 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
456 .output_mode = OUTMODE_MPEG2_SERIAL,
459 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
460 .demod_address = 0x0f,
463 .disable_i2c_gate_ctrl = 1,
466 static struct stv0900_reg stv0900_ts_regs[] = {
467 { R0900_TSGENERAL, 0x00 },
468 { R0900_P1_TSSPEED, 0x40 },
469 { R0900_P2_TSSPEED, 0x40 },
470 { R0900_P1_TSCFGM, 0xc0 },
471 { R0900_P2_TSCFGM, 0xc0 },
472 { R0900_P1_TSCFGH, 0xe0 },
473 { R0900_P2_TSCFGH, 0xe0 },
474 { R0900_P1_TSCFGL, 0x20 },
475 { R0900_P2_TSCFGL, 0x20 },
476 { 0xffff, 0xff }, /* terminate */
479 static struct stv0900_config netup_stv0900_config = {
480 .demod_address = 0x68,
481 .demod_mode = 1, /* dual */
483 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
484 .diseqc_mode = 2,/* 2/3 PWM */
485 .ts_config_regs = stv0900_ts_regs,
486 .tun1_maddress = 0,/* 0x60 */
487 .tun2_maddress = 3,/* 0x63 */
488 .tun1_adc = 1,/* 1 Vpp */
489 .tun2_adc = 1,/* 1 Vpp */
492 static struct stv6110_config netup_stv6110_tunerconfig_a = {
496 .gain = 8, /* +16 dB - maximum gain */
499 static struct stv6110_config netup_stv6110_tunerconfig_b = {
503 .gain = 8, /* +16 dB - maximum gain */
506 static struct cx24116_config tbs_cx24116_config = {
507 .demod_address = 0x55,
510 static struct cx24117_config tbs_cx24117_config = {
511 .demod_address = 0x55,
514 static struct ds3000_config tevii_ds3000_config = {
515 .demod_address = 0x68,
518 static struct ts2020_config tevii_ts2020_config = {
519 .tuner_address = 0x60,
521 .frequency_div = 1146000,
524 static struct cx24116_config dvbworld_cx24116_config = {
525 .demod_address = 0x05,
528 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
529 .prod = LGS8GXX_PROD_LGS8GL5,
530 .demod_address = 0x19,
534 .if_clk_freq = 30400, /* 30.4 MHz */
535 .if_freq = 5380, /* 5.38 MHz */
542 static struct xc5000_config mygica_x8506_xc5000_config = {
547 static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
548 .demod_address = 0x10,
551 static struct xc5000_config mygica_x8507_xc5000_config = {
556 static struct stv090x_config prof_8000_stv090x_config = {
558 .demod_mode = STV090x_SINGLE,
559 .clk_mode = STV090x_CLK_EXT,
562 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
563 .repeater_level = STV090x_RPTLEVEL_64,
564 .adc1_range = STV090x_ADC_2Vpp,
565 .diseqc_envelope_mode = false,
567 .tuner_get_frequency = stb6100_get_frequency,
568 .tuner_set_frequency = stb6100_set_frequency,
569 .tuner_set_bandwidth = stb6100_set_bandwidth,
570 .tuner_get_bandwidth = stb6100_get_bandwidth,
573 static struct stb6100_config prof_8000_stb6100_config = {
574 .tuner_address = 0x60,
575 .refclock = 27000000,
578 static int p8000_set_voltage(struct dvb_frontend *fe,
579 enum fe_sec_voltage voltage)
581 struct cx23885_tsport *port = fe->dvb->priv;
582 struct cx23885_dev *dev = port->dev;
584 if (voltage == SEC_VOLTAGE_18)
585 cx_write(MC417_RWD, 0x00001e00);
586 else if (voltage == SEC_VOLTAGE_13)
587 cx_write(MC417_RWD, 0x00001a00);
589 cx_write(MC417_RWD, 0x00001800);
593 static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
594 enum fe_sec_voltage voltage)
596 struct cx23885_tsport *port = fe->dvb->priv;
597 struct cx23885_dev *dev = port->dev;
599 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
603 cx23885_gpio_set(dev, GPIO_1);
604 cx23885_gpio_clear(dev, GPIO_0);
607 cx23885_gpio_set(dev, GPIO_1);
608 cx23885_gpio_set(dev, GPIO_0);
610 case SEC_VOLTAGE_OFF:
611 cx23885_gpio_clear(dev, GPIO_1);
612 cx23885_gpio_clear(dev, GPIO_0);
616 /* call the frontend set_voltage function */
617 port->fe_set_voltage(fe, voltage);
622 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
623 enum fe_sec_voltage voltage)
625 struct cx23885_tsport *port = fe->dvb->priv;
626 struct cx23885_dev *dev = port->dev;
628 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
632 cx23885_gpio_set(dev, GPIO_13);
633 cx23885_gpio_clear(dev, GPIO_12);
636 cx23885_gpio_set(dev, GPIO_13);
637 cx23885_gpio_set(dev, GPIO_12);
639 case SEC_VOLTAGE_OFF:
640 cx23885_gpio_clear(dev, GPIO_13);
641 cx23885_gpio_clear(dev, GPIO_12);
644 /* call the frontend set_voltage function */
645 return port->fe_set_voltage(fe, voltage);
648 static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
652 #define SP2_DATA 0x000000ff
653 #define SP2_WR 0x00008000
654 #define SP2_RD 0x00004000
655 #define SP2_ACK 0x00001000
656 #define SP2_ADHI 0x00000800
657 #define SP2_ADLO 0x00000400
658 #define SP2_CS1 0x00000200
659 #define SP2_CS0 0x00000100
660 #define SP2_EN_ALL 0x00001000
661 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
663 struct cx23885_tsport *port = priv;
664 struct cx23885_dev *dev = port->dev;
667 unsigned long timeout;
669 mutex_lock(&dev->gpio_lock);
672 cx_write(MC417_OEN, SP2_EN_ALL);
673 cx_write(MC417_RWD, SP2_CTRL_OFF |
674 SP2_ADLO | (0xff & addr));
675 cx_clear(MC417_RWD, SP2_ADLO);
676 cx_write(MC417_RWD, SP2_CTRL_OFF |
677 SP2_ADHI | (0xff & (addr >> 8)));
678 cx_clear(MC417_RWD, SP2_ADHI);
682 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
685 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
688 cx_clear(MC417_RWD, SP2_CS0);
691 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
693 /* wait for a maximum of 1 msec */
694 timeout = jiffies + msecs_to_jiffies(1);
695 while (!time_after(jiffies, timeout)) {
696 tmp = cx_read(MC417_RWD);
697 if ((tmp & SP2_ACK) == 0)
699 usleep_range(50, 100);
702 cx_set(MC417_RWD, SP2_CTRL_OFF);
705 mutex_unlock(&dev->gpio_lock);
719 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
721 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
722 struct cx23885_tsport *port = fe->dvb->priv;
723 struct cx23885_dev *dev = port->dev;
725 switch (dev->board) {
726 case CX23885_BOARD_HAUPPAUGE_HVR1275:
727 switch (p->modulation) {
729 cx23885_gpio_clear(dev, GPIO_5);
734 cx23885_gpio_set(dev, GPIO_5);
738 case CX23885_BOARD_MYGICA_X8506:
739 case CX23885_BOARD_MYGICA_X8507:
740 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
741 /* Select Digital TV */
742 cx23885_gpio_set(dev, GPIO_0);
746 /* Call the real set_frontend */
747 if (port->set_frontend)
748 return port->set_frontend(fe);
753 static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
754 struct dvb_frontend *fe)
756 port->set_frontend = fe->ops.set_frontend;
757 fe->ops.set_frontend = cx23885_dvb_set_frontend;
760 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
761 .prod = LGS8GXX_PROD_LGS8G75,
762 .demod_address = 0x19,
766 .if_clk_freq = 30400, /* 30.4 MHz */
767 .if_freq = 6500, /* 6.50 MHz */
771 .adc_vpp = 2, /* 1.6 Vpp */
775 static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
780 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
781 .prod = ATBM8830_PROD_8830,
782 .demod_address = 0x44,
784 .ts_sampling_edge = 1,
786 .osc_clk_freq = 30400, /* in kHz */
787 .if_freq = 0, /* zero IF */
794 static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
799 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
800 .prod = ATBM8830_PROD_8830,
801 .demod_address = 0x44,
803 .ts_sampling_edge = 1,
805 .osc_clk_freq = 30400, /* in kHz */
806 .if_freq = 0, /* zero IF */
813 static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
817 static struct stv0367_config netup_stv0367_config[] = {
819 .demod_address = 0x1c,
826 .demod_address = 0x1d,
835 static struct xc5000_config netup_xc5000_config[] = {
845 static struct drxk_config terratec_drxk_config[] = {
855 static struct mt2063_config terratec_mt2063_config[] = {
857 .tuner_address = 0x60,
859 .tuner_address = 0x67,
863 static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
864 .clk = 40444000, /* 40.444 MHz */
866 .ts_mode = TDA10071_TS_SERIAL,
867 .pll_multiplier = 20,
868 .tuner_i2c_addr = 0x54,
871 static const struct si2165_config hauppauge_hvr4400_si2165_config = {
873 .chip_mode = SI2165_MODE_PLL_XTAL,
874 .ref_freq_Hz = 16000000,
877 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
882 .ts_mode = M88DS3103_TS_PARALLEL,
890 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
895 .ts_mode = M88DS3103_TS_CI,
903 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
908 .ts_mode = M88DS3103_TS_SERIAL,
916 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
920 .ts_mode = M88DS3103_TS_PARALLEL,
926 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
928 struct cx23885_dev *dev = (struct cx23885_dev *)device;
929 unsigned long timeout = jiffies + msecs_to_jiffies(1);
932 mem = cx_read(MC417_RWD);
934 cx_set(MC417_OEN, ALT_DATA);
936 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
938 mem |= (data & ALT_DATA);
948 mem = (mem & ~ALT_RD) | ALT_WR;
950 mem = (mem & ~ALT_WR) | ALT_RD;
952 cx_write(MC417_RWD, mem); /* start RW cycle */
955 mem = cx_read(MC417_RWD);
956 if ((mem & ALT_RDY) == 0)
958 if (time_after(jiffies, timeout))
963 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
965 return mem & ALT_DATA;
970 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
972 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
974 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
977 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
982 static struct dib0070_config dib7070p_dib0070_config = {
983 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
984 .reset = dib7070_tuner_reset,
985 .sleep = dib7070_tuner_sleep,
987 .freq_offset_khz_vhf = 550,
988 /* .flip_chip = 1, */
991 /* DIB7070 generic */
992 static struct dibx000_agc_config dib7070_agc_config = {
993 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
996 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
997 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
998 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1000 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1001 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1003 .time_stabiliz = 10,
1027 .perform_agc_softsplit = 0,
1030 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1040 .IO_CLK_en_core = 1,
1043 /* refsel, sel, freq_15k */
1044 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1045 .ifreq = (0 << 25) | 0,
1047 .xtal_hz = 12000000,
1050 static struct dib7000p_config dib7070p_dib7000p_config = {
1051 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1052 .output_mode = OUTMODE_MPEG2_SERIAL,
1053 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1054 .output_mpeg2_in_188_bytes = 1,
1056 .agc_config_count = 1,
1057 .agc = &dib7070_agc_config,
1058 .bw = &dib7070_bw_config_12_mhz,
1059 .tuner_is_baseband = 1,
1062 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1063 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1064 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1066 .hostbus_diversity = 1,
1069 static int dvb_register_ci_mac(struct cx23885_tsport *port)
1071 struct cx23885_dev *dev = port->dev;
1072 struct i2c_client *client_ci = NULL;
1073 struct vb2_dvb_frontend *fe0;
1075 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1079 switch (dev->board) {
1080 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1081 static struct netup_card_info cinfo;
1083 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1084 memcpy(port->frontends.adapter.proposed_mac,
1085 cinfo.port[port->nr - 1].mac, 6);
1086 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1087 port->nr, port->frontends.adapter.proposed_mac);
1089 netup_ci_init(port);
1092 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1093 struct altera_ci_config netup_ci_cfg = {
1094 .dev = dev,/* magic number to identify*/
1095 .adapter = &port->frontends.adapter,/* for CI */
1096 .demux = &fe0->dvb.demux,/* for hw pid filter */
1097 .fpga_rw = netup_altera_fpga_rw,
1100 altera_ci_init(&netup_ci_cfg, port->nr);
1103 case CX23885_BOARD_TEVII_S470: {
1104 u8 eeprom[256]; /* 24C02 i2c eeprom */
1109 /* Read entire EEPROM */
1110 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1111 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1112 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1113 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1116 case CX23885_BOARD_DVBSKY_T9580:
1117 case CX23885_BOARD_DVBSKY_S950:
1118 case CX23885_BOARD_DVBSKY_S952:
1119 case CX23885_BOARD_DVBSKY_T982: {
1120 u8 eeprom[256]; /* 24C02 i2c eeprom */
1125 /* Read entire EEPROM */
1126 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1127 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1129 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1130 cx23885_boards[dev->board].name, port->nr,
1131 eeprom + 0xc0 + (port->nr-1) * 8);
1132 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1133 (port->nr-1) * 8, 6);
1136 case CX23885_BOARD_DVBSKY_S950C:
1137 case CX23885_BOARD_DVBSKY_T980C:
1138 case CX23885_BOARD_TT_CT2_4500_CI: {
1139 u8 eeprom[256]; /* 24C02 i2c eeprom */
1140 struct sp2_config sp2_config;
1141 struct i2c_board_info info;
1142 struct cx23885_i2c *i2c_bus2 = &dev->i2c_bus[1];
1145 memset(&sp2_config, 0, sizeof(sp2_config));
1146 sp2_config.dvb_adap = &port->frontends.adapter;
1147 sp2_config.priv = port;
1148 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1149 memset(&info, 0, sizeof(struct i2c_board_info));
1150 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1152 info.platform_data = &sp2_config;
1153 request_module(info.type);
1154 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
1155 if (client_ci == NULL || client_ci->dev.driver == NULL)
1157 if (!try_module_get(client_ci->dev.driver->owner)) {
1158 i2c_unregister_device(client_ci);
1161 port->i2c_client_ci = client_ci;
1166 /* Read entire EEPROM */
1167 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1168 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1170 printk(KERN_INFO "%s MAC address: %pM\n",
1171 cx23885_boards[dev->board].name, eeprom + 0xc0);
1172 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1179 static int dvb_register(struct cx23885_tsport *port)
1181 struct dib7000p_ops dib7000p_ops;
1182 struct cx23885_dev *dev = port->dev;
1183 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
1184 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
1185 struct si2168_config si2168_config;
1186 struct si2157_config si2157_config;
1187 struct ts2020_config ts2020_config;
1188 struct i2c_board_info info;
1189 struct i2c_adapter *adapter;
1190 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1191 struct i2c_client *client_sec = NULL;
1192 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1193 int (*p_set_voltage)(struct dvb_frontend *fe,
1194 enum fe_sec_voltage voltage) = NULL;
1195 int mfe_shared = 0; /* bus not shared by default */
1198 /* Get the first frontend */
1199 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1203 /* init struct vb2_dvb */
1204 fe0->dvb.name = dev->name;
1206 /* multi-frontend gate control is undefined or defaults to fe0 */
1207 port->frontends.gate = 0;
1209 /* Sets the gate control callback to be used by i2c command calls */
1210 port->gate_ctrl = cx23885_dvb_gate_ctrl;
1213 switch (dev->board) {
1214 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1215 i2c_bus = &dev->i2c_bus[0];
1216 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1217 &hauppauge_generic_config,
1218 &i2c_bus->i2c_adap);
1219 if (fe0->dvb.frontend == NULL)
1221 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1223 &hauppauge_generic_tunerconfig, 0);
1225 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1226 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1227 i2c_bus = &dev->i2c_bus[0];
1228 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1229 &hauppauge_lgdt3305_config,
1230 &i2c_bus->i2c_adap);
1231 if (fe0->dvb.frontend == NULL)
1233 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1234 0x60, &dev->i2c_bus[1].i2c_adap,
1235 &hauppauge_hvr127x_config);
1236 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
1237 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1239 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1240 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1241 i2c_bus = &dev->i2c_bus[0];
1242 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1243 &hcw_s5h1411_config,
1244 &i2c_bus->i2c_adap);
1245 if (fe0->dvb.frontend == NULL)
1248 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1249 0x60, &dev->i2c_bus[1].i2c_adap,
1250 &hauppauge_tda18271_config);
1252 tda18271_attach(&dev->ts1.analog_fe,
1253 0x60, &dev->i2c_bus[1].i2c_adap,
1254 &hauppauge_tda18271_config);
1257 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1258 i2c_bus = &dev->i2c_bus[0];
1259 switch (alt_tuner) {
1262 dvb_attach(s5h1409_attach,
1263 &hauppauge_ezqam_config,
1264 &i2c_bus->i2c_adap);
1265 if (fe0->dvb.frontend == NULL)
1268 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1269 &dev->i2c_bus[1].i2c_adap, 0x42,
1271 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1272 0x60, &dev->i2c_bus[1].i2c_adap,
1273 &hauppauge_tda18271_config);
1278 dvb_attach(s5h1409_attach,
1279 &hauppauge_generic_config,
1280 &i2c_bus->i2c_adap);
1281 if (fe0->dvb.frontend == NULL)
1283 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1285 &hauppauge_generic_tunerconfig, 0);
1288 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
1289 i2c_bus = &dev->i2c_bus[0];
1290 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1291 &hauppauge_hvr1800lp_config,
1292 &i2c_bus->i2c_adap);
1293 if (fe0->dvb.frontend == NULL)
1295 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1297 &hauppauge_generic_tunerconfig, 0);
1299 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
1300 i2c_bus = &dev->i2c_bus[0];
1301 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1302 &fusionhdtv_5_express,
1303 &i2c_bus->i2c_adap);
1304 if (fe0->dvb.frontend == NULL)
1306 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1307 &i2c_bus->i2c_adap, 0x61,
1308 TUNER_LG_TDVS_H06XF);
1310 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1311 i2c_bus = &dev->i2c_bus[1];
1312 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1313 &hauppauge_hvr1500q_config,
1314 &dev->i2c_bus[0].i2c_adap);
1315 if (fe0->dvb.frontend == NULL)
1317 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1319 &hauppauge_hvr1500q_tunerconfig);
1321 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1322 i2c_bus = &dev->i2c_bus[1];
1323 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1324 &hauppauge_hvr1500_config,
1325 &dev->i2c_bus[0].i2c_adap);
1326 if (fe0->dvb.frontend != NULL) {
1327 struct dvb_frontend *fe;
1328 struct xc2028_config cfg = {
1329 .i2c_adap = &i2c_bus->i2c_adap,
1332 static struct xc2028_ctrl ctl = {
1333 .fname = "/*(DEBLOBBED)*/",
1335 .demod = XC3028_FE_OREN538,
1338 fe = dvb_attach(xc2028_attach,
1339 fe0->dvb.frontend, &cfg);
1340 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1341 fe->ops.tuner_ops.set_config(fe, &ctl);
1344 case CX23885_BOARD_HAUPPAUGE_HVR1200:
1345 case CX23885_BOARD_HAUPPAUGE_HVR1700:
1346 i2c_bus = &dev->i2c_bus[0];
1347 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1348 &hauppauge_hvr1200_config,
1349 &i2c_bus->i2c_adap);
1350 if (fe0->dvb.frontend == NULL)
1352 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1353 &dev->i2c_bus[1].i2c_adap, 0x42,
1355 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1356 0x60, &dev->i2c_bus[1].i2c_adap,
1357 &hauppauge_hvr1200_tuner_config);
1359 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1360 i2c_bus = &dev->i2c_bus[0];
1361 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1362 &hauppauge_hvr1210_config,
1363 &i2c_bus->i2c_adap);
1364 if (fe0->dvb.frontend != NULL) {
1365 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1366 0x60, &dev->i2c_bus[1].i2c_adap,
1367 &hauppauge_hvr1210_tuner_config);
1370 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1371 i2c_bus = &dev->i2c_bus[0];
1373 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1376 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
1377 0x12, &hauppauge_hvr1400_dib7000_config);
1378 if (fe0->dvb.frontend != NULL) {
1379 struct dvb_frontend *fe;
1380 struct xc2028_config cfg = {
1381 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1384 static struct xc2028_ctrl ctl = {
1385 .fname = "/*(DEBLOBBED)*/",
1387 .demod = XC3028_FE_DIBCOM52,
1388 /* This is true for all demods with
1390 .type = XC2028_D2633,
1393 fe = dvb_attach(xc2028_attach,
1394 fe0->dvb.frontend, &cfg);
1395 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1396 fe->ops.tuner_ops.set_config(fe, &ctl);
1399 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1400 i2c_bus = &dev->i2c_bus[port->nr - 1];
1402 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1403 &dvico_s5h1409_config,
1404 &i2c_bus->i2c_adap);
1405 if (fe0->dvb.frontend == NULL)
1406 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1407 &dvico_s5h1411_config,
1408 &i2c_bus->i2c_adap);
1409 if (fe0->dvb.frontend != NULL)
1410 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1412 &dvico_xc5000_tunerconfig);
1414 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
1415 i2c_bus = &dev->i2c_bus[port->nr - 1];
1417 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1418 &dvico_fusionhdtv_xc3028,
1419 &i2c_bus->i2c_adap);
1420 if (fe0->dvb.frontend != NULL) {
1421 struct dvb_frontend *fe;
1422 struct xc2028_config cfg = {
1423 .i2c_adap = &i2c_bus->i2c_adap,
1426 static struct xc2028_ctrl ctl = {
1427 .fname = "/*(DEBLOBBED)*/",
1429 .demod = XC3028_FE_ZARLINK456,
1432 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1434 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1435 fe->ops.tuner_ops.set_config(fe, &ctl);
1439 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
1440 i2c_bus = &dev->i2c_bus[port->nr - 1];
1441 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1442 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1444 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1447 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1448 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1451 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
1452 if (fe0->dvb.frontend != NULL) {
1453 struct i2c_adapter *tun_i2c;
1455 fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
1456 if (!fe0->dvb.frontend->sec_priv)
1458 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1459 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1464 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1465 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1466 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1467 i2c_bus = &dev->i2c_bus[0];
1469 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1470 &dvico_fusionhdtv_xc3028,
1471 &i2c_bus->i2c_adap);
1472 if (fe0->dvb.frontend != NULL) {
1473 struct dvb_frontend *fe;
1474 struct xc2028_config cfg = {
1475 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1478 static struct xc2028_ctrl ctl = {
1479 .fname = "/*(DEBLOBBED)*/",
1481 .demod = XC3028_FE_ZARLINK456,
1484 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1486 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1487 fe->ops.tuner_ops.set_config(fe, &ctl);
1490 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1491 i2c_bus = &dev->i2c_bus[0];
1493 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1494 &dvico_fusionhdtv_xc3028,
1495 &i2c_bus->i2c_adap);
1496 if (fe0->dvb.frontend != NULL) {
1497 struct dvb_frontend *fe;
1498 struct xc4000_config cfg = {
1499 .i2c_address = 0x61,
1501 .dvb_amplitude = 134,
1502 .set_smoothedcvbs = 1,
1506 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1507 &dev->i2c_bus[1].i2c_adap, &cfg);
1509 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1511 goto frontend_detach;
1515 case CX23885_BOARD_TBS_6920:
1516 i2c_bus = &dev->i2c_bus[1];
1518 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1519 &tbs_cx24116_config,
1520 &i2c_bus->i2c_adap);
1521 if (fe0->dvb.frontend != NULL)
1522 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1525 case CX23885_BOARD_TBS_6980:
1526 case CX23885_BOARD_TBS_6981:
1527 i2c_bus = &dev->i2c_bus[1];
1532 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1533 &tbs_cx24117_config,
1534 &i2c_bus->i2c_adap);
1538 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1539 &tbs_cx24117_config,
1540 &i2c_bus->i2c_adap);
1544 case CX23885_BOARD_TEVII_S470:
1545 i2c_bus = &dev->i2c_bus[1];
1547 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1548 &tevii_ds3000_config,
1549 &i2c_bus->i2c_adap);
1550 if (fe0->dvb.frontend != NULL) {
1551 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1552 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1553 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1557 case CX23885_BOARD_DVBWORLD_2005:
1558 i2c_bus = &dev->i2c_bus[1];
1560 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1561 &dvbworld_cx24116_config,
1562 &i2c_bus->i2c_adap);
1564 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1565 i2c_bus = &dev->i2c_bus[0];
1569 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1570 &netup_stv0900_config,
1571 &i2c_bus->i2c_adap, 0);
1572 if (fe0->dvb.frontend != NULL) {
1573 if (dvb_attach(stv6110_attach,
1575 &netup_stv6110_tunerconfig_a,
1576 &i2c_bus->i2c_adap)) {
1577 if (!dvb_attach(lnbh24_attach,
1580 LNBH24_PCL | LNBH24_TTX,
1583 "No LNBH24 found!\n");
1590 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1591 &netup_stv0900_config,
1592 &i2c_bus->i2c_adap, 1);
1593 if (fe0->dvb.frontend != NULL) {
1594 if (dvb_attach(stv6110_attach,
1596 &netup_stv6110_tunerconfig_b,
1597 &i2c_bus->i2c_adap)) {
1598 if (!dvb_attach(lnbh24_attach,
1601 LNBH24_PCL | LNBH24_TTX,
1604 "No LNBH24 found!\n");
1611 case CX23885_BOARD_MYGICA_X8506:
1612 i2c_bus = &dev->i2c_bus[0];
1613 i2c_bus2 = &dev->i2c_bus[1];
1614 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1615 &mygica_x8506_lgs8gl5_config,
1616 &i2c_bus->i2c_adap);
1617 if (fe0->dvb.frontend == NULL)
1619 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1620 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1621 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1623 case CX23885_BOARD_MYGICA_X8507:
1624 i2c_bus = &dev->i2c_bus[0];
1625 i2c_bus2 = &dev->i2c_bus[1];
1626 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1627 &mygica_x8507_mb86a20s_config,
1628 &i2c_bus->i2c_adap);
1629 if (fe0->dvb.frontend == NULL)
1632 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1633 &i2c_bus2->i2c_adap,
1634 &mygica_x8507_xc5000_config);
1635 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1637 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1638 i2c_bus = &dev->i2c_bus[0];
1639 i2c_bus2 = &dev->i2c_bus[1];
1640 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1641 &magicpro_prohdtve2_lgs8g75_config,
1642 &i2c_bus->i2c_adap);
1643 if (fe0->dvb.frontend == NULL)
1645 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1646 &i2c_bus2->i2c_adap,
1647 &magicpro_prohdtve2_xc5000_config);
1648 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1650 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1651 i2c_bus = &dev->i2c_bus[0];
1652 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1653 &hcw_s5h1411_config,
1654 &i2c_bus->i2c_adap);
1655 if (fe0->dvb.frontend == NULL)
1657 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1658 0x60, &dev->i2c_bus[0].i2c_adap,
1659 &hauppauge_tda18271_config);
1661 tda18271_attach(&dev->ts1.analog_fe,
1662 0x60, &dev->i2c_bus[1].i2c_adap,
1663 &hauppauge_tda18271_config);
1666 case CX23885_BOARD_HAUPPAUGE_HVR1290:
1667 i2c_bus = &dev->i2c_bus[0];
1668 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1669 &hcw_s5h1411_config,
1670 &i2c_bus->i2c_adap);
1671 if (fe0->dvb.frontend == NULL)
1673 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1674 0x60, &dev->i2c_bus[0].i2c_adap,
1675 &hauppauge_tda18271_config);
1677 case CX23885_BOARD_MYGICA_X8558PRO:
1681 i2c_bus = &dev->i2c_bus[0];
1682 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1683 &mygica_x8558pro_atbm8830_cfg1,
1684 &i2c_bus->i2c_adap);
1685 if (fe0->dvb.frontend == NULL)
1687 dvb_attach(max2165_attach, fe0->dvb.frontend,
1689 &mygic_x8558pro_max2165_cfg1);
1693 i2c_bus = &dev->i2c_bus[1];
1694 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1695 &mygica_x8558pro_atbm8830_cfg2,
1696 &i2c_bus->i2c_adap);
1697 if (fe0->dvb.frontend == NULL)
1699 dvb_attach(max2165_attach, fe0->dvb.frontend,
1701 &mygic_x8558pro_max2165_cfg2);
1704 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1705 i2c_bus = &dev->i2c_bus[0];
1706 mfe_shared = 1;/* MFE */
1707 port->frontends.gate = 0;/* not clear for me yet */
1709 /* MFE frontend 1 DVB-T */
1710 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1711 &netup_stv0367_config[port->nr - 1],
1712 &i2c_bus->i2c_adap);
1713 if (fe0->dvb.frontend == NULL)
1715 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1717 &netup_xc5000_config[port->nr - 1]))
1718 goto frontend_detach;
1719 /* load xc5000 firmware */
1720 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1722 /* MFE frontend 2 */
1723 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1725 goto frontend_detach;
1727 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1728 &netup_stv0367_config[port->nr - 1],
1729 &i2c_bus->i2c_adap);
1730 if (fe1->dvb.frontend == NULL)
1733 fe1->dvb.frontend->id = 1;
1734 if (NULL == dvb_attach(xc5000_attach,
1737 &netup_xc5000_config[port->nr - 1]))
1738 goto frontend_detach;
1740 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1741 i2c_bus = &dev->i2c_bus[0];
1742 i2c_bus2 = &dev->i2c_bus[1];
1747 fe0->dvb.frontend = dvb_attach(drxk_attach,
1748 &terratec_drxk_config[0],
1749 &i2c_bus->i2c_adap);
1750 if (fe0->dvb.frontend == NULL)
1752 if (!dvb_attach(mt2063_attach,
1754 &terratec_mt2063_config[0],
1755 &i2c_bus2->i2c_adap))
1756 goto frontend_detach;
1760 fe0->dvb.frontend = dvb_attach(drxk_attach,
1761 &terratec_drxk_config[1],
1762 &i2c_bus->i2c_adap);
1763 if (fe0->dvb.frontend == NULL)
1765 if (!dvb_attach(mt2063_attach,
1767 &terratec_mt2063_config[1],
1768 &i2c_bus2->i2c_adap))
1769 goto frontend_detach;
1773 case CX23885_BOARD_TEVII_S471:
1774 i2c_bus = &dev->i2c_bus[1];
1776 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1777 &tevii_ds3000_config,
1778 &i2c_bus->i2c_adap);
1779 if (fe0->dvb.frontend == NULL)
1781 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1782 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1784 case CX23885_BOARD_PROF_8000:
1785 i2c_bus = &dev->i2c_bus[0];
1787 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1788 &prof_8000_stv090x_config,
1790 STV090x_DEMODULATOR_0);
1791 if (fe0->dvb.frontend == NULL)
1793 if (!dvb_attach(stb6100_attach,
1795 &prof_8000_stb6100_config,
1796 &i2c_bus->i2c_adap))
1797 goto frontend_detach;
1799 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1801 case CX23885_BOARD_HAUPPAUGE_HVR4400: {
1802 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1803 struct a8293_platform_data a8293_pdata = {};
1805 i2c_bus = &dev->i2c_bus[0];
1806 i2c_bus2 = &dev->i2c_bus[1];
1810 /* attach demod + tuner combo */
1811 memset(&info, 0, sizeof(info));
1812 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1814 info.platform_data = &tda10071_pdata;
1815 request_module("tda10071");
1816 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1817 if (!client_demod || !client_demod->dev.driver)
1818 goto frontend_detach;
1819 if (!try_module_get(client_demod->dev.driver->owner)) {
1820 i2c_unregister_device(client_demod);
1821 goto frontend_detach;
1823 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1824 port->i2c_client_demod = client_demod;
1827 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1828 memset(&info, 0, sizeof(info));
1829 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1831 info.platform_data = &a8293_pdata;
1832 request_module("a8293");
1833 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1834 if (!client_sec || !client_sec->dev.driver)
1835 goto frontend_detach;
1836 if (!try_module_get(client_sec->dev.driver->owner)) {
1837 i2c_unregister_device(client_sec);
1838 goto frontend_detach;
1840 port->i2c_client_sec = client_sec;
1844 fe0->dvb.frontend = dvb_attach(si2165_attach,
1845 &hauppauge_hvr4400_si2165_config,
1846 &i2c_bus->i2c_adap);
1847 if (fe0->dvb.frontend == NULL)
1849 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1850 if (!dvb_attach(tda18271_attach,
1852 0x60, &i2c_bus2->i2c_adap,
1853 &hauppauge_hvr4400_tuner_config))
1854 goto frontend_detach;
1859 case CX23885_BOARD_HAUPPAUGE_STARBURST: {
1860 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1861 struct a8293_platform_data a8293_pdata = {};
1863 i2c_bus = &dev->i2c_bus[0];
1865 /* attach demod + tuner combo */
1866 memset(&info, 0, sizeof(info));
1867 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1869 info.platform_data = &tda10071_pdata;
1870 request_module("tda10071");
1871 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1872 if (!client_demod || !client_demod->dev.driver)
1873 goto frontend_detach;
1874 if (!try_module_get(client_demod->dev.driver->owner)) {
1875 i2c_unregister_device(client_demod);
1876 goto frontend_detach;
1878 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1879 port->i2c_client_demod = client_demod;
1882 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1883 memset(&info, 0, sizeof(info));
1884 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1886 info.platform_data = &a8293_pdata;
1887 request_module("a8293");
1888 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1889 if (!client_sec || !client_sec->dev.driver)
1890 goto frontend_detach;
1891 if (!try_module_get(client_sec->dev.driver->owner)) {
1892 i2c_unregister_device(client_sec);
1893 goto frontend_detach;
1895 port->i2c_client_sec = client_sec;
1898 case CX23885_BOARD_DVBSKY_T9580:
1899 case CX23885_BOARD_DVBSKY_S950:
1900 i2c_bus = &dev->i2c_bus[0];
1901 i2c_bus2 = &dev->i2c_bus[1];
1903 /* port b - satellite */
1905 /* attach frontend */
1906 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1907 &dvbsky_t9580_m88ds3103_config,
1908 &i2c_bus2->i2c_adap, &adapter);
1909 if (fe0->dvb.frontend == NULL)
1913 memset(&ts2020_config, 0, sizeof(ts2020_config));
1914 ts2020_config.fe = fe0->dvb.frontend;
1915 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
1916 memset(&info, 0, sizeof(struct i2c_board_info));
1917 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
1919 info.platform_data = &ts2020_config;
1920 request_module(info.type);
1921 client_tuner = i2c_new_device(adapter, &info);
1922 if (client_tuner == NULL ||
1923 client_tuner->dev.driver == NULL)
1924 goto frontend_detach;
1925 if (!try_module_get(client_tuner->dev.driver->owner)) {
1926 i2c_unregister_device(client_tuner);
1927 goto frontend_detach;
1930 /* delegate signal strength measurement to tuner */
1931 fe0->dvb.frontend->ops.read_signal_strength =
1932 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1935 * for setting the voltage we need to set GPIOs on
1938 port->fe_set_voltage =
1939 fe0->dvb.frontend->ops.set_voltage;
1940 fe0->dvb.frontend->ops.set_voltage =
1941 dvbsky_t9580_set_voltage;
1943 port->i2c_client_tuner = client_tuner;
1946 /* port c - terrestrial/cable */
1948 /* attach frontend */
1949 memset(&si2168_config, 0, sizeof(si2168_config));
1950 si2168_config.i2c_adapter = &adapter;
1951 si2168_config.fe = &fe0->dvb.frontend;
1952 si2168_config.ts_mode = SI2168_TS_SERIAL;
1953 memset(&info, 0, sizeof(struct i2c_board_info));
1954 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1956 info.platform_data = &si2168_config;
1957 request_module(info.type);
1958 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1959 if (client_demod == NULL ||
1960 client_demod->dev.driver == NULL)
1961 goto frontend_detach;
1962 if (!try_module_get(client_demod->dev.driver->owner)) {
1963 i2c_unregister_device(client_demod);
1964 goto frontend_detach;
1966 port->i2c_client_demod = client_demod;
1969 memset(&si2157_config, 0, sizeof(si2157_config));
1970 si2157_config.fe = fe0->dvb.frontend;
1971 si2157_config.if_port = 1;
1972 memset(&info, 0, sizeof(struct i2c_board_info));
1973 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1975 info.platform_data = &si2157_config;
1976 request_module(info.type);
1977 client_tuner = i2c_new_device(adapter, &info);
1978 if (client_tuner == NULL ||
1979 client_tuner->dev.driver == NULL)
1980 goto frontend_detach;
1982 if (!try_module_get(client_tuner->dev.driver->owner)) {
1983 i2c_unregister_device(client_tuner);
1984 goto frontend_detach;
1986 port->i2c_client_tuner = client_tuner;
1990 case CX23885_BOARD_DVBSKY_T980C:
1991 case CX23885_BOARD_TT_CT2_4500_CI:
1992 i2c_bus = &dev->i2c_bus[1];
1993 i2c_bus2 = &dev->i2c_bus[0];
1995 /* attach frontend */
1996 memset(&si2168_config, 0, sizeof(si2168_config));
1997 si2168_config.i2c_adapter = &adapter;
1998 si2168_config.fe = &fe0->dvb.frontend;
1999 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2000 memset(&info, 0, sizeof(struct i2c_board_info));
2001 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2003 info.platform_data = &si2168_config;
2004 request_module(info.type);
2005 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2006 if (client_demod == NULL || client_demod->dev.driver == NULL)
2007 goto frontend_detach;
2008 if (!try_module_get(client_demod->dev.driver->owner)) {
2009 i2c_unregister_device(client_demod);
2010 goto frontend_detach;
2012 port->i2c_client_demod = client_demod;
2015 memset(&si2157_config, 0, sizeof(si2157_config));
2016 si2157_config.fe = fe0->dvb.frontend;
2017 si2157_config.if_port = 1;
2018 memset(&info, 0, sizeof(struct i2c_board_info));
2019 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2021 info.platform_data = &si2157_config;
2022 request_module(info.type);
2023 client_tuner = i2c_new_device(adapter, &info);
2024 if (client_tuner == NULL ||
2025 client_tuner->dev.driver == NULL)
2026 goto frontend_detach;
2027 if (!try_module_get(client_tuner->dev.driver->owner)) {
2028 i2c_unregister_device(client_tuner);
2029 goto frontend_detach;
2031 port->i2c_client_tuner = client_tuner;
2033 case CX23885_BOARD_DVBSKY_S950C:
2034 i2c_bus = &dev->i2c_bus[1];
2035 i2c_bus2 = &dev->i2c_bus[0];
2037 /* attach frontend */
2038 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2039 &dvbsky_s950c_m88ds3103_config,
2040 &i2c_bus->i2c_adap, &adapter);
2041 if (fe0->dvb.frontend == NULL)
2045 memset(&ts2020_config, 0, sizeof(ts2020_config));
2046 ts2020_config.fe = fe0->dvb.frontend;
2047 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2048 memset(&info, 0, sizeof(struct i2c_board_info));
2049 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2051 info.platform_data = &ts2020_config;
2052 request_module(info.type);
2053 client_tuner = i2c_new_device(adapter, &info);
2054 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2055 goto frontend_detach;
2056 if (!try_module_get(client_tuner->dev.driver->owner)) {
2057 i2c_unregister_device(client_tuner);
2058 goto frontend_detach;
2061 /* delegate signal strength measurement to tuner */
2062 fe0->dvb.frontend->ops.read_signal_strength =
2063 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2065 port->i2c_client_tuner = client_tuner;
2067 case CX23885_BOARD_DVBSKY_S952:
2071 i2c_bus = &dev->i2c_bus[1];
2072 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
2073 p_set_voltage = dvbsky_t9580_set_voltage;
2077 i2c_bus = &dev->i2c_bus[0];
2078 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
2079 p_set_voltage = dvbsky_s952_portc_set_voltage;
2083 /* attach frontend */
2084 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2086 &i2c_bus->i2c_adap, &adapter);
2087 if (fe0->dvb.frontend == NULL)
2091 memset(&ts2020_config, 0, sizeof(ts2020_config));
2092 ts2020_config.fe = fe0->dvb.frontend;
2093 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2094 memset(&info, 0, sizeof(struct i2c_board_info));
2095 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2097 info.platform_data = &ts2020_config;
2098 request_module(info.type);
2099 client_tuner = i2c_new_device(adapter, &info);
2100 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2101 goto frontend_detach;
2102 if (!try_module_get(client_tuner->dev.driver->owner)) {
2103 i2c_unregister_device(client_tuner);
2104 goto frontend_detach;
2107 /* delegate signal strength measurement to tuner */
2108 fe0->dvb.frontend->ops.read_signal_strength =
2109 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2112 * for setting the voltage we need to set GPIOs on
2115 port->fe_set_voltage =
2116 fe0->dvb.frontend->ops.set_voltage;
2117 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2119 port->i2c_client_tuner = client_tuner;
2121 case CX23885_BOARD_DVBSKY_T982:
2122 memset(&si2168_config, 0, sizeof(si2168_config));
2126 i2c_bus = &dev->i2c_bus[1];
2127 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2131 i2c_bus = &dev->i2c_bus[0];
2132 si2168_config.ts_mode = SI2168_TS_SERIAL;
2136 /* attach frontend */
2137 si2168_config.i2c_adapter = &adapter;
2138 si2168_config.fe = &fe0->dvb.frontend;
2139 memset(&info, 0, sizeof(struct i2c_board_info));
2140 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2142 info.platform_data = &si2168_config;
2143 request_module(info.type);
2144 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2145 if (client_demod == NULL || client_demod->dev.driver == NULL)
2146 goto frontend_detach;
2147 if (!try_module_get(client_demod->dev.driver->owner)) {
2148 i2c_unregister_device(client_demod);
2149 goto frontend_detach;
2151 port->i2c_client_demod = client_demod;
2154 memset(&si2157_config, 0, sizeof(si2157_config));
2155 si2157_config.fe = fe0->dvb.frontend;
2156 si2157_config.if_port = 1;
2157 memset(&info, 0, sizeof(struct i2c_board_info));
2158 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2160 info.platform_data = &si2157_config;
2161 request_module(info.type);
2162 client_tuner = i2c_new_device(adapter, &info);
2163 if (client_tuner == NULL ||
2164 client_tuner->dev.driver == NULL)
2165 goto frontend_detach;
2166 if (!try_module_get(client_tuner->dev.driver->owner)) {
2167 i2c_unregister_device(client_tuner);
2168 goto frontend_detach;
2170 port->i2c_client_tuner = client_tuner;
2172 case CX23885_BOARD_HAUPPAUGE_HVR5525: {
2173 struct m88rs6000t_config m88rs6000t_config;
2174 struct a8293_platform_data a8293_pdata = {};
2178 /* port b - satellite */
2180 /* attach frontend */
2181 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2182 &hauppauge_hvr5525_m88ds3103_config,
2183 &dev->i2c_bus[0].i2c_adap, &adapter);
2184 if (fe0->dvb.frontend == NULL)
2188 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
2189 memset(&info, 0, sizeof(info));
2190 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
2192 info.platform_data = &a8293_pdata;
2193 request_module("a8293");
2194 client_sec = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2195 if (!client_sec || !client_sec->dev.driver)
2196 goto frontend_detach;
2197 if (!try_module_get(client_sec->dev.driver->owner)) {
2198 i2c_unregister_device(client_sec);
2199 goto frontend_detach;
2201 port->i2c_client_sec = client_sec;
2204 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2205 m88rs6000t_config.fe = fe0->dvb.frontend;
2206 memset(&info, 0, sizeof(struct i2c_board_info));
2207 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2209 info.platform_data = &m88rs6000t_config;
2210 request_module("%s", info.type);
2211 client_tuner = i2c_new_device(adapter, &info);
2212 if (!client_tuner || !client_tuner->dev.driver)
2213 goto frontend_detach;
2214 if (!try_module_get(client_tuner->dev.driver->owner)) {
2215 i2c_unregister_device(client_tuner);
2216 goto frontend_detach;
2218 port->i2c_client_tuner = client_tuner;
2220 /* delegate signal strength measurement to tuner */
2221 fe0->dvb.frontend->ops.read_signal_strength =
2222 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2224 /* port c - terrestrial/cable */
2226 /* attach frontend */
2227 memset(&si2168_config, 0, sizeof(si2168_config));
2228 si2168_config.i2c_adapter = &adapter;
2229 si2168_config.fe = &fe0->dvb.frontend;
2230 si2168_config.ts_mode = SI2168_TS_SERIAL;
2231 memset(&info, 0, sizeof(struct i2c_board_info));
2232 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2234 info.platform_data = &si2168_config;
2235 request_module("%s", info.type);
2236 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2237 if (!client_demod || !client_demod->dev.driver)
2238 goto frontend_detach;
2239 if (!try_module_get(client_demod->dev.driver->owner)) {
2240 i2c_unregister_device(client_demod);
2241 goto frontend_detach;
2243 port->i2c_client_demod = client_demod;
2246 memset(&si2157_config, 0, sizeof(si2157_config));
2247 si2157_config.fe = fe0->dvb.frontend;
2248 si2157_config.if_port = 1;
2249 memset(&info, 0, sizeof(struct i2c_board_info));
2250 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2252 info.platform_data = &si2157_config;
2253 request_module("%s", info.type);
2254 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2255 if (!client_tuner || !client_tuner->dev.driver) {
2256 module_put(client_demod->dev.driver->owner);
2257 i2c_unregister_device(client_demod);
2258 port->i2c_client_demod = NULL;
2259 goto frontend_detach;
2261 if (!try_module_get(client_tuner->dev.driver->owner)) {
2262 i2c_unregister_device(client_tuner);
2263 module_put(client_demod->dev.driver->owner);
2264 i2c_unregister_device(client_demod);
2265 port->i2c_client_demod = NULL;
2266 goto frontend_detach;
2268 port->i2c_client_tuner = client_tuner;
2274 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2275 " isn't supported yet\n",
2280 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2281 printk(KERN_ERR "%s: frontend initialization failed\n",
2283 goto frontend_detach;
2286 /* define general-purpose callback pointer */
2287 fe0->dvb.frontend->callback = cx23885_tuner_callback;
2289 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2291 /* Ensure all frontends negotiate bus access */
2292 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2294 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2297 /* Put the analog decoder in standby to keep it quiet */
2298 call_all(dev, core, s_power, 0);
2300 if (fe0->dvb.frontend->ops.analog_ops.standby)
2301 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
2303 /* register everything */
2304 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2305 &dev->pci->dev, adapter_nr, mfe_shared);
2307 goto frontend_detach;
2309 ret = dvb_register_ci_mac(port);
2311 goto frontend_detach;
2316 /* remove I2C client for SEC */
2317 client_sec = port->i2c_client_sec;
2319 module_put(client_sec->dev.driver->owner);
2320 i2c_unregister_device(client_sec);
2321 port->i2c_client_sec = NULL;
2324 /* remove I2C client for tuner */
2325 client_tuner = port->i2c_client_tuner;
2327 module_put(client_tuner->dev.driver->owner);
2328 i2c_unregister_device(client_tuner);
2329 port->i2c_client_tuner = NULL;
2332 /* remove I2C client for demodulator */
2333 client_demod = port->i2c_client_demod;
2335 module_put(client_demod->dev.driver->owner);
2336 i2c_unregister_device(client_demod);
2337 port->i2c_client_demod = NULL;
2340 port->gate_ctrl = NULL;
2341 vb2_dvb_dealloc_frontends(&port->frontends);
2345 int cx23885_dvb_register(struct cx23885_tsport *port)
2348 struct vb2_dvb_frontend *fe0;
2349 struct cx23885_dev *dev = port->dev;
2352 /* Here we need to allocate the correct number of frontends,
2353 * as reflected in the cards struct. The reality is that currently
2354 * no cx23885 boards support this - yet. But, if we don't modify this
2355 * code then the second frontend would never be allocated (later)
2356 * and fail with error before the attach in dvb_register().
2357 * Without these changes we risk an OOPS later. The changes here
2358 * are for safety, and should provide a good foundation for the
2359 * future addition of any multi-frontend cx23885 based boards.
2361 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
2362 port->num_frontends);
2364 for (i = 1; i <= port->num_frontends; i++) {
2365 struct vb2_queue *q;
2367 if (vb2_dvb_alloc_frontend(
2368 &port->frontends, i) == NULL) {
2369 printk(KERN_ERR "%s() failed to alloc\n", __func__);
2373 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
2377 dprintk(1, "%s\n", __func__);
2378 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2387 /* We have to init the queue for each frontend on a port. */
2388 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
2390 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2391 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2392 q->gfp_flags = GFP_DMA32;
2393 q->min_buffers_needed = 2;
2395 q->buf_struct_size = sizeof(struct cx23885_buffer);
2397 q->mem_ops = &vb2_dma_sg_memops;
2398 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2399 q->lock = &dev->lock;
2401 err = vb2_queue_init(q);
2405 err = dvb_register(port);
2407 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
2413 int cx23885_dvb_unregister(struct cx23885_tsport *port)
2415 struct vb2_dvb_frontend *fe0;
2416 struct i2c_client *client;
2418 /* remove I2C client for CI */
2419 client = port->i2c_client_ci;
2421 module_put(client->dev.driver->owner);
2422 i2c_unregister_device(client);
2425 /* remove I2C client for SEC */
2426 client = port->i2c_client_sec;
2428 module_put(client->dev.driver->owner);
2429 i2c_unregister_device(client);
2432 /* remove I2C client for tuner */
2433 client = port->i2c_client_tuner;
2435 module_put(client->dev.driver->owner);
2436 i2c_unregister_device(client);
2439 /* remove I2C client for demodulator */
2440 client = port->i2c_client_demod;
2442 module_put(client->dev.driver->owner);
2443 i2c_unregister_device(client);
2446 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2448 if (fe0 && fe0->dvb.frontend)
2449 vb2_dvb_unregister_bus(&port->frontends);
2451 switch (port->dev->board) {
2452 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2453 netup_ci_exit(port);
2455 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2456 altera_ci_release(port->dev, port->nr);
2460 port->gate_ctrl = NULL;