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,
96 unsigned int *num_buffers, unsigned int *num_planes,
97 unsigned int sizes[], struct device *alloc_devs[])
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;
110 static int buffer_prepare(struct vb2_buffer *vb)
112 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
113 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
114 struct cx23885_buffer *buf =
115 container_of(vbuf, struct cx23885_buffer, vb);
117 return cx23885_buf_prepare(buf, port);
120 static void buffer_finish(struct vb2_buffer *vb)
122 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
123 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
124 struct cx23885_dev *dev = port->dev;
125 struct cx23885_buffer *buf = container_of(vbuf,
126 struct cx23885_buffer, vb);
128 cx23885_free_buffer(dev, buf);
131 static void buffer_queue(struct vb2_buffer *vb)
133 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
134 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
135 struct cx23885_buffer *buf = container_of(vbuf,
136 struct cx23885_buffer, vb);
138 cx23885_buf_queue(port, buf);
141 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
143 struct vb2_dvb_frontends *f;
144 struct vb2_dvb_frontend *fe;
146 f = &port->frontends;
148 if (f->gate <= 1) /* undefined or fe0 */
149 fe = vb2_dvb_get_frontend(f, 1);
151 fe = vb2_dvb_get_frontend(f, f->gate);
153 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
154 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
157 static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
159 struct cx23885_tsport *port = q->drv_priv;
160 struct cx23885_dmaqueue *dmaq = &port->mpegq;
161 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
162 struct cx23885_buffer, queue);
164 cx23885_start_dma(port, dmaq, buf);
168 static void cx23885_stop_streaming(struct vb2_queue *q)
170 struct cx23885_tsport *port = q->drv_priv;
172 cx23885_cancel_buffers(port);
175 static struct vb2_ops dvb_qops = {
176 .queue_setup = queue_setup,
177 .buf_prepare = buffer_prepare,
178 .buf_finish = buffer_finish,
179 .buf_queue = buffer_queue,
180 .wait_prepare = vb2_ops_wait_prepare,
181 .wait_finish = vb2_ops_wait_finish,
182 .start_streaming = cx23885_start_streaming,
183 .stop_streaming = cx23885_stop_streaming,
186 static struct s5h1409_config hauppauge_generic_config = {
187 .demod_address = 0x32 >> 1,
188 .output_mode = S5H1409_SERIAL_OUTPUT,
189 .gpio = S5H1409_GPIO_ON,
191 .inversion = S5H1409_INVERSION_OFF,
192 .status_mode = S5H1409_DEMODLOCKING,
193 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
196 static struct tda10048_config hauppauge_hvr1200_config = {
197 .demod_address = 0x10 >> 1,
198 .output_mode = TDA10048_SERIAL_OUTPUT,
199 .fwbulkwritelen = TDA10048_BULKWRITE_200,
200 .inversion = TDA10048_INVERSION_ON,
201 .dtv6_if_freq_khz = TDA10048_IF_3300,
202 .dtv7_if_freq_khz = TDA10048_IF_3800,
203 .dtv8_if_freq_khz = TDA10048_IF_4300,
204 .clk_freq_khz = TDA10048_CLK_16000,
207 static struct tda10048_config hauppauge_hvr1210_config = {
208 .demod_address = 0x10 >> 1,
209 .output_mode = TDA10048_SERIAL_OUTPUT,
210 .fwbulkwritelen = TDA10048_BULKWRITE_200,
211 .inversion = TDA10048_INVERSION_ON,
212 .dtv6_if_freq_khz = TDA10048_IF_3300,
213 .dtv7_if_freq_khz = TDA10048_IF_3500,
214 .dtv8_if_freq_khz = TDA10048_IF_4000,
215 .clk_freq_khz = TDA10048_CLK_16000,
218 static struct s5h1409_config hauppauge_ezqam_config = {
219 .demod_address = 0x32 >> 1,
220 .output_mode = S5H1409_SERIAL_OUTPUT,
221 .gpio = S5H1409_GPIO_OFF,
223 .inversion = S5H1409_INVERSION_ON,
224 .status_mode = S5H1409_DEMODLOCKING,
225 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
228 static struct s5h1409_config hauppauge_hvr1800lp_config = {
229 .demod_address = 0x32 >> 1,
230 .output_mode = S5H1409_SERIAL_OUTPUT,
231 .gpio = S5H1409_GPIO_OFF,
233 .inversion = S5H1409_INVERSION_OFF,
234 .status_mode = S5H1409_DEMODLOCKING,
235 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
238 static struct s5h1409_config hauppauge_hvr1500_config = {
239 .demod_address = 0x32 >> 1,
240 .output_mode = S5H1409_SERIAL_OUTPUT,
241 .gpio = S5H1409_GPIO_OFF,
242 .inversion = S5H1409_INVERSION_OFF,
243 .status_mode = S5H1409_DEMODLOCKING,
244 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
247 static struct mt2131_config hauppauge_generic_tunerconfig = {
251 static struct lgdt330x_config fusionhdtv_5_express = {
252 .demod_address = 0x0e,
253 .demod_chip = LGDT3303,
257 static struct s5h1409_config hauppauge_hvr1500q_config = {
258 .demod_address = 0x32 >> 1,
259 .output_mode = S5H1409_SERIAL_OUTPUT,
260 .gpio = S5H1409_GPIO_ON,
262 .inversion = S5H1409_INVERSION_OFF,
263 .status_mode = S5H1409_DEMODLOCKING,
264 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
267 static struct s5h1409_config dvico_s5h1409_config = {
268 .demod_address = 0x32 >> 1,
269 .output_mode = S5H1409_SERIAL_OUTPUT,
270 .gpio = S5H1409_GPIO_ON,
272 .inversion = S5H1409_INVERSION_OFF,
273 .status_mode = S5H1409_DEMODLOCKING,
274 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
277 static struct s5h1411_config dvico_s5h1411_config = {
278 .output_mode = S5H1411_SERIAL_OUTPUT,
279 .gpio = S5H1411_GPIO_ON,
280 .qam_if = S5H1411_IF_44000,
281 .vsb_if = S5H1411_IF_44000,
282 .inversion = S5H1411_INVERSION_OFF,
283 .status_mode = S5H1411_DEMODLOCKING,
284 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
287 static struct s5h1411_config hcw_s5h1411_config = {
288 .output_mode = S5H1411_SERIAL_OUTPUT,
289 .gpio = S5H1411_GPIO_OFF,
290 .vsb_if = S5H1411_IF_44000,
291 .qam_if = S5H1411_IF_4000,
292 .inversion = S5H1411_INVERSION_ON,
293 .status_mode = S5H1411_DEMODLOCKING,
294 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
297 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
302 static struct xc5000_config dvico_xc5000_tunerconfig = {
307 static struct tda829x_config tda829x_no_probe = {
308 .probe_tuner = TDA829X_DONT_PROBE,
311 static struct tda18271_std_map hauppauge_tda18271_std_map = {
312 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
313 .if_lvl = 6, .rfagc_top = 0x37 },
314 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
315 .if_lvl = 6, .rfagc_top = 0x37 },
318 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
319 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
320 .if_lvl = 1, .rfagc_top = 0x37, },
321 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
322 .if_lvl = 1, .rfagc_top = 0x37, },
323 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
324 .if_lvl = 1, .rfagc_top = 0x37, },
327 static struct tda18271_config hauppauge_tda18271_config = {
328 .std_map = &hauppauge_tda18271_std_map,
329 .gate = TDA18271_GATE_ANALOG,
330 .output_opt = TDA18271_OUTPUT_LT_OFF,
333 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
334 .std_map = &hauppauge_hvr1200_tda18271_std_map,
335 .gate = TDA18271_GATE_ANALOG,
336 .output_opt = TDA18271_OUTPUT_LT_OFF,
339 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
340 .gate = TDA18271_GATE_DIGITAL,
341 .output_opt = TDA18271_OUTPUT_LT_OFF,
344 static struct tda18271_config hauppauge_hvr4400_tuner_config = {
345 .gate = TDA18271_GATE_DIGITAL,
346 .output_opt = TDA18271_OUTPUT_LT_OFF,
349 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
350 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
351 .if_lvl = 1, .rfagc_top = 0x58 },
352 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
353 .if_lvl = 1, .rfagc_top = 0x58 },
356 static struct tda18271_config hauppauge_hvr127x_config = {
357 .std_map = &hauppauge_hvr127x_std_map,
358 .output_opt = TDA18271_OUTPUT_LT_OFF,
361 static struct lgdt3305_config hauppauge_lgdt3305_config = {
363 .mpeg_mode = LGDT3305_MPEG_SERIAL,
364 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
365 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
367 .spectral_inversion = 1,
372 static struct dibx000_agc_config xc3028_agc_config = {
373 BAND_VHF | BAND_UHF, /* band_caps */
375 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
376 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
377 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
378 * P_agc_nb_est=2, P_agc_write=0
380 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
381 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
384 21, /* time_stabiliz */
396 39718, /* agc2_max */
405 29, /* agc2_slope1 */
406 29, /* agc2_slope2 */
413 1, /* perform_agc_softsplit */
416 /* PLL Configuration for COFDM BW_MHz = 8.000000
417 * With external clock = 30.000000 */
418 static struct dibx000_bandwidth_config xc3028_bw_config = {
419 60000, /* internal */
420 30000, /* sampling */
421 1, /* pll_cfg: prediv */
422 8, /* pll_cfg: ratio */
423 3, /* pll_cfg: range */
424 1, /* pll_cfg: reset */
425 0, /* pll_cfg: bypass */
426 0, /* misc: refdiv */
427 0, /* misc: bypclk_div */
428 1, /* misc: IO_CLK_en_core */
429 1, /* misc: ADClkSrc */
430 0, /* misc: modulo */
431 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
432 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
434 30000000 /* xtal_hz */
437 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
438 .output_mpeg2_in_188_bytes = 1,
439 .hostbus_diversity = 1,
440 .tuner_is_baseband = 0,
443 .agc_config_count = 1,
444 .agc = &xc3028_agc_config,
445 .bw = &xc3028_bw_config,
447 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
448 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
449 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
455 .output_mode = OUTMODE_MPEG2_SERIAL,
458 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
459 .demod_address = 0x0f,
462 .disable_i2c_gate_ctrl = 1,
465 static struct stv0900_reg stv0900_ts_regs[] = {
466 { R0900_TSGENERAL, 0x00 },
467 { R0900_P1_TSSPEED, 0x40 },
468 { R0900_P2_TSSPEED, 0x40 },
469 { R0900_P1_TSCFGM, 0xc0 },
470 { R0900_P2_TSCFGM, 0xc0 },
471 { R0900_P1_TSCFGH, 0xe0 },
472 { R0900_P2_TSCFGH, 0xe0 },
473 { R0900_P1_TSCFGL, 0x20 },
474 { R0900_P2_TSCFGL, 0x20 },
475 { 0xffff, 0xff }, /* terminate */
478 static struct stv0900_config netup_stv0900_config = {
479 .demod_address = 0x68,
480 .demod_mode = 1, /* dual */
482 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
483 .diseqc_mode = 2,/* 2/3 PWM */
484 .ts_config_regs = stv0900_ts_regs,
485 .tun1_maddress = 0,/* 0x60 */
486 .tun2_maddress = 3,/* 0x63 */
487 .tun1_adc = 1,/* 1 Vpp */
488 .tun2_adc = 1,/* 1 Vpp */
491 static struct stv6110_config netup_stv6110_tunerconfig_a = {
495 .gain = 8, /* +16 dB - maximum gain */
498 static struct stv6110_config netup_stv6110_tunerconfig_b = {
502 .gain = 8, /* +16 dB - maximum gain */
505 static struct cx24116_config tbs_cx24116_config = {
506 .demod_address = 0x55,
509 static struct cx24117_config tbs_cx24117_config = {
510 .demod_address = 0x55,
513 static struct ds3000_config tevii_ds3000_config = {
514 .demod_address = 0x68,
517 static struct ts2020_config tevii_ts2020_config = {
518 .tuner_address = 0x60,
520 .frequency_div = 1146000,
523 static struct cx24116_config dvbworld_cx24116_config = {
524 .demod_address = 0x05,
527 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
528 .prod = LGS8GXX_PROD_LGS8GL5,
529 .demod_address = 0x19,
533 .if_clk_freq = 30400, /* 30.4 MHz */
534 .if_freq = 5380, /* 5.38 MHz */
541 static struct xc5000_config mygica_x8506_xc5000_config = {
546 static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
547 .demod_address = 0x10,
550 static struct xc5000_config mygica_x8507_xc5000_config = {
555 static struct stv090x_config prof_8000_stv090x_config = {
557 .demod_mode = STV090x_SINGLE,
558 .clk_mode = STV090x_CLK_EXT,
561 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
562 .repeater_level = STV090x_RPTLEVEL_64,
563 .adc1_range = STV090x_ADC_2Vpp,
564 .diseqc_envelope_mode = false,
566 .tuner_get_frequency = stb6100_get_frequency,
567 .tuner_set_frequency = stb6100_set_frequency,
568 .tuner_set_bandwidth = stb6100_set_bandwidth,
569 .tuner_get_bandwidth = stb6100_get_bandwidth,
572 static struct stb6100_config prof_8000_stb6100_config = {
573 .tuner_address = 0x60,
574 .refclock = 27000000,
577 static int p8000_set_voltage(struct dvb_frontend *fe,
578 enum fe_sec_voltage voltage)
580 struct cx23885_tsport *port = fe->dvb->priv;
581 struct cx23885_dev *dev = port->dev;
583 if (voltage == SEC_VOLTAGE_18)
584 cx_write(MC417_RWD, 0x00001e00);
585 else if (voltage == SEC_VOLTAGE_13)
586 cx_write(MC417_RWD, 0x00001a00);
588 cx_write(MC417_RWD, 0x00001800);
592 static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
593 enum fe_sec_voltage voltage)
595 struct cx23885_tsport *port = fe->dvb->priv;
596 struct cx23885_dev *dev = port->dev;
598 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
602 cx23885_gpio_set(dev, GPIO_1);
603 cx23885_gpio_clear(dev, GPIO_0);
606 cx23885_gpio_set(dev, GPIO_1);
607 cx23885_gpio_set(dev, GPIO_0);
609 case SEC_VOLTAGE_OFF:
610 cx23885_gpio_clear(dev, GPIO_1);
611 cx23885_gpio_clear(dev, GPIO_0);
615 /* call the frontend set_voltage function */
616 port->fe_set_voltage(fe, voltage);
621 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
622 enum fe_sec_voltage voltage)
624 struct cx23885_tsport *port = fe->dvb->priv;
625 struct cx23885_dev *dev = port->dev;
627 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
631 cx23885_gpio_set(dev, GPIO_13);
632 cx23885_gpio_clear(dev, GPIO_12);
635 cx23885_gpio_set(dev, GPIO_13);
636 cx23885_gpio_set(dev, GPIO_12);
638 case SEC_VOLTAGE_OFF:
639 cx23885_gpio_clear(dev, GPIO_13);
640 cx23885_gpio_clear(dev, GPIO_12);
643 /* call the frontend set_voltage function */
644 return port->fe_set_voltage(fe, voltage);
647 static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
651 #define SP2_DATA 0x000000ff
652 #define SP2_WR 0x00008000
653 #define SP2_RD 0x00004000
654 #define SP2_ACK 0x00001000
655 #define SP2_ADHI 0x00000800
656 #define SP2_ADLO 0x00000400
657 #define SP2_CS1 0x00000200
658 #define SP2_CS0 0x00000100
659 #define SP2_EN_ALL 0x00001000
660 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
662 struct cx23885_tsport *port = priv;
663 struct cx23885_dev *dev = port->dev;
666 unsigned long timeout;
668 mutex_lock(&dev->gpio_lock);
671 cx_write(MC417_OEN, SP2_EN_ALL);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADLO | (0xff & addr));
674 cx_clear(MC417_RWD, SP2_ADLO);
675 cx_write(MC417_RWD, SP2_CTRL_OFF |
676 SP2_ADHI | (0xff & (addr >> 8)));
677 cx_clear(MC417_RWD, SP2_ADHI);
681 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
684 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
687 cx_clear(MC417_RWD, SP2_CS0);
690 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
692 /* wait for a maximum of 1 msec */
693 timeout = jiffies + msecs_to_jiffies(1);
694 while (!time_after(jiffies, timeout)) {
695 tmp = cx_read(MC417_RWD);
696 if ((tmp & SP2_ACK) == 0)
698 usleep_range(50, 100);
701 cx_set(MC417_RWD, SP2_CTRL_OFF);
704 mutex_unlock(&dev->gpio_lock);
718 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
720 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
721 struct cx23885_tsport *port = fe->dvb->priv;
722 struct cx23885_dev *dev = port->dev;
724 switch (dev->board) {
725 case CX23885_BOARD_HAUPPAUGE_HVR1275:
726 switch (p->modulation) {
728 cx23885_gpio_clear(dev, GPIO_5);
733 cx23885_gpio_set(dev, GPIO_5);
737 case CX23885_BOARD_MYGICA_X8506:
738 case CX23885_BOARD_MYGICA_X8507:
739 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
740 /* Select Digital TV */
741 cx23885_gpio_set(dev, GPIO_0);
745 /* Call the real set_frontend */
746 if (port->set_frontend)
747 return port->set_frontend(fe);
752 static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
753 struct dvb_frontend *fe)
755 port->set_frontend = fe->ops.set_frontend;
756 fe->ops.set_frontend = cx23885_dvb_set_frontend;
759 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
760 .prod = LGS8GXX_PROD_LGS8G75,
761 .demod_address = 0x19,
765 .if_clk_freq = 30400, /* 30.4 MHz */
766 .if_freq = 6500, /* 6.50 MHz */
770 .adc_vpp = 2, /* 1.6 Vpp */
774 static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
779 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
780 .prod = ATBM8830_PROD_8830,
781 .demod_address = 0x44,
783 .ts_sampling_edge = 1,
785 .osc_clk_freq = 30400, /* in kHz */
786 .if_freq = 0, /* zero IF */
793 static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
798 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
799 .prod = ATBM8830_PROD_8830,
800 .demod_address = 0x44,
802 .ts_sampling_edge = 1,
804 .osc_clk_freq = 30400, /* in kHz */
805 .if_freq = 0, /* zero IF */
812 static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
816 static struct stv0367_config netup_stv0367_config[] = {
818 .demod_address = 0x1c,
825 .demod_address = 0x1d,
834 static struct xc5000_config netup_xc5000_config[] = {
844 static struct drxk_config terratec_drxk_config[] = {
854 static struct mt2063_config terratec_mt2063_config[] = {
856 .tuner_address = 0x60,
858 .tuner_address = 0x67,
862 static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
863 .clk = 40444000, /* 40.444 MHz */
865 .ts_mode = TDA10071_TS_SERIAL,
866 .pll_multiplier = 20,
867 .tuner_i2c_addr = 0x54,
870 static const struct si2165_config hauppauge_hvr4400_si2165_config = {
872 .chip_mode = SI2165_MODE_PLL_XTAL,
873 .ref_freq_Hz = 16000000,
876 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
881 .ts_mode = M88DS3103_TS_PARALLEL,
889 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
894 .ts_mode = M88DS3103_TS_CI,
902 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
907 .ts_mode = M88DS3103_TS_SERIAL,
915 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
919 .ts_mode = M88DS3103_TS_PARALLEL,
925 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
927 struct cx23885_dev *dev = (struct cx23885_dev *)device;
928 unsigned long timeout = jiffies + msecs_to_jiffies(1);
931 mem = cx_read(MC417_RWD);
933 cx_set(MC417_OEN, ALT_DATA);
935 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
937 mem |= (data & ALT_DATA);
947 mem = (mem & ~ALT_RD) | ALT_WR;
949 mem = (mem & ~ALT_WR) | ALT_RD;
951 cx_write(MC417_RWD, mem); /* start RW cycle */
954 mem = cx_read(MC417_RWD);
955 if ((mem & ALT_RDY) == 0)
957 if (time_after(jiffies, timeout))
962 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
964 return mem & ALT_DATA;
969 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
971 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
973 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
976 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
981 static struct dib0070_config dib7070p_dib0070_config = {
982 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
983 .reset = dib7070_tuner_reset,
984 .sleep = dib7070_tuner_sleep,
986 .freq_offset_khz_vhf = 550,
987 /* .flip_chip = 1, */
990 /* DIB7070 generic */
991 static struct dibx000_agc_config dib7070_agc_config = {
992 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
995 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
996 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
997 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
999 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1000 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1002 .time_stabiliz = 10,
1026 .perform_agc_softsplit = 0,
1029 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1039 .IO_CLK_en_core = 1,
1042 /* refsel, sel, freq_15k */
1043 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1044 .ifreq = (0 << 25) | 0,
1046 .xtal_hz = 12000000,
1049 static struct dib7000p_config dib7070p_dib7000p_config = {
1050 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1051 .output_mode = OUTMODE_MPEG2_SERIAL,
1052 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1053 .output_mpeg2_in_188_bytes = 1,
1055 .agc_config_count = 1,
1056 .agc = &dib7070_agc_config,
1057 .bw = &dib7070_bw_config_12_mhz,
1058 .tuner_is_baseband = 1,
1061 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1062 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1063 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1065 .hostbus_diversity = 1,
1068 static int dvb_register_ci_mac(struct cx23885_tsport *port)
1070 struct cx23885_dev *dev = port->dev;
1071 struct i2c_client *client_ci = NULL;
1072 struct vb2_dvb_frontend *fe0;
1074 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1078 switch (dev->board) {
1079 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1080 static struct netup_card_info cinfo;
1082 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1083 memcpy(port->frontends.adapter.proposed_mac,
1084 cinfo.port[port->nr - 1].mac, 6);
1085 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1086 port->nr, port->frontends.adapter.proposed_mac);
1088 netup_ci_init(port);
1091 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1092 struct altera_ci_config netup_ci_cfg = {
1093 .dev = dev,/* magic number to identify*/
1094 .adapter = &port->frontends.adapter,/* for CI */
1095 .demux = &fe0->dvb.demux,/* for hw pid filter */
1096 .fpga_rw = netup_altera_fpga_rw,
1099 altera_ci_init(&netup_ci_cfg, port->nr);
1102 case CX23885_BOARD_TEVII_S470: {
1103 u8 eeprom[256]; /* 24C02 i2c eeprom */
1108 /* Read entire EEPROM */
1109 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1110 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1111 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1112 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1115 case CX23885_BOARD_DVBSKY_T9580:
1116 case CX23885_BOARD_DVBSKY_S950:
1117 case CX23885_BOARD_DVBSKY_S952:
1118 case CX23885_BOARD_DVBSKY_T982: {
1119 u8 eeprom[256]; /* 24C02 i2c eeprom */
1124 /* Read entire EEPROM */
1125 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1126 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1128 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1129 cx23885_boards[dev->board].name, port->nr,
1130 eeprom + 0xc0 + (port->nr-1) * 8);
1131 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1132 (port->nr-1) * 8, 6);
1135 case CX23885_BOARD_DVBSKY_S950C:
1136 case CX23885_BOARD_DVBSKY_T980C:
1137 case CX23885_BOARD_TT_CT2_4500_CI: {
1138 u8 eeprom[256]; /* 24C02 i2c eeprom */
1139 struct sp2_config sp2_config;
1140 struct i2c_board_info info;
1141 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
1144 memset(&sp2_config, 0, sizeof(sp2_config));
1145 sp2_config.dvb_adap = &port->frontends.adapter;
1146 sp2_config.priv = port;
1147 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1148 memset(&info, 0, sizeof(struct i2c_board_info));
1149 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1151 info.platform_data = &sp2_config;
1152 request_module(info.type);
1153 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
1154 if (client_ci == NULL || client_ci->dev.driver == NULL)
1156 if (!try_module_get(client_ci->dev.driver->owner)) {
1157 i2c_unregister_device(client_ci);
1160 port->i2c_client_ci = client_ci;
1165 /* Read entire EEPROM */
1166 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1167 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1169 printk(KERN_INFO "%s MAC address: %pM\n",
1170 cx23885_boards[dev->board].name, eeprom + 0xc0);
1171 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1178 static int dvb_register(struct cx23885_tsport *port)
1180 struct dib7000p_ops dib7000p_ops;
1181 struct cx23885_dev *dev = port->dev;
1182 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
1183 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
1184 struct si2168_config si2168_config;
1185 struct si2157_config si2157_config;
1186 struct ts2020_config ts2020_config;
1187 struct i2c_board_info info;
1188 struct i2c_adapter *adapter;
1189 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1190 struct i2c_client *client_sec = NULL;
1191 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1192 int (*p_set_voltage)(struct dvb_frontend *fe,
1193 enum fe_sec_voltage voltage) = NULL;
1194 int mfe_shared = 0; /* bus not shared by default */
1197 /* Get the first frontend */
1198 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1202 /* init struct vb2_dvb */
1203 fe0->dvb.name = dev->name;
1205 /* multi-frontend gate control is undefined or defaults to fe0 */
1206 port->frontends.gate = 0;
1208 /* Sets the gate control callback to be used by i2c command calls */
1209 port->gate_ctrl = cx23885_dvb_gate_ctrl;
1212 switch (dev->board) {
1213 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1214 i2c_bus = &dev->i2c_bus[0];
1215 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1216 &hauppauge_generic_config,
1217 &i2c_bus->i2c_adap);
1218 if (fe0->dvb.frontend == NULL)
1220 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1222 &hauppauge_generic_tunerconfig, 0);
1224 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1225 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1226 i2c_bus = &dev->i2c_bus[0];
1227 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1228 &hauppauge_lgdt3305_config,
1229 &i2c_bus->i2c_adap);
1230 if (fe0->dvb.frontend == NULL)
1232 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1233 0x60, &dev->i2c_bus[1].i2c_adap,
1234 &hauppauge_hvr127x_config);
1235 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
1236 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1238 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1239 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1240 i2c_bus = &dev->i2c_bus[0];
1241 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1242 &hcw_s5h1411_config,
1243 &i2c_bus->i2c_adap);
1244 if (fe0->dvb.frontend == NULL)
1247 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1248 0x60, &dev->i2c_bus[1].i2c_adap,
1249 &hauppauge_tda18271_config);
1251 tda18271_attach(&dev->ts1.analog_fe,
1252 0x60, &dev->i2c_bus[1].i2c_adap,
1253 &hauppauge_tda18271_config);
1256 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1257 i2c_bus = &dev->i2c_bus[0];
1258 switch (alt_tuner) {
1261 dvb_attach(s5h1409_attach,
1262 &hauppauge_ezqam_config,
1263 &i2c_bus->i2c_adap);
1264 if (fe0->dvb.frontend == NULL)
1267 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1268 &dev->i2c_bus[1].i2c_adap, 0x42,
1270 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1271 0x60, &dev->i2c_bus[1].i2c_adap,
1272 &hauppauge_tda18271_config);
1277 dvb_attach(s5h1409_attach,
1278 &hauppauge_generic_config,
1279 &i2c_bus->i2c_adap);
1280 if (fe0->dvb.frontend == NULL)
1282 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1284 &hauppauge_generic_tunerconfig, 0);
1287 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
1288 i2c_bus = &dev->i2c_bus[0];
1289 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1290 &hauppauge_hvr1800lp_config,
1291 &i2c_bus->i2c_adap);
1292 if (fe0->dvb.frontend == NULL)
1294 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1296 &hauppauge_generic_tunerconfig, 0);
1298 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
1299 i2c_bus = &dev->i2c_bus[0];
1300 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1301 &fusionhdtv_5_express,
1302 &i2c_bus->i2c_adap);
1303 if (fe0->dvb.frontend == NULL)
1305 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1306 &i2c_bus->i2c_adap, 0x61,
1307 TUNER_LG_TDVS_H06XF);
1309 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1310 i2c_bus = &dev->i2c_bus[1];
1311 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1312 &hauppauge_hvr1500q_config,
1313 &dev->i2c_bus[0].i2c_adap);
1314 if (fe0->dvb.frontend == NULL)
1316 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1318 &hauppauge_hvr1500q_tunerconfig);
1320 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1321 i2c_bus = &dev->i2c_bus[1];
1322 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1323 &hauppauge_hvr1500_config,
1324 &dev->i2c_bus[0].i2c_adap);
1325 if (fe0->dvb.frontend != NULL) {
1326 struct dvb_frontend *fe;
1327 struct xc2028_config cfg = {
1328 .i2c_adap = &i2c_bus->i2c_adap,
1331 static struct xc2028_ctrl ctl = {
1332 .fname = XC2028_DEFAULT_FIRMWARE,
1334 .demod = XC3028_FE_OREN538,
1337 fe = dvb_attach(xc2028_attach,
1338 fe0->dvb.frontend, &cfg);
1339 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1340 fe->ops.tuner_ops.set_config(fe, &ctl);
1343 case CX23885_BOARD_HAUPPAUGE_HVR1200:
1344 case CX23885_BOARD_HAUPPAUGE_HVR1700:
1345 i2c_bus = &dev->i2c_bus[0];
1346 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1347 &hauppauge_hvr1200_config,
1348 &i2c_bus->i2c_adap);
1349 if (fe0->dvb.frontend == NULL)
1351 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1352 &dev->i2c_bus[1].i2c_adap, 0x42,
1354 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1355 0x60, &dev->i2c_bus[1].i2c_adap,
1356 &hauppauge_hvr1200_tuner_config);
1358 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1359 i2c_bus = &dev->i2c_bus[0];
1360 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1361 &hauppauge_hvr1210_config,
1362 &i2c_bus->i2c_adap);
1363 if (fe0->dvb.frontend != NULL) {
1364 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1365 0x60, &dev->i2c_bus[1].i2c_adap,
1366 &hauppauge_hvr1210_tuner_config);
1369 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1370 i2c_bus = &dev->i2c_bus[0];
1372 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1375 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
1376 0x12, &hauppauge_hvr1400_dib7000_config);
1377 if (fe0->dvb.frontend != NULL) {
1378 struct dvb_frontend *fe;
1379 struct xc2028_config cfg = {
1380 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1383 static struct xc2028_ctrl ctl = {
1384 .fname = XC3028L_DEFAULT_FIRMWARE,
1386 .demod = XC3028_FE_DIBCOM52,
1387 /* This is true for all demods with
1389 .type = XC2028_D2633,
1392 fe = dvb_attach(xc2028_attach,
1393 fe0->dvb.frontend, &cfg);
1394 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1395 fe->ops.tuner_ops.set_config(fe, &ctl);
1398 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1399 i2c_bus = &dev->i2c_bus[port->nr - 1];
1401 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1402 &dvico_s5h1409_config,
1403 &i2c_bus->i2c_adap);
1404 if (fe0->dvb.frontend == NULL)
1405 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1406 &dvico_s5h1411_config,
1407 &i2c_bus->i2c_adap);
1408 if (fe0->dvb.frontend != NULL)
1409 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1411 &dvico_xc5000_tunerconfig);
1413 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
1414 i2c_bus = &dev->i2c_bus[port->nr - 1];
1416 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1417 &dvico_fusionhdtv_xc3028,
1418 &i2c_bus->i2c_adap);
1419 if (fe0->dvb.frontend != NULL) {
1420 struct dvb_frontend *fe;
1421 struct xc2028_config cfg = {
1422 .i2c_adap = &i2c_bus->i2c_adap,
1425 static struct xc2028_ctrl ctl = {
1426 .fname = XC2028_DEFAULT_FIRMWARE,
1428 .demod = XC3028_FE_ZARLINK456,
1431 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1433 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1434 fe->ops.tuner_ops.set_config(fe, &ctl);
1438 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
1439 i2c_bus = &dev->i2c_bus[port->nr - 1];
1440 /* cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0); */
1441 /* cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1); */
1443 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1446 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1447 printk(KERN_WARNING "Unable to enumerate dib7000p\n");
1450 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
1451 if (fe0->dvb.frontend != NULL) {
1452 struct i2c_adapter *tun_i2c;
1454 fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
1455 memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
1456 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1457 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1462 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1463 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1464 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1465 i2c_bus = &dev->i2c_bus[0];
1467 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1468 &dvico_fusionhdtv_xc3028,
1469 &i2c_bus->i2c_adap);
1470 if (fe0->dvb.frontend != NULL) {
1471 struct dvb_frontend *fe;
1472 struct xc2028_config cfg = {
1473 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1476 static struct xc2028_ctrl ctl = {
1477 .fname = XC2028_DEFAULT_FIRMWARE,
1479 .demod = XC3028_FE_ZARLINK456,
1482 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1484 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1485 fe->ops.tuner_ops.set_config(fe, &ctl);
1488 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
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 xc4000_config cfg = {
1497 .i2c_address = 0x61,
1499 .dvb_amplitude = 134,
1500 .set_smoothedcvbs = 1,
1504 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1505 &dev->i2c_bus[1].i2c_adap, &cfg);
1507 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1509 goto frontend_detach;
1513 case CX23885_BOARD_TBS_6920:
1514 i2c_bus = &dev->i2c_bus[1];
1516 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1517 &tbs_cx24116_config,
1518 &i2c_bus->i2c_adap);
1519 if (fe0->dvb.frontend != NULL)
1520 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1523 case CX23885_BOARD_TBS_6980:
1524 case CX23885_BOARD_TBS_6981:
1525 i2c_bus = &dev->i2c_bus[1];
1530 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1531 &tbs_cx24117_config,
1532 &i2c_bus->i2c_adap);
1536 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1537 &tbs_cx24117_config,
1538 &i2c_bus->i2c_adap);
1542 case CX23885_BOARD_TEVII_S470:
1543 i2c_bus = &dev->i2c_bus[1];
1545 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1546 &tevii_ds3000_config,
1547 &i2c_bus->i2c_adap);
1548 if (fe0->dvb.frontend != NULL) {
1549 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1550 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1551 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1555 case CX23885_BOARD_DVBWORLD_2005:
1556 i2c_bus = &dev->i2c_bus[1];
1558 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1559 &dvbworld_cx24116_config,
1560 &i2c_bus->i2c_adap);
1562 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1563 i2c_bus = &dev->i2c_bus[0];
1567 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1568 &netup_stv0900_config,
1569 &i2c_bus->i2c_adap, 0);
1570 if (fe0->dvb.frontend != NULL) {
1571 if (dvb_attach(stv6110_attach,
1573 &netup_stv6110_tunerconfig_a,
1574 &i2c_bus->i2c_adap)) {
1575 if (!dvb_attach(lnbh24_attach,
1578 LNBH24_PCL | LNBH24_TTX,
1581 "No LNBH24 found!\n");
1588 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1589 &netup_stv0900_config,
1590 &i2c_bus->i2c_adap, 1);
1591 if (fe0->dvb.frontend != NULL) {
1592 if (dvb_attach(stv6110_attach,
1594 &netup_stv6110_tunerconfig_b,
1595 &i2c_bus->i2c_adap)) {
1596 if (!dvb_attach(lnbh24_attach,
1599 LNBH24_PCL | LNBH24_TTX,
1602 "No LNBH24 found!\n");
1609 case CX23885_BOARD_MYGICA_X8506:
1610 i2c_bus = &dev->i2c_bus[0];
1611 i2c_bus2 = &dev->i2c_bus[1];
1612 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1613 &mygica_x8506_lgs8gl5_config,
1614 &i2c_bus->i2c_adap);
1615 if (fe0->dvb.frontend == NULL)
1617 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1618 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1619 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1621 case CX23885_BOARD_MYGICA_X8507:
1622 i2c_bus = &dev->i2c_bus[0];
1623 i2c_bus2 = &dev->i2c_bus[1];
1624 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1625 &mygica_x8507_mb86a20s_config,
1626 &i2c_bus->i2c_adap);
1627 if (fe0->dvb.frontend == NULL)
1630 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1631 &i2c_bus2->i2c_adap,
1632 &mygica_x8507_xc5000_config);
1633 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1635 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1636 i2c_bus = &dev->i2c_bus[0];
1637 i2c_bus2 = &dev->i2c_bus[1];
1638 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1639 &magicpro_prohdtve2_lgs8g75_config,
1640 &i2c_bus->i2c_adap);
1641 if (fe0->dvb.frontend == NULL)
1643 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1644 &i2c_bus2->i2c_adap,
1645 &magicpro_prohdtve2_xc5000_config);
1646 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1648 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1649 i2c_bus = &dev->i2c_bus[0];
1650 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1651 &hcw_s5h1411_config,
1652 &i2c_bus->i2c_adap);
1653 if (fe0->dvb.frontend == NULL)
1655 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1656 0x60, &dev->i2c_bus[0].i2c_adap,
1657 &hauppauge_tda18271_config);
1659 tda18271_attach(&dev->ts1.analog_fe,
1660 0x60, &dev->i2c_bus[1].i2c_adap,
1661 &hauppauge_tda18271_config);
1664 case CX23885_BOARD_HAUPPAUGE_HVR1290:
1665 i2c_bus = &dev->i2c_bus[0];
1666 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1667 &hcw_s5h1411_config,
1668 &i2c_bus->i2c_adap);
1669 if (fe0->dvb.frontend == NULL)
1671 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1672 0x60, &dev->i2c_bus[0].i2c_adap,
1673 &hauppauge_tda18271_config);
1675 case CX23885_BOARD_MYGICA_X8558PRO:
1679 i2c_bus = &dev->i2c_bus[0];
1680 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1681 &mygica_x8558pro_atbm8830_cfg1,
1682 &i2c_bus->i2c_adap);
1683 if (fe0->dvb.frontend == NULL)
1685 dvb_attach(max2165_attach, fe0->dvb.frontend,
1687 &mygic_x8558pro_max2165_cfg1);
1691 i2c_bus = &dev->i2c_bus[1];
1692 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1693 &mygica_x8558pro_atbm8830_cfg2,
1694 &i2c_bus->i2c_adap);
1695 if (fe0->dvb.frontend == NULL)
1697 dvb_attach(max2165_attach, fe0->dvb.frontend,
1699 &mygic_x8558pro_max2165_cfg2);
1702 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1703 i2c_bus = &dev->i2c_bus[0];
1704 mfe_shared = 1;/* MFE */
1705 port->frontends.gate = 0;/* not clear for me yet */
1707 /* MFE frontend 1 DVB-T */
1708 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1709 &netup_stv0367_config[port->nr - 1],
1710 &i2c_bus->i2c_adap);
1711 if (fe0->dvb.frontend == NULL)
1713 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1715 &netup_xc5000_config[port->nr - 1]))
1716 goto frontend_detach;
1717 /* load xc5000 firmware */
1718 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1720 /* MFE frontend 2 */
1721 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1723 goto frontend_detach;
1725 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1726 &netup_stv0367_config[port->nr - 1],
1727 &i2c_bus->i2c_adap);
1728 if (fe1->dvb.frontend == NULL)
1731 fe1->dvb.frontend->id = 1;
1732 if (NULL == dvb_attach(xc5000_attach,
1735 &netup_xc5000_config[port->nr - 1]))
1736 goto frontend_detach;
1738 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1739 i2c_bus = &dev->i2c_bus[0];
1740 i2c_bus2 = &dev->i2c_bus[1];
1745 fe0->dvb.frontend = dvb_attach(drxk_attach,
1746 &terratec_drxk_config[0],
1747 &i2c_bus->i2c_adap);
1748 if (fe0->dvb.frontend == NULL)
1750 if (!dvb_attach(mt2063_attach,
1752 &terratec_mt2063_config[0],
1753 &i2c_bus2->i2c_adap))
1754 goto frontend_detach;
1758 fe0->dvb.frontend = dvb_attach(drxk_attach,
1759 &terratec_drxk_config[1],
1760 &i2c_bus->i2c_adap);
1761 if (fe0->dvb.frontend == NULL)
1763 if (!dvb_attach(mt2063_attach,
1765 &terratec_mt2063_config[1],
1766 &i2c_bus2->i2c_adap))
1767 goto frontend_detach;
1771 case CX23885_BOARD_TEVII_S471:
1772 i2c_bus = &dev->i2c_bus[1];
1774 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1775 &tevii_ds3000_config,
1776 &i2c_bus->i2c_adap);
1777 if (fe0->dvb.frontend == NULL)
1779 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1780 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1782 case CX23885_BOARD_PROF_8000:
1783 i2c_bus = &dev->i2c_bus[0];
1785 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1786 &prof_8000_stv090x_config,
1788 STV090x_DEMODULATOR_0);
1789 if (fe0->dvb.frontend == NULL)
1791 if (!dvb_attach(stb6100_attach,
1793 &prof_8000_stb6100_config,
1794 &i2c_bus->i2c_adap))
1795 goto frontend_detach;
1797 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1799 case CX23885_BOARD_HAUPPAUGE_HVR4400: {
1800 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1801 struct a8293_platform_data a8293_pdata = {};
1803 i2c_bus = &dev->i2c_bus[0];
1804 i2c_bus2 = &dev->i2c_bus[1];
1808 /* attach demod + tuner combo */
1809 memset(&info, 0, sizeof(info));
1810 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1812 info.platform_data = &tda10071_pdata;
1813 request_module("tda10071");
1814 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1815 if (!client_demod || !client_demod->dev.driver)
1816 goto frontend_detach;
1817 if (!try_module_get(client_demod->dev.driver->owner)) {
1818 i2c_unregister_device(client_demod);
1819 goto frontend_detach;
1821 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1822 port->i2c_client_demod = client_demod;
1825 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1826 memset(&info, 0, sizeof(info));
1827 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1829 info.platform_data = &a8293_pdata;
1830 request_module("a8293");
1831 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1832 if (!client_sec || !client_sec->dev.driver)
1833 goto frontend_detach;
1834 if (!try_module_get(client_sec->dev.driver->owner)) {
1835 i2c_unregister_device(client_sec);
1836 goto frontend_detach;
1838 port->i2c_client_sec = client_sec;
1842 fe0->dvb.frontend = dvb_attach(si2165_attach,
1843 &hauppauge_hvr4400_si2165_config,
1844 &i2c_bus->i2c_adap);
1845 if (fe0->dvb.frontend == NULL)
1847 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1848 if (!dvb_attach(tda18271_attach,
1850 0x60, &i2c_bus2->i2c_adap,
1851 &hauppauge_hvr4400_tuner_config))
1852 goto frontend_detach;
1857 case CX23885_BOARD_HAUPPAUGE_STARBURST: {
1858 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1859 struct a8293_platform_data a8293_pdata = {};
1861 i2c_bus = &dev->i2c_bus[0];
1863 /* attach demod + tuner combo */
1864 memset(&info, 0, sizeof(info));
1865 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1867 info.platform_data = &tda10071_pdata;
1868 request_module("tda10071");
1869 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1870 if (!client_demod || !client_demod->dev.driver)
1871 goto frontend_detach;
1872 if (!try_module_get(client_demod->dev.driver->owner)) {
1873 i2c_unregister_device(client_demod);
1874 goto frontend_detach;
1876 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1877 port->i2c_client_demod = client_demod;
1880 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1881 memset(&info, 0, sizeof(info));
1882 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1884 info.platform_data = &a8293_pdata;
1885 request_module("a8293");
1886 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1887 if (!client_sec || !client_sec->dev.driver)
1888 goto frontend_detach;
1889 if (!try_module_get(client_sec->dev.driver->owner)) {
1890 i2c_unregister_device(client_sec);
1891 goto frontend_detach;
1893 port->i2c_client_sec = client_sec;
1896 case CX23885_BOARD_DVBSKY_T9580:
1897 case CX23885_BOARD_DVBSKY_S950:
1898 i2c_bus = &dev->i2c_bus[0];
1899 i2c_bus2 = &dev->i2c_bus[1];
1901 /* port b - satellite */
1903 /* attach frontend */
1904 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1905 &dvbsky_t9580_m88ds3103_config,
1906 &i2c_bus2->i2c_adap, &adapter);
1907 if (fe0->dvb.frontend == NULL)
1911 memset(&ts2020_config, 0, sizeof(ts2020_config));
1912 ts2020_config.fe = fe0->dvb.frontend;
1913 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
1914 memset(&info, 0, sizeof(struct i2c_board_info));
1915 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
1917 info.platform_data = &ts2020_config;
1918 request_module(info.type);
1919 client_tuner = i2c_new_device(adapter, &info);
1920 if (client_tuner == NULL ||
1921 client_tuner->dev.driver == NULL)
1922 goto frontend_detach;
1923 if (!try_module_get(client_tuner->dev.driver->owner)) {
1924 i2c_unregister_device(client_tuner);
1925 goto frontend_detach;
1928 /* delegate signal strength measurement to tuner */
1929 fe0->dvb.frontend->ops.read_signal_strength =
1930 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1933 * for setting the voltage we need to set GPIOs on
1936 port->fe_set_voltage =
1937 fe0->dvb.frontend->ops.set_voltage;
1938 fe0->dvb.frontend->ops.set_voltage =
1939 dvbsky_t9580_set_voltage;
1941 port->i2c_client_tuner = client_tuner;
1944 /* port c - terrestrial/cable */
1946 /* attach frontend */
1947 memset(&si2168_config, 0, sizeof(si2168_config));
1948 si2168_config.i2c_adapter = &adapter;
1949 si2168_config.fe = &fe0->dvb.frontend;
1950 si2168_config.ts_mode = SI2168_TS_SERIAL;
1951 memset(&info, 0, sizeof(struct i2c_board_info));
1952 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1954 info.platform_data = &si2168_config;
1955 request_module(info.type);
1956 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1957 if (client_demod == NULL ||
1958 client_demod->dev.driver == NULL)
1959 goto frontend_detach;
1960 if (!try_module_get(client_demod->dev.driver->owner)) {
1961 i2c_unregister_device(client_demod);
1962 goto frontend_detach;
1964 port->i2c_client_demod = client_demod;
1967 memset(&si2157_config, 0, sizeof(si2157_config));
1968 si2157_config.fe = fe0->dvb.frontend;
1969 si2157_config.if_port = 1;
1970 memset(&info, 0, sizeof(struct i2c_board_info));
1971 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1973 info.platform_data = &si2157_config;
1974 request_module(info.type);
1975 client_tuner = i2c_new_device(adapter, &info);
1976 if (client_tuner == NULL ||
1977 client_tuner->dev.driver == NULL)
1978 goto frontend_detach;
1980 if (!try_module_get(client_tuner->dev.driver->owner)) {
1981 i2c_unregister_device(client_tuner);
1982 goto frontend_detach;
1984 port->i2c_client_tuner = client_tuner;
1988 case CX23885_BOARD_DVBSKY_T980C:
1989 case CX23885_BOARD_TT_CT2_4500_CI:
1990 i2c_bus = &dev->i2c_bus[0];
1991 i2c_bus2 = &dev->i2c_bus[1];
1993 /* attach frontend */
1994 memset(&si2168_config, 0, sizeof(si2168_config));
1995 si2168_config.i2c_adapter = &adapter;
1996 si2168_config.fe = &fe0->dvb.frontend;
1997 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1998 memset(&info, 0, sizeof(struct i2c_board_info));
1999 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2001 info.platform_data = &si2168_config;
2002 request_module(info.type);
2003 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2004 if (client_demod == NULL || client_demod->dev.driver == NULL)
2005 goto frontend_detach;
2006 if (!try_module_get(client_demod->dev.driver->owner)) {
2007 i2c_unregister_device(client_demod);
2008 goto frontend_detach;
2010 port->i2c_client_demod = client_demod;
2013 memset(&si2157_config, 0, sizeof(si2157_config));
2014 si2157_config.fe = fe0->dvb.frontend;
2015 si2157_config.if_port = 1;
2016 memset(&info, 0, sizeof(struct i2c_board_info));
2017 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2019 info.platform_data = &si2157_config;
2020 request_module(info.type);
2021 client_tuner = i2c_new_device(adapter, &info);
2022 if (client_tuner == NULL ||
2023 client_tuner->dev.driver == NULL)
2024 goto frontend_detach;
2025 if (!try_module_get(client_tuner->dev.driver->owner)) {
2026 i2c_unregister_device(client_tuner);
2027 goto frontend_detach;
2029 port->i2c_client_tuner = client_tuner;
2031 case CX23885_BOARD_DVBSKY_S950C:
2032 i2c_bus = &dev->i2c_bus[0];
2033 i2c_bus2 = &dev->i2c_bus[1];
2035 /* attach frontend */
2036 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2037 &dvbsky_s950c_m88ds3103_config,
2038 &i2c_bus2->i2c_adap, &adapter);
2039 if (fe0->dvb.frontend == NULL)
2043 memset(&ts2020_config, 0, sizeof(ts2020_config));
2044 ts2020_config.fe = fe0->dvb.frontend;
2045 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2046 memset(&info, 0, sizeof(struct i2c_board_info));
2047 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2049 info.platform_data = &ts2020_config;
2050 request_module(info.type);
2051 client_tuner = i2c_new_device(adapter, &info);
2052 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2053 goto frontend_detach;
2054 if (!try_module_get(client_tuner->dev.driver->owner)) {
2055 i2c_unregister_device(client_tuner);
2056 goto frontend_detach;
2059 /* delegate signal strength measurement to tuner */
2060 fe0->dvb.frontend->ops.read_signal_strength =
2061 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2063 port->i2c_client_tuner = client_tuner;
2065 case CX23885_BOARD_DVBSKY_S952:
2069 i2c_bus = &dev->i2c_bus[1];
2070 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
2071 p_set_voltage = dvbsky_t9580_set_voltage;
2075 i2c_bus = &dev->i2c_bus[0];
2076 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
2077 p_set_voltage = dvbsky_s952_portc_set_voltage;
2081 /* attach frontend */
2082 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2084 &i2c_bus->i2c_adap, &adapter);
2085 if (fe0->dvb.frontend == NULL)
2089 memset(&ts2020_config, 0, sizeof(ts2020_config));
2090 ts2020_config.fe = fe0->dvb.frontend;
2091 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2092 memset(&info, 0, sizeof(struct i2c_board_info));
2093 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2095 info.platform_data = &ts2020_config;
2096 request_module(info.type);
2097 client_tuner = i2c_new_device(adapter, &info);
2098 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2099 goto frontend_detach;
2100 if (!try_module_get(client_tuner->dev.driver->owner)) {
2101 i2c_unregister_device(client_tuner);
2102 goto frontend_detach;
2105 /* delegate signal strength measurement to tuner */
2106 fe0->dvb.frontend->ops.read_signal_strength =
2107 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2110 * for setting the voltage we need to set GPIOs on
2113 port->fe_set_voltage =
2114 fe0->dvb.frontend->ops.set_voltage;
2115 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2117 port->i2c_client_tuner = client_tuner;
2119 case CX23885_BOARD_DVBSKY_T982:
2120 memset(&si2168_config, 0, sizeof(si2168_config));
2124 i2c_bus = &dev->i2c_bus[1];
2125 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2129 i2c_bus = &dev->i2c_bus[0];
2130 si2168_config.ts_mode = SI2168_TS_SERIAL;
2134 /* attach frontend */
2135 si2168_config.i2c_adapter = &adapter;
2136 si2168_config.fe = &fe0->dvb.frontend;
2137 memset(&info, 0, sizeof(struct i2c_board_info));
2138 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2140 info.platform_data = &si2168_config;
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;
2152 memset(&si2157_config, 0, sizeof(si2157_config));
2153 si2157_config.fe = fe0->dvb.frontend;
2154 si2157_config.if_port = 1;
2155 memset(&info, 0, sizeof(struct i2c_board_info));
2156 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2158 info.platform_data = &si2157_config;
2159 request_module(info.type);
2160 client_tuner = i2c_new_device(adapter, &info);
2161 if (client_tuner == NULL ||
2162 client_tuner->dev.driver == NULL)
2163 goto frontend_detach;
2164 if (!try_module_get(client_tuner->dev.driver->owner)) {
2165 i2c_unregister_device(client_tuner);
2166 goto frontend_detach;
2168 port->i2c_client_tuner = client_tuner;
2170 case CX23885_BOARD_HAUPPAUGE_HVR5525: {
2171 struct m88rs6000t_config m88rs6000t_config;
2172 struct a8293_platform_data a8293_pdata = {};
2176 /* port b - satellite */
2178 /* attach frontend */
2179 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2180 &hauppauge_hvr5525_m88ds3103_config,
2181 &dev->i2c_bus[0].i2c_adap, &adapter);
2182 if (fe0->dvb.frontend == NULL)
2186 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
2187 memset(&info, 0, sizeof(info));
2188 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
2190 info.platform_data = &a8293_pdata;
2191 request_module("a8293");
2192 client_sec = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2193 if (!client_sec || !client_sec->dev.driver)
2194 goto frontend_detach;
2195 if (!try_module_get(client_sec->dev.driver->owner)) {
2196 i2c_unregister_device(client_sec);
2197 goto frontend_detach;
2199 port->i2c_client_sec = client_sec;
2202 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2203 m88rs6000t_config.fe = fe0->dvb.frontend;
2204 memset(&info, 0, sizeof(struct i2c_board_info));
2205 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2207 info.platform_data = &m88rs6000t_config;
2208 request_module("%s", info.type);
2209 client_tuner = i2c_new_device(adapter, &info);
2210 if (!client_tuner || !client_tuner->dev.driver)
2211 goto frontend_detach;
2212 if (!try_module_get(client_tuner->dev.driver->owner)) {
2213 i2c_unregister_device(client_tuner);
2214 goto frontend_detach;
2216 port->i2c_client_tuner = client_tuner;
2218 /* delegate signal strength measurement to tuner */
2219 fe0->dvb.frontend->ops.read_signal_strength =
2220 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2222 /* port c - terrestrial/cable */
2224 /* attach frontend */
2225 memset(&si2168_config, 0, sizeof(si2168_config));
2226 si2168_config.i2c_adapter = &adapter;
2227 si2168_config.fe = &fe0->dvb.frontend;
2228 si2168_config.ts_mode = SI2168_TS_SERIAL;
2229 memset(&info, 0, sizeof(struct i2c_board_info));
2230 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2232 info.platform_data = &si2168_config;
2233 request_module("%s", info.type);
2234 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2235 if (!client_demod || !client_demod->dev.driver)
2236 goto frontend_detach;
2237 if (!try_module_get(client_demod->dev.driver->owner)) {
2238 i2c_unregister_device(client_demod);
2239 goto frontend_detach;
2241 port->i2c_client_demod = client_demod;
2244 memset(&si2157_config, 0, sizeof(si2157_config));
2245 si2157_config.fe = fe0->dvb.frontend;
2246 si2157_config.if_port = 1;
2247 memset(&info, 0, sizeof(struct i2c_board_info));
2248 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2250 info.platform_data = &si2157_config;
2251 request_module("%s", info.type);
2252 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2253 if (!client_tuner || !client_tuner->dev.driver) {
2254 module_put(client_demod->dev.driver->owner);
2255 i2c_unregister_device(client_demod);
2256 port->i2c_client_demod = NULL;
2257 goto frontend_detach;
2259 if (!try_module_get(client_tuner->dev.driver->owner)) {
2260 i2c_unregister_device(client_tuner);
2261 module_put(client_demod->dev.driver->owner);
2262 i2c_unregister_device(client_demod);
2263 port->i2c_client_demod = NULL;
2264 goto frontend_detach;
2266 port->i2c_client_tuner = client_tuner;
2271 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
2273 /* port b - Terrestrial/cable */
2275 /* attach frontend */
2276 memset(&si2168_config, 0, sizeof(si2168_config));
2277 si2168_config.i2c_adapter = &adapter;
2278 si2168_config.fe = &fe0->dvb.frontend;
2279 si2168_config.ts_mode = SI2168_TS_SERIAL;
2280 memset(&info, 0, sizeof(struct i2c_board_info));
2281 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2283 info.platform_data = &si2168_config;
2284 request_module("%s", info.type);
2285 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2286 if (!client_demod || !client_demod->dev.driver)
2287 goto frontend_detach;
2288 if (!try_module_get(client_demod->dev.driver->owner)) {
2289 i2c_unregister_device(client_demod);
2290 goto frontend_detach;
2292 port->i2c_client_demod = client_demod;
2295 memset(&si2157_config, 0, sizeof(si2157_config));
2296 si2157_config.fe = fe0->dvb.frontend;
2297 si2157_config.if_port = 1;
2298 memset(&info, 0, sizeof(struct i2c_board_info));
2299 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2301 info.platform_data = &si2157_config;
2302 request_module("%s", info.type);
2303 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2304 if (!client_tuner || !client_tuner->dev.driver) {
2305 module_put(client_demod->dev.driver->owner);
2306 i2c_unregister_device(client_demod);
2307 port->i2c_client_demod = NULL;
2308 goto frontend_detach;
2310 if (!try_module_get(client_tuner->dev.driver->owner)) {
2311 i2c_unregister_device(client_tuner);
2312 module_put(client_demod->dev.driver->owner);
2313 i2c_unregister_device(client_demod);
2314 port->i2c_client_demod = NULL;
2315 goto frontend_detach;
2317 port->i2c_client_tuner = client_tuner;
2320 /* port c - terrestrial/cable */
2322 /* attach frontend */
2323 memset(&si2168_config, 0, sizeof(si2168_config));
2324 si2168_config.i2c_adapter = &adapter;
2325 si2168_config.fe = &fe0->dvb.frontend;
2326 si2168_config.ts_mode = SI2168_TS_SERIAL;
2327 memset(&info, 0, sizeof(struct i2c_board_info));
2328 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2330 info.platform_data = &si2168_config;
2331 request_module("%s", info.type);
2332 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2333 if (!client_demod || !client_demod->dev.driver)
2334 goto frontend_detach;
2335 if (!try_module_get(client_demod->dev.driver->owner)) {
2336 i2c_unregister_device(client_demod);
2337 goto frontend_detach;
2339 port->i2c_client_demod = client_demod;
2342 memset(&si2157_config, 0, sizeof(si2157_config));
2343 si2157_config.fe = fe0->dvb.frontend;
2344 si2157_config.if_port = 1;
2345 memset(&info, 0, sizeof(struct i2c_board_info));
2346 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2348 info.platform_data = &si2157_config;
2349 request_module("%s", info.type);
2350 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2351 if (!client_tuner || !client_tuner->dev.driver) {
2352 module_put(client_demod->dev.driver->owner);
2353 i2c_unregister_device(client_demod);
2354 port->i2c_client_demod = NULL;
2355 goto frontend_detach;
2357 if (!try_module_get(client_tuner->dev.driver->owner)) {
2358 i2c_unregister_device(client_tuner);
2359 module_put(client_demod->dev.driver->owner);
2360 i2c_unregister_device(client_demod);
2361 port->i2c_client_demod = NULL;
2362 goto frontend_detach;
2364 port->i2c_client_tuner = client_tuner;
2370 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2371 " isn't supported yet\n",
2376 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2377 printk(KERN_ERR "%s: frontend initialization failed\n",
2379 goto frontend_detach;
2382 /* define general-purpose callback pointer */
2383 fe0->dvb.frontend->callback = cx23885_tuner_callback;
2385 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2387 /* Ensure all frontends negotiate bus access */
2388 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2390 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2393 /* Put the analog decoder in standby to keep it quiet */
2394 call_all(dev, core, s_power, 0);
2396 if (fe0->dvb.frontend->ops.analog_ops.standby)
2397 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
2399 /* register everything */
2400 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2401 &dev->pci->dev, NULL,
2402 adapter_nr, mfe_shared);
2404 goto frontend_detach;
2406 ret = dvb_register_ci_mac(port);
2408 goto frontend_detach;
2413 /* remove I2C client for SEC */
2414 client_sec = port->i2c_client_sec;
2416 module_put(client_sec->dev.driver->owner);
2417 i2c_unregister_device(client_sec);
2418 port->i2c_client_sec = NULL;
2421 /* remove I2C client for tuner */
2422 client_tuner = port->i2c_client_tuner;
2424 module_put(client_tuner->dev.driver->owner);
2425 i2c_unregister_device(client_tuner);
2426 port->i2c_client_tuner = NULL;
2429 /* remove I2C client for demodulator */
2430 client_demod = port->i2c_client_demod;
2432 module_put(client_demod->dev.driver->owner);
2433 i2c_unregister_device(client_demod);
2434 port->i2c_client_demod = NULL;
2437 port->gate_ctrl = NULL;
2438 vb2_dvb_dealloc_frontends(&port->frontends);
2442 int cx23885_dvb_register(struct cx23885_tsport *port)
2445 struct vb2_dvb_frontend *fe0;
2446 struct cx23885_dev *dev = port->dev;
2449 /* Here we need to allocate the correct number of frontends,
2450 * as reflected in the cards struct. The reality is that currently
2451 * no cx23885 boards support this - yet. But, if we don't modify this
2452 * code then the second frontend would never be allocated (later)
2453 * and fail with error before the attach in dvb_register().
2454 * Without these changes we risk an OOPS later. The changes here
2455 * are for safety, and should provide a good foundation for the
2456 * future addition of any multi-frontend cx23885 based boards.
2458 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
2459 port->num_frontends);
2461 for (i = 1; i <= port->num_frontends; i++) {
2462 struct vb2_queue *q;
2464 if (vb2_dvb_alloc_frontend(
2465 &port->frontends, i) == NULL) {
2466 printk(KERN_ERR "%s() failed to alloc\n", __func__);
2470 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
2474 dprintk(1, "%s\n", __func__);
2475 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2484 /* We have to init the queue for each frontend on a port. */
2485 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
2487 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2488 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2489 q->gfp_flags = GFP_DMA32;
2490 q->min_buffers_needed = 2;
2492 q->buf_struct_size = sizeof(struct cx23885_buffer);
2494 q->mem_ops = &vb2_dma_sg_memops;
2495 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2496 q->lock = &dev->lock;
2497 q->dev = &dev->pci->dev;
2499 err = vb2_queue_init(q);
2503 err = dvb_register(port);
2505 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
2511 int cx23885_dvb_unregister(struct cx23885_tsport *port)
2513 struct vb2_dvb_frontend *fe0;
2514 struct i2c_client *client;
2516 /* remove I2C client for CI */
2517 client = port->i2c_client_ci;
2519 module_put(client->dev.driver->owner);
2520 i2c_unregister_device(client);
2523 /* remove I2C client for SEC */
2524 client = port->i2c_client_sec;
2526 module_put(client->dev.driver->owner);
2527 i2c_unregister_device(client);
2530 /* remove I2C client for tuner */
2531 client = port->i2c_client_tuner;
2533 module_put(client->dev.driver->owner);
2534 i2c_unregister_device(client);
2537 /* remove I2C client for demodulator */
2538 client = port->i2c_client_demod;
2540 module_put(client->dev.driver->owner);
2541 i2c_unregister_device(client);
2544 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2546 if (fe0 && fe0->dvb.frontend)
2547 vb2_dvb_unregister_bus(&port->frontends);
2549 switch (port->dev->board) {
2550 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2551 netup_ci_exit(port);
2553 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2554 altera_ci_release(port->dev, port->nr);
2558 port->gate_ctrl = NULL;