summaryrefslogtreecommitdiff
path: root/drivers/media/video/saa7134/saa7134-alsa.c
diff options
context:
space:
mode:
authorRicardo Cerqueira <v4l@cerqueira.org>2005-11-08 21:38:53 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 07:56:31 -0800
commit79dd0c69f05fccb0396bdcd861ad4686ce888cda (patch)
treee027b7eede37e1212c3237f3a85824a4990e23ee /drivers/media/video/saa7134/saa7134-alsa.c
parent875c296b8ef42a796dc8db57a40b5e2228240c33 (diff)
[PATCH] V4L: 925: saa7134 alsa is now a standalone module
Saa7134-alsa is now a standalone module Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-alsa.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c110
1 files changed, 98 insertions, 12 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index bf454437b771..7972939cb46c 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -1,6 +1,5 @@
/*
* SAA713x ALSA support for V4L
- * Ricardo Cerqueira <v4l@cerqueira.org>
*
*
* Caveats:
@@ -37,9 +36,13 @@
#include "saa7134.h"
#include "saa7134-reg.h"
-static unsigned int alsa_debug = 0;
-module_param(alsa_debug, int, 0644);
-MODULE_PARM_DESC(alsa_debug,"enable debug messages [alsa]");
+static unsigned int debug = 0;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
+
+unsigned int dsp_nr = 0;
+module_param(dsp_nr, int, 0444);
+MODULE_PARM_DESC(dsp_nr, "alsa device number");
/*
* Configuration macros
@@ -69,7 +72,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
-#define dprintk(fmt, arg...) if (alsa_debug) \
+#define dprintk(fmt, arg...) if (debug) \
printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg)
/*
@@ -107,6 +110,7 @@ typedef struct snd_card_saa7134_pcm {
static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR;
+
/*
* saa7134 DMA audio stop
*
@@ -189,12 +193,11 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
/* next block addr */
next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks;
saa_writel(reg,next_blk * dev->oss.blksize);
- if (alsa_debug > 2)
+ if (debug > 2)
dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n",
(status & 0x10000000) ? "even" : "odd ", next_blk,
next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count);
-
/* update status & wake waiting readers */
dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks;
dev->oss.read_count += dev->oss.blksize;
@@ -212,6 +215,41 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
}
/*
+ * IRQ request handler
+ *
+ * Runs along with saa7134's IRQ handler, discards anything that isn't
+ * DMA sound
+ *
+ */
+
+static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct saa7134_dev *dev = (struct saa7134_dev*) dev_id;
+ unsigned long report, status;
+ int loop, handled = 0;
+
+ for (loop = 0; loop < 10; loop++) {
+ report = saa_readl(SAA7134_IRQ_REPORT);
+ status = saa_readl(SAA7134_IRQ_STATUS);
+
+ if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
+ handled = 1;
+ saa_writel(SAA7134_IRQ_REPORT,report);
+ saa7134_irq_alsa_done(dev, status);
+ } else {
+ goto out;
+ }
+ }
+
+ if (loop == 10) {
+ dprintk("error! looping IRQ!");
+ }
+
+out:
+ return IRQ_RETVAL(handled);
+}
+
+/*
* ALSA capture trigger
*
* - One of the ALSA capture callbacks.
@@ -822,11 +860,9 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10);
if (left || right) { // We've got data, turn the input on
- //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010);
saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin);
saa_writel(SAA7133_ANALOG_IO_SELECT, anabar);
} else {
- //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010);
saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0);
saa_writel(SAA7133_ANALOG_IO_SELECT, 0);
}
@@ -889,9 +925,10 @@ static int snd_saa7134_dev_free(snd_device_t *device)
*
*/
-int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum)
+int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum)
{
static int dev;
+
snd_card_t *card;
snd_card_saa7134_t *chip;
int err;
@@ -899,6 +936,7 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum)
.dev_free = snd_saa7134_dev_free,
};
+
if (dev >= SNDRV_CARDS)
return -ENODEV;
if (!enable[dev])
@@ -906,6 +944,7 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum)
if (devicenum) {
card = snd_card_new(devicenum, id[dev], THIS_MODULE, 0);
+ dsp_nr++;
} else {
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
}
@@ -931,6 +970,15 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum)
chip->irq = saadev->pci->irq;
chip->iobase = pci_resource_start(saadev->pci, 0);
+ err = request_irq(chip->pci->irq, saa7134_alsa_irq,
+ SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev);
+
+ if (err < 0) {
+ printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n",
+ saadev->name, saadev->pci->irq);
+ return err;
+ }
+
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
snd_saa7134_free(chip);
return err;
@@ -963,10 +1011,48 @@ __nodev:
return err;
}
-void alsa_card_saa7134_exit(void)
+/*
+ * Module initializer
+ *
+ * Loops through present saa7134 cards, and assigns an ALSA device
+ * to each one
+ *
+ */
+
+static int saa7134_alsa_init(void)
+{
+ struct saa7134_dev *saadev = NULL;
+ struct list_head *list;
+
+ printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
+
+ list_for_each(list,&saa7134_devlist) {
+ saadev = list_entry(list, struct saa7134_dev, devlist);
+ alsa_card_saa7134_create(saadev,dsp_nr);
+ }
+
+ if (saadev == NULL)
+ printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
+
+ return 0;
+
+}
+
+/*
+ * Module destructor
+ */
+
+void saa7134_alsa_exit(void)
{
int idx;
- for (idx = 0; idx < SNDRV_CARDS; idx++) {
+ for (idx = 0; idx < SNDRV_CARDS; idx++) {
snd_card_free(snd_saa7134_cards[idx]);
}
+ printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n");
+ return;
}
+
+module_init(saa7134_alsa_init);
+module_exit(saa7134_alsa_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Ricardo Cerqueira");