diff options
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-alsa.c | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/linux/drivers/media/video/saa7134/saa7134-alsa.c b/linux/drivers/media/video/saa7134/saa7134-alsa.c index 7d05c6ea4..51bb1e259 100644 --- a/linux/drivers/media/video/saa7134/saa7134-alsa.c +++ b/linux/drivers/media/video/saa7134/saa7134-alsa.c @@ -1,7 +1,7 @@ /* * SAA713x ALSA support for V4L * - * $Id: saa7134-alsa.c,v 1.12 2005/11/07 19:06:29 rmcc Exp $ + * $Id: saa7134-alsa.c,v 1.13 2005/11/07 20:16:51 rmcc Exp $ * * Caveats: * - Volume doesn't work (it's always at max) @@ -47,25 +47,6 @@ MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); */ /* defaults */ -#define MAX_BUFFER_SIZE (256*1024) -#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S16_BE | \ - SNDRV_PCM_FMTBIT_S8 | \ - SNDRV_PCM_FMTBIT_U8 | \ - SNDRV_PCM_FMTBIT_U16_LE | \ - SNDRV_PCM_FMTBIT_U16_BE -#define USE_RATE SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 -#define USE_RATE_MIN 32000 -#define USE_RATE_MAX 48000 -#define USE_CHANNELS_MIN 1 -#define USE_CHANNELS_MAX 2 -#ifndef USE_PERIODS_MIN -#define USE_PERIODS_MIN 2 -#endif -#ifndef USE_PERIODS_MAX -#define USE_PERIODS_MAX 1024 -#endif - #define MIXER_ADDR_TVTUNER 0 #define MIXER_ADDR_LINE1 1 #define MIXER_ADDR_LINE2 2 @@ -276,7 +257,24 @@ out: static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, int cmd) { - return 0; + snd_pcm_runtime_t *runtime = substream->runtime; + snd_card_saa7134_pcm_t *saapcm = runtime->private_data; + struct saa7134_dev *dev=saapcm->saadev; + int err = 0; + + spin_lock_irq(&dev->slock); + if (cmd == SNDRV_PCM_TRIGGER_START) { + /* start dma */ + saa7134_dma_start(dev); + } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { + /* stop dma */ + saa7134_dma_stop(dev); + } else { + err = -EINVAL; + } + spin_unlock_irq(&dev->slock); + + return err; } /* @@ -483,10 +481,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) saa_writel(SAA7134_RS_CONTROL(6),control); dev->oss.rate = runtime->rate; - /* start dma */ - spin_lock_irq(&dev->slock); - saa7134_dma_start(dev); - spin_unlock_irq(&dev->slock); return 0; fail2: @@ -536,17 +530,22 @@ static snd_pcm_hardware_t snd_card_saa7134_capture = .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .buffer_bytes_max = MAX_BUFFER_SIZE, + .formats = SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S16_BE | \ + SNDRV_PCM_FMTBIT_S8 | \ + SNDRV_PCM_FMTBIT_U8 | \ + SNDRV_PCM_FMTBIT_U16_LE | \ + SNDRV_PCM_FMTBIT_U16_BE, + .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000, + .rate_min = 32000, + .rate_max = 48000, + .channels_min = 1, + .channels_max = 2, + .buffer_bytes_max = (256*1024), .period_bytes_min = 64, - .period_bytes_max = MAX_BUFFER_SIZE, - .periods_min = USE_PERIODS_MIN, - .periods_max = USE_PERIODS_MAX, + .period_bytes_max = (256*1024), + .periods_min = 2, + .periods_max = 1024, }; static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) @@ -629,11 +628,6 @@ static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream); struct saa7134_dev *dev = chip->saadev; - /* stop dma */ - spin_lock_irq(&dev->slock); - saa7134_dma_stop(dev); - spin_unlock_irq(&dev->slock); - /* unlock buffer */ saa7134_pgtable_free(dev->pci,&dev->oss.pt); videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); @@ -975,7 +969,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev) chip->irq = saadev->pci->irq; chip->iobase = pci_resource_start(saadev->pci, 0); - err = request_irq(chip->pci->irq, saa7134_alsa_irq, + err = request_irq(saadev->pci->irq, saa7134_alsa_irq, SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); if (err < 0) { @@ -1047,10 +1041,13 @@ static int saa7134_alsa_init(void) void saa7134_alsa_exit(void) { int 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; } |