blob: 694002a7dfc2fc8b7b4d4fda205b9e7e80269502 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
38#ifdef HAVE_VP3054_I2C
39# include "cx88-vp3054-i2c.h"
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070040#endif
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030041#include "zl10353.h"
42#include "cx22702.h"
43#include "or51132.h"
44#include "lgdt330x.h"
Michael Krufky76db93d2006-11-19 19:45:26 -030045#include "lgh06xf.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030046#include "nxt200x.h"
47#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030048#include "isl6421.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
51MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
52MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53MODULE_LICENSE("GPL");
54
55static unsigned int debug = 0;
56module_param(debug, int, 0644);
57MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
58
59#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020060 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62/* ------------------------------------------------------------------ */
63
64static int dvb_buf_setup(struct videobuf_queue *q,
65 unsigned int *count, unsigned int *size)
66{
67 struct cx8802_dev *dev = q->priv_data;
68
69 dev->ts_packet_size = 188 * 4;
70 dev->ts_packet_count = 32;
71
72 *size = dev->ts_packet_size * dev->ts_packet_count;
73 *count = 32;
74 return 0;
75}
76
77static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
78 enum v4l2_field field)
79{
80 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030081 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082}
83
84static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
85{
86 struct cx8802_dev *dev = q->priv_data;
87 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
88}
89
90static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
91{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030092 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Adrian Bunk408b6642005-05-01 08:59:29 -070095static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 .buf_setup = dvb_buf_setup,
97 .buf_prepare = dvb_buf_prepare,
98 .buf_queue = dvb_buf_queue,
99 .buf_release = dvb_buf_release,
100};
101
102/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300103
104static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
105{
106 struct cx8802_dev *dev= fe->dvb->priv;
107 struct cx8802_driver *drv = NULL;
108 int ret = 0;
109
110 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
111 if (drv) {
112 if(acquire)
113 ret = drv->request_acquire(drv);
114 else
115 ret = drv->request_release(drv);
116 }
117
118 return ret;
119}
120
121/* ------------------------------------------------------------------ */
122
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200123static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
125 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
126 static u8 reset [] = { RESET, 0x80 };
127 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
128 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
129 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
130 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
131
132 mt352_write(fe, clock_config, sizeof(clock_config));
133 udelay(200);
134 mt352_write(fe, reset, sizeof(reset));
135 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
136
137 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
138 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 return 0;
141}
142
Chris Pascoe43eabb42006-01-09 18:21:28 -0200143static int dvico_dual_demod_init(struct dvb_frontend *fe)
144{
145 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
146 static u8 reset [] = { RESET, 0x80 };
147 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
148 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
149 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
150 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
151
152 mt352_write(fe, clock_config, sizeof(clock_config));
153 udelay(200);
154 mt352_write(fe, reset, sizeof(reset));
155 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
156
157 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
158 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
159 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
160
161 return 0;
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
165{
166 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
167 static u8 reset [] = { 0x50, 0x80 };
168 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
169 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800170 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 static u8 dntv_extra[] = { 0xB5, 0x7A };
172 static u8 capt_range_cfg[] = { 0x75, 0x32 };
173
174 mt352_write(fe, clock_config, sizeof(clock_config));
175 udelay(2000);
176 mt352_write(fe, reset, sizeof(reset));
177 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
178
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 udelay(2000);
181 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
182 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
183
184 return 0;
185}
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300188 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200189 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190};
191
192static struct mt352_config dntv_live_dvbt_config = {
193 .demod_address = 0x0f,
194 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195};
Chris Pascoefc40b262006-01-09 15:25:35 -0200196
Chris Pascoe43eabb42006-01-09 18:21:28 -0200197static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300198 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200199 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200200};
201
Chris Pascoefc40b262006-01-09 15:25:35 -0200202#ifdef HAVE_VP3054_I2C
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200203static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
204{
205 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
206 static u8 reset [] = { 0x50, 0x80 };
207 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
208 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
209 0x00, 0xFF, 0x00, 0x40, 0x40 };
210 static u8 dntv_extra[] = { 0xB5, 0x7A };
211 static u8 capt_range_cfg[] = { 0x75, 0x32 };
212
213 mt352_write(fe, clock_config, sizeof(clock_config));
214 udelay(2000);
215 mt352_write(fe, reset, sizeof(reset));
216 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
217
218 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
219 udelay(2000);
220 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
221 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
222
223 return 0;
224}
225
Chris Pascoefc40b262006-01-09 15:25:35 -0200226static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
227{
228 struct cx8802_dev *dev= fe->dvb->priv;
229
230 /* this message is to set up ATC and ALC */
231 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
232 struct i2c_msg msg =
233 { .addr = dev->core->pll_addr, .flags = 0,
234 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
235 int err;
236
Patrick Boettcherdea74862006-05-14 05:01:31 -0300237 if (fe->ops.i2c_gate_ctrl)
238 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200239 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
240 if (err < 0)
241 return err;
242 else
243 return -EREMOTEIO;
244 }
245
246 return 0;
247}
248
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300249static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
250 struct dvb_frontend_parameters* params)
Chris Pascoefc40b262006-01-09 15:25:35 -0200251{
252 struct cx8802_dev *dev= fe->dvb->priv;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300253 u8 buf[4];
Chris Pascoefc40b262006-01-09 15:25:35 -0200254 struct i2c_msg msg =
255 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300256 .buf = buf, .len = 4 };
Chris Pascoefc40b262006-01-09 15:25:35 -0200257 int err;
258
259 /* Switch PLL to DVB mode */
260 err = philips_fmd1216_pll_init(fe);
261 if (err)
262 return err;
263
264 /* Tune PLL */
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300265 dvb_pll_configure(dev->core->pll_desc, buf,
Chris Pascoefc40b262006-01-09 15:25:35 -0200266 params->frequency,
267 params->u.ofdm.bandwidth);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300268 if (fe->ops.i2c_gate_ctrl)
269 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200270 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300271
Chris Pascoefc40b262006-01-09 15:25:35 -0200272 printk(KERN_WARNING "cx88-dvb: %s error "
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300273 "(addr %02x <- %02x, err = %i)\n",
274 __FUNCTION__, dev->core->pll_addr, buf[0], err);
Chris Pascoefc40b262006-01-09 15:25:35 -0200275 if (err < 0)
276 return err;
277 else
278 return -EREMOTEIO;
279 }
280
281 return 0;
282}
283
284static struct mt352_config dntv_live_dvbt_pro_config = {
285 .demod_address = 0x0f,
286 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200287 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200288};
289#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Chris Pascoe780dfef2006-02-28 08:34:59 -0300291static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300292 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300293 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300294};
295
296static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300297 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300298};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300299
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300static struct cx22702_config connexant_refboard_config = {
301 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700302 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303};
304
Michael Krufkyed355262006-12-05 01:34:56 -0300305static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300306 .demod_address = 0x63,
307 .output_mode = CX22702_SERIAL_OUTPUT,
308};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310static int or51132_set_ts_param(struct dvb_frontend* fe,
311 int is_punctured)
312{
313 struct cx8802_dev *dev= fe->dvb->priv;
314 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
315 return 0;
316}
317
Adrian Bunk408b6642005-05-01 08:59:29 -0700318static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300319 .demod_address = 0x15,
320 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Michael Krufky6ddcc912005-07-27 11:46:00 -0700323static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700324{
325 struct cx8802_dev *dev= fe->dvb->priv;
326 struct cx88_core *core = dev->core;
327
328 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
329 if (index == 0)
330 cx_clear(MO_GP0_IO, 8);
331 else
332 cx_set(MO_GP0_IO, 8);
333 return 0;
334}
335
Michael Krufky6ddcc912005-07-27 11:46:00 -0700336static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700337{
338 struct cx8802_dev *dev= fe->dvb->priv;
339 if (is_punctured)
340 dev->ts_gen_cntrl |= 0x04;
341 else
342 dev->ts_gen_cntrl &= ~0x04;
343 return 0;
344}
345
Michael Krufky6ddcc912005-07-27 11:46:00 -0700346static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300347 .demod_address = 0x0e,
348 .demod_chip = LGDT3302,
349 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
350 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700351};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700352
353static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300354 .demod_address = 0x0e,
355 .demod_chip = LGDT3303,
356 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
357 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700358};
Rusty Scottda215d22006-04-07 02:21:31 -0300359
360static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300361 .demod_address = 0x59,
362 .demod_chip = LGDT3303,
363 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
364 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300365};
Michael Krufkyf1798492005-07-07 17:58:39 -0700366
Kirk Laprayfde6d312005-11-08 21:38:18 -0800367static int nxt200x_set_ts_param(struct dvb_frontend* fe,
368 int is_punctured)
369{
370 struct cx8802_dev *dev= fe->dvb->priv;
371 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
372 return 0;
373}
374
Kirk Laprayd4c34aa2005-11-08 21:38:40 -0800375static int nxt200x_set_pll_input(u8* buf, int input)
376{
377 if (input)
378 buf[3] |= 0x08;
379 else
380 buf[3] &= ~0x08;
381 return 0;
382}
383
Kirk Laprayfde6d312005-11-08 21:38:18 -0800384static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300385 .demod_address = 0x0a,
386 .set_pll_input = nxt200x_set_pll_input,
387 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800388};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800389
Steven Toth0fa14aa2006-01-09 15:25:02 -0200390static int cx24123_set_ts_param(struct dvb_frontend* fe,
391 int is_punctured)
392{
393 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300394 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200395 return 0;
396}
397
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300398static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
399 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200400{
401 struct cx8802_dev *dev= fe->dvb->priv;
402 struct cx88_core *core = dev->core;
403
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300404 if (voltage == SEC_VOLTAGE_OFF) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300405 cx_write(MO_GP0_IO, 0x000006fb);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300406 } else {
407 cx_write(MO_GP0_IO, 0x000006f9);
408 }
409
410 if (core->prev_set_voltage)
411 return core->prev_set_voltage(fe, voltage);
412 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200413}
414
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300415static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
416 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300417{
418 struct cx8802_dev *dev= fe->dvb->priv;
419 struct cx88_core *core = dev->core;
420
421 if (voltage == SEC_VOLTAGE_OFF) {
422 dprintk(1,"LNB Voltage OFF\n");
423 cx_write(MO_GP0_IO, 0x0000efff);
424 }
425
426 if (core->prev_set_voltage)
427 return core->prev_set_voltage(fe, voltage);
428 return 0;
429}
430
431static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300432 .demod_address = 0x55,
433 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300434};
435
Steven Toth0fa14aa2006-01-09 15:25:02 -0200436static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300437 .demod_address = 0x55,
438 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200439};
440
441static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300442 .demod_address = 0x15,
443 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300444 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200445};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200446
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447static int dvb_register(struct cx8802_dev *dev)
448{
449 /* init struct videobuf_dvb */
450 dev->dvb.name = dev->core->name;
451 dev->ts_gen_cntrl = 0x0c;
452
453 /* init frontend */
454 switch (dev->core->board) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300456 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300457 &connexant_refboard_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300458 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300459 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300460 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300461 &dev->core->i2c_adap,
462 &dvb_pll_thomson_dtt759x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300463 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700465 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200467 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800468 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300469 dev->dvb.frontend = dvb_attach(cx22702_attach,
470 &connexant_refboard_config,
471 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300472 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300473 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300474 &dev->core->i2c_adap,
475 &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300478 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200479 case CX88_BOARD_HAUPPAUGE_HVR1100:
480 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300481 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300482 &hauppauge_hvr_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300483 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300484 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300485 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300486 &dev->core->i2c_adap,
487 &dvb_pll_fmd1216me);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300488 }
Steven Toth611900c2006-01-09 15:25:12 -0200489 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300490 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300491 dev->dvb.frontend = dvb_attach(mt352_attach,
492 &dvico_fusionhdtv,
493 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300494 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300495 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300496 NULL, &dvb_pll_thomson_dtt7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300497 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300498 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300499 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300500 dev->dvb.frontend = dvb_attach(zl10353_attach,
501 &dvico_fusionhdtv_plus_v1_1,
502 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300503 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300504 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300505 NULL, &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300506 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300507 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300508 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300509 /* The tin box says DEE1601, but it seems to be DTT7579
510 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300511 dev->dvb.frontend = dvb_attach(mt352_attach,
512 &dvico_fusionhdtv_dual,
513 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300514 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300515 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300516 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300517 break;
518 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300519 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300520 dev->dvb.frontend = dvb_attach(zl10353_attach,
521 &dvico_fusionhdtv_plus_v1_1,
522 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300523 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300524 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300525 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300526 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300527 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300529 dev->dvb.frontend = dvb_attach(mt352_attach,
530 &dvico_fusionhdtv,
531 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300532 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300533 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300534 NULL, &dvb_pll_lg_z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300535 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 case CX88_BOARD_KWORLD_DVB_T:
538 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700539 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300540 dev->dvb.frontend = dvb_attach(mt352_attach,
541 &dntv_live_dvbt_config,
542 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300543 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300544 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300545 NULL, &dvb_pll_unknown_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300546 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200548 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
549#ifdef HAVE_VP3054_I2C
550 dev->core->pll_addr = 0x61;
551 dev->core->pll_desc = &dvb_pll_fmd1216me;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300552 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Chris Pascoefc40b262006-01-09 15:25:35 -0200553 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300554 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300555 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300556 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200557#else
558 printk("%s: built without vp3054 support\n", dev->core->name);
559#endif
560 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300561 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300562 dev->dvb.frontend = dvb_attach(zl10353_attach,
563 &dvico_fusionhdtv_hybrid,
564 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300565 if (dev->dvb.frontend != NULL) {
Michael Krufky5786a342006-12-05 01:21:19 -0300566 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
567 &dev->core->i2c_adap,
568 &dvb_pll_thomson_fe6600);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300569 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300570 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300572 dev->dvb.frontend = dvb_attach(or51132_attach,
573 &pchdtv_hd3000,
574 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300575 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300576 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300577 &dev->core->i2c_adap,
578 &dvb_pll_thomson_dtt761x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300579 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700581 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
582 dev->ts_gen_cntrl = 0x08;
583 {
584 /* Do a hardware reset of chip before using it. */
585 struct cx88_core *core = dev->core;
586
587 cx_clear(MO_GP0_IO, 1);
588 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700589 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700590 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700591
592 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700593 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300594 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
595 &fusionhdtv_3_gold,
596 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300597 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300598 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
599 &dev->core->i2c_adap,
600 &dvb_pll_microtune_4042);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300601 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700602 }
603 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700604 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
605 dev->ts_gen_cntrl = 0x08;
606 {
607 /* Do a hardware reset of chip before using it. */
608 struct cx88_core *core = dev->core;
609
610 cx_clear(MO_GP0_IO, 1);
611 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700612 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700613 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300614 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
615 &fusionhdtv_3_gold,
616 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300617 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300618 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
619 &dev->core->i2c_adap,
620 &dvb_pll_thomson_dtt761x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300621 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700622 }
623 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700624 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
625 dev->ts_gen_cntrl = 0x08;
626 {
627 /* Do a hardware reset of chip before using it. */
628 struct cx88_core *core = dev->core;
629
630 cx_clear(MO_GP0_IO, 1);
631 mdelay(100);
632 cx_set(MO_GP0_IO, 1);
633 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300634 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
635 &fusionhdtv_5_gold,
636 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300637 if (dev->dvb.frontend != NULL) {
Michael Krufky76db93d2006-11-19 19:45:26 -0300638 dvb_attach(lgh06xf_attach, dev->dvb.frontend,
639 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300640 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700641 }
642 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300643 case CX88_BOARD_PCHDTV_HD5500:
644 dev->ts_gen_cntrl = 0x08;
645 {
646 /* Do a hardware reset of chip before using it. */
647 struct cx88_core *core = dev->core;
648
649 cx_clear(MO_GP0_IO, 1);
650 mdelay(100);
651 cx_set(MO_GP0_IO, 1);
652 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300653 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
654 &pchdtv_hd5500,
655 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300656 if (dev->dvb.frontend != NULL) {
Michael Krufky76db93d2006-11-19 19:45:26 -0300657 dvb_attach(lgh06xf_attach, dev->dvb.frontend,
658 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300659 }
Rusty Scottda215d22006-04-07 02:21:31 -0300660 }
661 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800662 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300663 dev->dvb.frontend = dvb_attach(nxt200x_attach,
664 &ati_hdtvwonder,
665 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300666 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300667 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4ad8eee52006-08-08 15:48:08 -0300668 NULL, &dvb_pll_tuv1236d);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300669 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800670 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200671 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
672 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300673 dev->dvb.frontend = dvb_attach(cx24123_attach,
674 &hauppauge_novas_config,
675 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300676 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300677 dvb_attach(isl6421_attach, dev->dvb.frontend,
678 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300679 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200680 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200681 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300682 dev->dvb.frontend = dvb_attach(cx24123_attach,
683 &kworld_dvbs_100_config,
684 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300685 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300686 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
687 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300688 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200689 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300690 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300691 dev->dvb.frontend = dvb_attach(cx24123_attach,
692 &geniatech_dvbs_config,
693 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300694 if (dev->dvb.frontend) {
695 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
696 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
697 }
698 break;
Steven Toth6c5be742006-12-02 21:15:51 -0200699 case CX88_BOARD_HAUPPAUGE_HVR1300:
700 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300701 &hauppauge_hvr_config,
Steven Toth6c5be742006-12-02 21:15:51 -0200702 &dev->core->i2c_adap);
703 if (dev->dvb.frontend != NULL) {
704 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
705 &dev->core->i2c_adap,
706 &dvb_pll_fmd1216me);
707 }
708 break;
709 case CX88_BOARD_HAUPPAUGE_HVR3000:
710 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300711 &hauppauge_hvr_config,
Steven Toth6c5be742006-12-02 21:15:51 -0200712 &dev->core->i2c_adap);
713 if (dev->dvb.frontend != NULL) {
714 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
715 &dev->core->i2c_adap,
716 &dvb_pll_fmd1216me);
717 }
718 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 default:
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700720 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
721 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 break;
723 }
724 if (NULL == dev->dvb.frontend) {
725 printk("%s: frontend initialization failed\n",dev->core->name);
726 return -1;
727 }
728
729 if (dev->core->pll_desc) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300730 dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min;
731 dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 }
Steven Toth6c5be742006-12-02 21:15:51 -0200733 /* Ensure all frontends negotiate bus access */
734 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700736 /* Put the analog decoder in standby to keep it quiet */
737 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300740 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741}
742
743/* ----------------------------------------------------------- */
744
Steven Toth6c5be742006-12-02 21:15:51 -0200745/* CX8802 MPEG -> mini driver - We have been given the hardware */
746static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747{
Steven Toth6c5be742006-12-02 21:15:51 -0200748 struct cx88_core *core = drv->core;
749 int err = 0;
750 dprintk( 1, "%s\n", __FUNCTION__);
751
752 switch (core->board) {
753 case CX88_BOARD_HAUPPAUGE_HVR1300:
754 /* We arrive here with either the cx23416 or the cx22702
755 * on the bus. Take the bus from the cx23416 and enable the
756 * cx22702 demod
757 */
758 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
759 cx_clear(MO_GP0_IO, 0x00000004);
760 udelay(1000);
761 break;
762 default:
763 err = -ENODEV;
764 }
765 return err;
766}
767
768/* CX8802 MPEG -> mini driver - We no longer have the hardware */
769static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
770{
771 struct cx88_core *core = drv->core;
772 int err = 0;
773 dprintk( 1, "%s\n", __FUNCTION__);
774
775 switch (core->board) {
776 case CX88_BOARD_HAUPPAUGE_HVR1300:
777 /* Do Nothing, leave the cx22702 on the bus. */
778 break;
779 default:
780 err = -ENODEV;
781 }
782 return err;
783}
784
785static int cx8802_dvb_probe(struct cx8802_driver *drv)
786{
787 struct cx88_core *core = drv->core;
788 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 int err;
790
Steven Toth6c5be742006-12-02 21:15:51 -0200791 dprintk( 1, "%s\n", __FUNCTION__);
792 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
793 core->board,
794 core->name,
795 core->pci_bus,
796 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797
798 err = -ENODEV;
Michael Krufky48d5e802006-09-25 14:09:10 -0300799 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 goto fail_core;
801
Chris Pascoefc40b262006-01-09 15:25:35 -0200802#ifdef HAVE_VP3054_I2C
803 err = vp3054_i2c_probe(dev);
804 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200805 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200806#endif
807
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 /* dvb stuff */
809 printk("%s/2: cx2388x based dvb card\n", core->name);
810 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
811 dev->pci, &dev->slock,
812 V4L2_BUF_TYPE_VIDEO_CAPTURE,
813 V4L2_FIELD_TOP,
814 sizeof(struct cx88_buffer),
815 dev);
816 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200817 if (err != 0)
818 printk("%s dvb_register failed err = %d\n", __FUNCTION__, err);
Steven Toth611900c2006-01-09 15:25:12 -0200819
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 return err;
822}
823
Steven Toth6c5be742006-12-02 21:15:51 -0200824static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825{
Steven Toth6c5be742006-12-02 21:15:51 -0200826 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200827
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 /* dvb */
829 videobuf_dvb_unregister(&dev->dvb);
830
Chris Pascoefc40b262006-01-09 15:25:35 -0200831#ifdef HAVE_VP3054_I2C
832 vp3054_i2c_remove(dev);
833#endif
834
Steven Toth6c5be742006-12-02 21:15:51 -0200835 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836}
837
Steven Toth6c5be742006-12-02 21:15:51 -0200838static struct cx8802_driver cx8802_dvb_driver = {
839 .type_id = CX88_MPEG_DVB,
840 .hw_access = CX8802_DRVCTL_SHARED,
841 .probe = cx8802_dvb_probe,
842 .remove = cx8802_dvb_remove,
843 .advise_acquire = cx8802_dvb_advise_acquire,
844 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845};
846
847static int dvb_init(void)
848{
849 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
850 (CX88_VERSION_CODE >> 16) & 0xff,
851 (CX88_VERSION_CODE >> 8) & 0xff,
852 CX88_VERSION_CODE & 0xff);
853#ifdef SNAPSHOT
854 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
855 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
856#endif
Steven Toth6c5be742006-12-02 21:15:51 -0200857 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858}
859
860static void dvb_fini(void)
861{
Steven Toth6c5be742006-12-02 21:15:51 -0200862 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863}
864
865module_init(dvb_init);
866module_exit(dvb_fini);
867
868/*
869 * Local variables:
870 * c-basic-offset: 8
871 * compile-command: "make DVB=1"
872 * End:
873 */