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