28 #include <linux/types.h>
29 #include <linux/errno.h>
30 #include <linux/signal.h>
31 #include <linux/fcntl.h>
32 #include <linux/ctype.h>
33 #include <linux/stddef.h>
35 #include <linux/kernel.h>
38 #include <linux/wait.h>
44 #include <linux/module.h>
46 #include <linux/device.h>
52 #define valid_dma(n) ((n) >= 0 && (n) < MAX_DMA_CHANNELS && (n) != 4)
63 #ifdef CONFIG_SOUND_DMAP
71 #define DMA_MAP_UNAVAIL 0
72 #define DMA_MAP_FREE 1
73 #define DMA_MAP_BUSY 2
83 static int num_mixer_volumes;
89 for (i = 0; i < num_mixer_volumes; i++) {
90 if (
strncmp(name, mixer_vols[i].name, 32) == 0) {
92 mixer_vols[
i].
num =
i;
100 n = num_mixer_volumes++;
102 strncpy(mixer_vols[n].name, name, 32);
105 mixer_vols[
n].
num =
n;
107 mixer_vols[
n].
num = -1;
109 for (i = 0; i < 32; i++)
110 mixer_vols[n].levels[i] = levels[i];
115 static int set_mixer_levels(
void __user *
arg)
128 static int get_mixer_levels(
void __user * arg)
134 if (n < 0 || n >= num_mixer_volumes)
142 #define PROC_BLOCK_SIZE (3*1024)
146 int dev = iminor(file->
f_path.dentry->d_inode);
157 DEB(
printk(
"sound_read(dev=%d, count=%d)\n", dev, count));
158 switch (dev & 0x0f) {
177 static ssize_t sound_write(
struct file *
file,
const char __user *buf,
size_t count, loff_t *ppos)
179 int dev = iminor(file->
f_path.dentry->d_inode);
183 DEB(
printk(
"sound_write(dev=%d, count=%d)\n", dev, count));
184 switch (dev & 0x0f) {
204 static int sound_open(
struct inode *
inode,
struct file *file)
206 int dev = iminor(inode);
209 DEB(
printk(
"sound_open(dev=%d)\n", dev));
215 switch (dev & 0x0f) {
219 request_module(
"mixer%d", dev);
255 static int sound_release(
struct inode *inode,
struct file *file)
257 int dev = iminor(inode);
260 DEB(
printk(
"sound_release(dev=%d)\n", dev));
261 switch (dev & 0x0f) {
282 printk(
KERN_ERR "Sound error: Releasing unknown device 0x%02x\n", dev);
289 static int get_mixer_info(
int dev,
void __user *arg)
292 memset(&info, 0,
sizeof(info));
301 static int get_old_mixer_info(
int dev,
void __user *arg)
304 memset(&info, 0,
sizeof(info));
312 static int sound_mixer_ioctl(
int mixdev,
unsigned int cmd,
void __user *arg)
318 request_module(
"mixer%d", mixdev);
323 return get_mixer_info(mixdev, arg);
325 return get_old_mixer_info(mixdev, arg);
330 return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg);
333 static long sound_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
336 int dev = iminor(file->f_dentry->d_inode);
345 if (len < 1 || len > 65536 || !p)
354 DEB(
printk(
"sound_ioctl(dev=%d, cmd=0x%x, arg=0x%x)\n", dev, cmd, arg));
366 ret = sound_mixer_ioctl(
audio_devs[dev >> 4]->mixer_dev,
370 ret = sound_mixer_ioctl(dev >> 4, cmd, p);
377 switch (dev & 0x0f) {
380 ret = get_mixer_levels(p);
382 ret = set_mixer_levels(p);
384 ret = sound_mixer_ioctl(dev >> 4, cmd, p);
407 static unsigned int sound_poll(
struct file *file,
poll_table *
wait)
409 struct inode *inode = file->
f_path.dentry->d_inode;
410 int dev = iminor(inode);
412 DEB(
printk(
"sound_poll(dev=%d)\n", dev));
413 switch (dev & 0x0f) {
429 static int sound_mmap(
struct file *file,
struct vm_area_struct *vma)
434 int dev = iminor(file->
f_path.dentry->d_inode);
436 dev_class = dev & 0x0f;
440 printk(
KERN_ERR "Sound: mmap() not supported for other than audio devices\n");
465 printk(
KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n");
502 .write = sound_write,
504 .unlocked_ioctl = sound_ioctl,
507 .release = sound_release,
514 static int create_special_devices(
void)
554 err = create_special_devices();
556 printk(
KERN_ERR "sound: driver already loaded/included in kernel\n");
573 printk(
KERN_ERR "Sound warning: Deallocation table was too small.\n");
578 static void __exit oss_cleanup(
void)
599 printk(
KERN_ERR "Sound: Hmm, DMA%d was left allocated - fixed\n", i);
636 printk(
"sound_open_dma: DMA channel %d busy or not allocated (%d)\n", chn, dma_alloc_map[chn]);
658 printk(
KERN_ERR "sound_close_dma: Bad access to DMA channel %d\n", chn);
665 static void do_sequencer_timer(
unsigned long dummy)
671 static DEFINE_TIMER(seq_timer, do_sequencer_timer, 0, 0);
700 #ifndef CONFIG_SOUND_TRACEINIT
706 printk(
" irq %d", (hw_config->
irq > 0) ? hw_config->
irq : -hw_config->
irq);
708 if (hw_config->
dma != -1 || hw_config->
dma2 != -1)
711 if (hw_config->
dma2 != -1)
721 #ifndef CONFIG_SOUND_TRACEINIT
724 printk(
"<%s> at 0x%03x", name, base);
727 printk(
" irq %d", (irq > 0) ? irq : -irq);
729 if (dma != -1 || dma2 != -1)