diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/core |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/core')
95 files changed, 43314 insertions, 0 deletions
diff --git a/sound/core/Kconfig b/sound/core/Kconfig new file mode 100644 index 00000000000..d1e800b9866 --- /dev/null +++ b/sound/core/Kconfig @@ -0,0 +1,133 @@ +# ALSA soundcard-configuration +config SND_TIMER + tristate + depends on SND + +config SND_PCM + tristate + select SND_TIMER + depends on SND + +config SND_HWDEP + tristate + depends on SND + +config SND_RAWMIDI + tristate + depends on SND + +config SND_SEQUENCER + tristate "Sequencer support" + depends on SND + select SND_TIMER + help + Say Y or M to enable MIDI sequencer and router support. This + feature allows routing and enqueueing of MIDI events. Events + can be processed at a given time. + + Many programs require this feature, so you should enable it + unless you know what you're doing. + +config SND_SEQ_DUMMY + tristate "Sequencer dummy client" + depends on SND_SEQUENCER + help + Say Y here to enable the dummy sequencer client. This client + is a simple MIDI-through client: all normal input events are + redirected to the output port immediately. + + You don't need this unless you want to connect many MIDI + devices or applications together. + + To compile this driver as a module, choose M here: the module + will be called snd-seq-dummy. + +config SND_OSSEMUL + bool + depends on SND + +config SND_MIXER_OSS + tristate "OSS Mixer API" + depends on SND + select SND_OSSEMUL + help + To enable OSS mixer API emulation (/dev/mixer*), say Y here + and read <file:Documentation/sound/alsa/OSS-Emulation.txt>. + + Many programs still use the OSS API, so say Y. + + To compile this driver as a module, choose M here: the module + will be called snd-mixer-oss. + +config SND_PCM_OSS + tristate "OSS PCM (digital audio) API" + depends on SND + select SND_OSSEMUL + select SND_PCM + help + To enable OSS digital audio (PCM) emulation (/dev/dsp*), say Y + here and read <file:Documentation/sound/alsa/OSS-Emulation.txt>. + + Many programs still use the OSS API, so say Y. + + To compile this driver as a module, choose M here: the module + will be called snd-pcm-oss. + +config SND_SEQUENCER_OSS + bool "OSS Sequencer API" + depends on SND && SND_SEQUENCER + select SND_OSSEMUL + help + Say Y here to enable OSS sequencer emulation (both + /dev/sequencer and /dev/music interfaces). + + Many programs still use the OSS API, so say Y. + + To compile this driver as a module, choose M here: the module + will be called snd-seq-oss. + +config SND_RTCTIMER + tristate "RTC Timer support" + depends on SND && RTC + select SND_TIMER + help + Say Y here to enable RTC timer support for ALSA. ALSA uses + the RTC timer as a precise timing source and maps the RTC + timer to ALSA's timer interface. The ALSA sequencer code also + can use this timing source. + + To compile this driver as a module, choose M here: the module + will be called snd-rtctimer. + +config SND_VERBOSE_PRINTK + bool "Verbose printk" + depends on SND + help + Say Y here to enable verbose log messages. These messages + will help to identify source file and position containing + printed messages. + + You don't need this unless you're debugging ALSA. + +config SND_DEBUG + bool "Debug" + depends on SND + help + Say Y here to enable ALSA debug code. + +config SND_DEBUG_MEMORY + bool "Debug memory" + depends on SND_DEBUG + help + Say Y here to enable debugging of memory allocations. + +config SND_DEBUG_DETECT + bool "Debug detection" + depends on SND_DEBUG + help + Say Y here to enable extra-verbose log messages printed when + detecting devices. + +config SND_GENERIC_PM + bool + depends on SND diff --git a/sound/core/Makefile b/sound/core/Makefile new file mode 100644 index 00000000000..764ac184b22 --- /dev/null +++ b/sound/core/Makefile @@ -0,0 +1,33 @@ +# +# Makefile for ALSA +# Copyright (c) 1999,2001 by Jaroslav Kysela <perex@suse.cz> +# + +snd-objs := sound.o init.o memory.o info.o control.o misc.o \ + device.o wrappers.o +ifeq ($(CONFIG_ISA),y) +snd-objs += isadma.o +endif +ifeq ($(CONFIG_SND_OSSEMUL),y) +snd-objs += sound_oss.o info_oss.o +endif + +snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ + pcm_memory.o + +snd-page-alloc-objs := memalloc.o sgbuf.o + +snd-rawmidi-objs := rawmidi.o +snd-timer-objs := timer.o +snd-rtctimer-objs := rtctimer.o +snd-hwdep-objs := hwdep.o + +obj-$(CONFIG_SND) += snd.o +obj-$(CONFIG_SND_HWDEP) += snd-hwdep.o +obj-$(CONFIG_SND_TIMER) += snd-timer.o +obj-$(CONFIG_SND_RTCTIMER) += snd-rtctimer.o +obj-$(CONFIG_SND_PCM) += snd-pcm.o snd-page-alloc.o +obj-$(CONFIG_SND_RAWMIDI) += snd-rawmidi.o + +obj-$(CONFIG_SND_OSSEMUL) += oss/ +obj-$(CONFIG_SND_SEQUENCER) += seq/ diff --git a/sound/core/control.c b/sound/core/control.c new file mode 100644 index 00000000000..f4ea6bff1dd --- /dev/null +++ b/sound/core/control.c @@ -0,0 +1,1375 @@ +/* + * Routines for driver control interface + * Copyright (c) by Jaroslav Kysela <perex@suse.cz> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <sound/driver.h> +#include <linux/threads.h> +#include <linux/interrupt.h> +#include <linux/smp_lock.h> +#include <linux/slab.h> +#include <linux/vmalloc.h> +#include <linux/time.h> +#include <sound/core.h> +#include <sound/minors.h> +#include <sound/info.h> +#include <sound/control.h> + +/* max number of user-defined controls */ +#define MAX_USER_CONTROLS 32 + +typedef struct _snd_kctl_ioctl { + struct list_head list; /* list of all ioctls */ + snd_kctl_ioctl_func_t fioctl; +} snd_kctl_ioctl_t; + +#define snd_kctl_ioctl(n) list_entry(n, snd_kctl_ioctl_t, list) + +static DECLARE_RWSEM(snd_ioctl_rwsem); +static LIST_HEAD(snd_control_ioctls); +#ifdef CONFIG_COMPAT +static LIST_HEAD(snd_control_compat_ioctls); +#endif + +static int snd_ctl_open(struct inode *inode, struct file *file) +{ + int cardnum = SNDRV_MINOR_CARD(iminor(inode)); + unsigned long flags; + snd_card_t *card; + snd_ctl_file_t *ctl; + int err; + + card = snd_cards[cardnum]; + if (!card) { + err = -ENODEV; + goto __error1; + } + err = snd_card_file_add(card, file); + if (err < 0) { + err = -ENODEV; + goto __error1; + } + if (!try_module_get(card->module)) { + err = -EFAULT; + goto __error2; + } + ctl = kcalloc(1, sizeof(*ctl), GFP_KERNEL); + if (ctl == NULL) { + err = -ENOMEM; + goto __error; + } + INIT_LIST_HEAD(&ctl->events); + init_waitqueue_head(&ctl->change_sleep); + spin_lock_init(&ctl->read_lock); + ctl->card = card; + ctl->pid = current->pid; + file->private_data = ctl; + write_lock_irqsave(&card->ctl_files_rwlock, flags); + list_add_tail(&ctl->list, &card->ctl_files); + write_unlock_irqrestore(&card->ctl_files_rwlock, flags); + return 0; + + __error: + module_put(card->module); + __error2: + snd_card_file_remove(card, file); + __error1: + return err; +} + +static void snd_ctl_empty_read_queue(snd_ctl_file_t * ctl) +{ + snd_kctl_event_t *cread; + + spin_lock(&ctl->read_lock); + while (!list_empty(&ctl->events)) { + cread = snd_kctl_event(ctl->events.next); + list_del(&cread->list); + kfree(cread); + } + spin_unlock(&ctl->read_lock); +} + +static int snd_ctl_release(struct inode *inode, struct file *file) +{ + unsigned long flags; + struct list_head *list; + snd_card_t *card; + snd_ctl_file_t *ctl; + snd_kcontrol_t *control; + unsigned int idx; + + ctl = file->private_data; + fasync_helper(-1, file, 0, &ctl->fasync); + file->private_data = NULL; + card = ctl->card; + write_lock_irqsave(&card->ctl_files_rwlock, flags); + list_del(&ctl->list); + write_unlock_irqrestore(&card->ctl_files_rwlock, flags); + down_write(&card->controls_rwsem); + list_for_each(list, &card->controls) { + control = snd_kcontrol(list); + for (idx = 0; idx < control->count; idx++) + if (control->vd[idx].owner == ctl) + control->vd[idx].owner = NULL; + } + up_write(&card->controls_rwsem); + snd_ctl_empty_read_queue(ctl); + kfree(ctl); + module_put(card->module); + snd_card_file_remove(card, file); + return 0; +} + +void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id) +{ + unsigned long flags; + struct list_head *flist; + snd_ctl_file_t *ctl; + snd_kctl_event_t *ev; + + snd_runtime_check(card != NULL && id != NULL, return); + read_lock(&card->ctl_files_rwlock); +#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) + card->mixer_oss_change_count++; +#endif + list_for_each(flist, &card->ctl_files) { + struct list_head *elist; + ctl = snd_ctl_file(flist); + if (!ctl->subscribed) + continue; + spin_lock_irqsave(&ctl->read_lock, flags); + list_for_each(elist, &ctl->events) { + ev = snd_kctl_event(elist); + if (ev->id.numid == id->numid) { + ev->mask |= mask; + goto _found; + } + } + ev = kcalloc(1, sizeof(*ev), GFP_ATOMIC); + if (ev) { + ev->id = *id; + ev->mask = mask; + list_add_tail(&ev->list, &ctl->events); + } else { + snd_printk(KERN_ERR "No memory available to allocate event\n"); + } + _found: + wake_up(&ctl->change_sleep); + spin_unlock_irqrestore(&ctl->read_lock, flags); + kill_fasync(&ctl->fasync, SIGIO, POLL_IN); + } + read_unlock(&card->ctl_files_rwlock); +} + +/** + * snd_ctl_new - create a control instance from the template + * @control: the control template + * @access: the default control access + * + * Allocates a new snd_kcontrol_t instance and copies the given template + * to the new instance. It does not copy volatile data (access). + * + * Returns the pointer of the new instance, or NULL on failure. + */ +snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) +{ + snd_kcont |