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