3 * Support for the mpeg transport stream transfers
4 * PCI function #2 of the cx2388x.
6 * (c) 2004 Jelle Foks <jelle@foks.us>
7 * (c) 2004 Chris Pascoe <c.pascoe@itee.uq.edu.au>
8 * (c) 2004 Gerd Knorr <kraxel@bytesex.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <linux/module.h>
28 #include <linux/slab.h>
29 #include <linux/init.h>
30 #include <linux/device.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/interrupt.h>
33 #include <asm/delay.h>
35 /* ------------------------------------------------------------------ */
37 MODULE_DESCRIPTION("mpeg driver for cx2388x based TV cards");
38 MODULE_AUTHOR("Jelle Foks <jelle@foks.us>");
39 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
40 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
41 MODULE_LICENSE("GPL");
42 MODULE_VERSION(CX88_VERSION
);
44 static unsigned int debug
;
45 module_param(debug
, int, 0644);
46 MODULE_PARM_DESC(debug
, "enable debug messages [mpeg]");
48 #define dprintk(level, fmt, arg...) do { \
49 if (debug + 1 > level) \
50 printk(KERN_DEBUG pr_fmt("%s: mpeg:" fmt), \
54 #if defined(CONFIG_MODULES) && defined(MODULE)
55 static void request_module_async(struct work_struct
*work
)
57 struct cx8802_dev
*dev
= container_of(work
, struct cx8802_dev
, request_module_wk
);
59 if (dev
->core
->board
.mpeg
& CX88_MPEG_DVB
)
60 request_module("cx88-dvb");
61 if (dev
->core
->board
.mpeg
& CX88_MPEG_BLACKBIRD
)
62 request_module("cx88-blackbird");
65 static void request_modules(struct cx8802_dev
*dev
)
67 INIT_WORK(&dev
->request_module_wk
, request_module_async
);
68 schedule_work(&dev
->request_module_wk
);
71 static void flush_request_modules(struct cx8802_dev
*dev
)
73 flush_work(&dev
->request_module_wk
);
76 #define request_modules(dev)
77 #define flush_request_modules(dev)
78 #endif /* CONFIG_MODULES */
81 static LIST_HEAD(cx8802_devlist
);
82 static DEFINE_MUTEX(cx8802_mutex
);
83 /* ------------------------------------------------------------------ */
85 int cx8802_start_dma(struct cx8802_dev
*dev
,
86 struct cx88_dmaqueue
*q
,
87 struct cx88_buffer
*buf
)
89 struct cx88_core
*core
= dev
->core
;
91 dprintk(1, "w: %d, h: %d, f: %d\n",
92 core
->width
, core
->height
, core
->field
);
94 /* setup fifo + format */
95 cx88_sram_channel_setup(core
, &cx88_sram_channels
[SRAM_CH28
],
96 dev
->ts_packet_size
, buf
->risc
.dma
);
98 /* write TS length to chip */
99 cx_write(MO_TS_LNGTH
, dev
->ts_packet_size
);
101 /* FIXME: this needs a review.
102 * also: move to cx88-blackbird + cx88-dvb source files? */
104 dprintk(1, "core->active_type_id = 0x%08x\n", core
->active_type_id
);
106 if ((core
->active_type_id
== CX88_MPEG_DVB
) &&
107 (core
->board
.mpeg
& CX88_MPEG_DVB
)) {
109 dprintk(1, "cx8802_start_dma doing .dvb\n");
110 /* negedge driven & software reset */
111 cx_write(TS_GEN_CNTRL
, 0x0040 | dev
->ts_gen_cntrl
);
113 cx_write(MO_PINMUX_IO
, 0x00);
114 cx_write(TS_HW_SOP_CNTRL
, 0x47<<16|188<<4|0x01);
115 switch (core
->boardnr
) {
116 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q
:
117 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T
:
118 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
119 case CX88_BOARD_PCHDTV_HD5500
:
120 cx_write(TS_SOP_STAT
, 1<<13);
122 case CX88_BOARD_SAMSUNG_SMT_7020
:
123 cx_write(TS_SOP_STAT
, 0x00);
125 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1
:
126 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1
:
127 cx_write(MO_PINMUX_IO
, 0x88); /* Enable MPEG parallel IO and video signal pins */
130 case CX88_BOARD_HAUPPAUGE_HVR1300
:
131 /* Enable MPEG parallel IO and video signal pins */
132 cx_write(MO_PINMUX_IO
, 0x88);
133 cx_write(TS_SOP_STAT
, 0);
134 cx_write(TS_VALERR_CNTRL
, 0);
136 case CX88_BOARD_PINNACLE_PCTV_HD_800i
:
137 /* Enable MPEG parallel IO and video signal pins */
138 cx_write(MO_PINMUX_IO
, 0x88);
139 cx_write(TS_HW_SOP_CNTRL
, (0x47 << 16) | (188 << 4));
140 dev
->ts_gen_cntrl
= 5;
141 cx_write(TS_SOP_STAT
, 0);
142 cx_write(TS_VALERR_CNTRL
, 0);
146 cx_write(TS_SOP_STAT
, 0x00);
149 cx_write(TS_GEN_CNTRL
, dev
->ts_gen_cntrl
);
151 } else if ((core
->active_type_id
== CX88_MPEG_BLACKBIRD
) &&
152 (core
->board
.mpeg
& CX88_MPEG_BLACKBIRD
)) {
153 dprintk(1, "cx8802_start_dma doing .blackbird\n");
154 cx_write(MO_PINMUX_IO
, 0x88); /* enable MPEG parallel IO */
156 cx_write(TS_GEN_CNTRL
, 0x46); /* punctured clock TS & posedge driven & software reset */
159 cx_write(TS_HW_SOP_CNTRL
, 0x408); /* mpeg start byte */
160 cx_write(TS_VALERR_CNTRL
, 0x2000);
162 cx_write(TS_GEN_CNTRL
, 0x06); /* punctured clock TS & posedge driven */
165 pr_err("%s() Failed. Unsupported value in .mpeg (0x%08x)\n",
166 __func__
, core
->board
.mpeg
);
171 cx_write(MO_TS_GPCNTRL
, GP_COUNT_CONTROL_RESET
);
175 dprintk(1, "setting the interrupt mask\n");
176 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
| PCI_INT_TSINT
);
177 cx_set(MO_TS_INTMSK
, 0x1f0011);
180 cx_set(MO_DEV_CNTRL2
, (1<<5));
181 cx_set(MO_TS_DMACNTRL
, 0x11);
185 static int cx8802_stop_dma(struct cx8802_dev
*dev
)
187 struct cx88_core
*core
= dev
->core
;
192 cx_clear(MO_TS_DMACNTRL
, 0x11);
195 cx_clear(MO_PCI_INTMSK
, PCI_INT_TSINT
);
196 cx_clear(MO_TS_INTMSK
, 0x1f0011);
198 /* Reset the controller */
199 cx_write(TS_GEN_CNTRL
, 0xcd);
203 static int cx8802_restart_queue(struct cx8802_dev
*dev
,
204 struct cx88_dmaqueue
*q
)
206 struct cx88_buffer
*buf
;
209 if (list_empty(&q
->active
))
212 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, list
);
213 dprintk(2, "restart_queue [%p/%d]: restart dma\n",
214 buf
, buf
->vb
.vb2_buf
.index
);
215 cx8802_start_dma(dev
, q
, buf
);
219 /* ------------------------------------------------------------------ */
221 int cx8802_buf_prepare(struct vb2_queue
*q
, struct cx8802_dev
*dev
,
222 struct cx88_buffer
*buf
)
224 int size
= dev
->ts_packet_size
* dev
->ts_packet_count
;
225 struct sg_table
*sgt
= vb2_dma_sg_plane_desc(&buf
->vb
.vb2_buf
, 0);
226 struct cx88_riscmem
*risc
= &buf
->risc
;
229 if (vb2_plane_size(&buf
->vb
.vb2_buf
, 0) < size
)
231 vb2_set_plane_payload(&buf
->vb
.vb2_buf
, 0, size
);
233 rc
= cx88_risc_databuffer(dev
->pci
, risc
, sgt
->sgl
,
234 dev
->ts_packet_size
, dev
->ts_packet_count
, 0);
237 pci_free_consistent(dev
->pci
, risc
->size
, risc
->cpu
, risc
->dma
);
238 memset(risc
, 0, sizeof(*risc
));
244 void cx8802_buf_queue(struct cx8802_dev
*dev
, struct cx88_buffer
*buf
)
246 struct cx88_buffer
*prev
;
247 struct cx88_dmaqueue
*cx88q
= &dev
->mpegq
;
250 /* add jump to start */
251 buf
->risc
.cpu
[1] = cpu_to_le32(buf
->risc
.dma
+ 8);
252 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_CNT_INC
);
253 buf
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
+ 8);
255 if (list_empty(&cx88q
->active
)) {
256 dprintk(1, "queue is empty - first active\n");
257 list_add_tail(&buf
->list
, &cx88q
->active
);
258 dprintk(1, "[%p/%d] %s - first active\n",
259 buf
, buf
->vb
.vb2_buf
.index
, __func__
);
262 buf
->risc
.cpu
[0] |= cpu_to_le32(RISC_IRQ1
);
263 dprintk(1, "queue is not empty - append to active\n");
264 prev
= list_entry(cx88q
->active
.prev
, struct cx88_buffer
, list
);
265 list_add_tail(&buf
->list
, &cx88q
->active
);
266 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
267 dprintk(1, "[%p/%d] %s - append to active\n",
268 buf
, buf
->vb
.vb2_buf
.index
, __func__
);
272 /* ----------------------------------------------------------- */
274 static void do_cancel_buffers(struct cx8802_dev
*dev
)
276 struct cx88_dmaqueue
*q
= &dev
->mpegq
;
277 struct cx88_buffer
*buf
;
280 spin_lock_irqsave(&dev
->slock
, flags
);
281 while (!list_empty(&q
->active
)) {
282 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, list
);
283 list_del(&buf
->list
);
284 vb2_buffer_done(&buf
->vb
.vb2_buf
, VB2_BUF_STATE_ERROR
);
286 spin_unlock_irqrestore(&dev
->slock
, flags
);
289 void cx8802_cancel_buffers(struct cx8802_dev
*dev
)
292 cx8802_stop_dma(dev
);
293 do_cancel_buffers(dev
);
296 static const char *cx88_mpeg_irqs
[32] = {
297 "ts_risci1", NULL
, NULL
, NULL
,
298 "ts_risci2", NULL
, NULL
, NULL
,
299 "ts_oflow", NULL
, NULL
, NULL
,
300 "ts_sync", NULL
, NULL
, NULL
,
301 "opc_err", "par_err", "rip_err", "pci_abort",
305 static void cx8802_mpeg_irq(struct cx8802_dev
*dev
)
307 struct cx88_core
*core
= dev
->core
;
308 u32 status
, mask
, count
;
311 status
= cx_read(MO_TS_INTSTAT
);
312 mask
= cx_read(MO_TS_INTMSK
);
313 if (0 == (status
& mask
))
316 cx_write(MO_TS_INTSTAT
, status
);
318 if (debug
|| (status
& mask
& ~0xff))
319 cx88_print_irqbits("irq mpeg ",
320 cx88_mpeg_irqs
, ARRAY_SIZE(cx88_mpeg_irqs
),
323 /* risc op code error */
324 if (status
& (1 << 16)) {
325 pr_warn("mpeg risc op code error\n");
326 cx_clear(MO_TS_DMACNTRL
, 0x11);
327 cx88_sram_channel_dump(dev
->core
, &cx88_sram_channels
[SRAM_CH28
]);
332 dprintk(1, "wake up\n");
333 spin_lock(&dev
->slock
);
334 count
= cx_read(MO_TS_GPCNT
);
335 cx88_wakeup(dev
->core
, &dev
->mpegq
, count
);
336 spin_unlock(&dev
->slock
);
339 /* other general errors */
340 if (status
& 0x1f0100) {
341 dprintk(0, "general errors: 0x%08x\n", status
& 0x1f0100);
342 spin_lock(&dev
->slock
);
343 cx8802_stop_dma(dev
);
344 spin_unlock(&dev
->slock
);
348 #define MAX_IRQ_LOOP 10
350 static irqreturn_t
cx8802_irq(int irq
, void *dev_id
)
352 struct cx8802_dev
*dev
= dev_id
;
353 struct cx88_core
*core
= dev
->core
;
355 int loop
, handled
= 0;
357 for (loop
= 0; loop
< MAX_IRQ_LOOP
; loop
++) {
358 status
= cx_read(MO_PCI_INTSTAT
) &
359 (core
->pci_irqmask
| PCI_INT_TSINT
);
362 dprintk(1, "cx8802_irq\n");
363 dprintk(1, " loop: %d/%d\n", loop
, MAX_IRQ_LOOP
);
364 dprintk(1, " status: %d\n", status
);
366 cx_write(MO_PCI_INTSTAT
, status
);
368 if (status
& core
->pci_irqmask
)
369 cx88_core_irq(core
, status
);
370 if (status
& PCI_INT_TSINT
)
371 cx8802_mpeg_irq(dev
);
373 if (loop
== MAX_IRQ_LOOP
) {
374 dprintk(0, "clearing mask\n");
375 pr_warn("irq loop -- clearing mask\n");
376 cx_write(MO_PCI_INTMSK
, 0);
380 return IRQ_RETVAL(handled
);
383 static int cx8802_init_common(struct cx8802_dev
*dev
)
385 struct cx88_core
*core
= dev
->core
;
389 if (pci_enable_device(dev
->pci
))
391 pci_set_master(dev
->pci
);
392 err
= pci_set_dma_mask(dev
->pci
, DMA_BIT_MASK(32));
394 pr_err("Oops: no 32bit PCI DMA ???\n");
398 dev
->pci_rev
= dev
->pci
->revision
;
399 pci_read_config_byte(dev
->pci
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
400 pr_info("found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
401 pci_name(dev
->pci
), dev
->pci_rev
, dev
->pci
->irq
,
403 (unsigned long long)pci_resource_start(dev
->pci
, 0));
405 /* initialize driver struct */
406 spin_lock_init(&dev
->slock
);
409 INIT_LIST_HEAD(&dev
->mpegq
.active
);
412 err
= request_irq(dev
->pci
->irq
, cx8802_irq
,
413 IRQF_SHARED
, dev
->core
->name
, dev
);
415 pr_err("can't get IRQ %d\n", dev
->pci
->irq
);
418 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
420 /* everything worked */
421 pci_set_drvdata(dev
->pci
, dev
);
425 static void cx8802_fini_common(struct cx8802_dev
*dev
)
428 cx8802_stop_dma(dev
);
429 pci_disable_device(dev
->pci
);
431 /* unregister stuff */
432 free_irq(dev
->pci
->irq
, dev
);
435 /* ----------------------------------------------------------- */
437 static int cx8802_suspend_common(struct pci_dev
*pci_dev
, pm_message_t state
)
439 struct cx8802_dev
*dev
= pci_get_drvdata(pci_dev
);
443 spin_lock_irqsave(&dev
->slock
, flags
);
444 if (!list_empty(&dev
->mpegq
.active
)) {
445 dprintk(2, "suspend\n");
446 pr_info("suspend mpeg\n");
447 cx8802_stop_dma(dev
);
449 spin_unlock_irqrestore(&dev
->slock
, flags
);
451 /* FIXME -- shutdown device */
452 cx88_shutdown(dev
->core
);
454 pci_save_state(pci_dev
);
455 if (pci_set_power_state(pci_dev
, pci_choose_state(pci_dev
, state
)) != 0) {
456 pci_disable_device(pci_dev
);
457 dev
->state
.disabled
= 1;
462 static int cx8802_resume_common(struct pci_dev
*pci_dev
)
464 struct cx8802_dev
*dev
= pci_get_drvdata(pci_dev
);
468 if (dev
->state
.disabled
) {
469 err
= pci_enable_device(pci_dev
);
471 pr_err("can't enable device\n");
474 dev
->state
.disabled
= 0;
476 err
= pci_set_power_state(pci_dev
, PCI_D0
);
478 pr_err("can't enable device\n");
479 pci_disable_device(pci_dev
);
480 dev
->state
.disabled
= 1;
484 pci_restore_state(pci_dev
);
486 /* FIXME: re-initialize hardware */
487 cx88_reset(dev
->core
);
489 /* restart video+vbi capture */
490 spin_lock_irqsave(&dev
->slock
, flags
);
491 if (!list_empty(&dev
->mpegq
.active
)) {
492 pr_info("resume mpeg\n");
493 cx8802_restart_queue(dev
, &dev
->mpegq
);
495 spin_unlock_irqrestore(&dev
->slock
, flags
);
500 struct cx8802_driver
*cx8802_get_driver(struct cx8802_dev
*dev
, enum cx88_board_type btype
)
502 struct cx8802_driver
*d
;
504 list_for_each_entry(d
, &dev
->drvlist
, drvlist
)
505 if (d
->type_id
== btype
)
511 /* Driver asked for hardware access. */
512 static int cx8802_request_acquire(struct cx8802_driver
*drv
)
514 struct cx88_core
*core
= drv
->core
;
517 /* Fail a request for hardware if the device is busy. */
518 if (core
->active_type_id
!= CX88_BOARD_NONE
&&
519 core
->active_type_id
!= drv
->type_id
)
522 if (drv
->type_id
== CX88_MPEG_DVB
) {
523 /* When switching to DVB, always set the input to the tuner */
524 core
->last_analog_input
= core
->input
;
527 i
< (sizeof(core
->board
.input
) / sizeof(struct cx88_input
));
529 if (core
->board
.input
[i
].type
== CX88_VMUX_DVB
) {
536 if (drv
->advise_acquire
)
539 if (core
->active_type_id
== CX88_BOARD_NONE
) {
540 core
->active_type_id
= drv
->type_id
;
541 drv
->advise_acquire(drv
);
544 dprintk(1, "Post acquire GPIO=%x\n", cx_read(MO_GP0_IO
));
550 /* Driver asked to release hardware. */
551 static int cx8802_request_release(struct cx8802_driver
*drv
)
553 struct cx88_core
*core
= drv
->core
;
555 if (drv
->advise_release
&& --core
->active_ref
== 0)
557 if (drv
->type_id
== CX88_MPEG_DVB
) {
558 /* If the DVB driver is releasing, reset the input
559 state to the last configured analog input */
560 core
->input
= core
->last_analog_input
;
563 drv
->advise_release(drv
);
564 core
->active_type_id
= CX88_BOARD_NONE
;
565 dprintk(1, "Post release GPIO=%x\n", cx_read(MO_GP0_IO
));
571 static int cx8802_check_driver(struct cx8802_driver
*drv
)
576 if ((drv
->type_id
!= CX88_MPEG_DVB
) &&
577 (drv
->type_id
!= CX88_MPEG_BLACKBIRD
))
580 if ((drv
->hw_access
!= CX8802_DRVCTL_SHARED
) &&
581 (drv
->hw_access
!= CX8802_DRVCTL_EXCLUSIVE
))
584 if ((drv
->probe
== NULL
) ||
585 (drv
->remove
== NULL
) ||
586 (drv
->advise_acquire
== NULL
) ||
587 (drv
->advise_release
== NULL
))
593 int cx8802_register_driver(struct cx8802_driver
*drv
)
595 struct cx8802_dev
*dev
;
596 struct cx8802_driver
*driver
;
599 pr_info("registering cx8802 driver, type: %s access: %s\n",
600 drv
->type_id
== CX88_MPEG_DVB
? "dvb" : "blackbird",
601 drv
->hw_access
== CX8802_DRVCTL_SHARED
? "shared" : "exclusive");
603 if ((err
= cx8802_check_driver(drv
)) != 0) {
604 pr_err("cx8802_driver is invalid\n");
608 mutex_lock(&cx8802_mutex
);
610 list_for_each_entry(dev
, &cx8802_devlist
, devlist
) {
611 pr_info("subsystem: %04x:%04x, board: %s [card=%d]\n",
612 dev
->pci
->subsystem_vendor
,
613 dev
->pci
->subsystem_device
, dev
->core
->board
.name
,
616 /* Bring up a new struct for each driver instance */
617 driver
= kzalloc(sizeof(*drv
), GFP_KERNEL
);
618 if (driver
== NULL
) {
623 /* Snapshot of the driver registration data */
624 drv
->core
= dev
->core
;
625 drv
->suspend
= cx8802_suspend_common
;
626 drv
->resume
= cx8802_resume_common
;
627 drv
->request_acquire
= cx8802_request_acquire
;
628 drv
->request_release
= cx8802_request_release
;
629 memcpy(driver
, drv
, sizeof(*driver
));
631 mutex_lock(&drv
->core
->lock
);
632 err
= drv
->probe(driver
);
635 list_add_tail(&driver
->drvlist
, &dev
->drvlist
);
637 pr_err("cx8802 probe failed, err = %d\n", err
);
639 mutex_unlock(&drv
->core
->lock
);
642 err
= i
? 0 : -ENODEV
;
644 mutex_unlock(&cx8802_mutex
);
648 int cx8802_unregister_driver(struct cx8802_driver
*drv
)
650 struct cx8802_dev
*dev
;
651 struct cx8802_driver
*d
, *dtmp
;
654 pr_info("unregistering cx8802 driver, type: %s access: %s\n",
655 drv
->type_id
== CX88_MPEG_DVB
? "dvb" : "blackbird",
656 drv
->hw_access
== CX8802_DRVCTL_SHARED
? "shared" : "exclusive");
658 mutex_lock(&cx8802_mutex
);
660 list_for_each_entry(dev
, &cx8802_devlist
, devlist
) {
661 pr_info("subsystem: %04x:%04x, board: %s [card=%d]\n",
662 dev
->pci
->subsystem_vendor
,
663 dev
->pci
->subsystem_device
, dev
->core
->board
.name
,
666 mutex_lock(&dev
->core
->lock
);
668 list_for_each_entry_safe(d
, dtmp
, &dev
->drvlist
, drvlist
) {
669 /* only unregister the correct driver type */
670 if (d
->type_id
!= drv
->type_id
)
675 list_del(&d
->drvlist
);
678 pr_err("cx8802 driver remove failed (%d)\n",
682 mutex_unlock(&dev
->core
->lock
);
685 mutex_unlock(&cx8802_mutex
);
690 /* ----------------------------------------------------------- */
691 static int cx8802_probe(struct pci_dev
*pci_dev
,
692 const struct pci_device_id
*pci_id
)
694 struct cx8802_dev
*dev
;
695 struct cx88_core
*core
;
699 core
= cx88_core_get(pci_dev
);
703 pr_info("cx2388x 8802 Driver Manager\n");
706 if (!core
->board
.mpeg
)
710 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
716 /* Maintain a reference so cx88-video can query the 8802 device. */
719 err
= cx8802_init_common(dev
);
723 INIT_LIST_HEAD(&dev
->drvlist
);
724 mutex_lock(&cx8802_mutex
);
725 list_add_tail(&dev
->devlist
, &cx8802_devlist
);
726 mutex_unlock(&cx8802_mutex
);
728 /* now autoload cx88-dvb or cx88-blackbird */
729 request_modules(dev
);
736 cx88_core_put(core
, pci_dev
);
740 static void cx8802_remove(struct pci_dev
*pci_dev
)
742 struct cx8802_dev
*dev
;
744 dev
= pci_get_drvdata(pci_dev
);
746 dprintk(1, "%s\n", __func__
);
748 flush_request_modules(dev
);
750 mutex_lock(&dev
->core
->lock
);
752 if (!list_empty(&dev
->drvlist
)) {
753 struct cx8802_driver
*drv
, *tmp
;
756 pr_warn("Trying to remove cx8802 driver while cx8802 sub-drivers still loaded?!\n");
758 list_for_each_entry_safe(drv
, tmp
, &dev
->drvlist
, drvlist
) {
759 err
= drv
->remove(drv
);
761 list_del(&drv
->drvlist
);
763 pr_err("cx8802 driver remove failed (%d)\n",
769 mutex_unlock(&dev
->core
->lock
);
771 /* Destroy any 8802 reference. */
772 dev
->core
->dvbdev
= NULL
;
775 cx8802_fini_common(dev
);
776 cx88_core_put(dev
->core
, dev
->pci
);
780 static const struct pci_device_id cx8802_pci_tbl
[] = {
784 .subvendor
= PCI_ANY_ID
,
785 .subdevice
= PCI_ANY_ID
,
787 /* --- end of list --- */
790 MODULE_DEVICE_TABLE(pci
, cx8802_pci_tbl
);
792 static struct pci_driver cx8802_pci_driver
= {
793 .name
= "cx88-mpeg driver manager",
794 .id_table
= cx8802_pci_tbl
,
795 .probe
= cx8802_probe
,
796 .remove
= cx8802_remove
,
799 module_pci_driver(cx8802_pci_driver
);
801 EXPORT_SYMBOL(cx8802_buf_prepare
);
802 EXPORT_SYMBOL(cx8802_buf_queue
);
803 EXPORT_SYMBOL(cx8802_cancel_buffers
);
804 EXPORT_SYMBOL(cx8802_start_dma
);
806 EXPORT_SYMBOL(cx8802_register_driver
);
807 EXPORT_SYMBOL(cx8802_unregister_driver
);
808 EXPORT_SYMBOL(cx8802_get_driver
);