diff options
author | Sri Deevi <Srinivasa.Deevi@conexant.com> | 2009-03-03 12:37:50 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:44:01 -0400 |
commit | e0d3bafd02586cfde286c320f56906fd9fa8d256 (patch) | |
tree | bf9a37d90b902dfcc9d37a6f252c8c97de1c40ff /drivers/media/video/cx231xx/cx231xx-dvb.c | |
parent | 95b14fb23b543e0a9213b4ba3cc4fc640d9e453f (diff) |
V4L/DVB (10954): Add cx231xx USB driver
Signed-off-by: Srinivasa Deevi <srinivasa.deevi@conexant.com>
[mchehab@redhat.com: Remove the Kconfig changes, to avoid git breakages]
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-dvb.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-dvb.c | 565 |
1 files changed, 565 insertions, 0 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c new file mode 100644 index 000000000000..46bdcecb4055 --- /dev/null +++ b/drivers/media/video/cx231xx/cx231xx-dvb.c | |||
@@ -0,0 +1,565 @@ | |||
1 | /* | ||
2 | DVB device driver for cx231xx | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/usb.h> | ||
24 | |||
25 | #include "cx231xx.h" | ||
26 | #include <media/v4l2-common.h> | ||
27 | #include <media/videobuf-vmalloc.h> | ||
28 | |||
29 | #include "xc5000.h" | ||
30 | #include "dvb_dummy_fe.h" | ||
31 | |||
32 | |||
33 | MODULE_DESCRIPTION("driver for cx231xx based DVB cards"); | ||
34 | MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | |||
37 | static unsigned int debug; | ||
38 | module_param(debug, int, 0644); | ||
39 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
40 | |||
41 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
42 | |||
43 | #define dprintk(level, fmt, arg...) do { \ | ||
44 | if (debug >= level) \ | ||
45 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | ||
46 | } while (0) | ||
47 | |||
48 | #define CX231XX_DVB_NUM_BUFS 5 | ||
49 | #define CX231XX_DVB_MAX_PACKETSIZE 564 | ||
50 | #define CX231XX_DVB_MAX_PACKETS 64 | ||
51 | |||
52 | struct cx231xx_dvb { | ||
53 | struct dvb_frontend *frontend; | ||
54 | |||
55 | /* feed count management */ | ||
56 | struct mutex lock; | ||
57 | int nfeeds; | ||
58 | |||
59 | /* general boilerplate stuff */ | ||
60 | struct dvb_adapter adapter; | ||
61 | struct dvb_demux demux; | ||
62 | struct dmxdev dmxdev; | ||
63 | struct dmx_frontend fe_hw; | ||
64 | struct dmx_frontend fe_mem; | ||
65 | struct dvb_net net; | ||
66 | }; | ||
67 | |||
68 | |||
69 | static inline void print_err_status(struct cx231xx *dev, | ||
70 | int packet, int status) | ||
71 | { | ||
72 | char *errmsg = "Unknown"; | ||
73 | |||
74 | switch (status) { | ||
75 | case -ENOENT: | ||
76 | errmsg = "unlinked synchronuously"; | ||
77 | break; | ||
78 | case -ECONNRESET: | ||
79 | errmsg = "unlinked asynchronuously"; | ||
80 | break; | ||
81 | case -ENOSR: | ||
82 | errmsg = "Buffer error (overrun)"; | ||
83 | break; | ||
84 | case -EPIPE: | ||
85 | errmsg = "Stalled (device not responding)"; | ||
86 | break; | ||
87 | case -EOVERFLOW: | ||
88 | errmsg = "Babble (bad cable?)"; | ||
89 | break; | ||
90 | case -EPROTO: | ||
91 | errmsg = "Bit-stuff error (bad cable?)"; | ||
92 | break; | ||
93 | case -EILSEQ: | ||
94 | errmsg = "CRC/Timeout (could be anything)"; | ||
95 | break; | ||
96 | case -ETIME: | ||
97 | errmsg = "Device does not respond"; | ||
98 | break; | ||
99 | } | ||
100 | if (packet < 0) { | ||
101 | dprintk(1, "URB status %d [%s].\n", status, errmsg); | ||
102 | } else { | ||
103 | dprintk(1, "URB packet %d, status %d [%s].\n", | ||
104 | packet, status, errmsg); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | static inline int dvb_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
109 | { | ||
110 | int i; | ||
111 | |||
112 | if (!dev) | ||
113 | return 0; | ||
114 | |||
115 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
116 | return 0; | ||
117 | |||
118 | if (urb->status < 0) { | ||
119 | print_err_status(dev, -1, urb->status); | ||
120 | if (urb->status == -ENOENT) | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | for (i = 0; i < urb->number_of_packets; i++) { | ||
125 | int status = urb->iso_frame_desc[i].status; | ||
126 | |||
127 | if (status < 0) { | ||
128 | print_err_status(dev, i, status); | ||
129 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
130 | continue; | ||
131 | } | ||
132 | |||
133 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + | ||
134 | urb->iso_frame_desc[i].offset, | ||
135 | urb->iso_frame_desc[i].actual_length); | ||
136 | } | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static int start_streaming(struct cx231xx_dvb *dvb) | ||
142 | { | ||
143 | int rc; | ||
144 | struct cx231xx *dev = dvb->adapter.priv; | ||
145 | |||
146 | usb_set_interface(dev->udev, 0, 1); | ||
147 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
148 | if (rc < 0) | ||
149 | return rc; | ||
150 | |||
151 | return cx231xx_init_isoc(dev, CX231XX_DVB_MAX_PACKETS, | ||
152 | CX231XX_DVB_NUM_BUFS, CX231XX_DVB_MAX_PACKETSIZE, | ||
153 | dvb_isoc_copy); | ||
154 | } | ||
155 | |||
156 | static int stop_streaming(struct cx231xx_dvb *dvb) | ||
157 | { | ||
158 | struct cx231xx *dev = dvb->adapter.priv; | ||
159 | |||
160 | cx231xx_uninit_isoc(dev); | ||
161 | |||
162 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
163 | |||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static int start_feed(struct dvb_demux_feed *feed) | ||
168 | { | ||
169 | struct dvb_demux *demux = feed->demux; | ||
170 | struct cx231xx_dvb *dvb = demux->priv; | ||
171 | int rc, ret; | ||
172 | |||
173 | if (!demux->dmx.frontend) | ||
174 | return -EINVAL; | ||
175 | |||
176 | mutex_lock(&dvb->lock); | ||
177 | dvb->nfeeds++; | ||
178 | rc = dvb->nfeeds; | ||
179 | |||
180 | if (dvb->nfeeds == 1) { | ||
181 | ret = start_streaming(dvb); | ||
182 | if (ret < 0) | ||
183 | rc = ret; | ||
184 | } | ||
185 | |||
186 | mutex_unlock(&dvb->lock); | ||
187 | return rc; | ||
188 | } | ||
189 | |||
190 | static int stop_feed(struct dvb_demux_feed *feed) | ||
191 | { | ||
192 | struct dvb_demux *demux = feed->demux; | ||
193 | struct cx231xx_dvb *dvb = demux->priv; | ||
194 | int err = 0; | ||
195 | |||
196 | mutex_lock(&dvb->lock); | ||
197 | dvb->nfeeds--; | ||
198 | |||
199 | if (0 == dvb->nfeeds) | ||
200 | err = stop_streaming(dvb); | ||
201 | |||
202 | mutex_unlock(&dvb->lock); | ||
203 | return err; | ||
204 | } | ||
205 | |||
206 | |||
207 | |||
208 | /* ------------------------------------------------------------------ */ | ||
209 | static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | ||
210 | { | ||
211 | struct cx231xx *dev = fe->dvb->priv; | ||
212 | |||
213 | if (acquire) | ||
214 | return cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
215 | else | ||
216 | return cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
217 | } | ||
218 | |||
219 | /* ------------------------------------------------------------------ */ | ||
220 | |||
221 | |||
222 | static struct xc5000_config cnxt_rde250_tunerconfig = { | ||
223 | .i2c_address = 0x61, | ||
224 | .if_khz = 5380, | ||
225 | }; | ||
226 | |||
227 | |||
228 | /* ------------------------------------------------------------------ */ | ||
229 | #if 0 | ||
230 | static int attach_xc5000(u8 addr, struct cx231xx *dev) | ||
231 | { | ||
232 | |||
233 | struct dvb_frontend *fe; | ||
234 | struct xc5000_config cfg; | ||
235 | |||
236 | memset(&cfg, 0, sizeof(cfg)); | ||
237 | cfg.i2c_adap = &dev->i2c_bus[1].i2c_adap; | ||
238 | cfg.i2c_addr = addr; | ||
239 | |||
240 | if (!dev->dvb->frontend) { | ||
241 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
242 | "Can't attach xc5000\n", | ||
243 | dev->name); | ||
244 | return -EINVAL; | ||
245 | } | ||
246 | |||
247 | fe = dvb_attach(xc5000_attach, dev->dvb->frontend, &cfg); | ||
248 | if (!fe) { | ||
249 | printk(KERN_ERR "%s/2: xc5000 attach failed\n", dev->name); | ||
250 | dvb_frontend_detach(dev->dvb->frontend); | ||
251 | dev->dvb->frontend = NULL; | ||
252 | return -EINVAL; | ||
253 | } | ||
254 | |||
255 | printk(KERN_INFO "%s/2: xc5000 attached\n", dev->name); | ||
256 | |||
257 | return 0; | ||
258 | } | ||
259 | #endif | ||
260 | |||
261 | int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq ) | ||
262 | { | ||
263 | int status = 0; | ||
264 | |||
265 | if( (dev->dvb != NULL) && (dev->dvb->frontend != NULL) ){ | ||
266 | |||
267 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
268 | |||
269 | if(dops->set_analog_params != NULL) { | ||
270 | struct analog_parameters params; | ||
271 | |||
272 | params.frequency = freq; | ||
273 | params.std = dev->norm; | ||
274 | params.mode = 0 ; /* 0- Air; 1 - cable */ | ||
275 | /*params.audmode = ; */ | ||
276 | |||
277 | /* Set the analog parameters to set the frequency */ | ||
278 | cx231xx_info("Setting Frequency for XC5000\n"); | ||
279 | dops->set_analog_params(dev->dvb->frontend, ¶ms); | ||
280 | } | ||
281 | |||
282 | } | ||
283 | |||
284 | return status; | ||
285 | } | ||
286 | |||
287 | int cx231xx_reset_analog_tuner(struct cx231xx *dev) | ||
288 | { | ||
289 | int status = 0; | ||
290 | |||
291 | if( (dev->dvb != NULL) && (dev->dvb->frontend != NULL) ){ | ||
292 | |||
293 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
294 | |||
295 | if(dops->init != NULL && !dev->xc_fw_load_done) { | ||
296 | |||
297 | cx231xx_info("Reloading firmware for XC5000\n"); | ||
298 | status = dops->init(dev->dvb->frontend); | ||
299 | if(status == 0 ) { | ||
300 | dev->xc_fw_load_done = 1; | ||
301 | cx231xx_info("XC5000 firmware download completed\n"); | ||
302 | } else { | ||
303 | dev->xc_fw_load_done = 0; | ||
304 | cx231xx_info("XC5000 firmware download failed !!!\n"); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | } | ||
309 | |||
310 | return status; | ||
311 | } | ||
312 | |||
313 | |||
314 | /* ------------------------------------------------------------------ */ | ||
315 | |||
316 | static int register_dvb(struct cx231xx_dvb *dvb, | ||
317 | struct module *module, | ||
318 | struct cx231xx *dev, | ||
319 | struct device *device) | ||
320 | { | ||
321 | int result; | ||
322 | |||
323 | mutex_init(&dvb->lock); | ||
324 | |||
325 | /* register adapter */ | ||
326 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, | ||
327 | adapter_nr); | ||
328 | if (result < 0) { | ||
329 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", | ||
330 | dev->name, result); | ||
331 | goto fail_adapter; | ||
332 | } | ||
333 | |||
334 | /* Ensure all frontends negotiate bus access */ | ||
335 | dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl; | ||
336 | |||
337 | dvb->adapter.priv = dev; | ||
338 | |||
339 | /* register frontend */ | ||
340 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | ||
341 | if (result < 0) { | ||
342 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", | ||
343 | dev->name, result); | ||
344 | goto fail_frontend; | ||
345 | } | ||
346 | |||
347 | /* register demux stuff */ | ||
348 | dvb->demux.dmx.capabilities = | ||
349 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | | ||
350 | DMX_MEMORY_BASED_FILTERING; | ||
351 | dvb->demux.priv = dvb; | ||
352 | dvb->demux.filternum = 256; | ||
353 | dvb->demux.feednum = 256; | ||
354 | dvb->demux.start_feed = start_feed; | ||
355 | dvb->demux.stop_feed = stop_feed; | ||
356 | |||
357 | result = dvb_dmx_init(&dvb->demux); | ||
358 | if (result < 0) { | ||
359 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", | ||
360 | dev->name, result); | ||
361 | goto fail_dmx; | ||
362 | } | ||
363 | |||
364 | dvb->dmxdev.filternum = 256; | ||
365 | dvb->dmxdev.demux = &dvb->demux.dmx; | ||
366 | dvb->dmxdev.capabilities = 0; | ||
367 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | ||
368 | if (result < 0) { | ||
369 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | ||
370 | dev->name, result); | ||
371 | goto fail_dmxdev; | ||
372 | } | ||
373 | |||
374 | dvb->fe_hw.source = DMX_FRONTEND_0; | ||
375 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
376 | if (result < 0) { | ||
377 | printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", | ||
378 | dev->name, result); | ||
379 | goto fail_fe_hw; | ||
380 | } | ||
381 | |||
382 | dvb->fe_mem.source = DMX_MEMORY_FE; | ||
383 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
384 | if (result < 0) { | ||
385 | printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", | ||
386 | dev->name, result); | ||
387 | goto fail_fe_mem; | ||
388 | } | ||
389 | |||
390 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
391 | if (result < 0) { | ||
392 | printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", | ||
393 | dev->name, result); | ||
394 | goto fail_fe_conn; | ||
395 | } | ||
396 | |||
397 | /* register network adapter */ | ||
398 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | ||
399 | return 0; | ||
400 | |||
401 | fail_fe_conn: | ||
402 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
403 | fail_fe_mem: | ||
404 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
405 | fail_fe_hw: | ||
406 | dvb_dmxdev_release(&dvb->dmxdev); | ||
407 | fail_dmxdev: | ||
408 | dvb_dmx_release(&dvb->demux); | ||
409 | fail_dmx: | ||
410 | dvb_unregister_frontend(dvb->frontend); | ||
411 | fail_frontend: | ||
412 | dvb_frontend_detach(dvb->frontend); | ||
413 | dvb_unregister_adapter(&dvb->adapter); | ||
414 | fail_adapter: | ||
415 | return result; | ||
416 | } | ||
417 | |||
418 | static void unregister_dvb(struct cx231xx_dvb *dvb) | ||
419 | { | ||
420 | dvb_net_release(&dvb->net); | ||
421 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
422 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
423 | dvb_dmxdev_release(&dvb->dmxdev); | ||
424 | dvb_dmx_release(&dvb->demux); | ||
425 | dvb_unregister_frontend(dvb->frontend); | ||
426 | dvb_frontend_detach(dvb->frontend); | ||
427 | dvb_unregister_adapter(&dvb->adapter); | ||
428 | } | ||
429 | |||
430 | |||
431 | static int dvb_init(struct cx231xx *dev) | ||
432 | { | ||
433 | int result = 0; | ||
434 | struct cx231xx_dvb *dvb; | ||
435 | |||
436 | if (!dev->board.has_dvb) { | ||
437 | /* This device does not support the extension */ | ||
438 | return 0; | ||
439 | } | ||
440 | |||
441 | dvb = kzalloc(sizeof(struct cx231xx_dvb), GFP_KERNEL); | ||
442 | |||
443 | if (dvb == NULL) { | ||
444 | printk(KERN_INFO "cx231xx_dvb: memory allocation failed\n"); | ||
445 | return -ENOMEM; | ||
446 | } | ||
447 | dev->dvb = dvb; | ||
448 | dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; | ||
449 | dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; | ||
450 | |||
451 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
452 | /* init frontend */ | ||
453 | switch (dev->model) { | ||
454 | case CX231XX_BOARD_CNXT_RDE_250: | ||
455 | |||
456 | /* dev->dvb->frontend = dvb_attach(s5h1411_attach, | ||
457 | &dvico_s5h1411_config, | ||
458 | &dev->i2c_bus[1].i2c_adap);*/ | ||
459 | dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); | ||
460 | |||
461 | if(dev->dvb->frontend == NULL) { | ||
462 | printk(DRIVER_NAME ": Failed to attach dummy front end\n"); | ||
463 | result = -EINVAL; | ||
464 | goto out_free; | ||
465 | } | ||
466 | |||
467 | /* define general-purpose callback pointer */ | ||
468 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
469 | |||
470 | if(dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
471 | &dev->i2c_bus[1].i2c_adap, | ||
472 | &cnxt_rde250_tunerconfig) < 0) { | ||
473 | result = -EINVAL; | ||
474 | goto out_free; | ||
475 | } | ||
476 | |||
477 | break; | ||
478 | case CX231XX_BOARD_CNXT_RDU_250: | ||
479 | |||
480 | dev->dvb->frontend = dvb_attach(dvb_dummy_fe_ofdm_attach); | ||
481 | |||
482 | if(dev->dvb->frontend == NULL) { | ||
483 | printk(DRIVER_NAME ": Failed to attach dummy front end\n"); | ||
484 | result = -EINVAL; | ||
485 | goto out_free; | ||
486 | } | ||
487 | |||
488 | /* define general-purpose callback pointer */ | ||
489 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
490 | |||
491 | if(dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
492 | &dev->i2c_bus[1].i2c_adap, | ||
493 | &cnxt_rde250_tunerconfig) < 0) { | ||
494 | result = -EINVAL; | ||
495 | goto out_free; | ||
496 | } | ||
497 | break; | ||
498 | |||
499 | default: | ||
500 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
501 | " isn't supported yet\n", | ||
502 | dev->name); | ||
503 | break; | ||
504 | } | ||
505 | if (NULL == dvb->frontend) { | ||
506 | printk(KERN_ERR | ||
507 | "%s/2: frontend initialization failed\n", | ||
508 | dev->name); | ||
509 | result = -EINVAL; | ||
510 | goto out_free; | ||
511 | } | ||
512 | |||
513 | |||
514 | /* register everything */ | ||
515 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); | ||
516 | |||
517 | if (result < 0) | ||
518 | goto out_free; | ||
519 | |||
520 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
521 | printk(KERN_INFO "Successfully loaded cx231xx-dvb\n"); | ||
522 | return 0; | ||
523 | |||
524 | out_free: | ||
525 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
526 | kfree(dvb); | ||
527 | dev->dvb = NULL; | ||
528 | return result; | ||
529 | } | ||
530 | |||
531 | static int dvb_fini(struct cx231xx *dev) | ||
532 | { | ||
533 | if (!dev->board.has_dvb) { | ||
534 | /* This device does not support the extension */ | ||
535 | return 0; | ||
536 | } | ||
537 | |||
538 | if (dev->dvb) { | ||
539 | unregister_dvb(dev->dvb); | ||
540 | dev->dvb = NULL; | ||
541 | } | ||
542 | |||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | static struct cx231xx_ops dvb_ops = { | ||
547 | .id = CX231XX_DVB, | ||
548 | .name = "Cx231xx dvb Extension", | ||
549 | .init = dvb_init, | ||
550 | .fini = dvb_fini, | ||
551 | }; | ||
552 | |||
553 | static int __init cx231xx_dvb_register(void) | ||
554 | { | ||
555 | return cx231xx_register_extension(&dvb_ops); | ||
556 | } | ||
557 | |||
558 | static void __exit cx231xx_dvb_unregister(void) | ||
559 | { | ||
560 | cx231xx_unregister_extension(&dvb_ops); | ||
561 | } | ||
562 | |||
563 | module_init(cx231xx_dvb_register); | ||
564 | module_exit(cx231xx_dvb_unregister); | ||
565 | |||