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 struct v4l2_format *fmt,
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 cx23885_tsport *port = vb->vb2_queue->drv_priv;
114 struct cx23885_buffer *buf =
115 container_of(vb, struct cx23885_buffer, vb);
117 return cx23885_buf_prepare(buf, port);
120 static void buffer_finish(struct vb2_buffer *vb)
122 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
123 struct cx23885_dev *dev = port->dev;
124 struct cx23885_buffer *buf = container_of(vb,
125 struct cx23885_buffer, vb);
127 cx23885_free_buffer(dev, buf);
130 static void buffer_queue(struct vb2_buffer *vb)
132 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
133 struct cx23885_buffer *buf = container_of(vb,
134 struct cx23885_buffer, vb);
136 cx23885_buf_queue(port, buf);
139 static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
141 struct vb2_dvb_frontends *f;
142 struct vb2_dvb_frontend *fe;
144 f = &port->frontends;
146 if (f->gate <= 1) /* undefined or fe0 */
147 fe = vb2_dvb_get_frontend(f, 1);
149 fe = vb2_dvb_get_frontend(f, f->gate);
151 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
152 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
155 static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
157 struct cx23885_tsport *port = q->drv_priv;
158 struct cx23885_dmaqueue *dmaq = &port->mpegq;
159 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
160 struct cx23885_buffer, queue);
162 cx23885_start_dma(port, dmaq, buf);
166 static void cx23885_stop_streaming(struct vb2_queue *q)
168 struct cx23885_tsport *port = q->drv_priv;
170 cx23885_cancel_buffers(port);
173 static struct vb2_ops dvb_qops = {
174 .queue_setup = queue_setup,
175 .buf_prepare = buffer_prepare,
176 .buf_finish = buffer_finish,
177 .buf_queue = buffer_queue,
178 .wait_prepare = vb2_ops_wait_prepare,
179 .wait_finish = vb2_ops_wait_finish,
180 .start_streaming = cx23885_start_streaming,
181 .stop_streaming = cx23885_stop_streaming,
184 static struct s5h1409_config hauppauge_generic_config = {
185 .demod_address = 0x32 >> 1,
186 .output_mode = S5H1409_SERIAL_OUTPUT,
187 .gpio = S5H1409_GPIO_ON,
189 .inversion = S5H1409_INVERSION_OFF,
190 .status_mode = S5H1409_DEMODLOCKING,
191 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
194 static struct tda10048_config hauppauge_hvr1200_config = {
195 .demod_address = 0x10 >> 1,
196 .output_mode = TDA10048_SERIAL_OUTPUT,
197 .fwbulkwritelen = TDA10048_BULKWRITE_200,
198 .inversion = TDA10048_INVERSION_ON,
199 .dtv6_if_freq_khz = TDA10048_IF_3300,
200 .dtv7_if_freq_khz = TDA10048_IF_3800,
201 .dtv8_if_freq_khz = TDA10048_IF_4300,
202 .clk_freq_khz = TDA10048_CLK_16000,
205 static struct tda10048_config hauppauge_hvr1210_config = {
206 .demod_address = 0x10 >> 1,
207 .output_mode = TDA10048_SERIAL_OUTPUT,
208 .fwbulkwritelen = TDA10048_BULKWRITE_200,
209 .inversion = TDA10048_INVERSION_ON,
210 .dtv6_if_freq_khz = TDA10048_IF_3300,
211 .dtv7_if_freq_khz = TDA10048_IF_3500,
212 .dtv8_if_freq_khz = TDA10048_IF_4000,
213 .clk_freq_khz = TDA10048_CLK_16000,
216 static struct s5h1409_config hauppauge_ezqam_config = {
217 .demod_address = 0x32 >> 1,
218 .output_mode = S5H1409_SERIAL_OUTPUT,
219 .gpio = S5H1409_GPIO_OFF,
221 .inversion = S5H1409_INVERSION_ON,
222 .status_mode = S5H1409_DEMODLOCKING,
223 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
226 static struct s5h1409_config hauppauge_hvr1800lp_config = {
227 .demod_address = 0x32 >> 1,
228 .output_mode = S5H1409_SERIAL_OUTPUT,
229 .gpio = S5H1409_GPIO_OFF,
231 .inversion = S5H1409_INVERSION_OFF,
232 .status_mode = S5H1409_DEMODLOCKING,
233 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
236 static struct s5h1409_config hauppauge_hvr1500_config = {
237 .demod_address = 0x32 >> 1,
238 .output_mode = S5H1409_SERIAL_OUTPUT,
239 .gpio = S5H1409_GPIO_OFF,
240 .inversion = S5H1409_INVERSION_OFF,
241 .status_mode = S5H1409_DEMODLOCKING,
242 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
245 static struct mt2131_config hauppauge_generic_tunerconfig = {
249 static struct lgdt330x_config fusionhdtv_5_express = {
250 .demod_address = 0x0e,
251 .demod_chip = LGDT3303,
255 static struct s5h1409_config hauppauge_hvr1500q_config = {
256 .demod_address = 0x32 >> 1,
257 .output_mode = S5H1409_SERIAL_OUTPUT,
258 .gpio = S5H1409_GPIO_ON,
260 .inversion = S5H1409_INVERSION_OFF,
261 .status_mode = S5H1409_DEMODLOCKING,
262 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
265 static struct s5h1409_config dvico_s5h1409_config = {
266 .demod_address = 0x32 >> 1,
267 .output_mode = S5H1409_SERIAL_OUTPUT,
268 .gpio = S5H1409_GPIO_ON,
270 .inversion = S5H1409_INVERSION_OFF,
271 .status_mode = S5H1409_DEMODLOCKING,
272 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
275 static struct s5h1411_config dvico_s5h1411_config = {
276 .output_mode = S5H1411_SERIAL_OUTPUT,
277 .gpio = S5H1411_GPIO_ON,
278 .qam_if = S5H1411_IF_44000,
279 .vsb_if = S5H1411_IF_44000,
280 .inversion = S5H1411_INVERSION_OFF,
281 .status_mode = S5H1411_DEMODLOCKING,
282 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
285 static struct s5h1411_config hcw_s5h1411_config = {
286 .output_mode = S5H1411_SERIAL_OUTPUT,
287 .gpio = S5H1411_GPIO_OFF,
288 .vsb_if = S5H1411_IF_44000,
289 .qam_if = S5H1411_IF_4000,
290 .inversion = S5H1411_INVERSION_ON,
291 .status_mode = S5H1411_DEMODLOCKING,
292 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
295 static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
300 static struct xc5000_config dvico_xc5000_tunerconfig = {
305 static struct tda829x_config tda829x_no_probe = {
306 .probe_tuner = TDA829X_DONT_PROBE,
309 static struct tda18271_std_map hauppauge_tda18271_std_map = {
310 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
311 .if_lvl = 6, .rfagc_top = 0x37 },
312 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
313 .if_lvl = 6, .rfagc_top = 0x37 },
316 static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
317 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
318 .if_lvl = 1, .rfagc_top = 0x37, },
319 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
320 .if_lvl = 1, .rfagc_top = 0x37, },
321 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
322 .if_lvl = 1, .rfagc_top = 0x37, },
325 static struct tda18271_config hauppauge_tda18271_config = {
326 .std_map = &hauppauge_tda18271_std_map,
327 .gate = TDA18271_GATE_ANALOG,
328 .output_opt = TDA18271_OUTPUT_LT_OFF,
331 static struct tda18271_config hauppauge_hvr1200_tuner_config = {
332 .std_map = &hauppauge_hvr1200_tda18271_std_map,
333 .gate = TDA18271_GATE_ANALOG,
334 .output_opt = TDA18271_OUTPUT_LT_OFF,
337 static struct tda18271_config hauppauge_hvr1210_tuner_config = {
338 .gate = TDA18271_GATE_DIGITAL,
339 .output_opt = TDA18271_OUTPUT_LT_OFF,
342 static struct tda18271_config hauppauge_hvr4400_tuner_config = {
343 .gate = TDA18271_GATE_DIGITAL,
344 .output_opt = TDA18271_OUTPUT_LT_OFF,
347 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
348 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
349 .if_lvl = 1, .rfagc_top = 0x58 },
350 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
351 .if_lvl = 1, .rfagc_top = 0x58 },
354 static struct tda18271_config hauppauge_hvr127x_config = {
355 .std_map = &hauppauge_hvr127x_std_map,
356 .output_opt = TDA18271_OUTPUT_LT_OFF,
359 static struct lgdt3305_config hauppauge_lgdt3305_config = {
361 .mpeg_mode = LGDT3305_MPEG_SERIAL,
362 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
363 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
365 .spectral_inversion = 1,
370 static struct dibx000_agc_config xc3028_agc_config = {
371 BAND_VHF | BAND_UHF, /* band_caps */
373 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
374 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
375 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
376 * P_agc_nb_est=2, P_agc_write=0
378 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
379 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
382 21, /* time_stabiliz */
394 39718, /* agc2_max */
403 29, /* agc2_slope1 */
404 29, /* agc2_slope2 */
411 1, /* perform_agc_softsplit */
414 /* PLL Configuration for COFDM BW_MHz = 8.000000
415 * With external clock = 30.000000 */
416 static struct dibx000_bandwidth_config xc3028_bw_config = {
417 60000, /* internal */
418 30000, /* sampling */
419 1, /* pll_cfg: prediv */
420 8, /* pll_cfg: ratio */
421 3, /* pll_cfg: range */
422 1, /* pll_cfg: reset */
423 0, /* pll_cfg: bypass */
424 0, /* misc: refdiv */
425 0, /* misc: bypclk_div */
426 1, /* misc: IO_CLK_en_core */
427 1, /* misc: ADClkSrc */
428 0, /* misc: modulo */
429 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
430 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
432 30000000 /* xtal_hz */
435 static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
436 .output_mpeg2_in_188_bytes = 1,
437 .hostbus_diversity = 1,
438 .tuner_is_baseband = 0,
441 .agc_config_count = 1,
442 .agc = &xc3028_agc_config,
443 .bw = &xc3028_bw_config,
445 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
446 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
447 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
453 .output_mode = OUTMODE_MPEG2_SERIAL,
456 static struct zl10353_config dvico_fusionhdtv_xc3028 = {
457 .demod_address = 0x0f,
460 .disable_i2c_gate_ctrl = 1,
463 static struct stv0900_reg stv0900_ts_regs[] = {
464 { R0900_TSGENERAL, 0x00 },
465 { R0900_P1_TSSPEED, 0x40 },
466 { R0900_P2_TSSPEED, 0x40 },
467 { R0900_P1_TSCFGM, 0xc0 },
468 { R0900_P2_TSCFGM, 0xc0 },
469 { R0900_P1_TSCFGH, 0xe0 },
470 { R0900_P2_TSCFGH, 0xe0 },
471 { R0900_P1_TSCFGL, 0x20 },
472 { R0900_P2_TSCFGL, 0x20 },
473 { 0xffff, 0xff }, /* terminate */
476 static struct stv0900_config netup_stv0900_config = {
477 .demod_address = 0x68,
478 .demod_mode = 1, /* dual */
480 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
481 .diseqc_mode = 2,/* 2/3 PWM */
482 .ts_config_regs = stv0900_ts_regs,
483 .tun1_maddress = 0,/* 0x60 */
484 .tun2_maddress = 3,/* 0x63 */
485 .tun1_adc = 1,/* 1 Vpp */
486 .tun2_adc = 1,/* 1 Vpp */
489 static struct stv6110_config netup_stv6110_tunerconfig_a = {
493 .gain = 8, /* +16 dB - maximum gain */
496 static struct stv6110_config netup_stv6110_tunerconfig_b = {
500 .gain = 8, /* +16 dB - maximum gain */
503 static struct cx24116_config tbs_cx24116_config = {
504 .demod_address = 0x55,
507 static struct cx24117_config tbs_cx24117_config = {
508 .demod_address = 0x55,
511 static struct ds3000_config tevii_ds3000_config = {
512 .demod_address = 0x68,
515 static struct ts2020_config tevii_ts2020_config = {
516 .tuner_address = 0x60,
518 .frequency_div = 1146000,
521 static struct cx24116_config dvbworld_cx24116_config = {
522 .demod_address = 0x05,
525 static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
526 .prod = LGS8GXX_PROD_LGS8GL5,
527 .demod_address = 0x19,
531 .if_clk_freq = 30400, /* 30.4 MHz */
532 .if_freq = 5380, /* 5.38 MHz */
539 static struct xc5000_config mygica_x8506_xc5000_config = {
544 static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
545 .demod_address = 0x10,
548 static struct xc5000_config mygica_x8507_xc5000_config = {
553 static struct stv090x_config prof_8000_stv090x_config = {
555 .demod_mode = STV090x_SINGLE,
556 .clk_mode = STV090x_CLK_EXT,
559 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
560 .repeater_level = STV090x_RPTLEVEL_64,
561 .adc1_range = STV090x_ADC_2Vpp,
562 .diseqc_envelope_mode = false,
564 .tuner_get_frequency = stb6100_get_frequency,
565 .tuner_set_frequency = stb6100_set_frequency,
566 .tuner_set_bandwidth = stb6100_set_bandwidth,
567 .tuner_get_bandwidth = stb6100_get_bandwidth,
570 static struct stb6100_config prof_8000_stb6100_config = {
571 .tuner_address = 0x60,
572 .refclock = 27000000,
575 static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
577 struct cx23885_tsport *port = fe->dvb->priv;
578 struct cx23885_dev *dev = port->dev;
580 if (voltage == SEC_VOLTAGE_18)
581 cx_write(MC417_RWD, 0x00001e00);
582 else if (voltage == SEC_VOLTAGE_13)
583 cx_write(MC417_RWD, 0x00001a00);
585 cx_write(MC417_RWD, 0x00001800);
589 static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
590 fe_sec_voltage_t voltage)
592 struct cx23885_tsport *port = fe->dvb->priv;
593 struct cx23885_dev *dev = port->dev;
595 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
599 cx23885_gpio_set(dev, GPIO_1);
600 cx23885_gpio_clear(dev, GPIO_0);
603 cx23885_gpio_set(dev, GPIO_1);
604 cx23885_gpio_set(dev, GPIO_0);
606 case SEC_VOLTAGE_OFF:
607 cx23885_gpio_clear(dev, GPIO_1);
608 cx23885_gpio_clear(dev, GPIO_0);
612 /* call the frontend set_voltage function */
613 port->fe_set_voltage(fe, voltage);
618 static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
619 fe_sec_voltage_t voltage)
621 struct cx23885_tsport *port = fe->dvb->priv;
622 struct cx23885_dev *dev = port->dev;
624 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
628 cx23885_gpio_set(dev, GPIO_13);
629 cx23885_gpio_clear(dev, GPIO_12);
632 cx23885_gpio_set(dev, GPIO_13);
633 cx23885_gpio_set(dev, GPIO_12);
635 case SEC_VOLTAGE_OFF:
636 cx23885_gpio_clear(dev, GPIO_13);
637 cx23885_gpio_clear(dev, GPIO_12);
640 /* call the frontend set_voltage function */
641 return port->fe_set_voltage(fe, voltage);
644 static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
648 #define SP2_DATA 0x000000ff
649 #define SP2_WR 0x00008000
650 #define SP2_RD 0x00004000
651 #define SP2_ACK 0x00001000
652 #define SP2_ADHI 0x00000800
653 #define SP2_ADLO 0x00000400
654 #define SP2_CS1 0x00000200
655 #define SP2_CS0 0x00000100
656 #define SP2_EN_ALL 0x00001000
657 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
659 struct cx23885_tsport *port = priv;
660 struct cx23885_dev *dev = port->dev;
663 unsigned long timeout;
665 mutex_lock(&dev->gpio_lock);
668 cx_write(MC417_OEN, SP2_EN_ALL);
669 cx_write(MC417_RWD, SP2_CTRL_OFF |
670 SP2_ADLO | (0xff & addr));
671 cx_clear(MC417_RWD, SP2_ADLO);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADHI | (0xff & (addr >> 8)));
674 cx_clear(MC417_RWD, SP2_ADHI);
678 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
681 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
684 cx_clear(MC417_RWD, SP2_CS0);
687 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
689 /* wait for a maximum of 1 msec */
690 timeout = jiffies + msecs_to_jiffies(1);
691 while (!time_after(jiffies, timeout)) {
692 tmp = cx_read(MC417_RWD);
693 if ((tmp & SP2_ACK) == 0)
695 usleep_range(50, 100);
698 cx_set(MC417_RWD, SP2_CTRL_OFF);
701 mutex_unlock(&dev->gpio_lock);
715 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
717 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
718 struct cx23885_tsport *port = fe->dvb->priv;
719 struct cx23885_dev *dev = port->dev;
721 switch (dev->board) {
722 case CX23885_BOARD_HAUPPAUGE_HVR1275:
723 switch (p->modulation) {
725 cx23885_gpio_clear(dev, GPIO_5);
730 cx23885_gpio_set(dev, GPIO_5);
734 case CX23885_BOARD_MYGICA_X8506:
735 case CX23885_BOARD_MYGICA_X8507:
736 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
737 /* Select Digital TV */
738 cx23885_gpio_set(dev, GPIO_0);
742 /* Call the real set_frontend */
743 if (port->set_frontend)
744 return port->set_frontend(fe);
749 static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
750 struct dvb_frontend *fe)
752 port->set_frontend = fe->ops.set_frontend;
753 fe->ops.set_frontend = cx23885_dvb_set_frontend;
756 static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
757 .prod = LGS8GXX_PROD_LGS8G75,
758 .demod_address = 0x19,
762 .if_clk_freq = 30400, /* 30.4 MHz */
763 .if_freq = 6500, /* 6.50 MHz */
767 .adc_vpp = 2, /* 1.6 Vpp */
771 static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
776 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
777 .prod = ATBM8830_PROD_8830,
778 .demod_address = 0x44,
780 .ts_sampling_edge = 1,
782 .osc_clk_freq = 30400, /* in kHz */
783 .if_freq = 0, /* zero IF */
790 static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
795 static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
796 .prod = ATBM8830_PROD_8830,
797 .demod_address = 0x44,
799 .ts_sampling_edge = 1,
801 .osc_clk_freq = 30400, /* in kHz */
802 .if_freq = 0, /* zero IF */
809 static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
813 static struct stv0367_config netup_stv0367_config[] = {
815 .demod_address = 0x1c,
822 .demod_address = 0x1d,
831 static struct xc5000_config netup_xc5000_config[] = {
841 static struct drxk_config terratec_drxk_config[] = {
851 static struct mt2063_config terratec_mt2063_config[] = {
853 .tuner_address = 0x60,
855 .tuner_address = 0x67,
859 static const struct tda10071_config hauppauge_tda10071_config = {
860 .demod_i2c_addr = 0x05,
861 .tuner_i2c_addr = 0x54,
863 .ts_mode = TDA10071_TS_SERIAL,
865 .xtal = 40444000, /* 40.444 MHz */
866 .pll_multiplier = 20,
869 static const struct a8293_config hauppauge_a8293_config = {
873 static const struct si2165_config hauppauge_hvr4400_si2165_config = {
875 .chip_mode = SI2165_MODE_PLL_XTAL,
876 .ref_freq_Hz = 16000000,
879 static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
884 .ts_mode = M88DS3103_TS_PARALLEL,
892 static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
897 .ts_mode = M88DS3103_TS_CI,
905 static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
910 .ts_mode = M88DS3103_TS_SERIAL,
918 static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
922 .ts_mode = M88DS3103_TS_PARALLEL,
928 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
930 struct cx23885_dev *dev = (struct cx23885_dev *)device;
931 unsigned long timeout = jiffies + msecs_to_jiffies(1);
934 mem = cx_read(MC417_RWD);
936 cx_set(MC417_OEN, ALT_DATA);
938 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
940 mem |= (data & ALT_DATA);
950 mem = (mem & ~ALT_RD) | ALT_WR;
952 mem = (mem & ~ALT_WR) | ALT_RD;
954 cx_write(MC417_RWD, mem); /* start RW cycle */
957 mem = cx_read(MC417_RWD);
958 if ((mem & ALT_RDY) == 0)
960 if (time_after(jiffies, timeout))
965 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
967 return mem & ALT_DATA;
972 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
974 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
976 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
979 static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
984 static struct dib0070_config dib7070p_dib0070_config = {
985 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
986 .reset = dib7070_tuner_reset,
987 .sleep = dib7070_tuner_sleep,
989 .freq_offset_khz_vhf = 550,
990 /* .flip_chip = 1, */
993 /* DIB7070 generic */
994 static struct dibx000_agc_config dib7070_agc_config = {
995 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
998 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
999 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
1000 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
1002 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1003 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1005 .time_stabiliz = 10,
1029 .perform_agc_softsplit = 0,
1032 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1042 .IO_CLK_en_core = 1,
1045 /* refsel, sel, freq_15k */
1046 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1047 .ifreq = (0 << 25) | 0,
1049 .xtal_hz = 12000000,
1052 static struct dib7000p_config dib7070p_dib7000p_config = {
1053 /* .output_mode = OUTMODE_MPEG2_FIFO, */
1054 .output_mode = OUTMODE_MPEG2_SERIAL,
1055 /* .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK, */
1056 .output_mpeg2_in_188_bytes = 1,
1058 .agc_config_count = 1,
1059 .agc = &dib7070_agc_config,
1060 .bw = &dib7070_bw_config_12_mhz,
1061 .tuner_is_baseband = 1,
1064 .gpio_dir = 0xfcef, /* DIB7000P_GPIO_DEFAULT_DIRECTIONS, */
1065 .gpio_val = 0x0110, /* DIB7000P_GPIO_DEFAULT_VALUES, */
1066 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1068 .hostbus_diversity = 1,
1071 static int dvb_register_ci_mac(struct cx23885_tsport *port)
1073 struct cx23885_dev *dev = port->dev;
1074 struct i2c_client *client_ci = NULL;
1075 struct vb2_dvb_frontend *fe0;
1077 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1081 switch (dev->board) {
1082 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1083 static struct netup_card_info cinfo;
1085 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1086 memcpy(port->frontends.adapter.proposed_mac,
1087 cinfo.port[port->nr - 1].mac, 6);
1088 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1089 port->nr, port->frontends.adapter.proposed_mac);
1091 netup_ci_init(port);
1094 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1095 struct altera_ci_config netup_ci_cfg = {
1096 .dev = dev,/* magic number to identify*/
1097 .adapter = &port->frontends.adapter,/* for CI */
1098 .demux = &fe0->dvb.demux,/* for hw pid filter */
1099 .fpga_rw = netup_altera_fpga_rw,
1102 altera_ci_init(&netup_ci_cfg, port->nr);
1105 case CX23885_BOARD_TEVII_S470: {
1106 u8 eeprom[256]; /* 24C02 i2c eeprom */
1111 /* Read entire EEPROM */
1112 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1113 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1114 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1115 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1118 case CX23885_BOARD_DVBSKY_T9580:
1119 case CX23885_BOARD_DVBSKY_S950:
1120 case CX23885_BOARD_DVBSKY_S952:
1121 case CX23885_BOARD_DVBSKY_T982: {
1122 u8 eeprom[256]; /* 24C02 i2c eeprom */
1127 /* Read entire EEPROM */
1128 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1129 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1131 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1132 cx23885_boards[dev->board].name, port->nr,
1133 eeprom + 0xc0 + (port->nr-1) * 8);
1134 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1135 (port->nr-1) * 8, 6);
1138 case CX23885_BOARD_DVBSKY_S950C:
1139 case CX23885_BOARD_DVBSKY_T980C:
1140 case CX23885_BOARD_TT_CT2_4500_CI: {
1141 u8 eeprom[256]; /* 24C02 i2c eeprom */
1142 struct sp2_config sp2_config;
1143 struct i2c_board_info info;
1144 struct cx23885_i2c *i2c_bus2 = &dev->i2c_bus[1];
1147 memset(&sp2_config, 0, sizeof(sp2_config));
1148 sp2_config.dvb_adap = &port->frontends.adapter;
1149 sp2_config.priv = port;
1150 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1151 memset(&info, 0, sizeof(struct i2c_board_info));
1152 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1154 info.platform_data = &sp2_config;
1155 request_module(info.type);
1156 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
1157 if (client_ci == NULL || client_ci->dev.driver == NULL)
1159 if (!try_module_get(client_ci->dev.driver->owner)) {
1160 i2c_unregister_device(client_ci);
1163 port->i2c_client_ci = client_ci;
1168 /* Read entire EEPROM */
1169 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1170 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1172 printk(KERN_INFO "%s MAC address: %pM\n",
1173 cx23885_boards[dev->board].name, eeprom + 0xc0);
1174 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1181 static int dvb_register(struct cx23885_tsport *port)
1183 struct dib7000p_ops dib7000p_ops;
1184 struct cx23885_dev *dev = port->dev;
1185 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
1186 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
1187 struct si2168_config si2168_config;
1188 struct si2157_config si2157_config;
1189 struct ts2020_config ts2020_config;
1190 struct i2c_board_info info;
1191 struct i2c_adapter *adapter;
1192 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1193 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1194 int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t 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 = XC2028_DEFAULT_FIRMWARE,
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 = XC3028L_DEFAULT_FIRMWARE,
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 = XC2028_DEFAULT_FIRMWARE,
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 = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
1456 memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
1457 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1458 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1463 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1464 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1465 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1466 i2c_bus = &dev->i2c_bus[0];
1468 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1469 &dvico_fusionhdtv_xc3028,
1470 &i2c_bus->i2c_adap);
1471 if (fe0->dvb.frontend != NULL) {
1472 struct dvb_frontend *fe;
1473 struct xc2028_config cfg = {
1474 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1477 static struct xc2028_ctrl ctl = {
1478 .fname = XC2028_DEFAULT_FIRMWARE,
1480 .demod = XC3028_FE_ZARLINK456,
1483 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1485 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1486 fe->ops.tuner_ops.set_config(fe, &ctl);
1489 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1490 i2c_bus = &dev->i2c_bus[0];
1492 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1493 &dvico_fusionhdtv_xc3028,
1494 &i2c_bus->i2c_adap);
1495 if (fe0->dvb.frontend != NULL) {
1496 struct dvb_frontend *fe;
1497 struct xc4000_config cfg = {
1498 .i2c_address = 0x61,
1500 .dvb_amplitude = 134,
1501 .set_smoothedcvbs = 1,
1505 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1506 &dev->i2c_bus[1].i2c_adap, &cfg);
1508 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1510 goto frontend_detach;
1514 case CX23885_BOARD_TBS_6920:
1515 i2c_bus = &dev->i2c_bus[1];
1517 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1518 &tbs_cx24116_config,
1519 &i2c_bus->i2c_adap);
1520 if (fe0->dvb.frontend != NULL)
1521 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1524 case CX23885_BOARD_TBS_6980:
1525 case CX23885_BOARD_TBS_6981:
1526 i2c_bus = &dev->i2c_bus[1];
1531 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1532 &tbs_cx24117_config,
1533 &i2c_bus->i2c_adap);
1537 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1538 &tbs_cx24117_config,
1539 &i2c_bus->i2c_adap);
1543 case CX23885_BOARD_TEVII_S470:
1544 i2c_bus = &dev->i2c_bus[1];
1546 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1547 &tevii_ds3000_config,
1548 &i2c_bus->i2c_adap);
1549 if (fe0->dvb.frontend != NULL) {
1550 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1551 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1552 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1556 case CX23885_BOARD_DVBWORLD_2005:
1557 i2c_bus = &dev->i2c_bus[1];
1559 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1560 &dvbworld_cx24116_config,
1561 &i2c_bus->i2c_adap);
1563 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1564 i2c_bus = &dev->i2c_bus[0];
1568 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1569 &netup_stv0900_config,
1570 &i2c_bus->i2c_adap, 0);
1571 if (fe0->dvb.frontend != NULL) {
1572 if (dvb_attach(stv6110_attach,
1574 &netup_stv6110_tunerconfig_a,
1575 &i2c_bus->i2c_adap)) {
1576 if (!dvb_attach(lnbh24_attach,
1579 LNBH24_PCL | LNBH24_TTX,
1582 "No LNBH24 found!\n");
1589 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1590 &netup_stv0900_config,
1591 &i2c_bus->i2c_adap, 1);
1592 if (fe0->dvb.frontend != NULL) {
1593 if (dvb_attach(stv6110_attach,
1595 &netup_stv6110_tunerconfig_b,
1596 &i2c_bus->i2c_adap)) {
1597 if (!dvb_attach(lnbh24_attach,
1600 LNBH24_PCL | LNBH24_TTX,
1603 "No LNBH24 found!\n");
1610 case CX23885_BOARD_MYGICA_X8506:
1611 i2c_bus = &dev->i2c_bus[0];
1612 i2c_bus2 = &dev->i2c_bus[1];
1613 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1614 &mygica_x8506_lgs8gl5_config,
1615 &i2c_bus->i2c_adap);
1616 if (fe0->dvb.frontend == NULL)
1618 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1619 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1620 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1622 case CX23885_BOARD_MYGICA_X8507:
1623 i2c_bus = &dev->i2c_bus[0];
1624 i2c_bus2 = &dev->i2c_bus[1];
1625 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1626 &mygica_x8507_mb86a20s_config,
1627 &i2c_bus->i2c_adap);
1628 if (fe0->dvb.frontend == NULL)
1631 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1632 &i2c_bus2->i2c_adap,
1633 &mygica_x8507_xc5000_config);
1634 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1636 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1637 i2c_bus = &dev->i2c_bus[0];
1638 i2c_bus2 = &dev->i2c_bus[1];
1639 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1640 &magicpro_prohdtve2_lgs8g75_config,
1641 &i2c_bus->i2c_adap);
1642 if (fe0->dvb.frontend == NULL)
1644 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1645 &i2c_bus2->i2c_adap,
1646 &magicpro_prohdtve2_xc5000_config);
1647 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1649 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1650 i2c_bus = &dev->i2c_bus[0];
1651 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1652 &hcw_s5h1411_config,
1653 &i2c_bus->i2c_adap);
1654 if (fe0->dvb.frontend == NULL)
1656 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1657 0x60, &dev->i2c_bus[0].i2c_adap,
1658 &hauppauge_tda18271_config);
1660 tda18271_attach(&dev->ts1.analog_fe,
1661 0x60, &dev->i2c_bus[1].i2c_adap,
1662 &hauppauge_tda18271_config);
1665 case CX23885_BOARD_HAUPPAUGE_HVR1290:
1666 i2c_bus = &dev->i2c_bus[0];
1667 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1668 &hcw_s5h1411_config,
1669 &i2c_bus->i2c_adap);
1670 if (fe0->dvb.frontend == NULL)
1672 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1673 0x60, &dev->i2c_bus[0].i2c_adap,
1674 &hauppauge_tda18271_config);
1676 case CX23885_BOARD_MYGICA_X8558PRO:
1680 i2c_bus = &dev->i2c_bus[0];
1681 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1682 &mygica_x8558pro_atbm8830_cfg1,
1683 &i2c_bus->i2c_adap);
1684 if (fe0->dvb.frontend == NULL)
1686 dvb_attach(max2165_attach, fe0->dvb.frontend,
1688 &mygic_x8558pro_max2165_cfg1);
1692 i2c_bus = &dev->i2c_bus[1];
1693 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1694 &mygica_x8558pro_atbm8830_cfg2,
1695 &i2c_bus->i2c_adap);
1696 if (fe0->dvb.frontend == NULL)
1698 dvb_attach(max2165_attach, fe0->dvb.frontend,
1700 &mygic_x8558pro_max2165_cfg2);
1703 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1704 i2c_bus = &dev->i2c_bus[0];
1705 mfe_shared = 1;/* MFE */
1706 port->frontends.gate = 0;/* not clear for me yet */
1708 /* MFE frontend 1 DVB-T */
1709 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1710 &netup_stv0367_config[port->nr - 1],
1711 &i2c_bus->i2c_adap);
1712 if (fe0->dvb.frontend == NULL)
1714 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1716 &netup_xc5000_config[port->nr - 1]))
1717 goto frontend_detach;
1718 /* load xc5000 firmware */
1719 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1721 /* MFE frontend 2 */
1722 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1724 goto frontend_detach;
1726 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1727 &netup_stv0367_config[port->nr - 1],
1728 &i2c_bus->i2c_adap);
1729 if (fe1->dvb.frontend == NULL)
1732 fe1->dvb.frontend->id = 1;
1733 if (NULL == dvb_attach(xc5000_attach,
1736 &netup_xc5000_config[port->nr - 1]))
1737 goto frontend_detach;
1739 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1740 i2c_bus = &dev->i2c_bus[0];
1741 i2c_bus2 = &dev->i2c_bus[1];
1746 fe0->dvb.frontend = dvb_attach(drxk_attach,
1747 &terratec_drxk_config[0],
1748 &i2c_bus->i2c_adap);
1749 if (fe0->dvb.frontend == NULL)
1751 if (!dvb_attach(mt2063_attach,
1753 &terratec_mt2063_config[0],
1754 &i2c_bus2->i2c_adap))
1755 goto frontend_detach;
1759 fe0->dvb.frontend = dvb_attach(drxk_attach,
1760 &terratec_drxk_config[1],
1761 &i2c_bus->i2c_adap);
1762 if (fe0->dvb.frontend == NULL)
1764 if (!dvb_attach(mt2063_attach,
1766 &terratec_mt2063_config[1],
1767 &i2c_bus2->i2c_adap))
1768 goto frontend_detach;
1772 case CX23885_BOARD_TEVII_S471:
1773 i2c_bus = &dev->i2c_bus[1];
1775 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1776 &tevii_ds3000_config,
1777 &i2c_bus->i2c_adap);
1778 if (fe0->dvb.frontend == NULL)
1780 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1781 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1783 case CX23885_BOARD_PROF_8000:
1784 i2c_bus = &dev->i2c_bus[0];
1786 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1787 &prof_8000_stv090x_config,
1789 STV090x_DEMODULATOR_0);
1790 if (fe0->dvb.frontend == NULL)
1792 if (!dvb_attach(stb6100_attach,
1794 &prof_8000_stb6100_config,
1795 &i2c_bus->i2c_adap))
1796 goto frontend_detach;
1798 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1800 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1801 i2c_bus = &dev->i2c_bus[0];
1802 i2c_bus2 = &dev->i2c_bus[1];
1806 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1807 &hauppauge_tda10071_config,
1808 &i2c_bus->i2c_adap);
1809 if (fe0->dvb.frontend == NULL)
1811 if (!dvb_attach(a8293_attach, fe0->dvb.frontend,
1813 &hauppauge_a8293_config))
1814 goto frontend_detach;
1818 fe0->dvb.frontend = dvb_attach(si2165_attach,
1819 &hauppauge_hvr4400_si2165_config,
1820 &i2c_bus->i2c_adap);
1821 if (fe0->dvb.frontend == NULL)
1823 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1824 if (!dvb_attach(tda18271_attach,
1826 0x60, &i2c_bus2->i2c_adap,
1827 &hauppauge_hvr4400_tuner_config))
1828 goto frontend_detach;
1832 case CX23885_BOARD_HAUPPAUGE_STARBURST:
1833 i2c_bus = &dev->i2c_bus[0];
1834 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1835 &hauppauge_tda10071_config,
1836 &i2c_bus->i2c_adap);
1837 if (fe0->dvb.frontend != NULL) {
1838 dvb_attach(a8293_attach, fe0->dvb.frontend,
1840 &hauppauge_a8293_config);
1843 case CX23885_BOARD_DVBSKY_T9580:
1844 case CX23885_BOARD_DVBSKY_S950:
1845 i2c_bus = &dev->i2c_bus[0];
1846 i2c_bus2 = &dev->i2c_bus[1];
1848 /* port b - satellite */
1850 /* attach frontend */
1851 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1852 &dvbsky_t9580_m88ds3103_config,
1853 &i2c_bus2->i2c_adap, &adapter);
1854 if (fe0->dvb.frontend == NULL)
1858 memset(&ts2020_config, 0, sizeof(ts2020_config));
1859 ts2020_config.fe = fe0->dvb.frontend;
1860 memset(&info, 0, sizeof(struct i2c_board_info));
1861 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
1863 info.platform_data = &ts2020_config;
1864 request_module(info.type);
1865 client_tuner = i2c_new_device(adapter, &info);
1866 if (client_tuner == NULL ||
1867 client_tuner->dev.driver == NULL)
1868 goto frontend_detach;
1869 if (!try_module_get(client_tuner->dev.driver->owner)) {
1870 i2c_unregister_device(client_tuner);
1871 goto frontend_detach;
1874 /* delegate signal strength measurement to tuner */
1875 fe0->dvb.frontend->ops.read_signal_strength =
1876 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1879 * for setting the voltage we need to set GPIOs on
1882 port->fe_set_voltage =
1883 fe0->dvb.frontend->ops.set_voltage;
1884 fe0->dvb.frontend->ops.set_voltage =
1885 dvbsky_t9580_set_voltage;
1887 port->i2c_client_tuner = client_tuner;
1890 /* port c - terrestrial/cable */
1892 /* attach frontend */
1893 memset(&si2168_config, 0, sizeof(si2168_config));
1894 si2168_config.i2c_adapter = &adapter;
1895 si2168_config.fe = &fe0->dvb.frontend;
1896 si2168_config.ts_mode = SI2168_TS_SERIAL;
1897 memset(&info, 0, sizeof(struct i2c_board_info));
1898 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1900 info.platform_data = &si2168_config;
1901 request_module(info.type);
1902 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1903 if (client_demod == NULL ||
1904 client_demod->dev.driver == NULL)
1905 goto frontend_detach;
1906 if (!try_module_get(client_demod->dev.driver->owner)) {
1907 i2c_unregister_device(client_demod);
1908 goto frontend_detach;
1910 port->i2c_client_demod = client_demod;
1913 memset(&si2157_config, 0, sizeof(si2157_config));
1914 si2157_config.fe = fe0->dvb.frontend;
1915 memset(&info, 0, sizeof(struct i2c_board_info));
1916 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1918 info.platform_data = &si2157_config;
1919 request_module(info.type);
1920 client_tuner = i2c_new_device(adapter, &info);
1921 if (client_tuner == NULL ||
1922 client_tuner->dev.driver == NULL)
1923 goto frontend_detach;
1925 if (!try_module_get(client_tuner->dev.driver->owner)) {
1926 i2c_unregister_device(client_tuner);
1927 goto frontend_detach;
1929 port->i2c_client_tuner = client_tuner;
1933 case CX23885_BOARD_DVBSKY_T980C:
1934 case CX23885_BOARD_TT_CT2_4500_CI:
1935 i2c_bus = &dev->i2c_bus[1];
1936 i2c_bus2 = &dev->i2c_bus[0];
1938 /* attach frontend */
1939 memset(&si2168_config, 0, sizeof(si2168_config));
1940 si2168_config.i2c_adapter = &adapter;
1941 si2168_config.fe = &fe0->dvb.frontend;
1942 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1943 memset(&info, 0, sizeof(struct i2c_board_info));
1944 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1946 info.platform_data = &si2168_config;
1947 request_module(info.type);
1948 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1949 if (client_demod == NULL || client_demod->dev.driver == NULL)
1950 goto frontend_detach;
1951 if (!try_module_get(client_demod->dev.driver->owner)) {
1952 i2c_unregister_device(client_demod);
1953 goto frontend_detach;
1955 port->i2c_client_demod = client_demod;
1958 memset(&si2157_config, 0, sizeof(si2157_config));
1959 si2157_config.fe = fe0->dvb.frontend;
1960 memset(&info, 0, sizeof(struct i2c_board_info));
1961 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1963 info.platform_data = &si2157_config;
1964 request_module(info.type);
1965 client_tuner = i2c_new_device(adapter, &info);
1966 if (client_tuner == NULL ||
1967 client_tuner->dev.driver == NULL)
1968 goto frontend_detach;
1969 if (!try_module_get(client_tuner->dev.driver->owner)) {
1970 i2c_unregister_device(client_tuner);
1971 goto frontend_detach;
1973 port->i2c_client_tuner = client_tuner;
1975 case CX23885_BOARD_DVBSKY_S950C:
1976 i2c_bus = &dev->i2c_bus[1];
1977 i2c_bus2 = &dev->i2c_bus[0];
1979 /* attach frontend */
1980 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1981 &dvbsky_s950c_m88ds3103_config,
1982 &i2c_bus->i2c_adap, &adapter);
1983 if (fe0->dvb.frontend == NULL)
1987 memset(&ts2020_config, 0, sizeof(ts2020_config));
1988 ts2020_config.fe = fe0->dvb.frontend;
1989 memset(&info, 0, sizeof(struct i2c_board_info));
1990 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
1992 info.platform_data = &ts2020_config;
1993 request_module(info.type);
1994 client_tuner = i2c_new_device(adapter, &info);
1995 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
1996 goto frontend_detach;
1997 if (!try_module_get(client_tuner->dev.driver->owner)) {
1998 i2c_unregister_device(client_tuner);
1999 goto frontend_detach;
2002 /* delegate signal strength measurement to tuner */
2003 fe0->dvb.frontend->ops.read_signal_strength =
2004 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2006 port->i2c_client_tuner = client_tuner;
2008 case CX23885_BOARD_DVBSKY_S952:
2012 i2c_bus = &dev->i2c_bus[1];
2013 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
2014 p_set_voltage = dvbsky_t9580_set_voltage;
2018 i2c_bus = &dev->i2c_bus[0];
2019 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
2020 p_set_voltage = dvbsky_s952_portc_set_voltage;
2024 /* attach frontend */
2025 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2027 &i2c_bus->i2c_adap, &adapter);
2028 if (fe0->dvb.frontend == NULL)
2032 memset(&ts2020_config, 0, sizeof(ts2020_config));
2033 ts2020_config.fe = fe0->dvb.frontend;
2034 memset(&info, 0, sizeof(struct i2c_board_info));
2035 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2037 info.platform_data = &ts2020_config;
2038 request_module(info.type);
2039 client_tuner = i2c_new_device(adapter, &info);
2040 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2041 goto frontend_detach;
2042 if (!try_module_get(client_tuner->dev.driver->owner)) {
2043 i2c_unregister_device(client_tuner);
2044 goto frontend_detach;
2047 /* delegate signal strength measurement to tuner */
2048 fe0->dvb.frontend->ops.read_signal_strength =
2049 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2052 * for setting the voltage we need to set GPIOs on
2055 port->fe_set_voltage =
2056 fe0->dvb.frontend->ops.set_voltage;
2057 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2059 port->i2c_client_tuner = client_tuner;
2061 case CX23885_BOARD_DVBSKY_T982:
2062 memset(&si2168_config, 0, sizeof(si2168_config));
2066 i2c_bus = &dev->i2c_bus[1];
2067 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2071 i2c_bus = &dev->i2c_bus[0];
2072 si2168_config.ts_mode = SI2168_TS_SERIAL;
2076 /* attach frontend */
2077 si2168_config.i2c_adapter = &adapter;
2078 si2168_config.fe = &fe0->dvb.frontend;
2079 memset(&info, 0, sizeof(struct i2c_board_info));
2080 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2082 info.platform_data = &si2168_config;
2083 request_module(info.type);
2084 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2085 if (client_demod == NULL || client_demod->dev.driver == NULL)
2086 goto frontend_detach;
2087 if (!try_module_get(client_demod->dev.driver->owner)) {
2088 i2c_unregister_device(client_demod);
2089 goto frontend_detach;
2091 port->i2c_client_demod = client_demod;
2094 memset(&si2157_config, 0, sizeof(si2157_config));
2095 si2157_config.fe = fe0->dvb.frontend;
2096 memset(&info, 0, sizeof(struct i2c_board_info));
2097 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2099 info.platform_data = &si2157_config;
2100 request_module(info.type);
2101 client_tuner = i2c_new_device(adapter, &info);
2102 if (client_tuner == NULL ||
2103 client_tuner->dev.driver == NULL)
2104 goto frontend_detach;
2105 if (!try_module_get(client_tuner->dev.driver->owner)) {
2106 i2c_unregister_device(client_tuner);
2107 goto frontend_detach;
2109 port->i2c_client_tuner = client_tuner;
2111 case CX23885_BOARD_HAUPPAUGE_HVR5525:
2113 struct m88rs6000t_config m88rs6000t_config;
2115 /* port b - satellite */
2117 /* attach frontend */
2118 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2119 &hauppauge_hvr5525_m88ds3103_config,
2120 &dev->i2c_bus[0].i2c_adap, &adapter);
2121 if (fe0->dvb.frontend == NULL)
2125 if (!dvb_attach(a8293_attach, fe0->dvb.frontend,
2126 &dev->i2c_bus[0].i2c_adap,
2127 &hauppauge_a8293_config))
2128 goto frontend_detach;
2131 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2132 m88rs6000t_config.fe = fe0->dvb.frontend;
2133 memset(&info, 0, sizeof(struct i2c_board_info));
2134 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2136 info.platform_data = &m88rs6000t_config;
2137 request_module("%s", info.type);
2138 client_tuner = i2c_new_device(adapter, &info);
2139 if (!client_tuner || !client_tuner->dev.driver)
2140 goto frontend_detach;
2141 if (!try_module_get(client_tuner->dev.driver->owner)) {
2142 i2c_unregister_device(client_tuner);
2143 goto frontend_detach;
2145 port->i2c_client_tuner = client_tuner;
2147 /* delegate signal strength measurement to tuner */
2148 fe0->dvb.frontend->ops.read_signal_strength =
2149 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2151 /* port c - terrestrial/cable */
2153 /* attach frontend */
2154 memset(&si2168_config, 0, sizeof(si2168_config));
2155 si2168_config.i2c_adapter = &adapter;
2156 si2168_config.fe = &fe0->dvb.frontend;
2157 si2168_config.ts_mode = SI2168_TS_SERIAL;
2158 memset(&info, 0, sizeof(struct i2c_board_info));
2159 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2161 info.platform_data = &si2168_config;
2162 request_module("%s", info.type);
2163 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2164 if (!client_demod || !client_demod->dev.driver)
2165 goto frontend_detach;
2166 if (!try_module_get(client_demod->dev.driver->owner)) {
2167 i2c_unregister_device(client_demod);
2168 goto frontend_detach;
2170 port->i2c_client_demod = client_demod;
2173 memset(&si2157_config, 0, sizeof(si2157_config));
2174 si2157_config.fe = fe0->dvb.frontend;
2175 memset(&info, 0, sizeof(struct i2c_board_info));
2176 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2178 info.platform_data = &si2157_config;
2179 request_module("%s", info.type);
2180 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2181 if (!client_tuner || !client_tuner->dev.driver) {
2182 module_put(client_demod->dev.driver->owner);
2183 i2c_unregister_device(client_demod);
2184 port->i2c_client_demod = NULL;
2185 goto frontend_detach;
2187 if (!try_module_get(client_tuner->dev.driver->owner)) {
2188 i2c_unregister_device(client_tuner);
2189 module_put(client_demod->dev.driver->owner);
2190 i2c_unregister_device(client_demod);
2191 port->i2c_client_demod = NULL;
2192 goto frontend_detach;
2194 port->i2c_client_tuner = client_tuner;
2199 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
2200 " isn't supported yet\n",
2205 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2206 printk(KERN_ERR "%s: frontend initialization failed\n",
2208 goto frontend_detach;
2211 /* define general-purpose callback pointer */
2212 fe0->dvb.frontend->callback = cx23885_tuner_callback;
2214 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2216 /* Ensure all frontends negotiate bus access */
2217 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2219 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2222 /* Put the analog decoder in standby to keep it quiet */
2223 call_all(dev, core, s_power, 0);
2225 if (fe0->dvb.frontend->ops.analog_ops.standby)
2226 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
2228 /* register everything */
2229 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2230 &dev->pci->dev, adapter_nr, mfe_shared);
2232 goto frontend_detach;
2234 ret = dvb_register_ci_mac(port);
2236 goto frontend_detach;
2241 /* remove I2C client for tuner */
2242 client_tuner = port->i2c_client_tuner;
2244 module_put(client_tuner->dev.driver->owner);
2245 i2c_unregister_device(client_tuner);
2246 port->i2c_client_tuner = NULL;
2249 /* remove I2C client for demodulator */
2250 client_demod = port->i2c_client_demod;
2252 module_put(client_demod->dev.driver->owner);
2253 i2c_unregister_device(client_demod);
2254 port->i2c_client_demod = NULL;
2257 port->gate_ctrl = NULL;
2258 vb2_dvb_dealloc_frontends(&port->frontends);
2262 int cx23885_dvb_register(struct cx23885_tsport *port)
2265 struct vb2_dvb_frontend *fe0;
2266 struct cx23885_dev *dev = port->dev;
2269 /* Here we need to allocate the correct number of frontends,
2270 * as reflected in the cards struct. The reality is that currently
2271 * no cx23885 boards support this - yet. But, if we don't modify this
2272 * code then the second frontend would never be allocated (later)
2273 * and fail with error before the attach in dvb_register().
2274 * Without these changes we risk an OOPS later. The changes here
2275 * are for safety, and should provide a good foundation for the
2276 * future addition of any multi-frontend cx23885 based boards.
2278 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
2279 port->num_frontends);
2281 for (i = 1; i <= port->num_frontends; i++) {
2282 struct vb2_queue *q;
2284 if (vb2_dvb_alloc_frontend(
2285 &port->frontends, i) == NULL) {
2286 printk(KERN_ERR "%s() failed to alloc\n", __func__);
2290 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
2294 dprintk(1, "%s\n", __func__);
2295 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2304 /* We have to init the queue for each frontend on a port. */
2305 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
2307 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2308 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2309 q->gfp_flags = GFP_DMA32;
2310 q->min_buffers_needed = 2;
2312 q->buf_struct_size = sizeof(struct cx23885_buffer);
2314 q->mem_ops = &vb2_dma_sg_memops;
2315 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2316 q->lock = &dev->lock;
2318 err = vb2_queue_init(q);
2322 err = dvb_register(port);
2324 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
2330 int cx23885_dvb_unregister(struct cx23885_tsport *port)
2332 struct vb2_dvb_frontend *fe0;
2333 struct i2c_client *client;
2335 /* remove I2C client for CI */
2336 client = port->i2c_client_ci;
2338 module_put(client->dev.driver->owner);
2339 i2c_unregister_device(client);
2342 /* remove I2C client for tuner */
2343 client = port->i2c_client_tuner;
2345 module_put(client->dev.driver->owner);
2346 i2c_unregister_device(client);
2349 /* remove I2C client for demodulator */
2350 client = port->i2c_client_demod;
2352 module_put(client->dev.driver->owner);
2353 i2c_unregister_device(client);
2356 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2358 if (fe0 && fe0->dvb.frontend)
2359 vb2_dvb_unregister_bus(&port->frontends);
2361 switch (port->dev->board) {
2362 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2363 netup_ci_exit(port);
2365 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2366 altera_ci_release(port->dev, port->nr);
2370 port->gate_ctrl = NULL;