1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include "cx23885.h"
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/device.h>
23#include <linux/fs.h>
24#include <linux/kthread.h>
25#include <linux/file.h>
26#include <linux/suspend.h>
27
28#include <media/v4l2-common.h>
29
30#include <media/dvb_ca_en50221.h>
31#include "s5h1409.h"
32#include "s5h1411.h"
33#include "mt2131.h"
34#include "tda8290.h"
35#include "tda18271.h"
36#include "lgdt330x.h"
37#include "xc4000.h"
38#include "xc5000.h"
39#include "max2165.h"
40#include "tda10048.h"
41#include "tuner-xc2028.h"
42#include "tuner-simple.h"
43#include "dib7000p.h"
44#include "dib0070.h"
45#include "dibx000_common.h"
46#include "zl10353.h"
47#include "stv0900.h"
48#include "stv0900_reg.h"
49#include "stv6110.h"
50#include "lnbh24.h"
51#include "cx24116.h"
52#include "cx24117.h"
53#include "cimax2.h"
54#include "lgs8gxx.h"
55#include "netup-eeprom.h"
56#include "netup-init.h"
57#include "lgdt3305.h"
58#include "atbm8830.h"
59#include "ts2020.h"
60#include "ds3000.h"
61#include "cx23885-f300.h"
62#include "altera-ci.h"
63#include "stv0367.h"
64#include "drxk.h"
65#include "mt2063.h"
66#include "stv090x.h"
67#include "stb6100.h"
68#include "stb6100_cfg.h"
69#include "tda10071.h"
70#include "a8293.h"
71#include "mb86a20s.h"
72#include "si2165.h"
73#include "si2168.h"
74#include "si2157.h"
75#include "sp2.h"
76#include "m88ds3103.h"
77#include "m88rs6000t.h"
78#include "lgdt3306a.h"
79
80static unsigned int debug;
81
82#define dprintk(level, fmt, arg...)\
83 do { if (debug >= level)\
84 printk(KERN_DEBUG pr_fmt("%s dvb: " fmt), \
85 __func__, ##arg); \
86 } while (0)
87
88
89
90static unsigned int alt_tuner;
91module_param(alt_tuner, int, 0644);
92MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
93
94DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
95
96
97
98static int queue_setup(struct vb2_queue *q,
99 unsigned int *num_buffers, unsigned int *num_planes,
100 unsigned int sizes[], struct device *alloc_devs[])
101{
102 struct cx23885_tsport *port = q->drv_priv;
103
104 port->ts_packet_size = 188 * 4;
105 port->ts_packet_count = 32;
106 *num_planes = 1;
107 sizes[0] = port->ts_packet_size * port->ts_packet_count;
108 *num_buffers = 32;
109 return 0;
110}
111
112
113static int buffer_prepare(struct vb2_buffer *vb)
114{
115 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
116 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
117 struct cx23885_buffer *buf =
118 container_of(vbuf, struct cx23885_buffer, vb);
119
120 return cx23885_buf_prepare(buf, port);
121}
122
123static void buffer_finish(struct vb2_buffer *vb)
124{
125 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
126 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
127 struct cx23885_dev *dev = port->dev;
128 struct cx23885_buffer *buf = container_of(vbuf,
129 struct cx23885_buffer, vb);
130
131 cx23885_free_buffer(dev, buf);
132}
133
134static void buffer_queue(struct vb2_buffer *vb)
135{
136 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
137 struct cx23885_tsport *port = vb->vb2_queue->drv_priv;
138 struct cx23885_buffer *buf = container_of(vbuf,
139 struct cx23885_buffer, vb);
140
141 cx23885_buf_queue(port, buf);
142}
143
144static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
145{
146 struct vb2_dvb_frontends *f;
147 struct vb2_dvb_frontend *fe;
148
149 f = &port->frontends;
150
151 if (f->gate <= 1)
152 fe = vb2_dvb_get_frontend(f, 1);
153 else
154 fe = vb2_dvb_get_frontend(f, f->gate);
155
156 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
157 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
158}
159
160static int cx23885_start_streaming(struct vb2_queue *q, unsigned int count)
161{
162 struct cx23885_tsport *port = q->drv_priv;
163 struct cx23885_dmaqueue *dmaq = &port->mpegq;
164 struct cx23885_buffer *buf = list_entry(dmaq->active.next,
165 struct cx23885_buffer, queue);
166
167 cx23885_start_dma(port, dmaq, buf);
168 return 0;
169}
170
171static void cx23885_stop_streaming(struct vb2_queue *q)
172{
173 struct cx23885_tsport *port = q->drv_priv;
174
175 cx23885_cancel_buffers(port);
176}
177
178static const struct vb2_ops dvb_qops = {
179 .queue_setup = queue_setup,
180 .buf_prepare = buffer_prepare,
181 .buf_finish = buffer_finish,
182 .buf_queue = buffer_queue,
183 .wait_prepare = vb2_ops_wait_prepare,
184 .wait_finish = vb2_ops_wait_finish,
185 .start_streaming = cx23885_start_streaming,
186 .stop_streaming = cx23885_stop_streaming,
187};
188
189static struct s5h1409_config hauppauge_generic_config = {
190 .demod_address = 0x32 >> 1,
191 .output_mode = S5H1409_SERIAL_OUTPUT,
192 .gpio = S5H1409_GPIO_ON,
193 .qam_if = 44000,
194 .inversion = S5H1409_INVERSION_OFF,
195 .status_mode = S5H1409_DEMODLOCKING,
196 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
197};
198
199static struct tda10048_config hauppauge_hvr1200_config = {
200 .demod_address = 0x10 >> 1,
201 .output_mode = TDA10048_SERIAL_OUTPUT,
202 .fwbulkwritelen = TDA10048_BULKWRITE_200,
203 .inversion = TDA10048_INVERSION_ON,
204 .dtv6_if_freq_khz = TDA10048_IF_3300,
205 .dtv7_if_freq_khz = TDA10048_IF_3800,
206 .dtv8_if_freq_khz = TDA10048_IF_4300,
207 .clk_freq_khz = TDA10048_CLK_16000,
208};
209
210static struct tda10048_config hauppauge_hvr1210_config = {
211 .demod_address = 0x10 >> 1,
212 .output_mode = TDA10048_SERIAL_OUTPUT,
213 .fwbulkwritelen = TDA10048_BULKWRITE_200,
214 .inversion = TDA10048_INVERSION_ON,
215 .dtv6_if_freq_khz = TDA10048_IF_3300,
216 .dtv7_if_freq_khz = TDA10048_IF_3500,
217 .dtv8_if_freq_khz = TDA10048_IF_4000,
218 .clk_freq_khz = TDA10048_CLK_16000,
219};
220
221static struct s5h1409_config hauppauge_ezqam_config = {
222 .demod_address = 0x32 >> 1,
223 .output_mode = S5H1409_SERIAL_OUTPUT,
224 .gpio = S5H1409_GPIO_OFF,
225 .qam_if = 4000,
226 .inversion = S5H1409_INVERSION_ON,
227 .status_mode = S5H1409_DEMODLOCKING,
228 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
229};
230
231static struct s5h1409_config hauppauge_hvr1800lp_config = {
232 .demod_address = 0x32 >> 1,
233 .output_mode = S5H1409_SERIAL_OUTPUT,
234 .gpio = S5H1409_GPIO_OFF,
235 .qam_if = 44000,
236 .inversion = S5H1409_INVERSION_OFF,
237 .status_mode = S5H1409_DEMODLOCKING,
238 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
239};
240
241static struct s5h1409_config hauppauge_hvr1500_config = {
242 .demod_address = 0x32 >> 1,
243 .output_mode = S5H1409_SERIAL_OUTPUT,
244 .gpio = S5H1409_GPIO_OFF,
245 .inversion = S5H1409_INVERSION_OFF,
246 .status_mode = S5H1409_DEMODLOCKING,
247 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
248};
249
250static struct mt2131_config hauppauge_generic_tunerconfig = {
251 0x61
252};
253
254static struct lgdt330x_config fusionhdtv_5_express = {
255 .demod_address = 0x0e,
256 .demod_chip = LGDT3303,
257 .serial_mpeg = 0x40,
258};
259
260static struct s5h1409_config hauppauge_hvr1500q_config = {
261 .demod_address = 0x32 >> 1,
262 .output_mode = S5H1409_SERIAL_OUTPUT,
263 .gpio = S5H1409_GPIO_ON,
264 .qam_if = 44000,
265 .inversion = S5H1409_INVERSION_OFF,
266 .status_mode = S5H1409_DEMODLOCKING,
267 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
268};
269
270static struct s5h1409_config dvico_s5h1409_config = {
271 .demod_address = 0x32 >> 1,
272 .output_mode = S5H1409_SERIAL_OUTPUT,
273 .gpio = S5H1409_GPIO_ON,
274 .qam_if = 44000,
275 .inversion = S5H1409_INVERSION_OFF,
276 .status_mode = S5H1409_DEMODLOCKING,
277 .mpeg_timing = S5H1409_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
278};
279
280static struct s5h1411_config dvico_s5h1411_config = {
281 .output_mode = S5H1411_SERIAL_OUTPUT,
282 .gpio = S5H1411_GPIO_ON,
283 .qam_if = S5H1411_IF_44000,
284 .vsb_if = S5H1411_IF_44000,
285 .inversion = S5H1411_INVERSION_OFF,
286 .status_mode = S5H1411_DEMODLOCKING,
287 .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
288};
289
290static struct s5h1411_config hcw_s5h1411_config = {
291 .output_mode = S5H1411_SERIAL_OUTPUT,
292 .gpio = S5H1411_GPIO_OFF,
293 .vsb_if = S5H1411_IF_44000,
294 .qam_if = S5H1411_IF_4000,
295 .inversion = S5H1411_INVERSION_ON,
296 .status_mode = S5H1411_DEMODLOCKING,
297 .mpeg_timing = S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK,
298};
299
300static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
301 .i2c_address = 0x61,
302 .if_khz = 5380,
303};
304
305static struct xc5000_config dvico_xc5000_tunerconfig = {
306 .i2c_address = 0x64,
307 .if_khz = 5380,
308};
309
310static struct tda829x_config tda829x_no_probe = {
311 .probe_tuner = TDA829X_DONT_PROBE,
312};
313
314static struct tda18271_std_map hauppauge_tda18271_std_map = {
315 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
316 .if_lvl = 6, .rfagc_top = 0x37 },
317 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
318 .if_lvl = 6, .rfagc_top = 0x37 },
319};
320
321static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
322 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
323 .if_lvl = 1, .rfagc_top = 0x37, },
324 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
325 .if_lvl = 1, .rfagc_top = 0x37, },
326 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
327 .if_lvl = 1, .rfagc_top = 0x37, },
328};
329
330static struct tda18271_config hauppauge_tda18271_config = {
331 .std_map = &hauppauge_tda18271_std_map,
332 .gate = TDA18271_GATE_ANALOG,
333 .output_opt = TDA18271_OUTPUT_LT_OFF,
334};
335
336static struct tda18271_config hauppauge_hvr1200_tuner_config = {
337 .std_map = &hauppauge_hvr1200_tda18271_std_map,
338 .gate = TDA18271_GATE_ANALOG,
339 .output_opt = TDA18271_OUTPUT_LT_OFF,
340};
341
342static struct tda18271_config hauppauge_hvr1210_tuner_config = {
343 .gate = TDA18271_GATE_DIGITAL,
344 .output_opt = TDA18271_OUTPUT_LT_OFF,
345};
346
347static struct tda18271_config hauppauge_hvr4400_tuner_config = {
348 .gate = TDA18271_GATE_DIGITAL,
349 .output_opt = TDA18271_OUTPUT_LT_OFF,
350};
351
352static struct tda18271_std_map hauppauge_hvr127x_std_map = {
353 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
354 .if_lvl = 1, .rfagc_top = 0x58 },
355 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
356 .if_lvl = 1, .rfagc_top = 0x58 },
357};
358
359static struct tda18271_config hauppauge_hvr127x_config = {
360 .std_map = &hauppauge_hvr127x_std_map,
361 .output_opt = TDA18271_OUTPUT_LT_OFF,
362};
363
364static struct lgdt3305_config hauppauge_lgdt3305_config = {
365 .i2c_addr = 0x0e,
366 .mpeg_mode = LGDT3305_MPEG_SERIAL,
367 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
368 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
369 .deny_i2c_rptr = 1,
370 .spectral_inversion = 1,
371 .qam_if_khz = 4000,
372 .vsb_if_khz = 3250,
373};
374
375static struct dibx000_agc_config xc3028_agc_config = {
376 BAND_VHF | BAND_UHF,
377
378
379
380
381
382
383 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
384 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
385
386 712,
387 21,
388
389 0,
390 118,
391
392 0,
393 2867,
394 0,
395 2,
396
397 0,
398 0,
399 39718,
400 9930,
401 0,
402 0,
403 0,
404 0,
405 0,
406 0,
407 128,
408 29,
409 29,
410
411 17,
412 27,
413 23,
414 51,
415
416 1,
417};
418
419
420
421static struct dibx000_bandwidth_config xc3028_bw_config = {
422 60000,
423 30000,
424 1,
425 8,
426 3,
427 1,
428 0,
429 0,
430 0,
431 1,
432 1,
433 0,
434 (3 << 14) | (1 << 12) | (524 << 0),
435 (1 << 25) | 5816102,
436 20452225,
437 30000000
438};
439
440static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
441 .output_mpeg2_in_188_bytes = 1,
442 .hostbus_diversity = 1,
443 .tuner_is_baseband = 0,
444 .update_lna = NULL,
445
446 .agc_config_count = 1,
447 .agc = &xc3028_agc_config,
448 .bw = &xc3028_bw_config,
449
450 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
451 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
452 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
453
454 .pwm_freq_div = 0,
455 .agc_control = NULL,
456 .spur_protect = 0,
457
458 .output_mode = OUTMODE_MPEG2_SERIAL,
459};
460
461static struct zl10353_config dvico_fusionhdtv_xc3028 = {
462 .demod_address = 0x0f,
463 .if2 = 45600,
464 .no_tuner = 1,
465 .disable_i2c_gate_ctrl = 1,
466};
467
468static struct stv0900_reg stv0900_ts_regs[] = {
469 { R0900_TSGENERAL, 0x00 },
470 { R0900_P1_TSSPEED, 0x40 },
471 { R0900_P2_TSSPEED, 0x40 },
472 { R0900_P1_TSCFGM, 0xc0 },
473 { R0900_P2_TSCFGM, 0xc0 },
474 { R0900_P1_TSCFGH, 0xe0 },
475 { R0900_P2_TSCFGH, 0xe0 },
476 { R0900_P1_TSCFGL, 0x20 },
477 { R0900_P2_TSCFGL, 0x20 },
478 { 0xffff, 0xff },
479};
480
481static struct stv0900_config netup_stv0900_config = {
482 .demod_address = 0x68,
483 .demod_mode = 1,
484 .xtal = 8000000,
485 .clkmode = 3,
486 .diseqc_mode = 2,
487 .ts_config_regs = stv0900_ts_regs,
488 .tun1_maddress = 0,
489 .tun2_maddress = 3,
490 .tun1_adc = 1,
491 .tun2_adc = 1,
492};
493
494static struct stv6110_config netup_stv6110_tunerconfig_a = {
495 .i2c_address = 0x60,
496 .mclk = 16000000,
497 .clk_div = 1,
498 .gain = 8,
499};
500
501static struct stv6110_config netup_stv6110_tunerconfig_b = {
502 .i2c_address = 0x63,
503 .mclk = 16000000,
504 .clk_div = 1,
505 .gain = 8,
506};
507
508static struct cx24116_config tbs_cx24116_config = {
509 .demod_address = 0x55,
510};
511
512static struct cx24117_config tbs_cx24117_config = {
513 .demod_address = 0x55,
514};
515
516static struct ds3000_config tevii_ds3000_config = {
517 .demod_address = 0x68,
518};
519
520static struct ts2020_config tevii_ts2020_config = {
521 .tuner_address = 0x60,
522 .clk_out_div = 1,
523 .frequency_div = 1146000,
524};
525
526static struct cx24116_config dvbworld_cx24116_config = {
527 .demod_address = 0x05,
528};
529
530static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
531 .prod = LGS8GXX_PROD_LGS8GL5,
532 .demod_address = 0x19,
533 .serial_ts = 0,
534 .ts_clk_pol = 1,
535 .ts_clk_gated = 1,
536 .if_clk_freq = 30400,
537 .if_freq = 5380,
538 .if_neg_center = 1,
539 .ext_adc = 0,
540 .adc_signed = 0,
541 .if_neg_edge = 0,
542};
543
544static struct xc5000_config mygica_x8506_xc5000_config = {
545 .i2c_address = 0x61,
546 .if_khz = 5380,
547};
548
549static struct mb86a20s_config mygica_x8507_mb86a20s_config = {
550 .demod_address = 0x10,
551};
552
553static struct xc5000_config mygica_x8507_xc5000_config = {
554 .i2c_address = 0x61,
555 .if_khz = 4000,
556};
557
558static struct stv090x_config prof_8000_stv090x_config = {
559 .device = STV0903,
560 .demod_mode = STV090x_SINGLE,
561 .clk_mode = STV090x_CLK_EXT,
562 .xtal = 27000000,
563 .address = 0x6A,
564 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
565 .repeater_level = STV090x_RPTLEVEL_64,
566 .adc1_range = STV090x_ADC_2Vpp,
567 .diseqc_envelope_mode = false,
568
569 .tuner_get_frequency = stb6100_get_frequency,
570 .tuner_set_frequency = stb6100_set_frequency,
571 .tuner_set_bandwidth = stb6100_set_bandwidth,
572 .tuner_get_bandwidth = stb6100_get_bandwidth,
573};
574
575static struct stb6100_config prof_8000_stb6100_config = {
576 .tuner_address = 0x60,
577 .refclock = 27000000,
578};
579
580static struct lgdt3306a_config hauppauge_quadHD_ATSC_a_config = {
581 .i2c_addr = 0x59,
582 .qam_if_khz = 4000,
583 .vsb_if_khz = 3250,
584 .deny_i2c_rptr = 1,
585 .spectral_inversion = 0,
586 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
587 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
588 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
589 .xtalMHz = 25,
590};
591
592static struct lgdt3306a_config hauppauge_quadHD_ATSC_b_config = {
593 .i2c_addr = 0x0e,
594 .qam_if_khz = 4000,
595 .vsb_if_khz = 3250,
596 .deny_i2c_rptr = 1,
597 .spectral_inversion = 0,
598 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
599 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
600 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
601 .xtalMHz = 25,
602};
603
604static int p8000_set_voltage(struct dvb_frontend *fe,
605 enum fe_sec_voltage voltage)
606{
607 struct cx23885_tsport *port = fe->dvb->priv;
608 struct cx23885_dev *dev = port->dev;
609
610 if (voltage == SEC_VOLTAGE_18)
611 cx_write(MC417_RWD, 0x00001e00);
612 else if (voltage == SEC_VOLTAGE_13)
613 cx_write(MC417_RWD, 0x00001a00);
614 else
615 cx_write(MC417_RWD, 0x00001800);
616 return 0;
617}
618
619static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
620 enum fe_sec_voltage voltage)
621{
622 struct cx23885_tsport *port = fe->dvb->priv;
623 struct cx23885_dev *dev = port->dev;
624
625 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
626
627 switch (voltage) {
628 case SEC_VOLTAGE_13:
629 cx23885_gpio_set(dev, GPIO_1);
630 cx23885_gpio_clear(dev, GPIO_0);
631 break;
632 case SEC_VOLTAGE_18:
633 cx23885_gpio_set(dev, GPIO_1);
634 cx23885_gpio_set(dev, GPIO_0);
635 break;
636 case SEC_VOLTAGE_OFF:
637 cx23885_gpio_clear(dev, GPIO_1);
638 cx23885_gpio_clear(dev, GPIO_0);
639 break;
640 }
641
642
643 port->fe_set_voltage(fe, voltage);
644
645 return 0;
646}
647
648static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
649 enum fe_sec_voltage voltage)
650{
651 struct cx23885_tsport *port = fe->dvb->priv;
652 struct cx23885_dev *dev = port->dev;
653
654 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
655
656 switch (voltage) {
657 case SEC_VOLTAGE_13:
658 cx23885_gpio_set(dev, GPIO_13);
659 cx23885_gpio_clear(dev, GPIO_12);
660 break;
661 case SEC_VOLTAGE_18:
662 cx23885_gpio_set(dev, GPIO_13);
663 cx23885_gpio_set(dev, GPIO_12);
664 break;
665 case SEC_VOLTAGE_OFF:
666 cx23885_gpio_clear(dev, GPIO_13);
667 cx23885_gpio_clear(dev, GPIO_12);
668 break;
669 }
670
671 return port->fe_set_voltage(fe, voltage);
672}
673
674static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
675 u8 data, int *mem)
676{
677
678 #define SP2_DATA 0x000000ff
679 #define SP2_WR 0x00008000
680 #define SP2_RD 0x00004000
681 #define SP2_ACK 0x00001000
682 #define SP2_ADHI 0x00000800
683 #define SP2_ADLO 0x00000400
684 #define SP2_CS1 0x00000200
685 #define SP2_CS0 0x00000100
686 #define SP2_EN_ALL 0x00001000
687 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
688
689 struct cx23885_tsport *port = priv;
690 struct cx23885_dev *dev = port->dev;
691 int ret;
692 int tmp = 0;
693 unsigned long timeout;
694
695 mutex_lock(&dev->gpio_lock);
696
697
698 cx_write(MC417_OEN, SP2_EN_ALL);
699 cx_write(MC417_RWD, SP2_CTRL_OFF |
700 SP2_ADLO | (0xff & addr));
701 cx_clear(MC417_RWD, SP2_ADLO);
702 cx_write(MC417_RWD, SP2_CTRL_OFF |
703 SP2_ADHI | (0xff & (addr >> 8)));
704 cx_clear(MC417_RWD, SP2_ADHI);
705
706 if (read)
707
708 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
709 else
710
711 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
712
713
714 cx_clear(MC417_RWD, SP2_CS0);
715
716
717 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
718
719
720 timeout = jiffies + msecs_to_jiffies(1);
721 while (!time_after(jiffies, timeout)) {
722 tmp = cx_read(MC417_RWD);
723 if ((tmp & SP2_ACK) == 0)
724 break;
725 usleep_range(50, 100);
726 }
727
728 cx_set(MC417_RWD, SP2_CTRL_OFF);
729 *mem = tmp & 0xff;
730
731 mutex_unlock(&dev->gpio_lock);
732
733 if (!read) {
734 if (*mem < 0) {
735 ret = -EREMOTEIO;
736 goto err;
737 }
738 }
739
740 return 0;
741err:
742 return ret;
743}
744
745static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
746{
747 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
748 struct cx23885_tsport *port = fe->dvb->priv;
749 struct cx23885_dev *dev = port->dev;
750
751 switch (dev->board) {
752 case CX23885_BOARD_HAUPPAUGE_HVR1275:
753 switch (p->modulation) {
754 case VSB_8:
755 cx23885_gpio_clear(dev, GPIO_5);
756 break;
757 case QAM_64:
758 case QAM_256:
759 default:
760 cx23885_gpio_set(dev, GPIO_5);
761 break;
762 }
763 break;
764 case CX23885_BOARD_MYGICA_X8506:
765 case CX23885_BOARD_MYGICA_X8507:
766 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
767
768 cx23885_gpio_set(dev, GPIO_0);
769 break;
770 }
771
772
773 if (port->set_frontend)
774 return port->set_frontend(fe);
775
776 return 0;
777}
778
779static void cx23885_set_frontend_hook(struct cx23885_tsport *port,
780 struct dvb_frontend *fe)
781{
782 port->set_frontend = fe->ops.set_frontend;
783 fe->ops.set_frontend = cx23885_dvb_set_frontend;
784}
785
786static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
787 .prod = LGS8GXX_PROD_LGS8G75,
788 .demod_address = 0x19,
789 .serial_ts = 0,
790 .ts_clk_pol = 1,
791 .ts_clk_gated = 1,
792 .if_clk_freq = 30400,
793 .if_freq = 6500,
794 .if_neg_center = 1,
795 .ext_adc = 0,
796 .adc_signed = 1,
797 .adc_vpp = 2,
798 .if_neg_edge = 1,
799};
800
801static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
802 .i2c_address = 0x61,
803 .if_khz = 6500,
804};
805
806static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
807 .prod = ATBM8830_PROD_8830,
808 .demod_address = 0x44,
809 .serial_ts = 0,
810 .ts_sampling_edge = 1,
811 .ts_clk_gated = 0,
812 .osc_clk_freq = 30400,
813 .if_freq = 0,
814 .zif_swap_iq = 1,
815 .agc_min = 0x2E,
816 .agc_max = 0xFF,
817 .agc_hold_loop = 0,
818};
819
820static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
821 .i2c_address = 0x60,
822 .osc_clk = 20
823};
824
825static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
826 .prod = ATBM8830_PROD_8830,
827 .demod_address = 0x44,
828 .serial_ts = 1,
829 .ts_sampling_edge = 1,
830 .ts_clk_gated = 0,
831 .osc_clk_freq = 30400,
832 .if_freq = 0,
833 .zif_swap_iq = 1,
834 .agc_min = 0x2E,
835 .agc_max = 0xFF,
836 .agc_hold_loop = 0,
837};
838
839static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
840 .i2c_address = 0x60,
841 .osc_clk = 20
842};
843static struct stv0367_config netup_stv0367_config[] = {
844 {
845 .demod_address = 0x1c,
846 .xtal = 27000000,
847 .if_khz = 4500,
848 .if_iq_mode = 0,
849 .ts_mode = 1,
850 .clk_pol = 0,
851 }, {
852 .demod_address = 0x1d,
853 .xtal = 27000000,
854 .if_khz = 4500,
855 .if_iq_mode = 0,
856 .ts_mode = 1,
857 .clk_pol = 0,
858 },
859};
860
861static struct xc5000_config netup_xc5000_config[] = {
862 {
863 .i2c_address = 0x61,
864 .if_khz = 4500,
865 }, {
866 .i2c_address = 0x64,
867 .if_khz = 4500,
868 },
869};
870
871static struct drxk_config terratec_drxk_config[] = {
872 {
873 .adr = 0x29,
874 .no_i2c_bridge = 1,
875 }, {
876 .adr = 0x2a,
877 .no_i2c_bridge = 1,
878 },
879};
880
881static struct mt2063_config terratec_mt2063_config[] = {
882 {
883 .tuner_address = 0x60,
884 }, {
885 .tuner_address = 0x67,
886 },
887};
888
889static const struct tda10071_platform_data hauppauge_tda10071_pdata = {
890 .clk = 40444000,
891 .i2c_wr_max = 64,
892 .ts_mode = TDA10071_TS_SERIAL,
893 .pll_multiplier = 20,
894 .tuner_i2c_addr = 0x54,
895};
896
897static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
898 .i2c_addr = 0x68,
899 .clock = 27000000,
900 .i2c_wr_max = 33,
901 .clock_out = 0,
902 .ts_mode = M88DS3103_TS_PARALLEL,
903 .ts_clk = 16000,
904 .ts_clk_pol = 1,
905 .lnb_en_pol = 1,
906 .lnb_hv_pol = 0,
907 .agc = 0x99,
908};
909
910static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
911 .i2c_addr = 0x68,
912 .clock = 27000000,
913 .i2c_wr_max = 33,
914 .clock_out = 0,
915 .ts_mode = M88DS3103_TS_CI,
916 .ts_clk = 10000,
917 .ts_clk_pol = 1,
918 .lnb_en_pol = 1,
919 .lnb_hv_pol = 0,
920 .agc = 0x99,
921};
922
923static const struct m88ds3103_config hauppauge_hvr5525_m88ds3103_config = {
924 .i2c_addr = 0x69,
925 .clock = 27000000,
926 .i2c_wr_max = 33,
927 .ts_mode = M88DS3103_TS_PARALLEL,
928 .ts_clk = 16000,
929 .ts_clk_pol = 1,
930 .agc = 0x99,
931};
932
933static struct lgdt3306a_config hauppauge_hvr1265k4_config = {
934 .i2c_addr = 0x59,
935 .qam_if_khz = 4000,
936 .vsb_if_khz = 3250,
937 .deny_i2c_rptr = 1,
938 .spectral_inversion = 0,
939 .mpeg_mode = LGDT3306A_MPEG_SERIAL,
940 .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE,
941 .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH,
942 .xtalMHz = 25,
943};
944
945static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
946{
947 struct cx23885_dev *dev = (struct cx23885_dev *)device;
948 unsigned long timeout = jiffies + msecs_to_jiffies(1);
949 uint32_t mem = 0;
950
951 mem = cx_read(MC417_RWD);
952 if (read)
953 cx_set(MC417_OEN, ALT_DATA);
954 else {
955 cx_clear(MC417_OEN, ALT_DATA);
956 mem &= ~ALT_DATA;
957 mem |= (data & ALT_DATA);
958 }
959
960 if (flag)
961 mem |= ALT_AD_RG;
962 else
963 mem &= ~ALT_AD_RG;
964
965 mem &= ~ALT_CS;
966 if (read)
967 mem = (mem & ~ALT_RD) | ALT_WR;
968 else
969 mem = (mem & ~ALT_WR) | ALT_RD;
970
971 cx_write(MC417_RWD, mem);
972
973 for (;;) {
974 mem = cx_read(MC417_RWD);
975 if ((mem & ALT_RDY) == 0)
976 break;
977 if (time_after(jiffies, timeout))
978 break;
979 udelay(1);
980 }
981
982 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
983 if (read)
984 return mem & ALT_DATA;
985
986 return 0;
987};
988
989static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
990{
991 struct dib7000p_ops *dib7000p_ops = fe->sec_priv;
992
993 return dib7000p_ops->set_gpio(fe, 8, 0, !onoff);
994}
995
996static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
997{
998 return 0;
999}
1000
1001static struct dib0070_config dib7070p_dib0070_config = {
1002 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1003 .reset = dib7070_tuner_reset,
1004 .sleep = dib7070_tuner_sleep,
1005 .clock_khz = 12000,
1006 .freq_offset_khz_vhf = 550,
1007
1008};
1009
1010
1011static struct dibx000_agc_config dib7070_agc_config = {
1012 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
1013
1014
1015
1016
1017
1018
1019 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
1020 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
1021 .inv_gain = 600,
1022 .time_stabiliz = 10,
1023 .alpha_level = 0,
1024 .thlock = 118,
1025 .wbd_inv = 0,
1026 .wbd_ref = 3530,
1027 .wbd_sel = 1,
1028 .wbd_alpha = 5,
1029 .agc1_max = 65535,
1030 .agc1_min = 0,
1031 .agc2_max = 65535,
1032 .agc2_min = 0,
1033 .agc1_pt1 = 0,
1034 .agc1_pt2 = 40,
1035 .agc1_pt3 = 183,
1036 .agc1_slope1 = 206,
1037 .agc1_slope2 = 255,
1038 .agc2_pt1 = 72,
1039 .agc2_pt2 = 152,
1040 .agc2_slope1 = 88,
1041 .agc2_slope2 = 90,
1042 .alpha_mant = 17,
1043 .alpha_exp = 27,
1044 .beta_mant = 23,
1045 .beta_exp = 51,
1046 .perform_agc_softsplit = 0,
1047};
1048
1049static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
1050 .internal = 60000,
1051 .sampling = 15000,
1052 .pll_prediv = 1,
1053 .pll_ratio = 20,
1054 .pll_range = 3,
1055 .pll_reset = 1,
1056 .pll_bypass = 0,
1057 .enable_refdiv = 0,
1058 .bypclk_div = 0,
1059 .IO_CLK_en_core = 1,
1060 .ADClkSrc = 1,
1061 .modulo = 2,
1062
1063 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
1064 .ifreq = (0 << 25) | 0,
1065 .timf = 20452225,
1066 .xtal_hz = 12000000,
1067};
1068
1069static struct dib7000p_config dib7070p_dib7000p_config = {
1070
1071 .output_mode = OUTMODE_MPEG2_SERIAL,
1072
1073 .output_mpeg2_in_188_bytes = 1,
1074
1075 .agc_config_count = 1,
1076 .agc = &dib7070_agc_config,
1077 .bw = &dib7070_bw_config_12_mhz,
1078 .tuner_is_baseband = 1,
1079 .spur_protect = 1,
1080
1081 .gpio_dir = 0xfcef,
1082 .gpio_val = 0x0110,
1083 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1084
1085 .hostbus_diversity = 1,
1086};
1087
1088static int dvb_register_ci_mac(struct cx23885_tsport *port)
1089{
1090 struct cx23885_dev *dev = port->dev;
1091 struct i2c_client *client_ci = NULL;
1092 struct vb2_dvb_frontend *fe0;
1093
1094 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1095 if (!fe0)
1096 return -EINVAL;
1097
1098 switch (dev->board) {
1099 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1100 static struct netup_card_info cinfo;
1101
1102 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1103 memcpy(port->frontends.adapter.proposed_mac,
1104 cinfo.port[port->nr - 1].mac, 6);
1105 pr_info("NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1106 port->nr, port->frontends.adapter.proposed_mac);
1107
1108 netup_ci_init(port);
1109 return 0;
1110 }
1111 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1112 struct altera_ci_config netup_ci_cfg = {
1113 .dev = dev,
1114 .adapter = &port->frontends.adapter,
1115 .demux = &fe0->dvb.demux,
1116 .fpga_rw = netup_altera_fpga_rw,
1117 };
1118
1119 altera_ci_init(&netup_ci_cfg, port->nr);
1120 return 0;
1121 }
1122 case CX23885_BOARD_TEVII_S470: {
1123 u8 eeprom[256];
1124
1125 if (port->nr != 1)
1126 return 0;
1127
1128
1129 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1130 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
1131 pr_info("TeVii S470 MAC= %pM\n", eeprom + 0xa0);
1132 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1133 return 0;
1134 }
1135 case CX23885_BOARD_DVBSKY_T9580:
1136 case CX23885_BOARD_DVBSKY_S950:
1137 case CX23885_BOARD_DVBSKY_S952:
1138 case CX23885_BOARD_DVBSKY_T982: {
1139 u8 eeprom[256];
1140
1141 if (port->nr > 2)
1142 return 0;
1143
1144
1145 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1146 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1147 sizeof(eeprom));
1148 pr_info("%s port %d MAC address: %pM\n",
1149 cx23885_boards[dev->board].name, port->nr,
1150 eeprom + 0xc0 + (port->nr-1) * 8);
1151 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1152 (port->nr-1) * 8, 6);
1153 return 0;
1154 }
1155 case CX23885_BOARD_DVBSKY_S950C:
1156 case CX23885_BOARD_DVBSKY_T980C:
1157 case CX23885_BOARD_TT_CT2_4500_CI: {
1158 u8 eeprom[256];
1159 struct sp2_config sp2_config;
1160 struct i2c_board_info info;
1161 struct cx23885_i2c *i2c_bus = &dev->i2c_bus[0];
1162
1163
1164 memset(&sp2_config, 0, sizeof(sp2_config));
1165 sp2_config.dvb_adap = &port->frontends.adapter;
1166 sp2_config.priv = port;
1167 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
1168 memset(&info, 0, sizeof(struct i2c_board_info));
1169 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
1170 info.addr = 0x40;
1171 info.platform_data = &sp2_config;
1172 request_module(info.type);
1173 client_ci = i2c_new_device(&i2c_bus->i2c_adap, &info);
1174 if (client_ci == NULL || client_ci->dev.driver == NULL)
1175 return -ENODEV;
1176 if (!try_module_get(client_ci->dev.driver->owner)) {
1177 i2c_unregister_device(client_ci);
1178 return -ENODEV;
1179 }
1180 port->i2c_client_ci = client_ci;
1181
1182 if (port->nr != 1)
1183 return 0;
1184
1185
1186 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1187 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1188 sizeof(eeprom));
1189 pr_info("%s MAC address: %pM\n",
1190 cx23885_boards[dev->board].name, eeprom + 0xc0);
1191 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
1192 return 0;
1193 }
1194 }
1195 return 0;
1196}
1197
1198static int dvb_register(struct cx23885_tsport *port)
1199{
1200 struct dib7000p_ops dib7000p_ops;
1201 struct cx23885_dev *dev = port->dev;
1202 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
1203 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
1204 struct si2168_config si2168_config;
1205 struct si2165_platform_data si2165_pdata;
1206 struct si2157_config si2157_config;
1207 struct ts2020_config ts2020_config;
1208 struct m88ds3103_platform_data m88ds3103_pdata;
1209 struct m88rs6000t_config m88rs6000t_config = {};
1210 struct a8293_platform_data a8293_pdata = {};
1211 struct i2c_board_info info;
1212 struct i2c_adapter *adapter;
1213 struct i2c_client *client_demod = NULL, *client_tuner = NULL;
1214 struct i2c_client *client_sec = NULL;
1215 int (*p_set_voltage)(struct dvb_frontend *fe,
1216 enum fe_sec_voltage voltage) = NULL;
1217 int mfe_shared = 0;
1218 int ret;
1219
1220
1221 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
1222 if (!fe0)
1223 return -EINVAL;
1224
1225
1226 fe0->dvb.name = dev->name;
1227
1228
1229 port->frontends.gate = 0;
1230
1231
1232 port->gate_ctrl = cx23885_dvb_gate_ctrl;
1233
1234
1235 switch (dev->board) {
1236 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1237 i2c_bus = &dev->i2c_bus[0];
1238 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1239 &hauppauge_generic_config,
1240 &i2c_bus->i2c_adap);
1241 if (fe0->dvb.frontend == NULL)
1242 break;
1243 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1244 &i2c_bus->i2c_adap,
1245 &hauppauge_generic_tunerconfig, 0);
1246 break;
1247 case CX23885_BOARD_HAUPPAUGE_HVR1270:
1248 case CX23885_BOARD_HAUPPAUGE_HVR1275:
1249 i2c_bus = &dev->i2c_bus[0];
1250 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1251 &hauppauge_lgdt3305_config,
1252 &i2c_bus->i2c_adap);
1253 if (fe0->dvb.frontend == NULL)
1254 break;
1255 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1256 0x60, &dev->i2c_bus[1].i2c_adap,
1257 &hauppauge_hvr127x_config);
1258 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
1259 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1260 break;
1261 case CX23885_BOARD_HAUPPAUGE_HVR1255:
1262 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1263 i2c_bus = &dev->i2c_bus[0];
1264 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1265 &hcw_s5h1411_config,
1266 &i2c_bus->i2c_adap);
1267 if (fe0->dvb.frontend == NULL)
1268 break;
1269
1270 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1271 0x60, &dev->i2c_bus[1].i2c_adap,
1272 &hauppauge_tda18271_config);
1273
1274 tda18271_attach(&dev->ts1.analog_fe,
1275 0x60, &dev->i2c_bus[1].i2c_adap,
1276 &hauppauge_tda18271_config);
1277
1278 break;
1279 case CX23885_BOARD_HAUPPAUGE_HVR1800:
1280 i2c_bus = &dev->i2c_bus[0];
1281 switch (alt_tuner) {
1282 case 1:
1283 fe0->dvb.frontend =
1284 dvb_attach(s5h1409_attach,
1285 &hauppauge_ezqam_config,
1286 &i2c_bus->i2c_adap);
1287 if (fe0->dvb.frontend == NULL)
1288 break;
1289
1290 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1291 &dev->i2c_bus[1].i2c_adap, 0x42,
1292 &tda829x_no_probe);
1293 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1294 0x60, &dev->i2c_bus[1].i2c_adap,
1295 &hauppauge_tda18271_config);
1296 break;
1297 case 0:
1298 default:
1299 fe0->dvb.frontend =
1300 dvb_attach(s5h1409_attach,
1301 &hauppauge_generic_config,
1302 &i2c_bus->i2c_adap);
1303 if (fe0->dvb.frontend == NULL)
1304 break;
1305 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1306 &i2c_bus->i2c_adap,
1307 &hauppauge_generic_tunerconfig, 0);
1308 }
1309 break;
1310 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
1311 i2c_bus = &dev->i2c_bus[0];
1312 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1313 &hauppauge_hvr1800lp_config,
1314 &i2c_bus->i2c_adap);
1315 if (fe0->dvb.frontend == NULL)
1316 break;
1317 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1318 &i2c_bus->i2c_adap,
1319 &hauppauge_generic_tunerconfig, 0);
1320 break;
1321 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
1322 i2c_bus = &dev->i2c_bus[0];
1323 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1324 &fusionhdtv_5_express,
1325 &i2c_bus->i2c_adap);
1326 if (fe0->dvb.frontend == NULL)
1327 break;
1328 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1329 &i2c_bus->i2c_adap, 0x61,
1330 TUNER_LG_TDVS_H06XF);
1331 break;
1332 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1333 i2c_bus = &dev->i2c_bus[1];
1334 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1335 &hauppauge_hvr1500q_config,
1336 &dev->i2c_bus[0].i2c_adap);
1337 if (fe0->dvb.frontend == NULL)
1338 break;
1339 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1340 &i2c_bus->i2c_adap,
1341 &hauppauge_hvr1500q_tunerconfig);
1342 break;
1343 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1344 i2c_bus = &dev->i2c_bus[1];
1345 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1346 &hauppauge_hvr1500_config,
1347 &dev->i2c_bus[0].i2c_adap);
1348 if (fe0->dvb.frontend != NULL) {
1349 struct dvb_frontend *fe;
1350 struct xc2028_config cfg = {
1351 .i2c_adap = &i2c_bus->i2c_adap,
1352 .i2c_addr = 0x61,
1353 };
1354 static struct xc2028_ctrl ctl = {
1355 .fname = XC2028_DEFAULT_FIRMWARE,
1356 .max_len = 64,
1357 .demod = XC3028_FE_OREN538,
1358 };
1359
1360 fe = dvb_attach(xc2028_attach,
1361 fe0->dvb.frontend, &cfg);
1362 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1363 fe->ops.tuner_ops.set_config(fe, &ctl);
1364 }
1365 break;
1366 case CX23885_BOARD_HAUPPAUGE_HVR1200:
1367 case CX23885_BOARD_HAUPPAUGE_HVR1700:
1368 i2c_bus = &dev->i2c_bus[0];
1369 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1370 &hauppauge_hvr1200_config,
1371 &i2c_bus->i2c_adap);
1372 if (fe0->dvb.frontend == NULL)
1373 break;
1374 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1375 &dev->i2c_bus[1].i2c_adap, 0x42,
1376 &tda829x_no_probe);
1377 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1378 0x60, &dev->i2c_bus[1].i2c_adap,
1379 &hauppauge_hvr1200_tuner_config);
1380 break;
1381 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1382 i2c_bus = &dev->i2c_bus[0];
1383 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1384 &hauppauge_hvr1210_config,
1385 &i2c_bus->i2c_adap);
1386 if (fe0->dvb.frontend != NULL) {
1387 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1388 0x60, &dev->i2c_bus[1].i2c_adap,
1389 &hauppauge_hvr1210_tuner_config);
1390 }
1391 break;
1392 case CX23885_BOARD_HAUPPAUGE_HVR1400:
1393 i2c_bus = &dev->i2c_bus[0];
1394
1395 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1396 return -ENODEV;
1397
1398 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap,
1399 0x12, &hauppauge_hvr1400_dib7000_config);
1400 if (fe0->dvb.frontend != NULL) {
1401 struct dvb_frontend *fe;
1402 struct xc2028_config cfg = {
1403 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1404 .i2c_addr = 0x64,
1405 };
1406 static struct xc2028_ctrl ctl = {
1407 .fname = XC3028L_DEFAULT_FIRMWARE,
1408 .max_len = 64,
1409 .demod = XC3028_FE_DIBCOM52,
1410
1411
1412 .type = XC2028_D2633,
1413 };
1414
1415 fe = dvb_attach(xc2028_attach,
1416 fe0->dvb.frontend, &cfg);
1417 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1418 fe->ops.tuner_ops.set_config(fe, &ctl);
1419 }
1420 break;
1421 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1422 i2c_bus = &dev->i2c_bus[port->nr - 1];
1423
1424 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1425 &dvico_s5h1409_config,
1426 &i2c_bus->i2c_adap);
1427 if (fe0->dvb.frontend == NULL)
1428 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1429 &dvico_s5h1411_config,
1430 &i2c_bus->i2c_adap);
1431 if (fe0->dvb.frontend != NULL)
1432 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1433 &i2c_bus->i2c_adap,
1434 &dvico_xc5000_tunerconfig);
1435 break;
1436 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
1437 i2c_bus = &dev->i2c_bus[port->nr - 1];
1438
1439 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1440 &dvico_fusionhdtv_xc3028,
1441 &i2c_bus->i2c_adap);
1442 if (fe0->dvb.frontend != NULL) {
1443 struct dvb_frontend *fe;
1444 struct xc2028_config cfg = {
1445 .i2c_adap = &i2c_bus->i2c_adap,
1446 .i2c_addr = 0x61,
1447 };
1448 static struct xc2028_ctrl ctl = {
1449 .fname = XC2028_DEFAULT_FIRMWARE,
1450 .max_len = 64,
1451 .demod = XC3028_FE_ZARLINK456,
1452 };
1453
1454 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1455 &cfg);
1456 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1457 fe->ops.tuner_ops.set_config(fe, &ctl);
1458 }
1459 break;
1460 }
1461 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2: {
1462 i2c_bus = &dev->i2c_bus[port->nr - 1];
1463
1464
1465
1466 if (!dvb_attach(dib7000p_attach, &dib7000p_ops))
1467 return -ENODEV;
1468
1469 if (dib7000p_ops.i2c_enumeration(&i2c_bus->i2c_adap, 1, 0x12, &dib7070p_dib7000p_config) < 0) {
1470 pr_warn("Unable to enumerate dib7000p\n");
1471 return -ENODEV;
1472 }
1473 fe0->dvb.frontend = dib7000p_ops.init(&i2c_bus->i2c_adap, 0x80, &dib7070p_dib7000p_config);
1474 if (fe0->dvb.frontend != NULL) {
1475 struct i2c_adapter *tun_i2c;
1476
1477 fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
1478 memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
1479 tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
1480 if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
1481 return -ENODEV;
1482 }
1483 break;
1484 }
1485 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1486 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1487 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1488 i2c_bus = &dev->i2c_bus[0];
1489
1490 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1491 &dvico_fusionhdtv_xc3028,
1492 &i2c_bus->i2c_adap);
1493 if (fe0->dvb.frontend != NULL) {
1494 struct dvb_frontend *fe;
1495 struct xc2028_config cfg = {
1496 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
1497 .i2c_addr = 0x61,
1498 };
1499 static struct xc2028_ctrl ctl = {
1500 .fname = XC2028_DEFAULT_FIRMWARE,
1501 .max_len = 64,
1502 .demod = XC3028_FE_ZARLINK456,
1503 };
1504
1505 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
1506 &cfg);
1507 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1508 fe->ops.tuner_ops.set_config(fe, &ctl);
1509 }
1510 break;
1511 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1512 i2c_bus = &dev->i2c_bus[0];
1513
1514 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1515 &dvico_fusionhdtv_xc3028,
1516 &i2c_bus->i2c_adap);
1517 if (fe0->dvb.frontend != NULL) {
1518 struct dvb_frontend *fe;
1519 struct xc4000_config cfg = {
1520 .i2c_address = 0x61,
1521 .default_pm = 0,
1522 .dvb_amplitude = 134,
1523 .set_smoothedcvbs = 1,
1524 .if_khz = 4560
1525 };
1526
1527 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1528 &dev->i2c_bus[1].i2c_adap, &cfg);
1529 if (!fe) {
1530 pr_err("%s/2: xc4000 attach failed\n",
1531 dev->name);
1532 goto frontend_detach;
1533 }
1534 }
1535 break;
1536 case CX23885_BOARD_TBS_6920:
1537 i2c_bus = &dev->i2c_bus[1];
1538
1539 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1540 &tbs_cx24116_config,
1541 &i2c_bus->i2c_adap);
1542 if (fe0->dvb.frontend != NULL)
1543 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1544
1545 break;
1546 case CX23885_BOARD_TBS_6980:
1547 case CX23885_BOARD_TBS_6981:
1548 i2c_bus = &dev->i2c_bus[1];
1549
1550 switch (port->nr) {
1551
1552 case 1:
1553 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1554 &tbs_cx24117_config,
1555 &i2c_bus->i2c_adap);
1556 break;
1557
1558 case 2:
1559 fe0->dvb.frontend = dvb_attach(cx24117_attach,
1560 &tbs_cx24117_config,
1561 &i2c_bus->i2c_adap);
1562 break;
1563 }
1564 break;
1565 case CX23885_BOARD_TEVII_S470:
1566 i2c_bus = &dev->i2c_bus[1];
1567
1568 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1569 &tevii_ds3000_config,
1570 &i2c_bus->i2c_adap);
1571 if (fe0->dvb.frontend != NULL) {
1572 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1573 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1574 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
1575 }
1576
1577 break;
1578 case CX23885_BOARD_DVBWORLD_2005:
1579 i2c_bus = &dev->i2c_bus[1];
1580
1581 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1582 &dvbworld_cx24116_config,
1583 &i2c_bus->i2c_adap);
1584 break;
1585 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1586 i2c_bus = &dev->i2c_bus[0];
1587 switch (port->nr) {
1588
1589 case 1:
1590 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1591 &netup_stv0900_config,
1592 &i2c_bus->i2c_adap, 0);
1593 if (fe0->dvb.frontend != NULL) {
1594 if (dvb_attach(stv6110_attach,
1595 fe0->dvb.frontend,
1596 &netup_stv6110_tunerconfig_a,
1597 &i2c_bus->i2c_adap)) {
1598 if (!dvb_attach(lnbh24_attach,
1599 fe0->dvb.frontend,
1600 &i2c_bus->i2c_adap,
1601 LNBH24_PCL | LNBH24_TTX,
1602 LNBH24_TEN, 0x09))
1603 pr_err("No LNBH24 found!\n");
1604
1605 }
1606 }
1607 break;
1608
1609 case 2:
1610 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1611 &netup_stv0900_config,
1612 &i2c_bus->i2c_adap, 1);
1613 if (fe0->dvb.frontend != NULL) {
1614 if (dvb_attach(stv6110_attach,
1615 fe0->dvb.frontend,
1616 &netup_stv6110_tunerconfig_b,
1617 &i2c_bus->i2c_adap)) {
1618 if (!dvb_attach(lnbh24_attach,
1619 fe0->dvb.frontend,
1620 &i2c_bus->i2c_adap,
1621 LNBH24_PCL | LNBH24_TTX,
1622 LNBH24_TEN, 0x0a))
1623 pr_err("No LNBH24 found!\n");
1624
1625 }
1626 }
1627 break;
1628 }
1629 break;
1630 case CX23885_BOARD_MYGICA_X8506:
1631 i2c_bus = &dev->i2c_bus[0];
1632 i2c_bus2 = &dev->i2c_bus[1];
1633 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1634 &mygica_x8506_lgs8gl5_config,
1635 &i2c_bus->i2c_adap);
1636 if (fe0->dvb.frontend == NULL)
1637 break;
1638 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1639 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1640 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1641 break;
1642 case CX23885_BOARD_MYGICA_X8507:
1643 i2c_bus = &dev->i2c_bus[0];
1644 i2c_bus2 = &dev->i2c_bus[1];
1645 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1646 &mygica_x8507_mb86a20s_config,
1647 &i2c_bus->i2c_adap);
1648 if (fe0->dvb.frontend == NULL)
1649 break;
1650
1651 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1652 &i2c_bus2->i2c_adap,
1653 &mygica_x8507_xc5000_config);
1654 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1655 break;
1656 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1657 i2c_bus = &dev->i2c_bus[0];
1658 i2c_bus2 = &dev->i2c_bus[1];
1659 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1660 &magicpro_prohdtve2_lgs8g75_config,
1661 &i2c_bus->i2c_adap);
1662 if (fe0->dvb.frontend == NULL)
1663 break;
1664 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1665 &i2c_bus2->i2c_adap,
1666 &magicpro_prohdtve2_xc5000_config);
1667 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1668 break;
1669 case CX23885_BOARD_HAUPPAUGE_HVR1850:
1670 i2c_bus = &dev->i2c_bus[0];
1671 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1672 &hcw_s5h1411_config,
1673 &i2c_bus->i2c_adap);
1674 if (fe0->dvb.frontend == NULL)
1675 break;
1676 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1677 0x60, &dev->i2c_bus[0].i2c_adap,
1678 &hauppauge_tda18271_config);
1679
1680 tda18271_attach(&dev->ts1.analog_fe,
1681 0x60, &dev->i2c_bus[1].i2c_adap,
1682 &hauppauge_tda18271_config);
1683
1684 break;
1685 case CX23885_BOARD_HAUPPAUGE_HVR1290:
1686 i2c_bus = &dev->i2c_bus[0];
1687 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1688 &hcw_s5h1411_config,
1689 &i2c_bus->i2c_adap);
1690 if (fe0->dvb.frontend == NULL)
1691 break;
1692 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1693 0x60, &dev->i2c_bus[0].i2c_adap,
1694 &hauppauge_tda18271_config);
1695 break;
1696 case CX23885_BOARD_MYGICA_X8558PRO:
1697 switch (port->nr) {
1698
1699 case 1:
1700 i2c_bus = &dev->i2c_bus[0];
1701 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1702 &mygica_x8558pro_atbm8830_cfg1,
1703 &i2c_bus->i2c_adap);
1704 if (fe0->dvb.frontend == NULL)
1705 break;
1706 dvb_attach(max2165_attach, fe0->dvb.frontend,
1707 &i2c_bus->i2c_adap,
1708 &mygic_x8558pro_max2165_cfg1);
1709 break;
1710
1711 case 2:
1712 i2c_bus = &dev->i2c_bus[1];
1713 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1714 &mygica_x8558pro_atbm8830_cfg2,
1715 &i2c_bus->i2c_adap);
1716 if (fe0->dvb.frontend == NULL)
1717 break;
1718 dvb_attach(max2165_attach, fe0->dvb.frontend,
1719 &i2c_bus->i2c_adap,
1720 &mygic_x8558pro_max2165_cfg2);
1721 }
1722 break;
1723 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1724 if (port->nr > 2)
1725 return 0;
1726
1727 i2c_bus = &dev->i2c_bus[0];
1728 mfe_shared = 1;
1729 port->frontends.gate = 0;
1730
1731
1732 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1733 &netup_stv0367_config[port->nr - 1],
1734 &i2c_bus->i2c_adap);
1735 if (fe0->dvb.frontend == NULL)
1736 break;
1737 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1738 &i2c_bus->i2c_adap,
1739 &netup_xc5000_config[port->nr - 1]))
1740 goto frontend_detach;
1741
1742 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1743
1744
1745 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1746 if (fe1 == NULL)
1747 goto frontend_detach;
1748
1749 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1750 &netup_stv0367_config[port->nr - 1],
1751 &i2c_bus->i2c_adap);
1752 if (fe1->dvb.frontend == NULL)
1753 break;
1754
1755 fe1->dvb.frontend->id = 1;
1756 if (NULL == dvb_attach(xc5000_attach,
1757 fe1->dvb.frontend,
1758 &i2c_bus->i2c_adap,
1759 &netup_xc5000_config[port->nr - 1]))
1760 goto frontend_detach;
1761 break;
1762 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1763 i2c_bus = &dev->i2c_bus[0];
1764 i2c_bus2 = &dev->i2c_bus[1];
1765
1766 switch (port->nr) {
1767
1768 case 1:
1769 fe0->dvb.frontend = dvb_attach(drxk_attach,
1770 &terratec_drxk_config[0],
1771 &i2c_bus->i2c_adap);
1772 if (fe0->dvb.frontend == NULL)
1773 break;
1774 if (!dvb_attach(mt2063_attach,
1775 fe0->dvb.frontend,
1776 &terratec_mt2063_config[0],
1777 &i2c_bus2->i2c_adap))
1778 goto frontend_detach;
1779 break;
1780
1781 case 2:
1782 fe0->dvb.frontend = dvb_attach(drxk_attach,
1783 &terratec_drxk_config[1],
1784 &i2c_bus->i2c_adap);
1785 if (fe0->dvb.frontend == NULL)
1786 break;
1787 if (!dvb_attach(mt2063_attach,
1788 fe0->dvb.frontend,
1789 &terratec_mt2063_config[1],
1790 &i2c_bus2->i2c_adap))
1791 goto frontend_detach;
1792 break;
1793 }
1794 break;
1795 case CX23885_BOARD_TEVII_S471:
1796 i2c_bus = &dev->i2c_bus[1];
1797
1798 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1799 &tevii_ds3000_config,
1800 &i2c_bus->i2c_adap);
1801 if (fe0->dvb.frontend == NULL)
1802 break;
1803 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1804 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1805 break;
1806 case CX23885_BOARD_PROF_8000:
1807 i2c_bus = &dev->i2c_bus[0];
1808
1809 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1810 &prof_8000_stv090x_config,
1811 &i2c_bus->i2c_adap,
1812 STV090x_DEMODULATOR_0);
1813 if (fe0->dvb.frontend == NULL)
1814 break;
1815 if (!dvb_attach(stb6100_attach,
1816 fe0->dvb.frontend,
1817 &prof_8000_stb6100_config,
1818 &i2c_bus->i2c_adap))
1819 goto frontend_detach;
1820
1821 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1822 break;
1823 case CX23885_BOARD_HAUPPAUGE_HVR4400: {
1824 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1825 struct a8293_platform_data a8293_pdata = {};
1826
1827 i2c_bus = &dev->i2c_bus[0];
1828 i2c_bus2 = &dev->i2c_bus[1];
1829 switch (port->nr) {
1830
1831 case 1:
1832
1833 memset(&info, 0, sizeof(info));
1834 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1835 info.addr = 0x05;
1836 info.platform_data = &tda10071_pdata;
1837 request_module("tda10071");
1838 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1839 if (!client_demod || !client_demod->dev.driver)
1840 goto frontend_detach;
1841 if (!try_module_get(client_demod->dev.driver->owner)) {
1842 i2c_unregister_device(client_demod);
1843 goto frontend_detach;
1844 }
1845 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1846 port->i2c_client_demod = client_demod;
1847
1848
1849 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1850 memset(&info, 0, sizeof(info));
1851 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1852 info.addr = 0x0b;
1853 info.platform_data = &a8293_pdata;
1854 request_module("a8293");
1855 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1856 if (!client_sec || !client_sec->dev.driver)
1857 goto frontend_detach;
1858 if (!try_module_get(client_sec->dev.driver->owner)) {
1859 i2c_unregister_device(client_sec);
1860 goto frontend_detach;
1861 }
1862 port->i2c_client_sec = client_sec;
1863 break;
1864
1865 case 2:
1866
1867 memset(&si2165_pdata, 0, sizeof(si2165_pdata));
1868 si2165_pdata.fe = &fe0->dvb.frontend;
1869 si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL;
1870 si2165_pdata.ref_freq_hz = 16000000;
1871 memset(&info, 0, sizeof(struct i2c_board_info));
1872 strlcpy(info.type, "si2165", I2C_NAME_SIZE);
1873 info.addr = 0x64;
1874 info.platform_data = &si2165_pdata;
1875 request_module(info.type);
1876 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1877 if (client_demod == NULL ||
1878 client_demod->dev.driver == NULL)
1879 goto frontend_detach;
1880 if (!try_module_get(client_demod->dev.driver->owner)) {
1881 i2c_unregister_device(client_demod);
1882 goto frontend_detach;
1883 }
1884 port->i2c_client_demod = client_demod;
1885
1886 if (fe0->dvb.frontend == NULL)
1887 break;
1888 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1889 if (!dvb_attach(tda18271_attach,
1890 fe0->dvb.frontend,
1891 0x60, &i2c_bus2->i2c_adap,
1892 &hauppauge_hvr4400_tuner_config))
1893 goto frontend_detach;
1894 break;
1895 }
1896 break;
1897 }
1898 case CX23885_BOARD_HAUPPAUGE_STARBURST: {
1899 struct tda10071_platform_data tda10071_pdata = hauppauge_tda10071_pdata;
1900 struct a8293_platform_data a8293_pdata = {};
1901
1902 i2c_bus = &dev->i2c_bus[0];
1903
1904
1905 memset(&info, 0, sizeof(info));
1906 strlcpy(info.type, "tda10071_cx24118", I2C_NAME_SIZE);
1907 info.addr = 0x05;
1908 info.platform_data = &tda10071_pdata;
1909 request_module("tda10071");
1910 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1911 if (!client_demod || !client_demod->dev.driver)
1912 goto frontend_detach;
1913 if (!try_module_get(client_demod->dev.driver->owner)) {
1914 i2c_unregister_device(client_demod);
1915 goto frontend_detach;
1916 }
1917 fe0->dvb.frontend = tda10071_pdata.get_dvb_frontend(client_demod);
1918 port->i2c_client_demod = client_demod;
1919
1920
1921 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
1922 memset(&info, 0, sizeof(info));
1923 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
1924 info.addr = 0x0b;
1925 info.platform_data = &a8293_pdata;
1926 request_module("a8293");
1927 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
1928 if (!client_sec || !client_sec->dev.driver)
1929 goto frontend_detach;
1930 if (!try_module_get(client_sec->dev.driver->owner)) {
1931 i2c_unregister_device(client_sec);
1932 goto frontend_detach;
1933 }
1934 port->i2c_client_sec = client_sec;
1935 break;
1936 }
1937 case CX23885_BOARD_DVBSKY_T9580:
1938 case CX23885_BOARD_DVBSKY_S950:
1939 i2c_bus = &dev->i2c_bus[0];
1940 i2c_bus2 = &dev->i2c_bus[1];
1941 switch (port->nr) {
1942
1943 case 1:
1944
1945 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1946 &dvbsky_t9580_m88ds3103_config,
1947 &i2c_bus2->i2c_adap, &adapter);
1948 if (fe0->dvb.frontend == NULL)
1949 break;
1950
1951
1952 memset(&ts2020_config, 0, sizeof(ts2020_config));
1953 ts2020_config.fe = fe0->dvb.frontend;
1954 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
1955 memset(&info, 0, sizeof(struct i2c_board_info));
1956 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
1957 info.addr = 0x60;
1958 info.platform_data = &ts2020_config;
1959 request_module(info.type);
1960 client_tuner = i2c_new_device(adapter, &info);
1961 if (client_tuner == NULL ||
1962 client_tuner->dev.driver == NULL)
1963 goto frontend_detach;
1964 if (!try_module_get(client_tuner->dev.driver->owner)) {
1965 i2c_unregister_device(client_tuner);
1966 goto frontend_detach;
1967 }
1968
1969
1970 fe0->dvb.frontend->ops.read_signal_strength =
1971 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1972
1973
1974
1975
1976
1977 port->fe_set_voltage =
1978 fe0->dvb.frontend->ops.set_voltage;
1979 fe0->dvb.frontend->ops.set_voltage =
1980 dvbsky_t9580_set_voltage;
1981
1982 port->i2c_client_tuner = client_tuner;
1983
1984 break;
1985
1986 case 2:
1987
1988 memset(&si2168_config, 0, sizeof(si2168_config));
1989 si2168_config.i2c_adapter = &adapter;
1990 si2168_config.fe = &fe0->dvb.frontend;
1991 si2168_config.ts_mode = SI2168_TS_SERIAL;
1992 memset(&info, 0, sizeof(struct i2c_board_info));
1993 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1994 info.addr = 0x64;
1995 info.platform_data = &si2168_config;
1996 request_module(info.type);
1997 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1998 if (client_demod == NULL ||
1999 client_demod->dev.driver == NULL)
2000 goto frontend_detach;
2001 if (!try_module_get(client_demod->dev.driver->owner)) {
2002 i2c_unregister_device(client_demod);
2003 goto frontend_detach;
2004 }
2005 port->i2c_client_demod = client_demod;
2006
2007
2008 memset(&si2157_config, 0, sizeof(si2157_config));
2009 si2157_config.fe = fe0->dvb.frontend;
2010 si2157_config.if_port = 1;
2011 memset(&info, 0, sizeof(struct i2c_board_info));
2012 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2013 info.addr = 0x60;
2014 info.platform_data = &si2157_config;
2015 request_module(info.type);
2016 client_tuner = i2c_new_device(adapter, &info);
2017 if (client_tuner == NULL ||
2018 client_tuner->dev.driver == NULL)
2019 goto frontend_detach;
2020
2021 if (!try_module_get(client_tuner->dev.driver->owner)) {
2022 i2c_unregister_device(client_tuner);
2023 goto frontend_detach;
2024 }
2025 port->i2c_client_tuner = client_tuner;
2026 break;
2027 }
2028 break;
2029 case CX23885_BOARD_DVBSKY_T980C:
2030 case CX23885_BOARD_TT_CT2_4500_CI:
2031 i2c_bus = &dev->i2c_bus[0];
2032 i2c_bus2 = &dev->i2c_bus[1];
2033
2034
2035 memset(&si2168_config, 0, sizeof(si2168_config));
2036 si2168_config.i2c_adapter = &adapter;
2037 si2168_config.fe = &fe0->dvb.frontend;
2038 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2039 memset(&info, 0, sizeof(struct i2c_board_info));
2040 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2041 info.addr = 0x64;
2042 info.platform_data = &si2168_config;
2043 request_module(info.type);
2044 client_demod = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2045 if (client_demod == NULL || client_demod->dev.driver == NULL)
2046 goto frontend_detach;
2047 if (!try_module_get(client_demod->dev.driver->owner)) {
2048 i2c_unregister_device(client_demod);
2049 goto frontend_detach;
2050 }
2051 port->i2c_client_demod = client_demod;
2052
2053
2054 memset(&si2157_config, 0, sizeof(si2157_config));
2055 si2157_config.fe = fe0->dvb.frontend;
2056 si2157_config.if_port = 1;
2057 memset(&info, 0, sizeof(struct i2c_board_info));
2058 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2059 info.addr = 0x60;
2060 info.platform_data = &si2157_config;
2061 request_module(info.type);
2062 client_tuner = i2c_new_device(adapter, &info);
2063 if (client_tuner == NULL ||
2064 client_tuner->dev.driver == NULL)
2065 goto frontend_detach;
2066 if (!try_module_get(client_tuner->dev.driver->owner)) {
2067 i2c_unregister_device(client_tuner);
2068 goto frontend_detach;
2069 }
2070 port->i2c_client_tuner = client_tuner;
2071 break;
2072 case CX23885_BOARD_DVBSKY_S950C:
2073 i2c_bus = &dev->i2c_bus[0];
2074 i2c_bus2 = &dev->i2c_bus[1];
2075
2076
2077 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2078 &dvbsky_s950c_m88ds3103_config,
2079 &i2c_bus2->i2c_adap, &adapter);
2080 if (fe0->dvb.frontend == NULL)
2081 break;
2082
2083
2084 memset(&ts2020_config, 0, sizeof(ts2020_config));
2085 ts2020_config.fe = fe0->dvb.frontend;
2086 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2087 memset(&info, 0, sizeof(struct i2c_board_info));
2088 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2089 info.addr = 0x60;
2090 info.platform_data = &ts2020_config;
2091 request_module(info.type);
2092 client_tuner = i2c_new_device(adapter, &info);
2093 if (client_tuner == NULL || client_tuner->dev.driver == NULL)
2094 goto frontend_detach;
2095 if (!try_module_get(client_tuner->dev.driver->owner)) {
2096 i2c_unregister_device(client_tuner);
2097 goto frontend_detach;
2098 }
2099
2100
2101 fe0->dvb.frontend->ops.read_signal_strength =
2102 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2103
2104 port->i2c_client_tuner = client_tuner;
2105 break;
2106 case CX23885_BOARD_DVBSKY_S952:
2107
2108 memset(&m88ds3103_pdata, 0, sizeof(m88ds3103_pdata));
2109 m88ds3103_pdata.clk = 27000000;
2110 m88ds3103_pdata.i2c_wr_max = 33;
2111 m88ds3103_pdata.agc = 0x99;
2112 m88ds3103_pdata.clk_out = M88DS3103_CLOCK_OUT_DISABLED;
2113 m88ds3103_pdata.lnb_en_pol = 1;
2114
2115 switch (port->nr) {
2116
2117 case 1:
2118 i2c_bus = &dev->i2c_bus[1];
2119 m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
2120 m88ds3103_pdata.ts_clk = 16000;
2121 m88ds3103_pdata.ts_clk_pol = 1;
2122 p_set_voltage = dvbsky_t9580_set_voltage;
2123 break;
2124
2125 case 2:
2126 i2c_bus = &dev->i2c_bus[0];
2127 m88ds3103_pdata.ts_mode = M88DS3103_TS_SERIAL;
2128 m88ds3103_pdata.ts_clk = 96000;
2129 m88ds3103_pdata.ts_clk_pol = 0;
2130 p_set_voltage = dvbsky_s952_portc_set_voltage;
2131 break;
2132 default:
2133 return 0;
2134 }
2135
2136 memset(&info, 0, sizeof(info));
2137 strlcpy(info.type, "m88ds3103", I2C_NAME_SIZE);
2138 info.addr = 0x68;
2139 info.platform_data = &m88ds3103_pdata;
2140 request_module(info.type);
2141 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2142 if (client_demod == NULL || client_demod->dev.driver == NULL)
2143 goto frontend_detach;
2144 if (!try_module_get(client_demod->dev.driver->owner)) {
2145 i2c_unregister_device(client_demod);
2146 goto frontend_detach;
2147 }
2148 port->i2c_client_demod = client_demod;
2149 adapter = m88ds3103_pdata.get_i2c_adapter(client_demod);
2150 fe0->dvb.frontend = m88ds3103_pdata.get_dvb_frontend(client_demod);
2151
2152
2153 memset(&ts2020_config, 0, sizeof(ts2020_config));
2154 ts2020_config.fe = fe0->dvb.frontend;
2155 ts2020_config.get_agc_pwm = m88ds3103_get_agc_pwm;
2156 memset(&info, 0, sizeof(struct i2c_board_info));
2157 strlcpy(info.type, "ts2020", I2C_NAME_SIZE);
2158 info.addr = 0x60;
2159 info.platform_data = &ts2020_config;
2160 request_module(info.type);
2161 client_tuner = i2c_new_device(adapter, &info);
2162 if (client_tuner == NULL || 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;
2167 }
2168
2169
2170 fe0->dvb.frontend->ops.read_signal_strength =
2171 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2172
2173
2174
2175
2176
2177 port->fe_set_voltage =
2178 fe0->dvb.frontend->ops.set_voltage;
2179 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
2180
2181 port->i2c_client_tuner = client_tuner;
2182 break;
2183 case CX23885_BOARD_DVBSKY_T982:
2184 memset(&si2168_config, 0, sizeof(si2168_config));
2185 switch (port->nr) {
2186
2187 case 1:
2188 i2c_bus = &dev->i2c_bus[1];
2189 si2168_config.ts_mode = SI2168_TS_PARALLEL;
2190 break;
2191
2192 case 2:
2193 i2c_bus = &dev->i2c_bus[0];
2194 si2168_config.ts_mode = SI2168_TS_SERIAL;
2195 break;
2196 }
2197
2198
2199 si2168_config.i2c_adapter = &adapter;
2200 si2168_config.fe = &fe0->dvb.frontend;
2201 memset(&info, 0, sizeof(struct i2c_board_info));
2202 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2203 info.addr = 0x64;
2204 info.platform_data = &si2168_config;
2205 request_module(info.type);
2206 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2207 if (client_demod == NULL || client_demod->dev.driver == NULL)
2208 goto frontend_detach;
2209 if (!try_module_get(client_demod->dev.driver->owner)) {
2210 i2c_unregister_device(client_demod);
2211 goto frontend_detach;
2212 }
2213 port->i2c_client_demod = client_demod;
2214
2215
2216 memset(&si2157_config, 0, sizeof(si2157_config));
2217 si2157_config.fe = fe0->dvb.frontend;
2218 si2157_config.if_port = 1;
2219 memset(&info, 0, sizeof(struct i2c_board_info));
2220 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2221 info.addr = 0x60;
2222 info.platform_data = &si2157_config;
2223 request_module(info.type);
2224 client_tuner = i2c_new_device(adapter, &info);
2225 if (client_tuner == NULL ||
2226 client_tuner->dev.driver == NULL)
2227 goto frontend_detach;
2228 if (!try_module_get(client_tuner->dev.driver->owner)) {
2229 i2c_unregister_device(client_tuner);
2230 goto frontend_detach;
2231 }
2232 port->i2c_client_tuner = client_tuner;
2233 break;
2234 case CX23885_BOARD_HAUPPAUGE_STARBURST2:
2235 case CX23885_BOARD_HAUPPAUGE_HVR5525:
2236 i2c_bus = &dev->i2c_bus[0];
2237 i2c_bus2 = &dev->i2c_bus[1];
2238
2239 switch (port->nr) {
2240
2241
2242 case 1:
2243
2244 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
2245 &hauppauge_hvr5525_m88ds3103_config,
2246 &i2c_bus->i2c_adap, &adapter);
2247 if (fe0->dvb.frontend == NULL)
2248 break;
2249
2250
2251 a8293_pdata.dvb_frontend = fe0->dvb.frontend;
2252 memset(&info, 0, sizeof(info));
2253 strlcpy(info.type, "a8293", I2C_NAME_SIZE);
2254 info.addr = 0x0b;
2255 info.platform_data = &a8293_pdata;
2256 request_module("a8293");
2257 client_sec = i2c_new_device(&i2c_bus->i2c_adap, &info);
2258 if (!client_sec || !client_sec->dev.driver)
2259 goto frontend_detach;
2260 if (!try_module_get(client_sec->dev.driver->owner)) {
2261 i2c_unregister_device(client_sec);
2262 goto frontend_detach;
2263 }
2264 port->i2c_client_sec = client_sec;
2265
2266
2267 memset(&m88rs6000t_config, 0, sizeof(m88rs6000t_config));
2268 m88rs6000t_config.fe = fe0->dvb.frontend;
2269 memset(&info, 0, sizeof(struct i2c_board_info));
2270 strlcpy(info.type, "m88rs6000t", I2C_NAME_SIZE);
2271 info.addr = 0x21;
2272 info.platform_data = &m88rs6000t_config;
2273 request_module("%s", info.type);
2274 client_tuner = i2c_new_device(adapter, &info);
2275 if (!client_tuner || !client_tuner->dev.driver)
2276 goto frontend_detach;
2277 if (!try_module_get(client_tuner->dev.driver->owner)) {
2278 i2c_unregister_device(client_tuner);
2279 goto frontend_detach;
2280 }
2281 port->i2c_client_tuner = client_tuner;
2282
2283
2284 fe0->dvb.frontend->ops.read_signal_strength =
2285 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
2286 break;
2287
2288 case 2:
2289
2290 memset(&si2168_config, 0, sizeof(si2168_config));
2291 si2168_config.i2c_adapter = &adapter;
2292 si2168_config.fe = &fe0->dvb.frontend;
2293 si2168_config.ts_mode = SI2168_TS_SERIAL;
2294 memset(&info, 0, sizeof(struct i2c_board_info));
2295 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2296 info.addr = 0x64;
2297 info.platform_data = &si2168_config;
2298 request_module("%s", info.type);
2299 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
2300 if (!client_demod || !client_demod->dev.driver)
2301 goto frontend_detach;
2302 if (!try_module_get(client_demod->dev.driver->owner)) {
2303 i2c_unregister_device(client_demod);
2304 goto frontend_detach;
2305 }
2306 port->i2c_client_demod = client_demod;
2307
2308
2309 memset(&si2157_config, 0, sizeof(si2157_config));
2310 si2157_config.fe = fe0->dvb.frontend;
2311 si2157_config.if_port = 1;
2312 memset(&info, 0, sizeof(struct i2c_board_info));
2313 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2314 info.addr = 0x60;
2315 info.platform_data = &si2157_config;
2316 request_module("%s", info.type);
2317 client_tuner = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2318 if (!client_tuner || !client_tuner->dev.driver) {
2319 module_put(client_demod->dev.driver->owner);
2320 i2c_unregister_device(client_demod);
2321 port->i2c_client_demod = NULL;
2322 goto frontend_detach;
2323 }
2324 if (!try_module_get(client_tuner->dev.driver->owner)) {
2325 i2c_unregister_device(client_tuner);
2326 module_put(client_demod->dev.driver->owner);
2327 i2c_unregister_device(client_demod);
2328 port->i2c_client_demod = NULL;
2329 goto frontend_detach;
2330 }
2331 port->i2c_client_tuner = client_tuner;
2332 break;
2333 }
2334 break;
2335 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
2336 case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB_885:
2337 pr_info("%s(): board=%d port=%d\n", __func__,
2338 dev->board, port->nr);
2339 switch (port->nr) {
2340
2341 case 1:
2342
2343 memset(&si2168_config, 0, sizeof(si2168_config));
2344 si2168_config.i2c_adapter = &adapter;
2345 si2168_config.fe = &fe0->dvb.frontend;
2346 si2168_config.ts_mode = SI2168_TS_SERIAL;
2347 memset(&info, 0, sizeof(struct i2c_board_info));
2348 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2349 info.addr = 0x64;
2350 info.platform_data = &si2168_config;
2351 request_module("%s", info.type);
2352 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2353 if (!client_demod || !client_demod->dev.driver)
2354 goto frontend_detach;
2355 if (!try_module_get(client_demod->dev.driver->owner)) {
2356 i2c_unregister_device(client_demod);
2357 goto frontend_detach;
2358 }
2359 port->i2c_client_demod = client_demod;
2360
2361
2362 memset(&si2157_config, 0, sizeof(si2157_config));
2363 si2157_config.fe = fe0->dvb.frontend;
2364 si2157_config.if_port = 1;
2365 memset(&info, 0, sizeof(struct i2c_board_info));
2366 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2367 info.addr = 0x60;
2368 info.platform_data = &si2157_config;
2369 request_module("%s", info.type);
2370 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2371 if (!client_tuner || !client_tuner->dev.driver) {
2372 module_put(client_demod->dev.driver->owner);
2373 i2c_unregister_device(client_demod);
2374 port->i2c_client_demod = NULL;
2375 goto frontend_detach;
2376 }
2377 if (!try_module_get(client_tuner->dev.driver->owner)) {
2378 i2c_unregister_device(client_tuner);
2379 module_put(client_demod->dev.driver->owner);
2380 i2c_unregister_device(client_demod);
2381 port->i2c_client_demod = NULL;
2382 goto frontend_detach;
2383 }
2384 port->i2c_client_tuner = client_tuner;
2385 break;
2386
2387
2388 case 2:
2389
2390 memset(&si2168_config, 0, sizeof(si2168_config));
2391 si2168_config.i2c_adapter = &adapter;
2392 si2168_config.fe = &fe0->dvb.frontend;
2393 si2168_config.ts_mode = SI2168_TS_SERIAL;
2394 memset(&info, 0, sizeof(struct i2c_board_info));
2395 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
2396 info.addr = 0x66;
2397 info.platform_data = &si2168_config;
2398 request_module("%s", info.type);
2399 client_demod = i2c_new_device(&dev->i2c_bus[0].i2c_adap, &info);
2400 if (!client_demod || !client_demod->dev.driver)
2401 goto frontend_detach;
2402 if (!try_module_get(client_demod->dev.driver->owner)) {
2403 i2c_unregister_device(client_demod);
2404 goto frontend_detach;
2405 }
2406 port->i2c_client_demod = client_demod;
2407
2408
2409 memset(&si2157_config, 0, sizeof(si2157_config));
2410 si2157_config.fe = fe0->dvb.frontend;
2411 si2157_config.if_port = 1;
2412 memset(&info, 0, sizeof(struct i2c_board_info));
2413 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2414 info.addr = 0x62;
2415 info.platform_data = &si2157_config;
2416 request_module("%s", info.type);
2417 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2418 if (!client_tuner || !client_tuner->dev.driver) {
2419 module_put(client_demod->dev.driver->owner);
2420 i2c_unregister_device(client_demod);
2421 port->i2c_client_demod = NULL;
2422 goto frontend_detach;
2423 }
2424 if (!try_module_get(client_tuner->dev.driver->owner)) {
2425 i2c_unregister_device(client_tuner);
2426 module_put(client_demod->dev.driver->owner);
2427 i2c_unregister_device(client_demod);
2428 port->i2c_client_demod = NULL;
2429 goto frontend_detach;
2430 }
2431 port->i2c_client_tuner = client_tuner;
2432 break;
2433 }
2434 break;
2435 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
2436 case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC_885:
2437 pr_info("%s(): board=%d port=%d\n", __func__,
2438 dev->board, port->nr);
2439 switch (port->nr) {
2440
2441 case 1:
2442
2443 i2c_bus = &dev->i2c_bus[0];
2444 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2445 &hauppauge_quadHD_ATSC_a_config, &i2c_bus->i2c_adap);
2446 if (fe0->dvb.frontend == NULL)
2447 break;
2448
2449
2450 memset(&si2157_config, 0, sizeof(si2157_config));
2451 si2157_config.fe = fe0->dvb.frontend;
2452 si2157_config.if_port = 1;
2453 si2157_config.inversion = 1;
2454 memset(&info, 0, sizeof(struct i2c_board_info));
2455 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2456 info.addr = 0x60;
2457 info.platform_data = &si2157_config;
2458 request_module("%s", info.type);
2459 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2460 if (!client_tuner || !client_tuner->dev.driver) {
2461 module_put(client_demod->dev.driver->owner);
2462 i2c_unregister_device(client_demod);
2463 port->i2c_client_demod = NULL;
2464 goto frontend_detach;
2465 }
2466 if (!try_module_get(client_tuner->dev.driver->owner)) {
2467 i2c_unregister_device(client_tuner);
2468 module_put(client_demod->dev.driver->owner);
2469 i2c_unregister_device(client_demod);
2470 port->i2c_client_demod = NULL;
2471 goto frontend_detach;
2472 }
2473 port->i2c_client_tuner = client_tuner;
2474 break;
2475
2476
2477 case 2:
2478
2479 i2c_bus = &dev->i2c_bus[0];
2480 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2481 &hauppauge_quadHD_ATSC_b_config, &i2c_bus->i2c_adap);
2482 if (fe0->dvb.frontend == NULL)
2483 break;
2484
2485
2486 memset(&si2157_config, 0, sizeof(si2157_config));
2487 si2157_config.fe = fe0->dvb.frontend;
2488 si2157_config.if_port = 1;
2489 si2157_config.inversion = 1;
2490 memset(&info, 0, sizeof(struct i2c_board_info));
2491 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2492 info.addr = 0x62;
2493 info.platform_data = &si2157_config;
2494 request_module("%s", info.type);
2495 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2496 if (!client_tuner || !client_tuner->dev.driver) {
2497 module_put(client_demod->dev.driver->owner);
2498 i2c_unregister_device(client_demod);
2499 port->i2c_client_demod = NULL;
2500 goto frontend_detach;
2501 }
2502 if (!try_module_get(client_tuner->dev.driver->owner)) {
2503 i2c_unregister_device(client_tuner);
2504 module_put(client_demod->dev.driver->owner);
2505 i2c_unregister_device(client_demod);
2506 port->i2c_client_demod = NULL;
2507 goto frontend_detach;
2508 }
2509 port->i2c_client_tuner = client_tuner;
2510 break;
2511 }
2512 break;
2513 case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
2514 switch (port->nr) {
2515
2516 case 2:
2517
2518 i2c_bus = &dev->i2c_bus[0];
2519 fe0->dvb.frontend = dvb_attach(lgdt3306a_attach,
2520 &hauppauge_hvr1265k4_config,
2521 &i2c_bus->i2c_adap);
2522 if (fe0->dvb.frontend == NULL)
2523 break;
2524
2525
2526 memset(&si2157_config, 0, sizeof(si2157_config));
2527 si2157_config.fe = fe0->dvb.frontend;
2528 si2157_config.if_port = 1;
2529 si2157_config.inversion = 1;
2530 memset(&info, 0, sizeof(struct i2c_board_info));
2531 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
2532 info.addr = 0x60;
2533 info.platform_data = &si2157_config;
2534 request_module("%s", info.type);
2535 client_tuner = i2c_new_device(&dev->i2c_bus[1].i2c_adap, &info);
2536 if (!client_tuner || !client_tuner->dev.driver)
2537 goto frontend_detach;
2538
2539 if (!try_module_get(client_tuner->dev.driver->owner)) {
2540 i2c_unregister_device(client_tuner);
2541 client_tuner = NULL;
2542 goto frontend_detach;
2543 }
2544 port->i2c_client_tuner = client_tuner;
2545 break;
2546 }
2547 break;
2548 default:
2549 pr_info("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
2550 dev->name);
2551 break;
2552 }
2553
2554 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
2555 pr_err("%s: frontend initialization failed\n",
2556 dev->name);
2557 goto frontend_detach;
2558 }
2559
2560
2561 fe0->dvb.frontend->callback = cx23885_tuner_callback;
2562 if (fe1)
2563 fe1->dvb.frontend->callback = cx23885_tuner_callback;
2564#if 0
2565
2566 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2567 if (fe1)
2568 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
2569#endif
2570
2571
2572 call_all(dev, tuner, standby);
2573
2574 if (fe0->dvb.frontend->ops.analog_ops.standby)
2575 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
2576
2577
2578 ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
2579 &dev->pci->dev, NULL,
2580 adapter_nr, mfe_shared);
2581 if (ret)
2582 goto frontend_detach;
2583
2584 ret = dvb_register_ci_mac(port);
2585 if (ret)
2586 goto frontend_detach;
2587
2588 return 0;
2589
2590frontend_detach:
2591
2592 client_sec = port->i2c_client_sec;
2593 if (client_sec) {
2594 module_put(client_sec->dev.driver->owner);
2595 i2c_unregister_device(client_sec);
2596 port->i2c_client_sec = NULL;
2597 }
2598
2599
2600 client_tuner = port->i2c_client_tuner;
2601 if (client_tuner) {
2602 module_put(client_tuner->dev.driver->owner);
2603 i2c_unregister_device(client_tuner);
2604 port->i2c_client_tuner = NULL;
2605 }
2606
2607
2608 client_demod = port->i2c_client_demod;
2609 if (client_demod) {
2610 module_put(client_demod->dev.driver->owner);
2611 i2c_unregister_device(client_demod);
2612 port->i2c_client_demod = NULL;
2613 }
2614
2615 port->gate_ctrl = NULL;
2616 vb2_dvb_dealloc_frontends(&port->frontends);
2617 return -EINVAL;
2618}
2619
2620int cx23885_dvb_register(struct cx23885_tsport *port)
2621{
2622
2623 struct vb2_dvb_frontend *fe0;
2624 struct cx23885_dev *dev = port->dev;
2625 int err, i;
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636 pr_info("%s() allocating %d frontend(s)\n", __func__,
2637 port->num_frontends);
2638
2639 for (i = 1; i <= port->num_frontends; i++) {
2640 struct vb2_queue *q;
2641
2642 if (vb2_dvb_alloc_frontend(
2643 &port->frontends, i) == NULL) {
2644 pr_err("%s() failed to alloc\n", __func__);
2645 return -ENOMEM;
2646 }
2647
2648 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
2649 if (!fe0)
2650 return -EINVAL;
2651
2652 dprintk(1, "%s\n", __func__);
2653 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
2654 dev->board,
2655 dev->name,
2656 dev->pci_bus,
2657 dev->pci_slot);
2658
2659 err = -ENODEV;
2660
2661
2662
2663 pr_info("%s: cx23885 based dvb card\n", dev->name);
2664 q = &fe0->dvb.dvbq;
2665 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
2666 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ;
2667 q->gfp_flags = GFP_DMA32;
2668 q->min_buffers_needed = 2;
2669 q->drv_priv = port;
2670 q->buf_struct_size = sizeof(struct cx23885_buffer);
2671 q->ops = &dvb_qops;
2672 q->mem_ops = &vb2_dma_sg_memops;
2673 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
2674 q->lock = &dev->lock;
2675 q->dev = &dev->pci->dev;
2676
2677 err = vb2_queue_init(q);
2678 if (err < 0)
2679 return err;
2680 }
2681 err = dvb_register(port);
2682 if (err != 0)
2683 pr_err("%s() dvb_register failed err = %d\n",
2684 __func__, err);
2685
2686 return err;
2687}
2688
2689int cx23885_dvb_unregister(struct cx23885_tsport *port)
2690{
2691 struct vb2_dvb_frontend *fe0;
2692 struct i2c_client *client;
2693
2694 fe0 = vb2_dvb_get_frontend(&port->frontends, 1);
2695
2696 if (fe0 && fe0->dvb.frontend)
2697 vb2_dvb_unregister_bus(&port->frontends);
2698
2699
2700 client = port->i2c_client_ci;
2701 if (client) {
2702 module_put(client->dev.driver->owner);
2703 i2c_unregister_device(client);
2704 }
2705
2706
2707 client = port->i2c_client_sec;
2708 if (client) {
2709 module_put(client->dev.driver->owner);
2710 i2c_unregister_device(client);
2711 }
2712
2713
2714 client = port->i2c_client_tuner;
2715 if (client) {
2716 module_put(client->dev.driver->owner);
2717 i2c_unregister_device(client);
2718 }
2719
2720
2721 client = port->i2c_client_demod;
2722 if (client) {
2723 module_put(client->dev.driver->owner);
2724 i2c_unregister_device(client);
2725 }
2726
2727 switch (port->dev->board) {
2728 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2729 netup_ci_exit(port);
2730 break;
2731 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2732 altera_ci_release(port->dev, port->nr);
2733 break;
2734 }
2735
2736 port->gate_ctrl = NULL;
2737
2738 return 0;
2739}
2740