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. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | */ | |
21 | ||
22 | #include <linux/module.h> | |
23 | #include <linux/init.h> | |
24 | #include <linux/device.h> | |
25 | #include <linux/fs.h> | |
26 | #include <linux/kthread.h> | |
27 | #include <linux/file.h> | |
28 | #include <linux/suspend.h> | |
29 | ||
30 | #include "cx23885.h" | |
d19770e5 ST |
31 | #include <media/v4l2-common.h> |
32 | ||
33 | #include "s5h1409.h" | |
52b50450 | 34 | #include "s5h1411.h" |
d19770e5 | 35 | #include "mt2131.h" |
3ba71d21 | 36 | #include "tda8290.h" |
4041f1a5 | 37 | #include "tda18271.h" |
9bc37caa | 38 | #include "lgdt330x.h" |
d1987d55 | 39 | #include "xc5000.h" |
b3ea0166 | 40 | #include "tda10048.h" |
07b4a835 | 41 | #include "tuner-xc2028.h" |
827855d3 | 42 | #include "tuner-simple.h" |
66762373 ST |
43 | #include "dib7000p.h" |
44 | #include "dibx000_common.h" | |
aef2d186 | 45 | #include "zl10353.h" |
d19770e5 | 46 | |
4513fc69 | 47 | static unsigned int debug; |
d19770e5 | 48 | |
4513fc69 ST |
49 | #define dprintk(level, fmt, arg...)\ |
50 | do { if (debug >= level)\ | |
51 | printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\ | |
52 | } while (0) | |
d19770e5 ST |
53 | |
54 | /* ------------------------------------------------------------------ */ | |
55 | ||
3ba71d21 MK |
56 | static unsigned int alt_tuner; |
57 | module_param(alt_tuner, int, 0644); | |
58 | MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); | |
59 | ||
78e92006 JG |
60 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
61 | ||
3ba71d21 MK |
62 | /* ------------------------------------------------------------------ */ |
63 | ||
d19770e5 ST |
64 | static int dvb_buf_setup(struct videobuf_queue *q, |
65 | unsigned int *count, unsigned int *size) | |
66 | { | |
67 | struct cx23885_tsport *port = q->priv_data; | |
68 | ||
69 | port->ts_packet_size = 188 * 4; | |
70 | port->ts_packet_count = 32; | |
71 | ||
72 | *size = port->ts_packet_size * port->ts_packet_count; | |
73 | *count = 32; | |
74 | return 0; | |
75 | } | |
76 | ||
44a6481d MK |
77 | static int dvb_buf_prepare(struct videobuf_queue *q, |
78 | struct videobuf_buffer *vb, enum v4l2_field field) | |
d19770e5 ST |
79 | { |
80 | struct cx23885_tsport *port = q->priv_data; | |
44a6481d | 81 | return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field); |
d19770e5 ST |
82 | } |
83 | ||
84 | static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | |
85 | { | |
86 | struct cx23885_tsport *port = q->priv_data; | |
87 | cx23885_buf_queue(port, (struct cx23885_buffer*)vb); | |
88 | } | |
89 | ||
44a6481d MK |
90 | static void dvb_buf_release(struct videobuf_queue *q, |
91 | struct videobuf_buffer *vb) | |
d19770e5 ST |
92 | { |
93 | cx23885_free_buffer(q, (struct cx23885_buffer*)vb); | |
94 | } | |
95 | ||
96 | static struct videobuf_queue_ops dvb_qops = { | |
97 | .buf_setup = dvb_buf_setup, | |
98 | .buf_prepare = dvb_buf_prepare, | |
99 | .buf_queue = dvb_buf_queue, | |
100 | .buf_release = dvb_buf_release, | |
101 | }; | |
102 | ||
86184e06 | 103 | static struct s5h1409_config hauppauge_generic_config = { |
fc959bef ST |
104 | .demod_address = 0x32 >> 1, |
105 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
106 | .gpio = S5H1409_GPIO_ON, | |
2b03238a | 107 | .qam_if = 44000, |
fc959bef | 108 | .inversion = S5H1409_INVERSION_OFF, |
dfc1c08a ST |
109 | .status_mode = S5H1409_DEMODLOCKING, |
110 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
fc959bef ST |
111 | }; |
112 | ||
b3ea0166 ST |
113 | static struct tda10048_config hauppauge_hvr1200_config = { |
114 | .demod_address = 0x10 >> 1, | |
115 | .output_mode = TDA10048_SERIAL_OUTPUT, | |
116 | .fwbulkwritelen = TDA10048_BULKWRITE_200, | |
117 | .inversion = TDA10048_INVERSION_ON | |
118 | }; | |
119 | ||
3ba71d21 MK |
120 | static struct s5h1409_config hauppauge_ezqam_config = { |
121 | .demod_address = 0x32 >> 1, | |
122 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
123 | .gpio = S5H1409_GPIO_OFF, | |
124 | .qam_if = 4000, | |
125 | .inversion = S5H1409_INVERSION_ON, | |
dfc1c08a ST |
126 | .status_mode = S5H1409_DEMODLOCKING, |
127 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
3ba71d21 MK |
128 | }; |
129 | ||
fc959bef | 130 | static struct s5h1409_config hauppauge_hvr1800lp_config = { |
d19770e5 ST |
131 | .demod_address = 0x32 >> 1, |
132 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
133 | .gpio = S5H1409_GPIO_OFF, | |
2b03238a | 134 | .qam_if = 44000, |
fe475163 | 135 | .inversion = S5H1409_INVERSION_OFF, |
dfc1c08a ST |
136 | .status_mode = S5H1409_DEMODLOCKING, |
137 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
d19770e5 ST |
138 | }; |
139 | ||
07b4a835 MK |
140 | static struct s5h1409_config hauppauge_hvr1500_config = { |
141 | .demod_address = 0x32 >> 1, | |
142 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
143 | .gpio = S5H1409_GPIO_OFF, | |
144 | .inversion = S5H1409_INVERSION_OFF, | |
dfc1c08a ST |
145 | .status_mode = S5H1409_DEMODLOCKING, |
146 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
07b4a835 MK |
147 | }; |
148 | ||
86184e06 | 149 | static struct mt2131_config hauppauge_generic_tunerconfig = { |
a77743bc ST |
150 | 0x61 |
151 | }; | |
152 | ||
9bc37caa MK |
153 | static struct lgdt330x_config fusionhdtv_5_express = { |
154 | .demod_address = 0x0e, | |
155 | .demod_chip = LGDT3303, | |
156 | .serial_mpeg = 0x40, | |
157 | }; | |
158 | ||
d1987d55 ST |
159 | static struct s5h1409_config hauppauge_hvr1500q_config = { |
160 | .demod_address = 0x32 >> 1, | |
161 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
162 | .gpio = S5H1409_GPIO_ON, | |
163 | .qam_if = 44000, | |
164 | .inversion = S5H1409_INVERSION_OFF, | |
dfc1c08a ST |
165 | .status_mode = S5H1409_DEMODLOCKING, |
166 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
d1987d55 ST |
167 | }; |
168 | ||
335377b7 MK |
169 | static struct s5h1409_config dvico_s5h1409_config = { |
170 | .demod_address = 0x32 >> 1, | |
171 | .output_mode = S5H1409_SERIAL_OUTPUT, | |
172 | .gpio = S5H1409_GPIO_ON, | |
173 | .qam_if = 44000, | |
174 | .inversion = S5H1409_INVERSION_OFF, | |
175 | .status_mode = S5H1409_DEMODLOCKING, | |
176 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
177 | }; | |
178 | ||
52b50450 MK |
179 | static struct s5h1411_config dvico_s5h1411_config = { |
180 | .output_mode = S5H1411_SERIAL_OUTPUT, | |
181 | .gpio = S5H1411_GPIO_ON, | |
182 | .qam_if = S5H1411_IF_44000, | |
183 | .vsb_if = S5H1411_IF_44000, | |
184 | .inversion = S5H1411_INVERSION_OFF, | |
185 | .status_mode = S5H1411_DEMODLOCKING, | |
186 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | |
187 | }; | |
188 | ||
d1987d55 | 189 | static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { |
e12671cf ST |
190 | .i2c_address = 0x61, |
191 | .if_khz = 5380, | |
89ce2216 | 192 | .tuner_callback = cx23885_tuner_callback, |
d1987d55 ST |
193 | }; |
194 | ||
335377b7 MK |
195 | static struct xc5000_config dvico_xc5000_tunerconfig = { |
196 | .i2c_address = 0x64, | |
197 | .if_khz = 5380, | |
89ce2216 | 198 | .tuner_callback = cx23885_tuner_callback, |
335377b7 MK |
199 | }; |
200 | ||
4041f1a5 MK |
201 | static struct tda829x_config tda829x_no_probe = { |
202 | .probe_tuner = TDA829X_DONT_PROBE, | |
203 | }; | |
204 | ||
f21e0d7f | 205 | static struct tda18271_std_map hauppauge_tda18271_std_map = { |
c0dc0c11 MK |
206 | .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, |
207 | .if_lvl = 6, .rfagc_top = 0x37 }, | |
208 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, | |
209 | .if_lvl = 6, .rfagc_top = 0x37 }, | |
f21e0d7f MK |
210 | }; |
211 | ||
212 | static struct tda18271_config hauppauge_tda18271_config = { | |
213 | .std_map = &hauppauge_tda18271_std_map, | |
214 | .gate = TDA18271_GATE_ANALOG, | |
215 | }; | |
216 | ||
b3ea0166 ST |
217 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { |
218 | .gate = TDA18271_GATE_ANALOG, | |
219 | }; | |
220 | ||
b1721d0d | 221 | static struct dibx000_agc_config xc3028_agc_config = { |
66762373 ST |
222 | BAND_VHF | BAND_UHF, /* band_caps */ |
223 | ||
224 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, | |
225 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, | |
226 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, | |
227 | * P_agc_nb_est=2, P_agc_write=0 | |
228 | */ | |
229 | (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | | |
230 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ | |
231 | ||
232 | 712, /* inv_gain */ | |
233 | 21, /* time_stabiliz */ | |
234 | ||
235 | 0, /* alpha_level */ | |
236 | 118, /* thlock */ | |
237 | ||
238 | 0, /* wbd_inv */ | |
239 | 2867, /* wbd_ref */ | |
240 | 0, /* wbd_sel */ | |
241 | 2, /* wbd_alpha */ | |
242 | ||
243 | 0, /* agc1_max */ | |
244 | 0, /* agc1_min */ | |
245 | 39718, /* agc2_max */ | |
246 | 9930, /* agc2_min */ | |
247 | 0, /* agc1_pt1 */ | |
248 | 0, /* agc1_pt2 */ | |
249 | 0, /* agc1_pt3 */ | |
250 | 0, /* agc1_slope1 */ | |
251 | 0, /* agc1_slope2 */ | |
252 | 0, /* agc2_pt1 */ | |
253 | 128, /* agc2_pt2 */ | |
254 | 29, /* agc2_slope1 */ | |
255 | 29, /* agc2_slope2 */ | |
256 | ||
257 | 17, /* alpha_mant */ | |
258 | 27, /* alpha_exp */ | |
259 | 23, /* beta_mant */ | |
260 | 51, /* beta_exp */ | |
261 | ||
262 | 1, /* perform_agc_softsplit */ | |
263 | }; | |
264 | ||
265 | /* PLL Configuration for COFDM BW_MHz = 8.000000 | |
266 | * With external clock = 30.000000 */ | |
b1721d0d | 267 | static struct dibx000_bandwidth_config xc3028_bw_config = { |
66762373 ST |
268 | 60000, /* internal */ |
269 | 30000, /* sampling */ | |
270 | 1, /* pll_cfg: prediv */ | |
271 | 8, /* pll_cfg: ratio */ | |
272 | 3, /* pll_cfg: range */ | |
273 | 1, /* pll_cfg: reset */ | |
274 | 0, /* pll_cfg: bypass */ | |
275 | 0, /* misc: refdiv */ | |
276 | 0, /* misc: bypclk_div */ | |
277 | 1, /* misc: IO_CLK_en_core */ | |
278 | 1, /* misc: ADClkSrc */ | |
279 | 0, /* misc: modulo */ | |
280 | (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ | |
281 | (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ | |
282 | 20452225, /* timf */ | |
283 | 30000000 /* xtal_hz */ | |
284 | }; | |
285 | ||
286 | static struct dib7000p_config hauppauge_hvr1400_dib7000_config = { | |
287 | .output_mpeg2_in_188_bytes = 1, | |
288 | .hostbus_diversity = 1, | |
289 | .tuner_is_baseband = 0, | |
290 | .update_lna = NULL, | |
291 | ||
292 | .agc_config_count = 1, | |
293 | .agc = &xc3028_agc_config, | |
294 | .bw = &xc3028_bw_config, | |
295 | ||
296 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | |
297 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | |
298 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | |
299 | ||
300 | .pwm_freq_div = 0, | |
301 | .agc_control = NULL, | |
302 | .spur_protect = 0, | |
303 | ||
304 | .output_mode = OUTMODE_MPEG2_SERIAL, | |
305 | }; | |
306 | ||
aef2d186 ST |
307 | static struct zl10353_config dvico_fusionhdtv_xc3028 = { |
308 | .demod_address = 0x0f, | |
309 | .if2 = 45600, | |
310 | .no_tuner = 1, | |
311 | }; | |
312 | ||
d19770e5 ST |
313 | static int dvb_register(struct cx23885_tsport *port) |
314 | { | |
315 | struct cx23885_dev *dev = port->dev; | |
f139fa71 | 316 | struct cx23885_i2c *i2c_bus = NULL; |
d19770e5 ST |
317 | |
318 | /* init struct videobuf_dvb */ | |
319 | port->dvb.name = dev->name; | |
320 | ||
321 | /* init frontend */ | |
322 | switch (dev->board) { | |
a77743bc | 323 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
f139fa71 | 324 | i2c_bus = &dev->i2c_bus[0]; |
d19770e5 | 325 | port->dvb.frontend = dvb_attach(s5h1409_attach, |
86184e06 | 326 | &hauppauge_generic_config, |
f139fa71 | 327 | &i2c_bus->i2c_adap); |
d19770e5 | 328 | if (port->dvb.frontend != NULL) { |
44a6481d | 329 | dvb_attach(mt2131_attach, port->dvb.frontend, |
f139fa71 | 330 | &i2c_bus->i2c_adap, |
86184e06 | 331 | &hauppauge_generic_tunerconfig, 0); |
d19770e5 ST |
332 | } |
333 | break; | |
3ba71d21 MK |
334 | case CX23885_BOARD_HAUPPAUGE_HVR1800: |
335 | i2c_bus = &dev->i2c_bus[0]; | |
336 | switch (alt_tuner) { | |
337 | case 1: | |
338 | port->dvb.frontend = | |
339 | dvb_attach(s5h1409_attach, | |
340 | &hauppauge_ezqam_config, | |
341 | &i2c_bus->i2c_adap); | |
342 | if (port->dvb.frontend != NULL) { | |
343 | dvb_attach(tda829x_attach, port->dvb.frontend, | |
344 | &dev->i2c_bus[1].i2c_adap, 0x42, | |
4041f1a5 MK |
345 | &tda829x_no_probe); |
346 | dvb_attach(tda18271_attach, port->dvb.frontend, | |
347 | 0x60, &dev->i2c_bus[1].i2c_adap, | |
f21e0d7f | 348 | &hauppauge_tda18271_config); |
3ba71d21 MK |
349 | } |
350 | break; | |
351 | case 0: | |
352 | default: | |
353 | port->dvb.frontend = | |
354 | dvb_attach(s5h1409_attach, | |
355 | &hauppauge_generic_config, | |
356 | &i2c_bus->i2c_adap); | |
357 | if (port->dvb.frontend != NULL) | |
358 | dvb_attach(mt2131_attach, port->dvb.frontend, | |
359 | &i2c_bus->i2c_adap, | |
360 | &hauppauge_generic_tunerconfig, 0); | |
361 | break; | |
362 | } | |
363 | break; | |
fc959bef | 364 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
f139fa71 | 365 | i2c_bus = &dev->i2c_bus[0]; |
fc959bef ST |
366 | port->dvb.frontend = dvb_attach(s5h1409_attach, |
367 | &hauppauge_hvr1800lp_config, | |
f139fa71 | 368 | &i2c_bus->i2c_adap); |
fc959bef ST |
369 | if (port->dvb.frontend != NULL) { |
370 | dvb_attach(mt2131_attach, port->dvb.frontend, | |
f139fa71 | 371 | &i2c_bus->i2c_adap, |
fc959bef ST |
372 | &hauppauge_generic_tunerconfig, 0); |
373 | } | |
374 | break; | |
9bc37caa | 375 | case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: |
f139fa71 | 376 | i2c_bus = &dev->i2c_bus[0]; |
9bc37caa MK |
377 | port->dvb.frontend = dvb_attach(lgdt330x_attach, |
378 | &fusionhdtv_5_express, | |
f139fa71 | 379 | &i2c_bus->i2c_adap); |
9bc37caa | 380 | if (port->dvb.frontend != NULL) { |
827855d3 MK |
381 | dvb_attach(simple_tuner_attach, port->dvb.frontend, |
382 | &i2c_bus->i2c_adap, 0x61, | |
383 | TUNER_LG_TDVS_H06XF); | |
9bc37caa MK |
384 | } |
385 | break; | |
d1987d55 ST |
386 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
387 | i2c_bus = &dev->i2c_bus[1]; | |
388 | port->dvb.frontend = dvb_attach(s5h1409_attach, | |
389 | &hauppauge_hvr1500q_config, | |
390 | &dev->i2c_bus[0].i2c_adap); | |
48723543 | 391 | if (port->dvb.frontend != NULL) |
d1987d55 ST |
392 | dvb_attach(xc5000_attach, port->dvb.frontend, |
393 | &i2c_bus->i2c_adap, | |
89ce2216 | 394 | &hauppauge_hvr1500q_tunerconfig, port); |
d1987d55 | 395 | break; |
07b4a835 MK |
396 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
397 | i2c_bus = &dev->i2c_bus[1]; | |
398 | port->dvb.frontend = dvb_attach(s5h1409_attach, | |
399 | &hauppauge_hvr1500_config, | |
400 | &dev->i2c_bus[0].i2c_adap); | |
401 | if (port->dvb.frontend != NULL) { | |
402 | struct dvb_frontend *fe; | |
403 | struct xc2028_config cfg = { | |
404 | .i2c_adap = &i2c_bus->i2c_adap, | |
405 | .i2c_addr = 0x61, | |
89ce2216 ST |
406 | .video_dev = port, |
407 | .callback = cx23885_tuner_callback, | |
07b4a835 MK |
408 | }; |
409 | static struct xc2028_ctrl ctl = { | |
410 | .fname = "xc3028-v27.fw", | |
411 | .max_len = 64, | |
33e53161 | 412 | .scode_table = XC3028_FE_OREN538, |
07b4a835 MK |
413 | }; |
414 | ||
415 | fe = dvb_attach(xc2028_attach, | |
416 | port->dvb.frontend, &cfg); | |
417 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | |
418 | fe->ops.tuner_ops.set_config(fe, &ctl); | |
419 | } | |
420 | break; | |
b3ea0166 | 421 | case CX23885_BOARD_HAUPPAUGE_HVR1200: |
a780a31c | 422 | case CX23885_BOARD_HAUPPAUGE_HVR1700: |
b3ea0166 ST |
423 | i2c_bus = &dev->i2c_bus[0]; |
424 | port->dvb.frontend = dvb_attach(tda10048_attach, | |
425 | &hauppauge_hvr1200_config, | |
426 | &i2c_bus->i2c_adap); | |
427 | if (port->dvb.frontend != NULL) { | |
428 | dvb_attach(tda829x_attach, port->dvb.frontend, | |
429 | &dev->i2c_bus[1].i2c_adap, 0x42, | |
430 | &tda829x_no_probe); | |
431 | dvb_attach(tda18271_attach, port->dvb.frontend, | |
432 | 0x60, &dev->i2c_bus[1].i2c_adap, | |
433 | &hauppauge_hvr1200_tuner_config); | |
434 | } | |
435 | break; | |
66762373 ST |
436 | case CX23885_BOARD_HAUPPAUGE_HVR1400: |
437 | i2c_bus = &dev->i2c_bus[0]; | |
438 | port->dvb.frontend = dvb_attach(dib7000p_attach, | |
439 | &i2c_bus->i2c_adap, | |
440 | 0x12, &hauppauge_hvr1400_dib7000_config); | |
441 | if (port->dvb.frontend != NULL) { | |
442 | struct dvb_frontend *fe; | |
443 | struct xc2028_config cfg = { | |
444 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, | |
445 | .i2c_addr = 0x64, | |
89ce2216 ST |
446 | .video_dev = port, |
447 | .callback = cx23885_tuner_callback, | |
66762373 ST |
448 | }; |
449 | static struct xc2028_ctrl ctl = { | |
450 | .fname = "xc3028L-v36.fw", | |
451 | .max_len = 64, | |
452 | .demod = 5000, | |
453 | .d2633 = 1 | |
454 | }; | |
455 | ||
456 | fe = dvb_attach(xc2028_attach, | |
457 | port->dvb.frontend, &cfg); | |
458 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | |
459 | fe->ops.tuner_ops.set_config(fe, &ctl); | |
460 | } | |
461 | break; | |
335377b7 MK |
462 | case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP: |
463 | i2c_bus = &dev->i2c_bus[port->nr - 1]; | |
464 | ||
465 | port->dvb.frontend = dvb_attach(s5h1409_attach, | |
466 | &dvico_s5h1409_config, | |
467 | &i2c_bus->i2c_adap); | |
52b50450 MK |
468 | if (port->dvb.frontend == NULL) |
469 | port->dvb.frontend = dvb_attach(s5h1411_attach, | |
470 | &dvico_s5h1411_config, | |
471 | &i2c_bus->i2c_adap); | |
335377b7 MK |
472 | if (port->dvb.frontend != NULL) |
473 | dvb_attach(xc5000_attach, port->dvb.frontend, | |
474 | &i2c_bus->i2c_adap, | |
89ce2216 | 475 | &dvico_xc5000_tunerconfig, port); |
335377b7 | 476 | break; |
aef2d186 ST |
477 | case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: { |
478 | i2c_bus = &dev->i2c_bus[port->nr - 1]; | |
479 | ||
480 | port->dvb.frontend = dvb_attach(zl10353_attach, | |
481 | &dvico_fusionhdtv_xc3028, | |
482 | &i2c_bus->i2c_adap); | |
483 | if (port->dvb.frontend != NULL) { | |
484 | struct dvb_frontend *fe; | |
485 | struct xc2028_config cfg = { | |
486 | .i2c_adap = &i2c_bus->i2c_adap, | |
487 | .i2c_addr = 0x61, | |
488 | .video_dev = port, | |
89ce2216 | 489 | .callback = cx23885_tuner_callback, |
aef2d186 ST |
490 | }; |
491 | static struct xc2028_ctrl ctl = { | |
492 | .fname = "xc3028-v27.fw", | |
493 | .max_len = 64, | |
494 | .demod = XC3028_FE_ZARLINK456, | |
495 | }; | |
496 | ||
497 | fe = dvb_attach(xc2028_attach, port->dvb.frontend, | |
498 | &cfg); | |
499 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | |
500 | fe->ops.tuner_ops.set_config(fe, &ctl); | |
501 | } | |
502 | break; | |
503 | } | |
d19770e5 ST |
504 | default: |
505 | printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", | |
506 | dev->name); | |
507 | break; | |
508 | } | |
509 | if (NULL == port->dvb.frontend) { | |
510 | printk("%s: frontend initialization failed\n", dev->name); | |
511 | return -1; | |
512 | } | |
513 | ||
514 | /* Put the analog decoder in standby to keep it quiet */ | |
f139fa71 | 515 | cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); |
d19770e5 | 516 | |
3ba71d21 MK |
517 | if (port->dvb.frontend->ops.analog_ops.standby) |
518 | port->dvb.frontend->ops.analog_ops.standby(port->dvb.frontend); | |
519 | ||
d19770e5 | 520 | /* register everything */ |
44a6481d | 521 | return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, |
78e92006 | 522 | &dev->pci->dev, adapter_nr); |
d19770e5 ST |
523 | } |
524 | ||
525 | int cx23885_dvb_register(struct cx23885_tsport *port) | |
526 | { | |
527 | struct cx23885_dev *dev = port->dev; | |
528 | int err; | |
529 | ||
22b4e64f | 530 | dprintk(1, "%s\n", __func__); |
44a6481d | 531 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
d19770e5 ST |
532 | dev->board, |
533 | dev->name, | |
534 | dev->pci_bus, | |
535 | dev->pci_slot); | |
536 | ||
537 | err = -ENODEV; | |
d19770e5 ST |
538 | |
539 | /* dvb stuff */ | |
540 | printk("%s: cx23885 based dvb card\n", dev->name); | |
0705135e | 541 | videobuf_queue_sg_init(&port->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, |
44a6481d MK |
542 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, |
543 | sizeof(struct cx23885_buffer), port); | |
d19770e5 ST |
544 | err = dvb_register(port); |
545 | if (err != 0) | |
22b4e64f | 546 | printk("%s() dvb_register failed err = %d\n", __func__, err); |
d19770e5 | 547 | |
d19770e5 ST |
548 | return err; |
549 | } | |
550 | ||
551 | int cx23885_dvb_unregister(struct cx23885_tsport *port) | |
552 | { | |
553 | /* dvb */ | |
554 | if(port->dvb.frontend) | |
555 | videobuf_dvb_unregister(&port->dvb); | |
556 | ||
557 | return 0; | |
558 | } | |
44a6481d MK |
559 | |
560 | /* | |
561 | * Local variables: | |
562 | * c-basic-offset: 8 | |
563 | * End: | |
564 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | |
565 | */ |