diff options
author | Ricardo Cerqueira <devnull@localhost> | 2005-11-07 19:06:29 +0000 |
---|---|---|
committer | Ricardo Cerqueira <devnull@localhost> | 2005-11-07 19:06:29 +0000 |
commit | 6103695924a4a0e807729f4376b547b68565c01f (patch) | |
tree | b149851285323f19989d018ec287a32dd135a83e /linux/drivers/media/video | |
parent | 8613a2744e3cc9bfb6e2cabe13d87c2d79c1c438 (diff) | |
download | mediapointer-dvb-s2-6103695924a4a0e807729f4376b547b68565c01f.tar.gz mediapointer-dvb-s2-6103695924a4a0e807729f4376b547b68565c01f.tar.bz2 |
- Applied some of the changes proposed by the ALSA team
- dsp_nr replaced by ALSA's index[]
Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r-- | linux/drivers/media/video/saa7134/saa7134-alsa.c | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/linux/drivers/media/video/saa7134/saa7134-alsa.c b/linux/drivers/media/video/saa7134/saa7134-alsa.c index eb3fb7fff..7d05c6ea4 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.11 2005/11/07 02:33:06 rmcc Exp $ + * $Id: saa7134-alsa.c,v 1.12 2005/11/07 19:06:29 rmcc Exp $ * * Caveats: * - Volume doesn't work (it's always at max) @@ -33,7 +33,6 @@ #include <sound/core.h> #include <sound/control.h> #include <sound/pcm.h> -#include <sound/rawmidi.h> #include <sound/initval.h> #include "saa7134.h" @@ -43,17 +42,18 @@ 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 */ /* 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_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 @@ -76,10 +76,14 @@ 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}; +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); + #define dprintk(fmt, arg...) if (debug) \ printk(KERN_DEBUG "%s/alsa: " fmt, dev->name, ## arg) + /* * Main chip structure */ @@ -117,7 +121,7 @@ typedef struct snd_card_saa7134_pcm { snd_pcm_substream_t *substream; } snd_card_saa7134_pcm_t; -static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static snd_card_t *snd_saa7134_cards[SNDRV_CARDS]; /* @@ -195,6 +199,7 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) if (dev->oss.read_count >= dev->oss.blksize * (dev->oss.blocks-2)) { dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->oss.read_count, dev->oss.bufsize, dev->oss.blocks); + snd_pcm_stop(dev->oss.substream,SNDRV_PCM_STATE_XRUN); saa7134_dma_stop(dev); goto done; } @@ -349,7 +354,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; int err, bswap, sign; u32 fmt, control; - unsigned long flags; snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); struct saa7134_dev *dev; snd_card_saa7134_pcm_t *saapcm = runtime->private_data; @@ -480,9 +484,9 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) dev->oss.rate = runtime->rate; /* start dma */ - spin_lock_irqsave(&dev->slock,flags); + spin_lock_irq(&dev->slock); saa7134_dma_start(dev); - spin_unlock_irqrestore(&dev->slock,flags); + spin_unlock_irq(&dev->slock); return 0; fail2: @@ -543,7 +547,6 @@ static snd_pcm_hardware_t snd_card_saa7134_capture = .period_bytes_max = MAX_BUFFER_SIZE, .periods_min = USE_PERIODS_MIN, .periods_max = USE_PERIODS_MAX, - .fifo_size = 0x08070503, }; static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) @@ -625,12 +628,11 @@ 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; - unsigned long flags; /* stop dma */ - spin_lock_irqsave(&dev->slock,flags); + spin_lock_irq(&dev->slock); saa7134_dma_stop(dev); - spin_unlock_irqrestore(&dev->slock,flags); + spin_unlock_irq(&dev->slock); /* unlock buffer */ saa7134_pgtable_free(dev->pci,&dev->oss.pt); @@ -667,7 +669,7 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) up(&dev->oss.lock); - saapcm = kcalloc(1, sizeof(*saapcm), GFP_KERNEL); + saapcm = kzalloc(sizeof(*saapcm), GFP_KERNEL); if (saapcm == NULL) return -ENOMEM; saapcm->saadev=saa7134->saadev; @@ -740,13 +742,10 @@ static int snd_saa7134_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_ static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; int addr = kcontrol->private_value; - spin_lock_irqsave(&chip->mixer_lock, flags); ucontrol->value.integer.value[0] = chip->mixer_volume[addr][0]; ucontrol->value.integer.value[1] = chip->mixer_volume[addr][1]; - spin_unlock_irqrestore(&chip->mixer_lock, flags); return 0; } @@ -934,7 +933,7 @@ 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) { static int dev; @@ -951,12 +950,8 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum if (!enable[dev]) return -ENODEV; - 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); - } + card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + if (card == NULL) return -ENOMEM; @@ -970,6 +965,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum } spin_lock_init(&chip->lock); + spin_lock_init(&chip->mixer_lock); chip->saadev = saadev; @@ -985,12 +981,11 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum if (err < 0) { printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", saadev->name, saadev->pci->irq); - return err; + goto __nodev; } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { - snd_saa7134_free(chip); - return err; + goto __nodev; } if ((err = snd_card_saa7134_new_mixer(chip)) < 0) @@ -999,8 +994,6 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum if ((err = snd_card_saa7134_pcm(chip, 0)) < 0) goto __nodev; - spin_lock_init(&chip->mixer_lock); - snd_card_set_dev(card, &chip->pci->dev); /* End of "creation" */ @@ -1016,7 +1009,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum __nodev: snd_card_free(card); - kfree(card); + kfree(chip); return err; } @@ -1037,7 +1030,7 @@ static int saa7134_alsa_init(void) list_for_each(list,&saa7134_devlist) { saadev = list_entry(list, struct saa7134_dev, devlist); - alsa_card_saa7134_create(saadev,dsp_nr); + alsa_card_saa7134_create(saadev); } if (saadev == NULL) |