23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/module.h>
27 #include <linux/device.h>
31 #include <linux/pci.h>
32 #include <linux/slab.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); \
122 static unsigned int debug;
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)
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)
227 #define MAX_IRQ_LOOP 50
232 static char *cx25821_aud_irqs[32] = {
233 "dn_risci1",
"up_risci1",
"rds_dn_risc1",
235 "dn_risci2",
"up_risci2",
"rds_dn_risc2",
237 "dnf_of",
"upf_uf",
"rds_dnf_uf",
239 "dn_sync",
"up_sync",
"rds_dn_sync",
241 "opc_err",
"par_err",
"rip_err",
242 "pci_abort",
"ber_irq",
"mchg_irq"
253 if (0 == (status & mask))
257 if (debug > 1 || (status & mask & ~0xff))
263 pr_warn(
"WARNING %s/1: Audio risc op code error\n", dev->
name);
271 pr_warn(
"WARNING %s: Downstream sync error!\n", dev->
name);
291 u32 audint_status, audint_mask;
292 int loop, handled = 0;
298 for (loop = 0; loop < 1; loop++) {
309 cx25821_aud_irq(chip, audint_status,
320 cx25821_aud_irq(chip, audint_status, audint_mask);
336 dprintk(2,
"Freeing buffer\n");
355 #define DEFAULT_FIFO_SIZE 384
384 unsigned int bpl = 0;
387 pr_err(
"DEBUG: cx25821 can't find device struct. Can't proceed with open\n");
398 runtime->
hw = snd_cx25821_digital_hw;
409 runtime->
hw.period_bytes_min = bpl;
410 runtime->
hw.period_bytes_max = bpl;
415 dprintk(1,
"Error opening PCM!\n");
439 if (substream->
runtime->dma_area) {
440 dsp_buffer_free(chip);
444 chip->
period_size = params_period_bytes(hw_params);
474 pr_info(
"DEBUG: ERROR after cx25821_risc_databuffer_audio()\n");
488 substream->
runtime->dma_addr = 0;
504 if (substream->
runtime->dma_area) {
505 dsp_buffer_free(chip);
534 err = _cx25821_start_audio_dma(chip);
537 err = _cx25821_stop_audio_dma(chip);
579 .
open = snd_cx25821_pcm_open,
580 .close = snd_cx25821_close,
582 .hw_params = snd_cx25821_hw_params,
583 .hw_free = snd_cx25821_hw_free,
584 .prepare = snd_cx25821_prepare,
585 .trigger = snd_cx25821_card_trigger,
586 .pointer = snd_cx25821_pointer,
587 .page = snd_cx25821_page,
602 pr_info(
"ERROR: FAILED snd_pcm_new() in %s\n", __func__);
660 static int cx25821_audio_initdev(
struct cx25821_dev *dev)
667 pr_info(
"DEBUG ERROR: devno >= SNDRV_CARDS %s\n", __func__);
673 pr_info(
"DEBUG ERROR: !enable[devno] %s\n", __func__);
680 pr_info(
"DEBUG ERROR: cannot create snd_card_new in %s\n",
697 chip->
irq = dev->
pci->irq;
703 pr_err(
"ERROR %s: can't get IRQ %d for ALSA\n", chip->
dev->name,
708 err = snd_cx25821_pcm(chip, 0,
"cx25821 Digital");
710 pr_info(
"DEBUG ERROR: cannot create snd_cx25821_pcm %s\n",
722 pr_info(
"%s/%i: ALSA support for cx25821 boards\n", card->
driver,
727 pr_info(
"DEBUG ERROR: cannot register sound card %s\n",
745 static void cx25821_audio_fini(
void)
757 static int cx25821_alsa_init(
void)
765 cx25821_audio_initdev(dev);
770 pr_info(
"ERROR ALSA: no cx25821 cards found\n");