blob: 8b48c1f67a8bfea8595130d1909bcac60af61f81 [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
Michael Krufky29780bb2005-07-27 11:45:59 -070036#ifdef HAVE_MT352
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070037# include "mt352.h"
38# include "mt352_priv.h"
Chris Pascoefc40b262006-01-09 15:25:35 -020039# ifdef HAVE_VP3054_I2C
40# include "cx88-vp3054-i2c.h"
41# endif
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070042#endif
Chris Pascoe780dfef2006-02-28 08:34:59 -030043#ifdef HAVE_ZL10353
44# include "zl10353.h"
45#endif
Michael Krufky29780bb2005-07-27 11:45:59 -070046#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -070047# include "cx22702.h"
48#endif
Michael Krufky29780bb2005-07-27 11:45:59 -070049#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -070050# include "or51132.h"
51#endif
Michael Krufky6ddcc912005-07-27 11:46:00 -070052#ifdef HAVE_LGDT330X
53# include "lgdt330x.h"
Michael Krufky7e557742006-04-18 17:47:08 -030054# include "fe_lgh06xf.h"
Michael Krufkyf1798492005-07-07 17:58:39 -070055#endif
Kirk Laprayfde6d312005-11-08 21:38:18 -080056#ifdef HAVE_NXT200X
57# include "nxt200x.h"
58#endif
Steven Toth0fa14aa2006-01-09 15:25:02 -020059#ifdef HAVE_CX24123
60# include "cx24123.h"
61#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
64MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
65MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
66MODULE_LICENSE("GPL");
67
68static unsigned int debug = 0;
69module_param(debug, int, 0644);
70MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
71
72#define dprintk(level,fmt, arg...) if (debug >= level) \
73 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg)
74
75/* ------------------------------------------------------------------ */
76
77static int dvb_buf_setup(struct videobuf_queue *q,
78 unsigned int *count, unsigned int *size)
79{
80 struct cx8802_dev *dev = q->priv_data;
81
82 dev->ts_packet_size = 188 * 4;
83 dev->ts_packet_count = 32;
84
85 *size = dev->ts_packet_size * dev->ts_packet_count;
86 *count = 32;
87 return 0;
88}
89
90static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
91 enum v4l2_field field)
92{
93 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030094 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
97static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
98{
99 struct cx8802_dev *dev = q->priv_data;
100 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
101}
102
103static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
104{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300105 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}
107
Adrian Bunk408b6642005-05-01 08:59:29 -0700108static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 .buf_setup = dvb_buf_setup,
110 .buf_prepare = dvb_buf_prepare,
111 .buf_queue = dvb_buf_queue,
112 .buf_release = dvb_buf_release,
113};
114
115/* ------------------------------------------------------------------ */
116
Michael Krufky29780bb2005-07-27 11:45:59 -0700117#ifdef HAVE_MT352
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200118static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119{
120 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
121 static u8 reset [] = { RESET, 0x80 };
122 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
123 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
124 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
125 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
126
127 mt352_write(fe, clock_config, sizeof(clock_config));
128 udelay(200);
129 mt352_write(fe, reset, sizeof(reset));
130 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
131
132 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
133 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
134 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
135 return 0;
136}
137
Chris Pascoe43eabb42006-01-09 18:21:28 -0200138static int dvico_dual_demod_init(struct dvb_frontend *fe)
139{
140 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
141 static u8 reset [] = { RESET, 0x80 };
142 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
143 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
144 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
145 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
146
147 mt352_write(fe, clock_config, sizeof(clock_config));
148 udelay(200);
149 mt352_write(fe, reset, sizeof(reset));
150 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
151
152 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
153 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
154 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
155
156 return 0;
157}
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
160{
161 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
162 static u8 reset [] = { 0x50, 0x80 };
163 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
164 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800165 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 static u8 dntv_extra[] = { 0xB5, 0x7A };
167 static u8 capt_range_cfg[] = { 0x75, 0x32 };
168
169 mt352_write(fe, clock_config, sizeof(clock_config));
170 udelay(2000);
171 mt352_write(fe, reset, sizeof(reset));
172 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
173
174 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
175 udelay(2000);
176 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
177 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
178
179 return 0;
180}
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182static struct mt352_config dvico_fusionhdtv = {
183 .demod_address = 0x0F,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200184 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185};
186
187static struct mt352_config dntv_live_dvbt_config = {
188 .demod_address = 0x0f,
189 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190};
Chris Pascoefc40b262006-01-09 15:25:35 -0200191
Chris Pascoe43eabb42006-01-09 18:21:28 -0200192static struct mt352_config dvico_fusionhdtv_dual = {
193 .demod_address = 0x0F,
194 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200195};
196
Chris Pascoefc40b262006-01-09 15:25:35 -0200197#ifdef HAVE_VP3054_I2C
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200198static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
199{
200 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
201 static u8 reset [] = { 0x50, 0x80 };
202 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
203 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
204 0x00, 0xFF, 0x00, 0x40, 0x40 };
205 static u8 dntv_extra[] = { 0xB5, 0x7A };
206 static u8 capt_range_cfg[] = { 0x75, 0x32 };
207
208 mt352_write(fe, clock_config, sizeof(clock_config));
209 udelay(2000);
210 mt352_write(fe, reset, sizeof(reset));
211 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
212
213 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
214 udelay(2000);
215 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
216 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
217
218 return 0;
219}
220
Chris Pascoefc40b262006-01-09 15:25:35 -0200221static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
222{
223 struct cx8802_dev *dev= fe->dvb->priv;
224
225 /* this message is to set up ATC and ALC */
226 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
227 struct i2c_msg msg =
228 { .addr = dev->core->pll_addr, .flags = 0,
229 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
230 int err;
231
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300232 if (fe->ops->i2c_gate_ctrl)
233 fe->ops->i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200234 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
235 if (err < 0)
236 return err;
237 else
238 return -EREMOTEIO;
239 }
240
241 return 0;
242}
243
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300244static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
245 struct dvb_frontend_parameters* params)
Chris Pascoefc40b262006-01-09 15:25:35 -0200246{
247 struct cx8802_dev *dev= fe->dvb->priv;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300248 u8 buf[4];
Chris Pascoefc40b262006-01-09 15:25:35 -0200249 struct i2c_msg msg =
250 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300251 .buf = buf, .len = 4 };
Chris Pascoefc40b262006-01-09 15:25:35 -0200252 int err;
253
254 /* Switch PLL to DVB mode */
255 err = philips_fmd1216_pll_init(fe);
256 if (err)
257 return err;
258
259 /* Tune PLL */
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300260 dvb_pll_configure(dev->core->pll_desc, buf,
Chris Pascoefc40b262006-01-09 15:25:35 -0200261 params->frequency,
262 params->u.ofdm.bandwidth);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300263 if (fe->ops->i2c_gate_ctrl)
264 fe->ops->i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200265 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300266
Chris Pascoefc40b262006-01-09 15:25:35 -0200267 printk(KERN_WARNING "cx88-dvb: %s error "
268 "(addr %02x <- %02x, err = %i)\n",
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300269 __FUNCTION__, dev->core->pll_addr, buf[0], err);
Chris Pascoefc40b262006-01-09 15:25:35 -0200270 if (err < 0)
271 return err;
272 else
273 return -EREMOTEIO;
274 }
275
276 return 0;
277}
278
279static struct mt352_config dntv_live_dvbt_pro_config = {
280 .demod_address = 0x0f,
281 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200282 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200283};
284#endif
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -0700285#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Chris Pascoe780dfef2006-02-28 08:34:59 -0300287#ifdef HAVE_ZL10353
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300288static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
289 struct dvb_frontend_parameters *params)
Chris Pascoe780dfef2006-02-28 08:34:59 -0300290{
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300291 u8 pllbuf[4];
Chris Pascoe780dfef2006-02-28 08:34:59 -0300292 struct cx8802_dev *dev= fe->dvb->priv;
293 struct i2c_msg msg =
294 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300295 .buf = pllbuf, .len = 4 };
Chris Pascoe780dfef2006-02-28 08:34:59 -0300296 int err;
297
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300298 dvb_pll_configure(dev->core->pll_desc, pllbuf,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300299 params->frequency,
300 params->u.ofdm.bandwidth);
301
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300302 if (fe->ops->i2c_gate_ctrl)
303 fe->ops->i2c_gate_ctrl(fe, 1);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300304 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
305 printk(KERN_WARNING "cx88-dvb: %s error "
306 "(addr %02x <- %02x, err = %i)\n",
307 __FUNCTION__, pllbuf[0], pllbuf[1], err);
308 if (err < 0)
309 return err;
310 else
311 return -EREMOTEIO;
312 }
313
314 return 0;
315}
316
317static struct zl10353_config dvico_fusionhdtv_hybrid = {
318 .demod_address = 0x0F,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300319 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300320};
321
322static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
323 .demod_address = 0x0F,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300324};
325#endif
326
Michael Krufky29780bb2005-07-27 11:45:59 -0700327#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328static struct cx22702_config connexant_refboard_config = {
329 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700330 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331};
332
333static struct cx22702_config hauppauge_novat_config = {
334 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700335 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336};
Steven Toth611900c2006-01-09 15:25:12 -0200337static struct cx22702_config hauppauge_hvr1100_config = {
338 .demod_address = 0x63,
339 .output_mode = CX22702_SERIAL_OUTPUT,
Steven Toth611900c2006-01-09 15:25:12 -0200340};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341#endif
342
Michael Krufky29780bb2005-07-27 11:45:59 -0700343#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344static int or51132_set_ts_param(struct dvb_frontend* fe,
345 int is_punctured)
346{
347 struct cx8802_dev *dev= fe->dvb->priv;
348 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
349 return 0;
350}
351
Adrian Bunk408b6642005-05-01 08:59:29 -0700352static struct or51132_config pchdtv_hd3000 = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 .demod_address = 0x15,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 .set_ts_params = or51132_set_ts_param,
355};
356#endif
357
Michael Krufky6ddcc912005-07-27 11:46:00 -0700358#ifdef HAVE_LGDT330X
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300359static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
360 struct dvb_frontend_parameters* params)
Michael Krufkyb6aef072005-07-27 11:45:54 -0700361{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700362 /* FIXME make this routine use the tuner-simple code.
363 * It could probably be shared with a number of ATSC
364 * frontends. Many share the same tuner with analog TV. */
365
Michael Krufkyb6aef072005-07-27 11:45:54 -0700366 struct cx8802_dev *dev= fe->dvb->priv;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700367 struct cx88_core *core = dev->core;
Michael Krufky1963c902005-08-08 09:22:43 -0700368 u8 buf[4];
369 struct i2c_msg msg =
370 { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 };
371 int err;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700372
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700373 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
Michael Krufky1963c902005-08-08 09:22:43 -0700374 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
375 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300376
377 if (fe->ops->i2c_gate_ctrl)
378 fe->ops->i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700379 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
Michael Krufky1963c902005-08-08 09:22:43 -0700380 printk(KERN_WARNING "cx88-dvb: %s error "
381 "(addr %02x <- %02x, err = %i)\n",
382 __FUNCTION__, buf[0], buf[1], err);
383 if (err < 0)
384 return err;
385 else
386 return -EREMOTEIO;
387 }
Michael Krufkyb6aef072005-07-27 11:45:54 -0700388 return 0;
389}
390
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300391static int lgdt3303_tuner_set_params(struct dvb_frontend* fe,
392 struct dvb_frontend_parameters* params)
Michael Krufky7e557742006-04-18 17:47:08 -0300393{
394 struct cx8802_dev *dev= fe->dvb->priv;
395 struct cx88_core *core = dev->core;
396
397 /* Put the analog decoder in standby to keep it quiet */
398 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
399
400 return lg_h06xf_pll_set(fe, &core->i2c_adap, params);
401}
402
Michael Krufky6ddcc912005-07-27 11:46:00 -0700403static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700404{
405 struct cx8802_dev *dev= fe->dvb->priv;
406 struct cx88_core *core = dev->core;
407
408 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
409 if (index == 0)
410 cx_clear(MO_GP0_IO, 8);
411 else
412 cx_set(MO_GP0_IO, 8);
413 return 0;
414}
415
Michael Krufky6ddcc912005-07-27 11:46:00 -0700416static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700417{
418 struct cx8802_dev *dev= fe->dvb->priv;
419 if (is_punctured)
420 dev->ts_gen_cntrl |= 0x04;
421 else
422 dev->ts_gen_cntrl &= ~0x04;
423 return 0;
424}
425
Michael Krufky6ddcc912005-07-27 11:46:00 -0700426static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf1798492005-07-07 17:58:39 -0700427 .demod_address = 0x0e,
Michael Krufky1963c902005-08-08 09:22:43 -0700428 .demod_chip = LGDT3302,
429 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700430 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700431};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700432
433static struct lgdt330x_config fusionhdtv_5_gold = {
434 .demod_address = 0x0e,
435 .demod_chip = LGDT3303,
436 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700437 .set_ts_params = lgdt330x_set_ts_param,
438};
Rusty Scottda215d22006-04-07 02:21:31 -0300439
440static struct lgdt330x_config pchdtv_hd5500 = {
441 .demod_address = 0x59,
442 .demod_chip = LGDT3303,
443 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
Rusty Scottda215d22006-04-07 02:21:31 -0300444 .set_ts_params = lgdt330x_set_ts_param,
445};
Michael Krufkyf1798492005-07-07 17:58:39 -0700446#endif
447
Kirk Laprayfde6d312005-11-08 21:38:18 -0800448#ifdef HAVE_NXT200X
449static int nxt200x_set_ts_param(struct dvb_frontend* fe,
450 int is_punctured)
451{
452 struct cx8802_dev *dev= fe->dvb->priv;
453 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
454 return 0;
455}
456
Kirk Laprayd4c34aa2005-11-08 21:38:40 -0800457static int nxt200x_set_pll_input(u8* buf, int input)
458{
459 if (input)
460 buf[3] |= 0x08;
461 else
462 buf[3] &= ~0x08;
463 return 0;
464}
465
Kirk Laprayfde6d312005-11-08 21:38:18 -0800466static struct nxt200x_config ati_hdtvwonder = {
467 .demod_address = 0x0a,
Kirk Laprayd4c34aa2005-11-08 21:38:40 -0800468 .set_pll_input = nxt200x_set_pll_input,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800469 .set_ts_params = nxt200x_set_ts_param,
470};
471#endif
472
Steven Toth0fa14aa2006-01-09 15:25:02 -0200473#ifdef HAVE_CX24123
474static int cx24123_set_ts_param(struct dvb_frontend* fe,
475 int is_punctured)
476{
477 struct cx8802_dev *dev= fe->dvb->priv;
478 dev->ts_gen_cntrl = 0x2;
479 return 0;
480}
481
Vadim Catana0e0351e2006-01-09 15:25:02 -0200482static void cx24123_enable_lnb_voltage(struct dvb_frontend* fe, int on)
483{
484 struct cx8802_dev *dev= fe->dvb->priv;
485 struct cx88_core *core = dev->core;
486
487 if (on)
488 cx_write(MO_GP0_IO, 0x000006f9);
489 else
490 cx_write(MO_GP0_IO, 0x000006fB);
491}
492
Steven Toth0fa14aa2006-01-09 15:25:02 -0200493static struct cx24123_config hauppauge_novas_config = {
Vadim Catana0e0351e2006-01-09 15:25:02 -0200494 .demod_address = 0x55,
495 .use_isl6421 = 1,
496 .set_ts_params = cx24123_set_ts_param,
497};
498
499static struct cx24123_config kworld_dvbs_100_config = {
500 .demod_address = 0x15,
501 .use_isl6421 = 0,
502 .set_ts_params = cx24123_set_ts_param,
503 .enable_lnb_voltage = cx24123_enable_lnb_voltage,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200504};
505#endif
506
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507static int dvb_register(struct cx8802_dev *dev)
508{
509 /* init struct videobuf_dvb */
510 dev->dvb.name = dev->core->name;
511 dev->ts_gen_cntrl = 0x0c;
512
513 /* init frontend */
514 switch (dev->core->board) {
Michael Krufky29780bb2005-07-27 11:45:59 -0700515#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 case CX88_BOARD_HAUPPAUGE_DVB_T1:
517 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
518 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300519 if (dev->dvb.frontend != NULL) {
520 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_thomson_dtt759x);
521 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700523 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200525 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800526 case CX88_BOARD_WINFAST_DTV1000:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
528 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300529 if (dev->dvb.frontend != NULL) {
530 dvb_pll_attach(dev->dvb.frontend, 0x60, &dev->core->i2c_adap, &dvb_pll_thomson_dtt7579);
531 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 break;
Steven Toth611900c2006-01-09 15:25:12 -0200533 case CX88_BOARD_HAUPPAUGE_HVR1100:
534 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
535 dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config,
536 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300537 if (dev->dvb.frontend != NULL) {
538 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_fmd1216me);
539 }
Steven Toth611900c2006-01-09 15:25:12 -0200540 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541#endif
Chris Pascoe780dfef2006-02-28 08:34:59 -0300542#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
543 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Chris Pascoe780dfef2006-02-28 08:34:59 -0300544#ifdef HAVE_MT352
545 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
546 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300547 if (dev->dvb.frontend != NULL) {
548 dvb_pll_attach(dev->dvb.frontend, 0x60, &dev->core->i2c_adap, &dvb_pll_thomson_dtt7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300549 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300550 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300551#endif
552#ifdef HAVE_ZL10353
553 /* ZL10353 replaces MT352 on later cards */
554 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1,
555 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300556 if (dev->dvb.frontend != NULL) {
557 dvb_pll_attach(dev->dvb.frontend, 0x60, &dev->core->i2c_adap, &dvb_pll_thomson_dtt7579);
558 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300559#endif
560 break;
561#endif /* HAVE_MT352 || HAVE_ZL10353 */
Michael Krufky29780bb2005-07-27 11:45:59 -0700562#ifdef HAVE_MT352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
565 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300566 if (dev->dvb.frontend != NULL) {
567 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_lg_z201);
568 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 case CX88_BOARD_KWORLD_DVB_T:
571 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700572 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
574 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300575 if (dev->dvb.frontend != NULL) {
576 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_unknown_1);
577 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200579 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
580#ifdef HAVE_VP3054_I2C
581 dev->core->pll_addr = 0x61;
582 dev->core->pll_desc = &dvb_pll_fmd1216me;
583 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config,
584 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300585 if (dev->dvb.frontend != NULL) {
586 dev->dvb.frontend->ops->tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
587 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200588#else
589 printk("%s: built without vp3054 support\n", dev->core->name);
590#endif
591 break;
Chris Pascoe43eabb42006-01-09 18:21:28 -0200592 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
593 /* The tin box says DEE1601, but it seems to be DTT7579
594 * compatible, with a slightly different MT352 AGC gain. */
Chris Pascoe43eabb42006-01-09 18:21:28 -0200595 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual,
596 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300597 if (dev->dvb.frontend != NULL) {
598 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_thomson_dtt7579);
599 }
Chris Pascoe43eabb42006-01-09 18:21:28 -0200600 break;
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -0700601#endif
Chris Pascoe780dfef2006-02-28 08:34:59 -0300602#ifdef HAVE_ZL10353
603 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
604 dev->core->pll_addr = 0x61;
Michael Krufky91ae3292006-03-01 00:04:42 -0300605 dev->core->pll_desc = &dvb_pll_thomson_fe6600;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300606 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid,
607 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300608 if (dev->dvb.frontend != NULL) {
609 dev->dvb.frontend->ops->tuner_ops.set_params = dvico_hybrid_tuner_set_params;
610 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300611 break;
612#endif
Michael Krufky29780bb2005-07-27 11:45:59 -0700613#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 case CX88_BOARD_PCHDTV_HD3000:
615 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
616 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300617 if (dev->dvb.frontend != NULL) {
618 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_thomson_dtt761x);
619 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 break;
621#endif
Michael Krufky6ddcc912005-07-27 11:46:00 -0700622#ifdef HAVE_LGDT330X
Michael Krufkyf1798492005-07-07 17:58:39 -0700623 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
624 dev->ts_gen_cntrl = 0x08;
625 {
626 /* Do a hardware reset of chip before using it. */
627 struct cx88_core *core = dev->core;
628
629 cx_clear(MO_GP0_IO, 1);
630 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700631 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700632 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700633
634 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700635 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700636 dev->core->pll_addr = 0x61;
637 dev->core->pll_desc = &dvb_pll_microtune_4042;
Michael Krufky6ddcc912005-07-27 11:46:00 -0700638 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
Michael Krufkyf1798492005-07-07 17:58:39 -0700639 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300640 if (dev->dvb.frontend != NULL) {
641 dev->dvb.frontend->ops->tuner_ops.set_params = lgdt3302_tuner_set_params;
642 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700643 }
644 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700645 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
646 dev->ts_gen_cntrl = 0x08;
647 {
648 /* Do a hardware reset of chip before using it. */
649 struct cx88_core *core = dev->core;
650
651 cx_clear(MO_GP0_IO, 1);
652 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700653 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700654 mdelay(200);
Michael Krufkyb6aef072005-07-27 11:45:54 -0700655 dev->core->pll_addr = 0x61;
Michael Krufky83ac87222006-01-09 15:25:29 -0200656 dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
Michael Krufky6ddcc912005-07-27 11:46:00 -0700657 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
Michael Krufky0d723c02005-07-07 17:58:42 -0700658 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300659 if (dev->dvb.frontend != NULL) {
660 dev->dvb.frontend->ops->tuner_ops.set_params = lgdt3302_tuner_set_params;
661 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700662 }
663 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700664 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
665 dev->ts_gen_cntrl = 0x08;
666 {
667 /* Do a hardware reset of chip before using it. */
668 struct cx88_core *core = dev->core;
669
670 cx_clear(MO_GP0_IO, 1);
671 mdelay(100);
672 cx_set(MO_GP0_IO, 1);
673 mdelay(200);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700674 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold,
675 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300676 if (dev->dvb.frontend != NULL) {
677 dev->dvb.frontend->ops->tuner_ops.set_params = lgdt3303_tuner_set_params;
678 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700679 }
680 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300681 case CX88_BOARD_PCHDTV_HD5500:
682 dev->ts_gen_cntrl = 0x08;
683 {
684 /* Do a hardware reset of chip before using it. */
685 struct cx88_core *core = dev->core;
686
687 cx_clear(MO_GP0_IO, 1);
688 mdelay(100);
689 cx_set(MO_GP0_IO, 1);
690 mdelay(200);
Rusty Scottda215d22006-04-07 02:21:31 -0300691 dev->dvb.frontend = lgdt330x_attach(&pchdtv_hd5500,
692 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300693 if (dev->dvb.frontend != NULL) {
694 dev->dvb.frontend->ops->tuner_ops.set_params = lgdt3303_tuner_set_params;
695 }
Rusty Scottda215d22006-04-07 02:21:31 -0300696 }
697 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700698#endif
Kirk Laprayfde6d312005-11-08 21:38:18 -0800699#ifdef HAVE_NXT200X
700 case CX88_BOARD_ATI_HDTVWONDER:
701 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder,
702 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300703 if (dev->dvb.frontend != NULL) {
704 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->core->i2c_adap, &dvb_pll_tuv1236d);
705 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800706 break;
707#endif
Steven Toth0fa14aa2006-01-09 15:25:02 -0200708#ifdef HAVE_CX24123
709 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
710 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
711 dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config,
712 &dev->core->i2c_adap);
713 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200714 case CX88_BOARD_KWORLD_DVBS_100:
715 dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config,
716 &dev->core->i2c_adap);
717 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200718#endif
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) {
730 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;
732 }
733
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700734 /* Put the analog decoder in standby to keep it quiet */
735 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
736
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300738 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739}
740
741/* ----------------------------------------------------------- */
742
743static int __devinit dvb_probe(struct pci_dev *pci_dev,
744 const struct pci_device_id *pci_id)
745{
746 struct cx8802_dev *dev;
747 struct cx88_core *core;
748 int err;
749
750 /* general setup */
751 core = cx88_core_get(pci_dev);
752 if (NULL == core)
753 return -EINVAL;
754
755 err = -ENODEV;
756 if (!cx88_boards[core->board].dvb)
757 goto fail_core;
758
759 err = -ENOMEM;
Panagiotis Issaris74081872006-01-11 19:40:56 -0200760 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 if (NULL == dev)
762 goto fail_core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 dev->pci = pci_dev;
764 dev->core = core;
765
766 err = cx8802_init_common(dev);
767 if (0 != err)
768 goto fail_free;
769
Chris Pascoefc40b262006-01-09 15:25:35 -0200770#ifdef HAVE_VP3054_I2C
771 err = vp3054_i2c_probe(dev);
772 if (0 != err)
773 goto fail_free;
774#endif
775
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 /* dvb stuff */
777 printk("%s/2: cx2388x based dvb card\n", core->name);
778 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
779 dev->pci, &dev->slock,
780 V4L2_BUF_TYPE_VIDEO_CAPTURE,
781 V4L2_FIELD_TOP,
782 sizeof(struct cx88_buffer),
783 dev);
784 err = dvb_register(dev);
785 if (0 != err)
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700786 goto fail_fini;
Steven Toth611900c2006-01-09 15:25:12 -0200787
788 /* Maintain a reference to cx88-video can query the 8802 device. */
789 core->dvbdev = dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 return 0;
791
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700792 fail_fini:
793 cx8802_fini_common(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 fail_free:
795 kfree(dev);
796 fail_core:
797 cx88_core_put(core,pci_dev);
798 return err;
799}
800
801static void __devexit dvb_remove(struct pci_dev *pci_dev)
802{
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800803 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804
Steven Toth611900c2006-01-09 15:25:12 -0200805 /* Destroy any 8802 reference. */
806 dev->core->dvbdev = NULL;
807
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 /* dvb */
809 videobuf_dvb_unregister(&dev->dvb);
810
Chris Pascoefc40b262006-01-09 15:25:35 -0200811#ifdef HAVE_VP3054_I2C
812 vp3054_i2c_remove(dev);
813#endif
814
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 /* common */
816 cx8802_fini_common(dev);
817 cx88_core_put(dev->core,dev->pci);
818 kfree(dev);
819}
820
821static struct pci_device_id cx8802_pci_tbl[] = {
822 {
823 .vendor = 0x14f1,
824 .device = 0x8802,
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800825 .subvendor = PCI_ANY_ID,
826 .subdevice = PCI_ANY_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 },{
828 /* --- end of list --- */
829 }
830};
831MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
832
833static struct pci_driver dvb_pci_driver = {
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800834 .name = "cx88-dvb",
835 .id_table = cx8802_pci_tbl,
836 .probe = dvb_probe,
837 .remove = __devexit_p(dvb_remove),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .suspend = cx8802_suspend_common,
839 .resume = cx8802_resume_common,
840};
841
842static int dvb_init(void)
843{
844 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
845 (CX88_VERSION_CODE >> 16) & 0xff,
846 (CX88_VERSION_CODE >> 8) & 0xff,
847 CX88_VERSION_CODE & 0xff);
848#ifdef SNAPSHOT
849 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
850 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
851#endif
852 return pci_register_driver(&dvb_pci_driver);
853}
854
855static void dvb_fini(void)
856{
857 pci_unregister_driver(&dvb_pci_driver);
858}
859
860module_init(dvb_init);
861module_exit(dvb_fini);
862
863/*
864 * Local variables:
865 * c-basic-offset: 8
866 * compile-command: "make DVB=1"
867 * End:
868 */