added mtd driver
[linux-2.4.git] / drivers / sound / soundcard.c
1 /*
2  * linux/drivers/sound/soundcard.c
3  *
4  * Sound card driver for Linux
5  *
6  *
7  * Copyright (C) by Hannu Savolainen 1993-1997
8  *
9  * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
10  * Version 2 (June 1991). See the "COPYING" file distributed with this software
11  * for more info.
12  *
13  *
14  * Thomas Sailer     : ioctl code reworked (vmalloc/vfree removed)
15  *                   integrated sound_switch.c
16  * Stefan Reinauer   : integrated /proc/sound (equals to /dev/sndstat,
17  *                   which should disappear in the near future)
18  * Eric Dumas        : devfs support (22-Jan-98) <dumas@linux.eu.org> with
19  *                   fixups by C. Scott Ananian <cananian@alumni.princeton.edu>
20  * Richard Gooch     : moved common (non OSS-specific) devices to sound_core.c
21  * Rob Riggs         : Added persistent DMA buffers support (1998/10/17)
22  * Christoph Hellwig : Some cleanup work (2000/03/01)
23  */
24
25 #include <linux/config.h>
26
27 #include "sound_config.h"
28 #include <linux/init.h>
29 #include <linux/types.h>
30 #include <linux/errno.h>
31 #include <linux/signal.h>
32 #include <linux/fcntl.h>
33 #include <linux/ctype.h>
34 #include <linux/stddef.h>
35 #include <linux/kmod.h>
36 #include <asm/dma.h>
37 #include <asm/io.h>
38 #include <asm/segment.h>
39 #include <linux/wait.h>
40 #include <linux/slab.h>
41 #include <linux/ioport.h>
42 #include <linux/devfs_fs_kernel.h>
43 #include <linux/major.h>
44 #include <linux/delay.h>
45 #include <linux/proc_fs.h>
46 #include <linux/smp_lock.h>
47 #include <linux/module.h>
48
49 /*
50  * This ought to be moved into include/asm/dma.h
51  */
52 #ifndef valid_dma
53 #define valid_dma(n) ((n) >= 0 && (n) < MAX_DMA_CHANNELS && (n) != 4)
54 #endif
55
56 /*
57  * Table for permanently allocated memory (used when unloading the module)
58  */
59 caddr_t         sound_mem_blocks[1024];
60 int             sound_nblocks = 0;
61
62 /* Persistent DMA buffers */
63 #ifdef CONFIG_SOUND_DMAP
64 int             sound_dmap_flag = 1;
65 #else
66 int             sound_dmap_flag = 0;
67 #endif
68
69 static char     dma_alloc_map[MAX_DMA_CHANNELS] = {0};
70
71 #define DMA_MAP_UNAVAIL         0
72 #define DMA_MAP_FREE            1
73 #define DMA_MAP_BUSY            2
74
75
76 unsigned long seq_time = 0;     /* Time for /dev/sequencer */
77
78 /*
79  * Table for configurable mixer volume handling
80  */
81 static mixer_vol_table mixer_vols[MAX_MIXER_DEV];
82 static int num_mixer_volumes = 0;
83
84 int *load_mixer_volumes(char *name, int *levels, int present)
85 {
86         int             i, n;
87
88         for (i = 0; i < num_mixer_volumes; i++) {
89                 if (strcmp(name, mixer_vols[i].name) == 0) {
90                         if (present)
91                                 mixer_vols[i].num = i;
92                         return mixer_vols[i].levels;
93                 }
94         }
95         if (num_mixer_volumes >= MAX_MIXER_DEV) {
96                 printk(KERN_ERR "Sound: Too many mixers (%s)\n", name);
97                 return levels;
98         }
99         n = num_mixer_volumes++;
100
101         strcpy(mixer_vols[n].name, name);
102
103         if (present)
104                 mixer_vols[n].num = n;
105         else
106                 mixer_vols[n].num = -1;
107
108         for (i = 0; i < 32; i++)
109                 mixer_vols[n].levels[i] = levels[i];
110         return mixer_vols[n].levels;
111 }
112
113 static int set_mixer_levels(caddr_t arg)
114 {
115         /* mixer_vol_table is 174 bytes, so IMHO no reason to not allocate it on the stack */
116         mixer_vol_table buf;   
117
118         if (__copy_from_user(&buf, arg, sizeof(buf)))
119                 return -EFAULT;
120         load_mixer_volumes(buf.name, buf.levels, 0);
121         if (__copy_to_user(arg, &buf, sizeof(buf)))
122                 return -EFAULT;
123         return 0;
124 }
125
126 static int get_mixer_levels(caddr_t arg)
127 {
128         int n;
129
130         if (__get_user(n, (int *)(&(((mixer_vol_table *)arg)->num))))
131                 return -EFAULT;
132         if (n < 0 || n >= num_mixer_volumes)
133                 return -EINVAL;
134         if (__copy_to_user(arg, &mixer_vols[n], sizeof(mixer_vol_table)))
135                 return -EFAULT;
136         return 0;
137 }
138
139 #ifndef MIN
140 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
141 #endif
142
143 /* 4K page size but our output routines use some slack for overruns */
144 #define PROC_BLOCK_SIZE (3*1024)
145
146 static ssize_t sound_read(struct file *file, char *buf, size_t count, loff_t *ppos)
147 {
148         int dev = MINOR(file->f_dentry->d_inode->i_rdev);
149         int ret = -EINVAL;
150
151         /*
152          *      The OSS drivers aren't remotely happy without this locking,
153          *      and unless someone fixes them when they are about to bite the
154          *      big one anyway, we might as well bandage here..
155          */
156          
157         lock_kernel();
158         
159         DEB(printk("sound_read(dev=%d, count=%d)\n", dev, count));
160         switch (dev & 0x0f) {
161         case SND_DEV_DSP:
162         case SND_DEV_DSP16:
163         case SND_DEV_AUDIO:
164                 ret = audio_read(dev, file, buf, count);
165                 break;
166
167         case SND_DEV_SEQ:
168         case SND_DEV_SEQ2:
169                 ret = sequencer_read(dev, file, buf, count);
170                 break;
171
172         case SND_DEV_MIDIN:
173                 ret = MIDIbuf_read(dev, file, buf, count);
174         }
175         unlock_kernel();
176         return ret;
177 }
178
179 static ssize_t sound_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
180 {
181         int dev = MINOR(file->f_dentry->d_inode->i_rdev);
182         int ret = -EINVAL;
183         
184         lock_kernel();
185         DEB(printk("sound_write(dev=%d, count=%d)\n", dev, count));
186         switch (dev & 0x0f) {
187         case SND_DEV_SEQ:
188         case SND_DEV_SEQ2:
189                 ret =  sequencer_write(dev, file, buf, count);
190                 break;
191
192         case SND_DEV_DSP:
193         case SND_DEV_DSP16:
194         case SND_DEV_AUDIO:
195                 ret = audio_write(dev, file, buf, count);
196                 break;
197
198         case SND_DEV_MIDIN:
199                 ret =  MIDIbuf_write(dev, file, buf, count);
200                 break;
201         }
202         unlock_kernel();
203         return ret;
204 }
205
206 static int sound_open(struct inode *inode, struct file *file)
207 {
208         int dev = MINOR(inode->i_rdev);
209         int retval;
210
211         DEB(printk("sound_open(dev=%d)\n", dev));
212         if ((dev >= SND_NDEVS) || (dev < 0)) {
213                 printk(KERN_ERR "Invalid minor device %d\n", dev);
214                 return -ENXIO;
215         }
216         switch (dev & 0x0f) {
217         case SND_DEV_CTL:
218                 dev >>= 4;
219                 if (dev >= 0 && dev < MAX_MIXER_DEV && mixer_devs[dev] == NULL) {
220                         char modname[20];
221                         sprintf(modname, "mixer%d", dev);
222                         request_module(modname);
223                 }
224                 if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL))
225                         return -ENXIO;
226
227                 if (mixer_devs[dev]->owner)
228                         __MOD_INC_USE_COUNT (mixer_devs[dev]->owner);
229                 break;
230
231         case SND_DEV_SEQ:
232         case SND_DEV_SEQ2:
233                 if ((retval = sequencer_open(dev, file)) < 0)
234                         return retval;
235                 break;
236
237         case SND_DEV_MIDIN:
238                 if ((retval = MIDIbuf_open(dev, file)) < 0)
239                         return retval;
240                 break;
241
242         case SND_DEV_DSP:
243         case SND_DEV_DSP16:
244         case SND_DEV_AUDIO:
245                 if ((retval = audio_open(dev, file)) < 0)
246                         return retval;
247                 break;
248
249         default:
250                 printk(KERN_ERR "Invalid minor device %d\n", dev);
251                 return -ENXIO;
252         }
253
254         return 0;
255 }
256
257 static int sound_release(struct inode *inode, struct file *file)
258 {
259         int dev = MINOR(inode->i_rdev);
260
261         lock_kernel();
262         DEB(printk("sound_release(dev=%d)\n", dev));
263         switch (dev & 0x0f) {
264         case SND_DEV_CTL:
265                 dev >>= 4;
266                 if (mixer_devs[dev]->owner)
267                         __MOD_DEC_USE_COUNT (mixer_devs[dev]->owner);
268                 break;
269                 
270         case SND_DEV_SEQ:
271         case SND_DEV_SEQ2:
272                 sequencer_release(dev, file);
273                 break;
274
275         case SND_DEV_MIDIN:
276                 MIDIbuf_release(dev, file);
277                 break;
278
279         case SND_DEV_DSP:
280         case SND_DEV_DSP16:
281         case SND_DEV_AUDIO:
282                 audio_release(dev, file);
283                 break;
284
285         default:
286                 printk(KERN_ERR "Sound error: Releasing unknown device 0x%02x\n", dev);
287         }
288         unlock_kernel();
289
290         return 0;
291 }
292
293 static int get_mixer_info(int dev, caddr_t arg)
294 {
295         mixer_info info;
296
297         strncpy(info.id, mixer_devs[dev]->id, sizeof(info.id));
298         strncpy(info.name, mixer_devs[dev]->name, sizeof(info.name));
299         info.name[sizeof(info.name)-1] = 0;
300         info.modify_counter = mixer_devs[dev]->modify_counter;
301         if (__copy_to_user(arg, &info,  sizeof(info)))
302                 return -EFAULT;
303         return 0;
304 }
305
306 static int get_old_mixer_info(int dev, caddr_t arg)
307 {
308         _old_mixer_info info;
309
310         strncpy(info.id, mixer_devs[dev]->id, sizeof(info.id));
311         strncpy(info.name, mixer_devs[dev]->name, sizeof(info.name));
312         info.name[sizeof(info.name)-1] = 0;     
313         if (copy_to_user(arg, &info,  sizeof(info)))
314                 return -EFAULT;
315         return 0;
316 }
317
318 static int sound_mixer_ioctl(int mixdev, unsigned int cmd, caddr_t arg)
319 {
320         if (mixdev < 0 || mixdev >= MAX_MIXER_DEV)
321                 return -ENXIO;
322         /* Try to load the mixer... */
323         if (mixer_devs[mixdev] == NULL) {
324                 char modname[20];
325                 sprintf(modname, "mixer%d", mixdev);
326                 request_module(modname);
327         }
328         if (mixdev >= num_mixers || !mixer_devs[mixdev])
329                 return -ENXIO;
330         if (cmd == SOUND_MIXER_INFO)
331                 return get_mixer_info(mixdev, arg);
332         if (cmd == SOUND_OLD_MIXER_INFO)
333                 return get_old_mixer_info(mixdev, arg);
334         if (_SIOC_DIR(cmd) & _SIOC_WRITE)
335                 mixer_devs[mixdev]->modify_counter++;
336         if (!mixer_devs[mixdev]->ioctl)
337                 return -EINVAL;
338         return mixer_devs[mixdev]->ioctl(mixdev, cmd, arg);
339 }
340
341 static int sound_ioctl(struct inode *inode, struct file *file,
342                        unsigned int cmd, unsigned long arg)
343 {
344         int err, len = 0, dtype;
345         int dev = MINOR(inode->i_rdev);
346
347         if (_SIOC_DIR(cmd) != _SIOC_NONE && _SIOC_DIR(cmd) != 0) {
348                 /*
349                  * Have to validate the address given by the process.
350                  */
351                 len = _SIOC_SIZE(cmd);
352                 if (len < 1 || len > 65536 || arg == 0)
353                         return -EFAULT;
354                 if (_SIOC_DIR(cmd) & _SIOC_WRITE)
355                         if ((err = verify_area(VERIFY_READ, (void *)arg, len)) < 0)
356                                 return err;
357                 if (_SIOC_DIR(cmd) & _SIOC_READ)
358                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, len)) < 0)
359                                 return err;
360         }
361         DEB(printk("sound_ioctl(dev=%d, cmd=0x%x, arg=0x%x)\n", dev, cmd, arg));
362         if (cmd == OSS_GETVERSION)
363                 return __put_user(SOUND_VERSION, (int *)arg);
364         
365         if (_IOC_TYPE(cmd) == 'M' && num_mixers > 0 &&   /* Mixer ioctl */
366             (dev & 0x0f) != SND_DEV_CTL) {              
367                 dtype = dev & 0x0f;
368                 switch (dtype) {
369                 case SND_DEV_DSP:
370                 case SND_DEV_DSP16:
371                 case SND_DEV_AUDIO:
372                         return sound_mixer_ioctl(audio_devs[dev >> 4]->mixer_dev,
373                                                  cmd, (caddr_t)arg);
374                         
375                 default:
376                         return sound_mixer_ioctl(dev >> 4, cmd, (caddr_t)arg);
377                 }
378         }
379         switch (dev & 0x0f) {
380         case SND_DEV_CTL:
381                 if (cmd == SOUND_MIXER_GETLEVELS)
382                         return get_mixer_levels((caddr_t)arg);
383                 if (cmd == SOUND_MIXER_SETLEVELS)
384                         return set_mixer_levels((caddr_t)arg);
385                 return sound_mixer_ioctl(dev >> 4, cmd, (caddr_t)arg);
386
387         case SND_DEV_SEQ:
388         case SND_DEV_SEQ2:
389                 return sequencer_ioctl(dev, file, cmd, (caddr_t)arg);
390
391         case SND_DEV_DSP:
392         case SND_DEV_DSP16:
393         case SND_DEV_AUDIO:
394                 return audio_ioctl(dev, file, cmd, (caddr_t)arg);
395                 break;
396
397         case SND_DEV_MIDIN:
398                 return MIDIbuf_ioctl(dev, file, cmd, (caddr_t)arg);
399                 break;
400
401         }
402         return -EINVAL;
403 }
404
405 static unsigned int sound_poll(struct file *file, poll_table * wait)
406 {
407         struct inode *inode = file->f_dentry->d_inode;
408         int dev = MINOR(inode->i_rdev);
409
410         DEB(printk("sound_poll(dev=%d)\n", dev));
411         switch (dev & 0x0f) {
412         case SND_DEV_SEQ:
413         case SND_DEV_SEQ2:
414                 return sequencer_poll(dev, file, wait);
415
416         case SND_DEV_MIDIN:
417                 return MIDIbuf_poll(dev, file, wait);
418
419         case SND_DEV_DSP:
420         case SND_DEV_DSP16:
421         case SND_DEV_AUDIO:
422                 return DMAbuf_poll(file, dev >> 4, wait);
423         }
424         return 0;
425 }
426
427 static int sound_mmap(struct file *file, struct vm_area_struct *vma)
428 {
429         int dev_class;
430         unsigned long size;
431         struct dma_buffparms *dmap = NULL;
432         int dev = MINOR(file->f_dentry->d_inode->i_rdev);
433
434         dev_class = dev & 0x0f;
435         dev >>= 4;
436
437         if (dev_class != SND_DEV_DSP && dev_class != SND_DEV_DSP16 && dev_class != SND_DEV_AUDIO) {
438                 printk(KERN_ERR "Sound: mmap() not supported for other than audio devices\n");
439                 return -EINVAL;
440         }
441         lock_kernel();
442         if (vma->vm_flags & VM_WRITE)   /* Map write and read/write to the output buf */
443                 dmap = audio_devs[dev]->dmap_out;
444         else if (vma->vm_flags & VM_READ)
445                 dmap = audio_devs[dev]->dmap_in;
446         else {
447                 printk(KERN_ERR "Sound: Undefined mmap() access\n");
448                 unlock_kernel();
449                 return -EINVAL;
450         }
451
452         if (dmap == NULL) {
453                 printk(KERN_ERR "Sound: mmap() error. dmap == NULL\n");
454                 unlock_kernel();
455                 return -EIO;
456         }
457         if (dmap->raw_buf == NULL) {
458                 printk(KERN_ERR "Sound: mmap() called when raw_buf == NULL\n");
459                 unlock_kernel();
460                 return -EIO;
461         }
462         if (dmap->mapping_flags) {
463                 printk(KERN_ERR "Sound: mmap() called twice for the same DMA buffer\n");
464                 unlock_kernel();
465                 return -EIO;
466         }
467         if (vma->vm_pgoff != 0) {
468                 printk(KERN_ERR "Sound: mmap() offset must be 0.\n");
469                 unlock_kernel();
470                 return -EINVAL;
471         }
472         size = vma->vm_end - vma->vm_start;
473
474         if (size != dmap->bytes_in_use) {
475                 printk(KERN_WARNING "Sound: mmap() size = %ld. Should be %d\n", size, dmap->bytes_in_use);
476         }
477         if (remap_page_range(vma->vm_start, virt_to_phys(dmap->raw_buf),
478                 vma->vm_end - vma->vm_start,
479                 vma->vm_page_prot)) {
480                 unlock_kernel();
481                 return -EAGAIN;
482         }
483
484         dmap->mapping_flags |= DMA_MAP_MAPPED;
485
486         if( audio_devs[dev]->d->mmap)
487                 audio_devs[dev]->d->mmap(dev);
488
489         memset(dmap->raw_buf,
490                dmap->neutral_byte,
491                dmap->bytes_in_use);
492         unlock_kernel();
493         return 0;
494 }
495
496 struct file_operations oss_sound_fops = {
497         owner:          THIS_MODULE,
498         llseek:         no_llseek,
499         read:           sound_read,
500         write:          sound_write,
501         poll:           sound_poll,
502         ioctl:          sound_ioctl,
503         mmap:           sound_mmap,
504         open:           sound_open,
505         release:        sound_release,
506 };
507
508 /*
509  *      Create the required special subdevices
510  */
511  
512 static int create_special_devices(void)
513 {
514         int seq1,seq2;
515         seq1=register_sound_special(&oss_sound_fops, 1);
516         if(seq1==-1)
517                 goto bad;
518         seq2=register_sound_special(&oss_sound_fops, 8);
519         if(seq2!=-1)
520                 return 0;
521         unregister_sound_special(1);
522 bad:
523         return -1;
524 }
525
526
527 /* These device names follow the official Linux device list,
528  * Documentation/devices.txt.  Let us know if there are other
529  * common names we should support for compatibility.
530  * Only those devices not created by the generic code in sound_core.c are
531  * registered here.
532  */
533 static const struct {
534         unsigned short minor;
535         char *name;
536         umode_t mode;
537         int *num;
538 } dev_list[] = { /* list of minor devices */
539 /* seems to be some confusion here -- this device is not in the device list */
540         {SND_DEV_DSP16,     "dspW",      S_IWUGO | S_IRUSR | S_IRGRP,
541          &num_audiodevs},
542         {SND_DEV_AUDIO,     "audio",     S_IWUGO | S_IRUSR | S_IRGRP,
543          &num_audiodevs},
544 };
545
546 static char * 
547 soundcard_make_name(char *buf, char *name, int idx) {
548         if (idx==0)
549                 sprintf(buf, "sound/%s", name);
550         else
551                 sprintf(buf, "sound/%s%d", name, idx);
552         return buf;
553 }
554         
555 /* Register/unregister audio entries */
556 static void soundcard_register_devfs (int do_register)
557 {
558         char name_buf[32];
559         int i, j, num;
560
561         for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
562                 num = (dev_list[i].num == NULL) ? 0 : *dev_list[i].num;
563                 for (j = 0; j < num || j == 0; j++) {
564                         soundcard_make_name (name_buf, dev_list[i].name, j);
565                         if (do_register)
566                                 devfs_register (NULL, name_buf, DEVFS_FL_NONE,
567                                         SOUND_MAJOR, dev_list[i].minor+ (j* 0x10),
568                                         S_IFCHR | dev_list[i].mode,
569                                         &oss_sound_fops, NULL);
570                         else {
571                                 devfs_handle_t de;
572                                 
573                                 de = devfs_find_handle (NULL, name_buf, 0, 0,
574                                         DEVFS_SPECIAL_CHR, 0);
575                                 devfs_unregister (de);
576                         }
577                 }
578         }
579 }
580
581
582 static int dmabuf = 0;
583 static int dmabug = 0;
584
585 MODULE_PARM(dmabuf, "i");
586 MODULE_PARM(dmabug, "i");
587
588 static int __init oss_init(void)
589 {
590         int             err;
591         
592         /* drag in sound_syms.o */
593         {
594                 extern char sound_syms_symbol;
595                 sound_syms_symbol = 0;
596         }
597
598 #ifdef CONFIG_PCI
599         if(dmabug)
600                 isa_dma_bridge_buggy = dmabug;
601 #endif
602
603         err = create_special_devices();
604         if (err) {
605                 printk(KERN_ERR "sound: driver already loaded/included in kernel\n");
606                 return err;
607         }
608
609         /* Protecting the innocent */
610         sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
611
612         soundcard_register_devfs(1);
613
614         if (sound_nblocks >= 1024)
615                 printk(KERN_ERR "Sound warning: Deallocation table was too small.\n");
616         
617         return 0;
618 }
619
620 static void __exit oss_cleanup(void)
621 {
622         int i;
623
624         if (MOD_IN_USE)
625                 return;
626
627         soundcard_register_devfs (0);
628         
629         unregister_sound_special(1);
630         unregister_sound_special(8);
631
632         sound_stop_timer();
633
634         sequencer_unload();
635
636         for (i = 0; i < MAX_DMA_CHANNELS; i++)
637                 if (dma_alloc_map[i] != DMA_MAP_UNAVAIL) {
638                         printk(KERN_ERR "Sound: Hmm, DMA%d was left allocated - fixed\n", i);
639                         sound_free_dma(i);
640                 }
641
642         for (i = 0; i < sound_nblocks; i++)
643                 vfree(sound_mem_blocks[i]);
644
645 }
646
647 module_init(oss_init);
648 module_exit(oss_cleanup);
649 MODULE_LICENSE("GPL");
650
651
652 int sound_alloc_dma(int chn, char *deviceID)
653 {
654         int err;
655
656         if ((err = request_dma(chn, deviceID)) != 0)
657                 return err;
658
659         dma_alloc_map[chn] = DMA_MAP_FREE;
660
661         return 0;
662 }
663
664 int sound_open_dma(int chn, char *deviceID)
665 {
666         unsigned long   flags;
667
668         if (!valid_dma(chn)) {
669                 printk(KERN_ERR "sound_open_dma: Invalid DMA channel %d\n", chn);
670                 return 1;
671         }
672         save_flags(flags);
673         cli();
674
675         if (dma_alloc_map[chn] != DMA_MAP_FREE) {
676                 printk("sound_open_dma: DMA channel %d busy or not allocated (%d)\n", chn, dma_alloc_map[chn]);
677                 restore_flags(flags);
678                 return 1;
679         }
680         dma_alloc_map[chn] = DMA_MAP_BUSY;
681         restore_flags(flags);
682         return 0;
683 }
684
685 void sound_free_dma(int chn)
686 {
687         if (dma_alloc_map[chn] == DMA_MAP_UNAVAIL) {
688                 /* printk( "sound_free_dma: Bad access to DMA channel %d\n",  chn); */
689                 return;
690         }
691         free_dma(chn);
692         dma_alloc_map[chn] = DMA_MAP_UNAVAIL;
693 }
694
695 void sound_close_dma(int chn)
696 {
697         unsigned long   flags;
698
699         save_flags(flags);
700         cli();
701
702         if (dma_alloc_map[chn] != DMA_MAP_BUSY) {
703                 printk(KERN_ERR "sound_close_dma: Bad access to DMA channel %d\n", chn);
704                 restore_flags(flags);
705                 return;
706         }
707         dma_alloc_map[chn] = DMA_MAP_FREE;
708         restore_flags(flags);
709 }
710
711 static void do_sequencer_timer(unsigned long dummy)
712 {
713         sequencer_timer(0);
714 }
715
716
717 static struct timer_list seq_timer =
718 {function: do_sequencer_timer};
719
720 void request_sound_timer(int count)
721 {
722         extern unsigned long seq_time;
723
724         if (count < 0) {
725                 seq_timer.expires = (-count) + jiffies;
726                 add_timer(&seq_timer);
727                 return;
728         }
729         count += seq_time;
730
731         count -= jiffies;
732
733         if (count < 1)
734                 count = 1;
735
736         seq_timer.expires = (count) + jiffies;
737         add_timer(&seq_timer);
738 }
739
740 void sound_stop_timer(void)
741 {
742         del_timer(&seq_timer);;
743 }
744
745 void conf_printf(char *name, struct address_info *hw_config)
746 {
747 #ifndef CONFIG_SOUND_TRACEINIT
748         return;
749 #else
750         printk("<%s> at 0x%03x", name, hw_config->io_base);
751
752         if (hw_config->irq)
753                 printk(" irq %d", (hw_config->irq > 0) ? hw_config->irq : -hw_config->irq);
754
755         if (hw_config->dma != -1 || hw_config->dma2 != -1)
756         {
757                 printk(" dma %d", hw_config->dma);
758                 if (hw_config->dma2 != -1)
759                         printk(",%d", hw_config->dma2);
760         }
761         printk("\n");
762 #endif
763 }
764
765 void conf_printf2(char *name, int base, int irq, int dma, int dma2)
766 {
767 #ifndef CONFIG_SOUND_TRACEINIT
768         return;
769 #else
770         printk("<%s> at 0x%03x", name, base);
771
772         if (irq)
773                 printk(" irq %d", (irq > 0) ? irq : -irq);
774
775         if (dma != -1 || dma2 != -1)
776         {
777                   printk(" dma %d", dma);
778                   if (dma2 != -1)
779                           printk(",%d", dma2);
780         }
781         printk("\n");
782 #endif
783 }