blob: 4334744652de0b22c23122fa311190ff217e02e1 [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 *
6 * (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au>
7 * (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
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -070032
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include "cx88.h"
34#include "dvb-pll.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"
39#endif
Michael Krufky29780bb2005-07-27 11:45:59 -070040#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -070041# include "cx22702.h"
42#endif
Michael Krufky29780bb2005-07-27 11:45:59 -070043#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -070044# include "or51132.h"
45#endif
Michael Krufky6ddcc912005-07-27 11:46:00 -070046#ifdef HAVE_LGDT330X
47# include "lgdt330x.h"
Michael Krufkyf1798492005-07-07 17:58:39 -070048#endif
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) \
60 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg)
61
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;
81 return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb);
82}
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{
92 struct cx8802_dev *dev = q->priv_data;
93 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
94}
95
Adrian Bunk408b6642005-05-01 08:59:29 -070096static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .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
103/* ------------------------------------------------------------------ */
104
Michael Krufky29780bb2005-07-27 11:45:59 -0700105#ifdef HAVE_MT352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
107{
108 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
109 static u8 reset [] = { RESET, 0x80 };
110 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
111 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
112 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
113 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
114
115 mt352_write(fe, clock_config, sizeof(clock_config));
116 udelay(200);
117 mt352_write(fe, reset, sizeof(reset));
118 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
119
120 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
121 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
122 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
123 return 0;
124}
125
126static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
127{
128 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
129 static u8 reset [] = { 0x50, 0x80 };
130 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
131 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
132 0x00, 0xFF, 0x00, 0x40, 0x40 };
133 static u8 dntv_extra[] = { 0xB5, 0x7A };
134 static u8 capt_range_cfg[] = { 0x75, 0x32 };
135
136 mt352_write(fe, clock_config, sizeof(clock_config));
137 udelay(2000);
138 mt352_write(fe, reset, sizeof(reset));
139 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
140
141 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
142 udelay(2000);
143 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
144 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
145
146 return 0;
147}
148
149static int mt352_pll_set(struct dvb_frontend* fe,
150 struct dvb_frontend_parameters* params,
151 u8* pllbuf)
152{
153 struct cx8802_dev *dev= fe->dvb->priv;
154
155 pllbuf[0] = dev->core->pll_addr << 1;
156 dvb_pll_configure(dev->core->pll_desc, pllbuf+1,
157 params->frequency,
158 params->u.ofdm.bandwidth);
159 return 0;
160}
161
162static struct mt352_config dvico_fusionhdtv = {
163 .demod_address = 0x0F,
164 .demod_init = dvico_fusionhdtv_demod_init,
165 .pll_set = mt352_pll_set,
166};
167
168static struct mt352_config dntv_live_dvbt_config = {
169 .demod_address = 0x0f,
170 .demod_init = dntv_live_dvbt_demod_init,
171 .pll_set = mt352_pll_set,
172};
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -0700173#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Michael Krufky29780bb2005-07-27 11:45:59 -0700175#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176static struct cx22702_config connexant_refboard_config = {
177 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700178 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .pll_address = 0x60,
180 .pll_desc = &dvb_pll_thomson_dtt7579,
181};
182
183static struct cx22702_config hauppauge_novat_config = {
184 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700185 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 .pll_address = 0x61,
187 .pll_desc = &dvb_pll_thomson_dtt759x,
188};
189#endif
190
Michael Krufky29780bb2005-07-27 11:45:59 -0700191#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192static int or51132_set_ts_param(struct dvb_frontend* fe,
193 int is_punctured)
194{
195 struct cx8802_dev *dev= fe->dvb->priv;
196 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
197 return 0;
198}
199
Adrian Bunk408b6642005-05-01 08:59:29 -0700200static struct or51132_config pchdtv_hd3000 = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 .demod_address = 0x15,
202 .pll_address = 0x61,
203 .pll_desc = &dvb_pll_thomson_dtt7610,
204 .set_ts_params = or51132_set_ts_param,
205};
206#endif
207
Michael Krufky6ddcc912005-07-27 11:46:00 -0700208#ifdef HAVE_LGDT330X
209static int lgdt330x_pll_set(struct dvb_frontend* fe,
Michael Krufky1963c902005-08-08 09:22:43 -0700210 struct dvb_frontend_parameters* params)
Michael Krufkyb6aef072005-07-27 11:45:54 -0700211{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700212 /* FIXME make this routine use the tuner-simple code.
213 * It could probably be shared with a number of ATSC
214 * frontends. Many share the same tuner with analog TV. */
215
Michael Krufkyb6aef072005-07-27 11:45:54 -0700216 struct cx8802_dev *dev= fe->dvb->priv;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700217 struct cx88_core *core = dev->core;
Michael Krufky1963c902005-08-08 09:22:43 -0700218 u8 buf[4];
219 struct i2c_msg msg =
220 { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 };
221 int err;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700222
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700223 /* Put the analog decoder in standby to keep it quiet */
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700224 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700225
226 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
Michael Krufky1963c902005-08-08 09:22:43 -0700227 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
228 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700229 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
Michael Krufky1963c902005-08-08 09:22:43 -0700230 printk(KERN_WARNING "cx88-dvb: %s error "
231 "(addr %02x <- %02x, err = %i)\n",
232 __FUNCTION__, buf[0], buf[1], err);
233 if (err < 0)
234 return err;
235 else
236 return -EREMOTEIO;
237 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700238 if (core->tuner_type == TUNER_LG_TDVS_H062F) {
239 /* Set the Auxiliary Byte. */
240 buf[2] &= ~0x20;
241 buf[2] |= 0x18;
242 buf[3] = 0x50;
243 i2c_transfer(&core->i2c_adap, &msg, 1);
244 }
Michael Krufkyb6aef072005-07-27 11:45:54 -0700245 return 0;
246}
247
Michael Krufky6ddcc912005-07-27 11:46:00 -0700248static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700249{
250 struct cx8802_dev *dev= fe->dvb->priv;
251 struct cx88_core *core = dev->core;
252
253 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
254 if (index == 0)
255 cx_clear(MO_GP0_IO, 8);
256 else
257 cx_set(MO_GP0_IO, 8);
258 return 0;
259}
260
Michael Krufky6ddcc912005-07-27 11:46:00 -0700261static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700262{
263 struct cx8802_dev *dev= fe->dvb->priv;
264 if (is_punctured)
265 dev->ts_gen_cntrl |= 0x04;
266 else
267 dev->ts_gen_cntrl &= ~0x04;
268 return 0;
269}
270
Michael Krufky6ddcc912005-07-27 11:46:00 -0700271static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf1798492005-07-07 17:58:39 -0700272 .demod_address = 0x0e,
Michael Krufky1963c902005-08-08 09:22:43 -0700273 .demod_chip = LGDT3302,
274 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700275 .pll_set = lgdt330x_pll_set,
276 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700277};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700278
279static struct lgdt330x_config fusionhdtv_5_gold = {
280 .demod_address = 0x0e,
281 .demod_chip = LGDT3303,
282 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
283 .pll_set = lgdt330x_pll_set,
284 .set_ts_params = lgdt330x_set_ts_param,
285};
Michael Krufkyf1798492005-07-07 17:58:39 -0700286#endif
287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288static int dvb_register(struct cx8802_dev *dev)
289{
290 /* init struct videobuf_dvb */
291 dev->dvb.name = dev->core->name;
292 dev->ts_gen_cntrl = 0x0c;
293
294 /* init frontend */
295 switch (dev->core->board) {
Michael Krufky29780bb2005-07-27 11:45:59 -0700296#ifdef HAVE_CX22702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 case CX88_BOARD_HAUPPAUGE_DVB_T1:
298 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
299 &dev->core->i2c_adap);
300 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700301 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 case CX88_BOARD_CONEXANT_DVB_T1:
303 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config,
304 &dev->core->i2c_adap);
305 break;
306#endif
Michael Krufky29780bb2005-07-27 11:45:59 -0700307#ifdef HAVE_MT352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
309 dev->core->pll_addr = 0x61;
310 dev->core->pll_desc = &dvb_pll_lg_z201;
311 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
312 &dev->core->i2c_adap);
313 break;
314 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
315 dev->core->pll_addr = 0x60;
316 dev->core->pll_desc = &dvb_pll_thomson_dtt7579;
317 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv,
318 &dev->core->i2c_adap);
319 break;
320 case CX88_BOARD_KWORLD_DVB_T:
321 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700322 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 dev->core->pll_addr = 0x61;
324 dev->core->pll_desc = &dvb_pll_unknown_1;
325 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
326 &dev->core->i2c_adap);
327 break;
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -0700328#endif
Michael Krufky29780bb2005-07-27 11:45:59 -0700329#ifdef HAVE_OR51132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 case CX88_BOARD_PCHDTV_HD3000:
331 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
332 &dev->core->i2c_adap);
333 break;
334#endif
Michael Krufky6ddcc912005-07-27 11:46:00 -0700335#ifdef HAVE_LGDT330X
Michael Krufkyf1798492005-07-07 17:58:39 -0700336 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
337 dev->ts_gen_cntrl = 0x08;
338 {
339 /* Do a hardware reset of chip before using it. */
340 struct cx88_core *core = dev->core;
341
342 cx_clear(MO_GP0_IO, 1);
343 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700344 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700345 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700346
347 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700348 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700349 dev->core->pll_addr = 0x61;
350 dev->core->pll_desc = &dvb_pll_microtune_4042;
Michael Krufky6ddcc912005-07-27 11:46:00 -0700351 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
Michael Krufkyf1798492005-07-07 17:58:39 -0700352 &dev->core->i2c_adap);
353 }
354 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700355 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
356 dev->ts_gen_cntrl = 0x08;
357 {
358 /* Do a hardware reset of chip before using it. */
359 struct cx88_core *core = dev->core;
360
361 cx_clear(MO_GP0_IO, 1);
362 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700363 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700364 mdelay(200);
Michael Krufkyb6aef072005-07-27 11:45:54 -0700365 dev->core->pll_addr = 0x61;
366 dev->core->pll_desc = &dvb_pll_thomson_dtt7611;
Michael Krufky6ddcc912005-07-27 11:46:00 -0700367 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold,
Michael Krufky0d723c02005-07-07 17:58:42 -0700368 &dev->core->i2c_adap);
369 }
370 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700371 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
372 dev->ts_gen_cntrl = 0x08;
373 {
374 /* Do a hardware reset of chip before using it. */
375 struct cx88_core *core = dev->core;
376
377 cx_clear(MO_GP0_IO, 1);
378 mdelay(100);
379 cx_set(MO_GP0_IO, 1);
380 mdelay(200);
381 dev->core->pll_addr = 0x61;
382 dev->core->pll_desc = &dvb_pll_tdvs_tua6034;
383 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold,
384 &dev->core->i2c_adap);
385 }
386 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700387#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 default:
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700389 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
390 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 break;
392 }
393 if (NULL == dev->dvb.frontend) {
394 printk("%s: frontend initialization failed\n",dev->core->name);
395 return -1;
396 }
397
398 if (dev->core->pll_desc) {
399 dev->dvb.frontend->ops->info.frequency_min = dev->core->pll_desc->min;
400 dev->dvb.frontend->ops->info.frequency_max = dev->core->pll_desc->max;
401 }
402
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700403 /* Put the analog decoder in standby to keep it quiet */
404 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
405
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 /* register everything */
407 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
408}
409
410/* ----------------------------------------------------------- */
411
412static int __devinit dvb_probe(struct pci_dev *pci_dev,
413 const struct pci_device_id *pci_id)
414{
415 struct cx8802_dev *dev;
416 struct cx88_core *core;
417 int err;
418
419 /* general setup */
420 core = cx88_core_get(pci_dev);
421 if (NULL == core)
422 return -EINVAL;
423
424 err = -ENODEV;
425 if (!cx88_boards[core->board].dvb)
426 goto fail_core;
427
428 err = -ENOMEM;
429 dev = kmalloc(sizeof(*dev),GFP_KERNEL);
430 if (NULL == dev)
431 goto fail_core;
432 memset(dev,0,sizeof(*dev));
433 dev->pci = pci_dev;
434 dev->core = core;
435
436 err = cx8802_init_common(dev);
437 if (0 != err)
438 goto fail_free;
439
440 /* dvb stuff */
441 printk("%s/2: cx2388x based dvb card\n", core->name);
442 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
443 dev->pci, &dev->slock,
444 V4L2_BUF_TYPE_VIDEO_CAPTURE,
445 V4L2_FIELD_TOP,
446 sizeof(struct cx88_buffer),
447 dev);
448 err = dvb_register(dev);
449 if (0 != err)
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700450 goto fail_fini;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 return 0;
452
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700453 fail_fini:
454 cx8802_fini_common(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 fail_free:
456 kfree(dev);
457 fail_core:
458 cx88_core_put(core,pci_dev);
459 return err;
460}
461
462static void __devexit dvb_remove(struct pci_dev *pci_dev)
463{
464 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
465
466 /* dvb */
467 videobuf_dvb_unregister(&dev->dvb);
468
469 /* common */
470 cx8802_fini_common(dev);
471 cx88_core_put(dev->core,dev->pci);
472 kfree(dev);
473}
474
475static struct pci_device_id cx8802_pci_tbl[] = {
476 {
477 .vendor = 0x14f1,
478 .device = 0x8802,
479 .subvendor = PCI_ANY_ID,
480 .subdevice = PCI_ANY_ID,
481 },{
482 /* --- end of list --- */
483 }
484};
485MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
486
487static struct pci_driver dvb_pci_driver = {
488 .name = "cx88-dvb",
489 .id_table = cx8802_pci_tbl,
490 .probe = dvb_probe,
491 .remove = __devexit_p(dvb_remove),
492 .suspend = cx8802_suspend_common,
493 .resume = cx8802_resume_common,
494};
495
496static int dvb_init(void)
497{
498 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
499 (CX88_VERSION_CODE >> 16) & 0xff,
500 (CX88_VERSION_CODE >> 8) & 0xff,
501 CX88_VERSION_CODE & 0xff);
502#ifdef SNAPSHOT
503 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
504 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
505#endif
506 return pci_register_driver(&dvb_pci_driver);
507}
508
509static void dvb_fini(void)
510{
511 pci_unregister_driver(&dvb_pci_driver);
512}
513
514module_init(dvb_init);
515module_exit(dvb_fini);
516
517/*
518 * Local variables:
519 * c-basic-offset: 8
520 * compile-command: "make DVB=1"
521 * End:
522 */