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