2 * Driver for the Conexant CX25821 PCIe bridge
4 * Copyright (C) 2009 Conexant Systems Inc.
5 * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
6 * Based on SAA713x ALSA driver and CX88 driver
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, version 2
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/device.h>
28 #include <linux/interrupt.h>
29 #include <linux/vmalloc.h>
30 #include <linux/dma-mapping.h>
31 #include <linux/pci.h>
32 #include <linux/slab.h>
34 #include <linux/delay.h>
35 #include <sound/core.h>
36 #include <sound/pcm.h>
37 #include <sound/pcm_params.h>
38 #include <sound/control.h>
39 #include <sound/initval.h>
40 #include <sound/tlv.h>
43 #include "cx25821-reg.h"
45 #define AUDIO_SRAM_CHANNEL SRAM_CH08
47 #define dprintk(level, fmt, arg...) \
50 pr_info("%s/1: " fmt, chip->dev->name, ##arg); \
52 #define dprintk_core(level, fmt, arg...) \
55 printk(KERN_DEBUG "%s/1: " fmt, chip->dev->name, ##arg); \
58 /****************************************************************************
59 Data type declarations - Can be moded to a header file later
60 ****************************************************************************/
64 struct cx25821_audio_buffer
{
66 struct cx25821_riscmem risc
;
68 struct scatterlist
*sglist
;
73 struct cx25821_audio_dev
{
74 struct cx25821_dev
*dev
;
75 struct cx25821_dmaqueue q
;
83 struct snd_card
*card
;
89 unsigned int dma_size
;
90 unsigned int period_size
;
91 unsigned int num_periods
;
93 struct cx25821_audio_buffer
*buf
;
95 struct snd_pcm_substream
*substream
;
99 /****************************************************************************
100 Module global static vars
101 ****************************************************************************/
103 static int index
[SNDRV_CARDS
] = SNDRV_DEFAULT_IDX
; /* Index 0-MAX */
104 static char *id
[SNDRV_CARDS
] = SNDRV_DEFAULT_STR
; /* ID for this card */
105 static bool enable
[SNDRV_CARDS
] = SNDRV_DEFAULT_ENABLE_PNP
;
107 module_param_array(enable
, bool, NULL
, 0444);
108 MODULE_PARM_DESC(enable
, "Enable cx25821 soundcard. default enabled.");
110 module_param_array(index
, int, NULL
, 0444);
111 MODULE_PARM_DESC(index
, "Index value for cx25821 capture interface(s).");
113 /****************************************************************************
115 ****************************************************************************/
117 MODULE_DESCRIPTION("ALSA driver module for cx25821 based capture cards");
118 MODULE_AUTHOR("Hiep Huynh");
119 MODULE_LICENSE("GPL");
120 MODULE_SUPPORTED_DEVICE("{{Conexant,25821}"); /* "{{Conexant,23881}," */
122 static unsigned int debug
;
123 module_param(debug
, int, 0644);
124 MODULE_PARM_DESC(debug
, "enable debug messages");
126 /****************************************************************************
127 Module specific funtions
128 ****************************************************************************/
129 /* Constants taken from cx88-reg.h */
130 #define AUD_INT_DN_RISCI1 (1 << 0)
131 #define AUD_INT_UP_RISCI1 (1 << 1)
132 #define AUD_INT_RDS_DN_RISCI1 (1 << 2)
133 #define AUD_INT_DN_RISCI2 (1 << 4) /* yes, 3 is skipped */
134 #define AUD_INT_UP_RISCI2 (1 << 5)
135 #define AUD_INT_RDS_DN_RISCI2 (1 << 6)
136 #define AUD_INT_DN_SYNC (1 << 12)
137 #define AUD_INT_UP_SYNC (1 << 13)
138 #define AUD_INT_RDS_DN_SYNC (1 << 14)
139 #define AUD_INT_OPC_ERR (1 << 16)
140 #define AUD_INT_BER_IRQ (1 << 20)
141 #define AUD_INT_MCHG_IRQ (1 << 21)
142 #define GP_COUNT_CONTROL_RESET 0x3
144 #define PCI_MSK_AUD_EXT (1 << 4)
145 #define PCI_MSK_AUD_INT (1 << 3)
147 static int cx25821_alsa_dma_init(struct cx25821_audio_dev
*chip
, int nr_pages
)
149 struct cx25821_audio_buffer
*buf
= chip
->buf
;
153 buf
->vaddr
= vmalloc_32(nr_pages
<< PAGE_SHIFT
);
154 if (NULL
== buf
->vaddr
) {
155 dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages
);
159 dprintk(1, "vmalloc is at addr 0x%08lx, size=%d\n",
160 (unsigned long)buf
->vaddr
,
161 nr_pages
<< PAGE_SHIFT
);
163 memset(buf
->vaddr
, 0, nr_pages
<< PAGE_SHIFT
);
164 buf
->nr_pages
= nr_pages
;
166 buf
->sglist
= vzalloc(buf
->nr_pages
* sizeof(*buf
->sglist
));
167 if (NULL
== buf
->sglist
)
170 sg_init_table(buf
->sglist
, buf
->nr_pages
);
171 for (i
= 0; i
< buf
->nr_pages
; i
++) {
172 pg
= vmalloc_to_page(buf
->vaddr
+ i
* PAGE_SIZE
);
174 goto vmalloc_to_page_err
;
175 sg_set_page(&buf
->sglist
[i
], pg
, PAGE_SIZE
, 0);
188 static int cx25821_alsa_dma_map(struct cx25821_audio_dev
*dev
)
190 struct cx25821_audio_buffer
*buf
= dev
->buf
;
192 buf
->sglen
= dma_map_sg(&dev
->pci
->dev
, buf
->sglist
,
193 buf
->nr_pages
, PCI_DMA_FROMDEVICE
);
195 if (0 == buf
->sglen
) {
196 pr_warn("%s: cx25821_alsa_map_sg failed\n", __func__
);
202 static int cx25821_alsa_dma_unmap(struct cx25821_audio_dev
*dev
)
204 struct cx25821_audio_buffer
*buf
= dev
->buf
;
209 dma_unmap_sg(&dev
->pci
->dev
, buf
->sglist
, buf
->sglen
, PCI_DMA_FROMDEVICE
);
214 static int cx25821_alsa_dma_free(struct cx25821_audio_buffer
*buf
)
224 * BOARD Specific: Sets audio DMA
227 static int _cx25821_start_audio_dma(struct cx25821_audio_dev
*chip
)
229 struct cx25821_audio_buffer
*buf
= chip
->buf
;
230 struct cx25821_dev
*dev
= chip
->dev
;
231 const struct sram_channel
*audio_ch
=
232 &cx25821_sram_channels
[AUDIO_SRAM_CHANNEL
];
235 /* enable output on the GPIO 0 for the MCLK ADC (Audio) */
236 cx25821_set_gpiopin_direction(chip
->dev
, 0, 0);
238 /* Make sure RISC/FIFO are off before changing FIFO/RISC settings */
239 cx_clear(AUD_INT_DMA_CTL
,
240 FLD_AUD_DST_A_RISC_EN
| FLD_AUD_DST_A_FIFO_EN
);
242 /* setup fifo + format - out channel */
243 cx25821_sram_channel_setup_audio(chip
->dev
, audio_ch
, buf
->bpl
,
247 cx_write(AUD_A_LNGTH
, buf
->bpl
);
250 /* GP_COUNT_CONTROL_RESET = 0x3 */
251 cx_write(AUD_A_GPCNT_CTL
, GP_COUNT_CONTROL_RESET
);
252 atomic_set(&chip
->count
, 0);
254 /* Set the input mode to 16-bit */
255 tmp
= cx_read(AUD_A_CFG
);
256 cx_write(AUD_A_CFG
, tmp
| FLD_AUD_DST_PK_MODE
| FLD_AUD_DST_ENABLE
|
260 pr_info("DEBUG: Start audio DMA, %d B/line, cmds_start(0x%x)= %d lines/FIFO, %d periods, %d byte buffer\n",
261 buf->bpl, audio_ch->cmds_start,
262 cx_read(audio_ch->cmds_start + 12)>>1,
263 chip->num_periods, buf->bpl * chip->num_periods);
266 /* Enables corresponding bits at AUD_INT_STAT */
267 cx_write(AUD_A_INT_MSK
, FLD_AUD_DST_RISCI1
| FLD_AUD_DST_OF
|
268 FLD_AUD_DST_SYNC
| FLD_AUD_DST_OPC_ERR
);
270 /* Clean any pending interrupt bits already set */
271 cx_write(AUD_A_INT_STAT
, ~0);
273 /* enable audio irqs */
274 cx_set(PCI_INT_MSK
, chip
->dev
->pci_irqmask
| PCI_MSK_AUD_INT
);
276 /* Turn on audio downstream fifo and risc enable 0x101 */
277 tmp
= cx_read(AUD_INT_DMA_CTL
);
278 cx_set(AUD_INT_DMA_CTL
, tmp
|
279 (FLD_AUD_DST_A_RISC_EN
| FLD_AUD_DST_A_FIFO_EN
));
286 * BOARD Specific: Resets audio DMA
288 static int _cx25821_stop_audio_dma(struct cx25821_audio_dev
*chip
)
290 struct cx25821_dev
*dev
= chip
->dev
;
293 cx_clear(AUD_INT_DMA_CTL
,
294 FLD_AUD_DST_A_RISC_EN
| FLD_AUD_DST_A_FIFO_EN
);
297 cx_clear(PCI_INT_MSK
, PCI_MSK_AUD_INT
);
298 cx_clear(AUD_A_INT_MSK
, AUD_INT_OPC_ERR
| AUD_INT_DN_SYNC
|
299 AUD_INT_DN_RISCI2
| AUD_INT_DN_RISCI1
);
304 #define MAX_IRQ_LOOP 50
307 * BOARD Specific: IRQ dma bits
309 static char *cx25821_aud_irqs
[32] = {
310 "dn_risci1", "up_risci1", "rds_dn_risc1", /* 0-2 */
312 "dn_risci2", "up_risci2", "rds_dn_risc2", /* 4-6 */
314 "dnf_of", "upf_uf", "rds_dnf_uf", /* 8-10 */
316 "dn_sync", "up_sync", "rds_dn_sync", /* 12-14 */
318 "opc_err", "par_err", "rip_err", /* 16-18 */
319 "pci_abort", "ber_irq", "mchg_irq" /* 19-21 */
323 * BOARD Specific: Threats IRQ audio specific calls
325 static void cx25821_aud_irq(struct cx25821_audio_dev
*chip
, u32 status
,
328 struct cx25821_dev
*dev
= chip
->dev
;
330 if (0 == (status
& mask
))
333 cx_write(AUD_A_INT_STAT
, status
);
334 if (debug
> 1 || (status
& mask
& ~0xff))
335 cx25821_print_irqbits(dev
->name
, "irq aud", cx25821_aud_irqs
,
336 ARRAY_SIZE(cx25821_aud_irqs
), status
, mask
);
338 /* risc op code error */
339 if (status
& AUD_INT_OPC_ERR
) {
340 pr_warn("WARNING %s/1: Audio risc op code error\n", dev
->name
);
342 cx_clear(AUD_INT_DMA_CTL
,
343 FLD_AUD_DST_A_RISC_EN
| FLD_AUD_DST_A_FIFO_EN
);
344 cx25821_sram_channel_dump_audio(dev
,
345 &cx25821_sram_channels
[AUDIO_SRAM_CHANNEL
]);
347 if (status
& AUD_INT_DN_SYNC
) {
348 pr_warn("WARNING %s: Downstream sync error!\n", dev
->name
);
349 cx_write(AUD_A_GPCNT_CTL
, GP_COUNT_CONTROL_RESET
);
353 /* risc1 downstream */
354 if (status
& AUD_INT_DN_RISCI1
) {
355 atomic_set(&chip
->count
, cx_read(AUD_A_GPCNT
));
356 snd_pcm_period_elapsed(chip
->substream
);
361 * BOARD Specific: Handles IRQ calls
363 static irqreturn_t
cx25821_irq(int irq
, void *dev_id
)
365 struct cx25821_audio_dev
*chip
= dev_id
;
366 struct cx25821_dev
*dev
= chip
->dev
;
367 u32 status
, pci_status
;
368 u32 audint_status
, audint_mask
;
369 int loop
, handled
= 0;
371 audint_status
= cx_read(AUD_A_INT_STAT
);
372 audint_mask
= cx_read(AUD_A_INT_MSK
);
373 status
= cx_read(PCI_INT_STAT
);
375 for (loop
= 0; loop
< 1; loop
++) {
376 status
= cx_read(PCI_INT_STAT
);
378 status
= cx_read(PCI_INT_STAT
);
379 audint_status
= cx_read(AUD_A_INT_STAT
);
380 audint_mask
= cx_read(AUD_A_INT_MSK
);
384 cx_write(PCI_INT_STAT
, status
);
386 cx25821_aud_irq(chip
, audint_status
,
395 cx_write(PCI_INT_STAT
, status
);
397 cx25821_aud_irq(chip
, audint_status
, audint_mask
);
400 pci_status
= cx_read(PCI_INT_STAT
);
403 cx_write(PCI_INT_STAT
, pci_status
);
406 return IRQ_RETVAL(handled
);
409 static int dsp_buffer_free(struct cx25821_audio_dev
*chip
)
411 struct cx25821_riscmem
*risc
= &chip
->buf
->risc
;
413 BUG_ON(!chip
->dma_size
);
415 dprintk(2, "Freeing buffer\n");
416 cx25821_alsa_dma_unmap(chip
);
417 cx25821_alsa_dma_free(chip
->buf
);
418 pci_free_consistent(chip
->pci
, risc
->size
, risc
->cpu
, risc
->dma
);
427 /****************************************************************************
429 ****************************************************************************/
432 * Digital hardware definition
434 #define DEFAULT_FIFO_SIZE 384
435 static struct snd_pcm_hardware snd_cx25821_digital_hw
= {
436 .info
= SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
437 SNDRV_PCM_INFO_BLOCK_TRANSFER
| SNDRV_PCM_INFO_MMAP_VALID
,
438 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
440 .rates
= SNDRV_PCM_RATE_48000
,
445 /* Analog audio output will be full of clicks and pops if there
446 are not exactly four lines in the SRAM FIFO buffer. */
447 .period_bytes_min
= DEFAULT_FIFO_SIZE
/ 3,
448 .period_bytes_max
= DEFAULT_FIFO_SIZE
/ 3,
450 .periods_max
= AUDIO_LINE_SIZE
,
451 /* 128 * 128 = 16384 = 1024 * 16 */
452 .buffer_bytes_max
= (AUDIO_LINE_SIZE
* AUDIO_LINE_SIZE
),
456 * audio pcm capture open callback
458 static int snd_cx25821_pcm_open(struct snd_pcm_substream
*substream
)
460 struct cx25821_audio_dev
*chip
= snd_pcm_substream_chip(substream
);
461 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
463 unsigned int bpl
= 0;
466 pr_err("DEBUG: cx25821 can't find device struct. Can't proceed with open\n");
470 err
= snd_pcm_hw_constraint_pow2(runtime
, 0,
471 SNDRV_PCM_HW_PARAM_PERIODS
);
475 chip
->substream
= substream
;
477 runtime
->hw
= snd_cx25821_digital_hw
;
479 if (cx25821_sram_channels
[AUDIO_SRAM_CHANNEL
].fifo_size
!=
481 /* since there are 3 audio Clusters */
482 bpl
= cx25821_sram_channels
[AUDIO_SRAM_CHANNEL
].fifo_size
/ 3;
483 bpl
&= ~7; /* must be multiple of 8 */
485 if (bpl
> AUDIO_LINE_SIZE
)
486 bpl
= AUDIO_LINE_SIZE
;
488 runtime
->hw
.period_bytes_min
= bpl
;
489 runtime
->hw
.period_bytes_max
= bpl
;
494 dprintk(1, "Error opening PCM!\n");
499 * audio close callback
501 static int snd_cx25821_close(struct snd_pcm_substream
*substream
)
509 static int snd_cx25821_hw_params(struct snd_pcm_substream
*substream
,
510 struct snd_pcm_hw_params
*hw_params
)
512 struct cx25821_audio_dev
*chip
= snd_pcm_substream_chip(substream
);
513 struct cx25821_audio_buffer
*buf
;
516 if (substream
->runtime
->dma_area
) {
517 dsp_buffer_free(chip
);
518 substream
->runtime
->dma_area
= NULL
;
521 chip
->period_size
= params_period_bytes(hw_params
);
522 chip
->num_periods
= params_periods(hw_params
);
523 chip
->dma_size
= chip
->period_size
* params_periods(hw_params
);
525 BUG_ON(!chip
->dma_size
);
526 BUG_ON(chip
->num_periods
& (chip
->num_periods
- 1));
528 buf
= kzalloc(sizeof(*buf
), GFP_KERNEL
);
532 if (chip
->period_size
> AUDIO_LINE_SIZE
)
533 chip
->period_size
= AUDIO_LINE_SIZE
;
535 buf
->bpl
= chip
->period_size
;
538 ret
= cx25821_alsa_dma_init(chip
,
539 (PAGE_ALIGN(chip
->dma_size
) >> PAGE_SHIFT
));
543 ret
= cx25821_alsa_dma_map(chip
);
547 ret
= cx25821_risc_databuffer_audio(chip
->pci
, &buf
->risc
, buf
->sglist
,
548 chip
->period_size
, chip
->num_periods
, 1);
550 pr_info("DEBUG: ERROR after cx25821_risc_databuffer_audio()\n");
554 /* Loop back to start of program */
555 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| RISC_CNT_INC
);
556 buf
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
557 buf
->risc
.jmp
[2] = cpu_to_le32(0); /* bits 63-32 */
559 substream
->runtime
->dma_area
= chip
->buf
->vaddr
;
560 substream
->runtime
->dma_bytes
= chip
->dma_size
;
561 substream
->runtime
->dma_addr
= 0;
574 static int snd_cx25821_hw_free(struct snd_pcm_substream
*substream
)
576 struct cx25821_audio_dev
*chip
= snd_pcm_substream_chip(substream
);
578 if (substream
->runtime
->dma_area
) {
579 dsp_buffer_free(chip
);
580 substream
->runtime
->dma_area
= NULL
;
589 static int snd_cx25821_prepare(struct snd_pcm_substream
*substream
)
597 static int snd_cx25821_card_trigger(struct snd_pcm_substream
*substream
,
600 struct cx25821_audio_dev
*chip
= snd_pcm_substream_chip(substream
);
603 /* Local interrupts are already disabled by ALSA */
604 spin_lock(&chip
->reg_lock
);
607 case SNDRV_PCM_TRIGGER_START
:
608 err
= _cx25821_start_audio_dma(chip
);
610 case SNDRV_PCM_TRIGGER_STOP
:
611 err
= _cx25821_stop_audio_dma(chip
);
618 spin_unlock(&chip
->reg_lock
);
626 static snd_pcm_uframes_t
snd_cx25821_pointer(struct snd_pcm_substream
629 struct cx25821_audio_dev
*chip
= snd_pcm_substream_chip(substream
);
630 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
633 count
= atomic_read(&chip
->count
);
635 return runtime
->period_size
* (count
& (runtime
->periods
- 1));
639 * page callback (needed for mmap)
641 static struct page
*snd_cx25821_page(struct snd_pcm_substream
*substream
,
642 unsigned long offset
)
644 void *pageptr
= substream
->runtime
->dma_area
+ offset
;
646 return vmalloc_to_page(pageptr
);
652 static struct snd_pcm_ops snd_cx25821_pcm_ops
= {
653 .open
= snd_cx25821_pcm_open
,
654 .close
= snd_cx25821_close
,
655 .ioctl
= snd_pcm_lib_ioctl
,
656 .hw_params
= snd_cx25821_hw_params
,
657 .hw_free
= snd_cx25821_hw_free
,
658 .prepare
= snd_cx25821_prepare
,
659 .trigger
= snd_cx25821_card_trigger
,
660 .pointer
= snd_cx25821_pointer
,
661 .page
= snd_cx25821_page
,
665 * ALSA create a PCM device: Called when initializing the board.
666 * Sets up the name and hooks up the callbacks
668 static int snd_cx25821_pcm(struct cx25821_audio_dev
*chip
, int device
,
674 err
= snd_pcm_new(chip
->card
, name
, device
, 0, 1, &pcm
);
676 pr_info("ERROR: FAILED snd_pcm_new() in %s\n", __func__
);
679 pcm
->private_data
= chip
;
681 strcpy(pcm
->name
, name
);
682 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_cx25821_pcm_ops
);
687 /****************************************************************************
688 Basic Flow for Sound Devices
689 ****************************************************************************/
692 * PCI ID Table - 14f1:8801 and 14f1:8811 means function 1: Audio
693 * Only boards with eeprom and byte 1 at eeprom=1 have it
696 static const struct pci_device_id cx25821_audio_pci_tbl
[] = {
697 {0x14f1, 0x0920, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0},
701 MODULE_DEVICE_TABLE(pci
, cx25821_audio_pci_tbl
);
704 * Alsa Constructor - Component probe
706 static int cx25821_audio_initdev(struct cx25821_dev
*dev
)
708 struct snd_card
*card
;
709 struct cx25821_audio_dev
*chip
;
712 if (devno
>= SNDRV_CARDS
) {
713 pr_info("DEBUG ERROR: devno >= SNDRV_CARDS %s\n", __func__
);
717 if (!enable
[devno
]) {
719 pr_info("DEBUG ERROR: !enable[devno] %s\n", __func__
);
723 err
= snd_card_new(&dev
->pci
->dev
, index
[devno
], id
[devno
],
725 sizeof(struct cx25821_audio_dev
), &card
);
727 pr_info("DEBUG ERROR: cannot create snd_card_new in %s\n",
732 strcpy(card
->driver
, "cx25821");
734 /* Card "creation" */
735 chip
= card
->private_data
;
736 spin_lock_init(&chip
->reg_lock
);
740 chip
->pci
= dev
->pci
;
741 chip
->iobase
= pci_resource_start(dev
->pci
, 0);
743 chip
->irq
= dev
->pci
->irq
;
745 err
= request_irq(dev
->pci
->irq
, cx25821_irq
,
746 IRQF_SHARED
, chip
->dev
->name
, chip
);
749 pr_err("ERROR %s: can't get IRQ %d for ALSA\n", chip
->dev
->name
,
754 err
= snd_cx25821_pcm(chip
, 0, "cx25821 Digital");
756 pr_info("DEBUG ERROR: cannot create snd_cx25821_pcm %s\n",
761 strcpy(card
->shortname
, "cx25821");
762 sprintf(card
->longname
, "%s at 0x%lx irq %d", chip
->dev
->name
,
763 chip
->iobase
, chip
->irq
);
764 strcpy(card
->mixername
, "CX25821");
766 pr_info("%s/%i: ALSA support for cx25821 boards\n", card
->driver
,
769 err
= snd_card_register(card
);
771 pr_info("DEBUG ERROR: cannot register sound card %s\n",
785 /****************************************************************************
787 ****************************************************************************/
789 static int cx25821_alsa_exit_callback(struct device
*dev
, void *data
)
791 struct v4l2_device
*v4l2_dev
= dev_get_drvdata(dev
);
792 struct cx25821_dev
*cxdev
= get_cx25821(v4l2_dev
);
794 snd_card_free(cxdev
->card
);
798 static void cx25821_audio_fini(void)
800 struct device_driver
*drv
= driver_find("cx25821", &pci_bus_type
);
803 ret
= driver_for_each_device(drv
, NULL
, NULL
, cx25821_alsa_exit_callback
);
805 pr_err("%s failed to find a cx25821 driver.\n", __func__
);
808 static int cx25821_alsa_init_callback(struct device
*dev
, void *data
)
810 struct v4l2_device
*v4l2_dev
= dev_get_drvdata(dev
);
811 struct cx25821_dev
*cxdev
= get_cx25821(v4l2_dev
);
813 cx25821_audio_initdev(cxdev
);
820 * Loops through present saa7134 cards, and assigns an ALSA device
824 static int cx25821_alsa_init(void)
826 struct device_driver
*drv
= driver_find("cx25821", &pci_bus_type
);
828 return driver_for_each_device(drv
, NULL
, NULL
, cx25821_alsa_init_callback
);
832 late_initcall(cx25821_alsa_init
);
833 module_exit(cx25821_audio_fini
);