blob: c14878f74bcc33be88295c5cbee58ac8b694d5e3 [file] [log] [blame]
Steven Tothd19770e2007-03-11 20:44:05 -03001/*
2 * Driver for the Conexant CX23885 PCIe bridge
3 *
Steven Toth6d897612008-09-03 17:12:12 -03004 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
Steven Tothd19770e2007-03-11 20:44:05 -03005 *
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"
Steven Tothd19770e2007-03-11 20:44:05 -030031#include <media/v4l2-common.h>
32
33#include "s5h1409.h"
Michael Krufky52b50452008-07-09 02:18:49 -030034#include "s5h1411.h"
Steven Tothd19770e2007-03-11 20:44:05 -030035#include "mt2131.h"
Michael Krufky3ba71d22007-12-07 01:40:36 -030036#include "tda8290.h"
Michael Krufky4041f1a2007-12-24 04:52:08 -030037#include "tda18271.h"
Michael Krufky9bc37ca2007-09-08 15:17:13 -030038#include "lgdt330x.h"
Steven Tothd1987d52007-12-18 01:57:06 -030039#include "xc5000.h"
Steven Tothb3ea0162008-04-19 01:14:19 -030040#include "tda10048.h"
Michael Krufky07b4a832007-12-18 01:09:11 -030041#include "tuner-xc2028.h"
Michael Krufky827855d2008-04-22 14:46:16 -030042#include "tuner-simple.h"
Steven Toth66762372008-04-22 15:38:26 -030043#include "dib7000p.h"
44#include "dibx000_common.h"
Steven Tothaef2d182008-08-04 21:39:53 -030045#include "zl10353.h"
Steven Tothd19770e2007-03-11 20:44:05 -030046
Steven Toth4513fc692008-01-12 11:36:36 -030047static unsigned int debug;
Steven Tothd19770e2007-03-11 20:44:05 -030048
Steven Toth4513fc692008-01-12 11:36:36 -030049#define dprintk(level, fmt, arg...)\
50 do { if (debug >= level)\
51 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
52 } while (0)
Steven Tothd19770e2007-03-11 20:44:05 -030053
54/* ------------------------------------------------------------------ */
55
Michael Krufky3ba71d22007-12-07 01:40:36 -030056static unsigned int alt_tuner;
57module_param(alt_tuner, int, 0644);
58MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
59
Janne Grunau78e92002008-04-09 19:13:13 -030060DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
61
Michael Krufky3ba71d22007-12-07 01:40:36 -030062/* ------------------------------------------------------------------ */
63
Steven Tothd19770e2007-03-11 20:44:05 -030064static 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
Michael Krufky44a64812007-03-20 23:00:18 -030077static int dvb_buf_prepare(struct videobuf_queue *q,
78 struct videobuf_buffer *vb, enum v4l2_field field)
Steven Tothd19770e2007-03-11 20:44:05 -030079{
80 struct cx23885_tsport *port = q->priv_data;
Michael Krufky44a64812007-03-20 23:00:18 -030081 return cx23885_buf_prepare(q, port, (struct cx23885_buffer*)vb, field);
Steven Tothd19770e2007-03-11 20:44:05 -030082}
83
84static 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
Michael Krufky44a64812007-03-20 23:00:18 -030090static void dvb_buf_release(struct videobuf_queue *q,
91 struct videobuf_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -030092{
93 cx23885_free_buffer(q, (struct cx23885_buffer*)vb);
94}
95
96static 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
Steven Toth86184e02007-09-04 21:40:47 -0300103static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300104 .demod_address = 0x32 >> 1,
105 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300106 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300107 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300108 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300109 .status_mode = S5H1409_DEMODLOCKING,
110 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300111};
112
Steven Tothb3ea0162008-04-19 01:14:19 -0300113static 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
Michael Krufky3ba71d22007-12-07 01:40:36 -0300120static 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,
Steven Tothdfc1c082008-01-15 21:35:22 -0300126 .status_mode = S5H1409_DEMODLOCKING,
127 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300128};
129
Steven Tothfc959be2007-09-08 19:08:17 -0300130static struct s5h1409_config hauppauge_hvr1800lp_config = {
131 .demod_address = 0x32 >> 1,
132 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300133 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300134 .qam_if = 44000,
Steven Tothfe475162007-03-20 15:27:53 -0300135 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300136 .status_mode = S5H1409_DEMODLOCKING,
137 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300138};
139
Michael Krufky07b4a832007-12-18 01:09:11 -0300140static 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,
Steven Tothdfc1c082008-01-15 21:35:22 -0300145 .status_mode = S5H1409_DEMODLOCKING,
146 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300147};
148
Steven Toth86184e02007-09-04 21:40:47 -0300149static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300150 0x61
151};
152
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300153static struct lgdt330x_config fusionhdtv_5_express = {
154 .demod_address = 0x0e,
155 .demod_chip = LGDT3303,
156 .serial_mpeg = 0x40,
157};
158
Steven Tothd1987d52007-12-18 01:57:06 -0300159static 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,
Steven Tothdfc1c082008-01-15 21:35:22 -0300165 .status_mode = S5H1409_DEMODLOCKING,
166 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300167};
168
Michael Krufky335377b2008-05-07 01:43:10 -0300169static 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
Michael Krufky52b50452008-07-09 02:18:49 -0300179static 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
Steven Tothd1987d52007-12-18 01:57:06 -0300189static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300190 .i2c_address = 0x61,
191 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300192};
193
Michael Krufky335377b2008-05-07 01:43:10 -0300194static struct xc5000_config dvico_xc5000_tunerconfig = {
195 .i2c_address = 0x64,
196 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300197};
198
Michael Krufky4041f1a2007-12-24 04:52:08 -0300199static struct tda829x_config tda829x_no_probe = {
200 .probe_tuner = TDA829X_DONT_PROBE,
201};
202
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300203static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300204 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
205 .if_lvl = 6, .rfagc_top = 0x37 },
206 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
207 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300208};
209
210static struct tda18271_config hauppauge_tda18271_config = {
211 .std_map = &hauppauge_tda18271_std_map,
212 .gate = TDA18271_GATE_ANALOG,
213};
214
Steven Tothb3ea0162008-04-19 01:14:19 -0300215static struct tda18271_config hauppauge_hvr1200_tuner_config = {
216 .gate = TDA18271_GATE_ANALOG,
217};
218
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700219static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300220 BAND_VHF | BAND_UHF, /* band_caps */
221
222 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
223 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
224 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
225 * P_agc_nb_est=2, P_agc_write=0
226 */
227 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
228 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
229
230 712, /* inv_gain */
231 21, /* time_stabiliz */
232
233 0, /* alpha_level */
234 118, /* thlock */
235
236 0, /* wbd_inv */
237 2867, /* wbd_ref */
238 0, /* wbd_sel */
239 2, /* wbd_alpha */
240
241 0, /* agc1_max */
242 0, /* agc1_min */
243 39718, /* agc2_max */
244 9930, /* agc2_min */
245 0, /* agc1_pt1 */
246 0, /* agc1_pt2 */
247 0, /* agc1_pt3 */
248 0, /* agc1_slope1 */
249 0, /* agc1_slope2 */
250 0, /* agc2_pt1 */
251 128, /* agc2_pt2 */
252 29, /* agc2_slope1 */
253 29, /* agc2_slope2 */
254
255 17, /* alpha_mant */
256 27, /* alpha_exp */
257 23, /* beta_mant */
258 51, /* beta_exp */
259
260 1, /* perform_agc_softsplit */
261};
262
263/* PLL Configuration for COFDM BW_MHz = 8.000000
264 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700265static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300266 60000, /* internal */
267 30000, /* sampling */
268 1, /* pll_cfg: prediv */
269 8, /* pll_cfg: ratio */
270 3, /* pll_cfg: range */
271 1, /* pll_cfg: reset */
272 0, /* pll_cfg: bypass */
273 0, /* misc: refdiv */
274 0, /* misc: bypclk_div */
275 1, /* misc: IO_CLK_en_core */
276 1, /* misc: ADClkSrc */
277 0, /* misc: modulo */
278 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
279 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
280 20452225, /* timf */
281 30000000 /* xtal_hz */
282};
283
284static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
285 .output_mpeg2_in_188_bytes = 1,
286 .hostbus_diversity = 1,
287 .tuner_is_baseband = 0,
288 .update_lna = NULL,
289
290 .agc_config_count = 1,
291 .agc = &xc3028_agc_config,
292 .bw = &xc3028_bw_config,
293
294 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
295 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
296 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
297
298 .pwm_freq_div = 0,
299 .agc_control = NULL,
300 .spur_protect = 0,
301
302 .output_mode = OUTMODE_MPEG2_SERIAL,
303};
304
Steven Tothaef2d182008-08-04 21:39:53 -0300305static struct zl10353_config dvico_fusionhdtv_xc3028 = {
306 .demod_address = 0x0f,
307 .if2 = 45600,
308 .no_tuner = 1,
309};
310
Steven Tothd19770e2007-03-11 20:44:05 -0300311static int dvb_register(struct cx23885_tsport *port)
312{
313 struct cx23885_dev *dev = port->dev;
Michael Krufkyf139fa72007-09-09 03:55:34 -0300314 struct cx23885_i2c *i2c_bus = NULL;
Steven Toth363c35f2008-10-11 11:05:50 -0300315 struct videobuf_dvb_frontend *fe0;
316
Darron Broadf972e0b2008-10-11 11:24:30 -0300317 /* FIXME: add support for multi-frontend */
318 mutex_init(&port->frontends.lock);
319 INIT_LIST_HEAD(&port->frontends.frontend.felist);
320 port->frontends.active_fe_id = 0;
321
322 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
323
324 if (videobuf_dvb_alloc_frontend(dev, &port->frontends, 1) == NULL) {
325 printk(KERN_ERR "%s() failed to alloc\n", __func__);
326 return -ENOMEM;
327 }
328
329 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300330 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300331 if (!fe0)
332 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300333
334 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300335 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300336
337 /* init frontend */
338 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300339 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300340 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300341 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300342 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300343 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300344 if (fe0->dvb.frontend != NULL) {
345 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300346 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300347 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300348 }
349 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300350 case CX23885_BOARD_HAUPPAUGE_HVR1800:
351 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300352 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300353 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300354 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300355 dvb_attach(s5h1409_attach,
356 &hauppauge_ezqam_config,
357 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300358 if (fe0->dvb.frontend != NULL) {
359 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300360 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300361 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300362 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300363 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300364 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300365 }
366 break;
367 case 0:
368 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300369 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300370 dvb_attach(s5h1409_attach,
371 &hauppauge_generic_config,
372 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300373 if (fe0->dvb.frontend != NULL)
374 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300375 &i2c_bus->i2c_adap,
376 &hauppauge_generic_tunerconfig, 0);
377 break;
378 }
379 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300380 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300381 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300382 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300383 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300384 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300385 if (fe0->dvb.frontend != NULL) {
386 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300387 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300388 &hauppauge_generic_tunerconfig, 0);
389 }
390 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300391 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300392 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300393 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300394 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300395 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300396 if (fe0->dvb.frontend != NULL) {
397 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300398 &i2c_bus->i2c_adap, 0x61,
399 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300400 }
401 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300402 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
403 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300404 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300405 &hauppauge_hvr1500q_config,
406 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300407 if (fe0->dvb.frontend != NULL)
408 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300409 &i2c_bus->i2c_adap,
410 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300411 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300412 case CX23885_BOARD_HAUPPAUGE_HVR1500:
413 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300414 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300415 &hauppauge_hvr1500_config,
416 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300417 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300418 struct dvb_frontend *fe;
419 struct xc2028_config cfg = {
420 .i2c_adap = &i2c_bus->i2c_adap,
421 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300422 };
423 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300424 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300425 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -0300426 .scode_table = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300427 };
428
429 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300430 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300431 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
432 fe->ops.tuner_ops.set_config(fe, &ctl);
433 }
434 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300435 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300436 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300437 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300438 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300439 &hauppauge_hvr1200_config,
440 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300441 if (fe0->dvb.frontend != NULL) {
442 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300443 &dev->i2c_bus[1].i2c_adap, 0x42,
444 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300445 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300446 0x60, &dev->i2c_bus[1].i2c_adap,
447 &hauppauge_hvr1200_tuner_config);
448 }
449 break;
Steven Toth66762372008-04-22 15:38:26 -0300450 case CX23885_BOARD_HAUPPAUGE_HVR1400:
451 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300452 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300453 &i2c_bus->i2c_adap,
454 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300455 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300456 struct dvb_frontend *fe;
457 struct xc2028_config cfg = {
458 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
459 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300460 };
461 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300462 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300463 .max_len = 64,
464 .demod = 5000,
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300465 /* This is true for all demods with v36 firmware? */
466 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300467 };
468
469 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300470 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300471 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
472 fe->ops.tuner_ops.set_config(fe, &ctl);
473 }
474 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300475 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
476 i2c_bus = &dev->i2c_bus[port->nr - 1];
477
Steven Toth363c35f2008-10-11 11:05:50 -0300478 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300479 &dvico_s5h1409_config,
480 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300481 if (fe0->dvb.frontend == NULL)
482 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300483 &dvico_s5h1411_config,
484 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300485 if (fe0->dvb.frontend != NULL)
486 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300487 &i2c_bus->i2c_adap,
488 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300489 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300490 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
491 i2c_bus = &dev->i2c_bus[port->nr - 1];
492
Steven Toth363c35f2008-10-11 11:05:50 -0300493 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300494 &dvico_fusionhdtv_xc3028,
495 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300496 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300497 struct dvb_frontend *fe;
498 struct xc2028_config cfg = {
499 .i2c_adap = &i2c_bus->i2c_adap,
500 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300501 };
502 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300503 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300504 .max_len = 64,
505 .demod = XC3028_FE_ZARLINK456,
506 };
507
Steven Toth363c35f2008-10-11 11:05:50 -0300508 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300509 &cfg);
510 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
511 fe->ops.tuner_ops.set_config(fe, &ctl);
512 }
513 break;
514 }
Steven Toth4c56b042008-08-12 13:30:03 -0300515 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
516 i2c_bus = &dev->i2c_bus[0];
517
Steven Toth363c35f2008-10-11 11:05:50 -0300518 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300519 &dvico_fusionhdtv_xc3028,
520 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300521 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300522 struct dvb_frontend *fe;
523 struct xc2028_config cfg = {
524 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
525 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300526 };
527 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300528 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300529 .max_len = 64,
530 .demod = XC3028_FE_ZARLINK456,
531 };
532
Steven Toth363c35f2008-10-11 11:05:50 -0300533 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300534 &cfg);
535 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
536 fe->ops.tuner_ops.set_config(fe, &ctl);
537 }
538 break;
Steven Tothd19770e2007-03-11 20:44:05 -0300539 default:
540 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
541 dev->name);
542 break;
543 }
Steven Toth363c35f2008-10-11 11:05:50 -0300544 if (NULL == fe0->dvb.frontend) {
Steven Tothd19770e2007-03-11 20:44:05 -0300545 printk("%s: frontend initialization failed\n", dev->name);
546 return -1;
547 }
Michael Krufkyd7cba042008-09-12 13:31:45 -0300548 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -0300549 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Steven Tothd19770e2007-03-11 20:44:05 -0300550
551 /* Put the analog decoder in standby to keep it quiet */
Michael Krufkyf139fa72007-09-09 03:55:34 -0300552 cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL);
Steven Tothd19770e2007-03-11 20:44:05 -0300553
Steven Toth363c35f2008-10-11 11:05:50 -0300554 if (fe0->dvb.frontend->ops.analog_ops.standby)
555 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300556
Steven Tothd19770e2007-03-11 20:44:05 -0300557 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -0300558 return videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Janne Grunau78e92002008-04-09 19:13:13 -0300559 &dev->pci->dev, adapter_nr);
Steven Toth363c35f2008-10-11 11:05:50 -0300560
Steven Tothd19770e2007-03-11 20:44:05 -0300561}
562
563int cx23885_dvb_register(struct cx23885_tsport *port)
564{
Steven Toth363c35f2008-10-11 11:05:50 -0300565
566 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -0300567 struct cx23885_dev *dev = port->dev;
568 int err;
569
Darron Broad92abe9e2008-10-11 11:18:53 -0300570 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300571 if (!fe0)
572 err = -EINVAL;
573
Harvey Harrison22b4e642008-04-08 23:20:00 -0300574 dprintk(1, "%s\n", __func__);
Michael Krufky44a64812007-03-20 23:00:18 -0300575 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Tothd19770e2007-03-11 20:44:05 -0300576 dev->board,
577 dev->name,
578 dev->pci_bus,
579 dev->pci_slot);
580
581 err = -ENODEV;
Steven Tothd19770e2007-03-11 20:44:05 -0300582
583 /* dvb stuff */
584 printk("%s: cx23885 based dvb card\n", dev->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300585 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -0300586 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
587 sizeof(struct cx23885_buffer), port);
Steven Tothd19770e2007-03-11 20:44:05 -0300588 err = dvb_register(port);
589 if (err != 0)
Harvey Harrison22b4e642008-04-08 23:20:00 -0300590 printk("%s() dvb_register failed err = %d\n", __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -0300591
Steven Tothd19770e2007-03-11 20:44:05 -0300592 return err;
593}
594
595int cx23885_dvb_unregister(struct cx23885_tsport *port)
596{
Steven Toth363c35f2008-10-11 11:05:50 -0300597 struct videobuf_dvb_frontend *fe0;
598
Darron Broad92abe9e2008-10-11 11:18:53 -0300599 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Tothd19770e2007-03-11 20:44:05 -0300600 /* dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300601 if(fe0->dvb.frontend)
602 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -0300603
604 return 0;
605}
Michael Krufky44a64812007-03-20 23:00:18 -0300606
607/*
608 * Local variables:
609 * c-basic-offset: 8
610 * End:
611 * 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
612*/