Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / sound / isa / i386 / soundcard.c
1 /*
2  * sound/386bsd/soundcard.c
3  * 
4  * Soundcard driver for 386BSD.
5  * 
6  * Copyright by Hannu Savolainen 1993
7  * 
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer. 2.
12  * Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  * 
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/i386/isa/sound/soundcard.c,v 1.87 1999/12/20 18:05:01 eivind Exp $
29  *
30  */
31 #include <i386/isa/sound/sound_config.h>
32 #if NSND > 0    /* from "snd.h" */
33 #include "uart.h"
34
35 #include <sys/select.h>
36 #include <vm/vm.h>
37 #include <vm/pmap.h>
38 #include <sys/mman.h>
39
40 #include <i386/isa/isa_device.h>
41
42
43 /*
44 **  Register definitions for DMA controller 1 (channels 0..3):
45 */
46 #define DMA1_CHN(c)     (IO_DMA1 + 1*(2*(c)))   /* addr reg for channel c */
47 #define DMA1_SMSK       (IO_DMA1 + 1*10)        /* single mask register */
48 #define DMA1_MODE       (IO_DMA1 + 1*11)        /* mode register */
49 #define DMA1_FFC        (IO_DMA1 + 1*12)        /* clear first/last FF */
50
51 /*
52 **  Register definitions for DMA controller 2 (channels 4..7):
53 */
54 #define DMA2_CHN(c)     (IO_DMA2 + 2*(2*(c)))   /* addr reg for channel c */
55 #define DMA2_SMSK       (IO_DMA2 + 2*10)        /* single mask register */
56 #define DMA2_MODE       (IO_DMA2 + 2*11)        /* mode register */
57 #define DMA2_FFC        (IO_DMA2 + 2*12)        /* clear first/last FF */
58
59
60 #define FIX_RETURN(ret) {if ((ret)<0) return -(ret); else return 0;}
61
62 static int      soundcards_installed = 0; /* Number of installed soundcards */
63 static int      soundcard_configured = 0;
64
65 static struct fileinfo files[SND_NDEVS];
66 struct selinfo  selinfo[SND_NDEVS >> 4];
67
68 int
69 MIDIbuf_poll (int dev, struct fileinfo *file, int events, select_table * wait);
70
71 int
72 audio_poll(int dev, struct fileinfo * file, int events, select_table * wait);
73
74 int
75 sequencer_poll (int dev, struct fileinfo *file, int events, select_table * wait);
76
77 static int sndprobe    __P((struct isa_device *));
78 static int sndattach   __P((struct isa_device *));
79
80 static d_open_t sndopen;
81 static d_close_t sndclose;
82 static d_ioctl_t sndioctl;
83 static d_read_t sndread;
84 static d_write_t sndwrite;
85 static d_poll_t sndpoll;
86 static d_mmap_t sndmmap;
87
88 static char     driver_name[] = "snd";
89
90 #define CDEV_MAJOR 30
91 static struct cdevsw snd_cdevsw = {
92         /* open */      sndopen,
93         /* close */     sndclose,
94         /* read */      sndread,
95         /* write */     sndwrite,
96         /* ioctl */     sndioctl,
97         /* poll */      sndpoll,
98         /* mmap */      sndmmap,
99         /* strategy */  nostrategy,
100         /* name */      driver_name,
101         /* maj */       CDEV_MAJOR,
102         /* dump */      nodump,
103         /* psize */     nopsize,
104         /* flags */     0,
105         /* bmaj */      -1
106 };
107
108
109
110
111 static void     sound_mem_init(void);
112
113 /*
114  * for each "device XXX" entry in the config file, we have
115  * a struct isa_driver which is linked into isa_devtab_null[]
116  *
117  * XXX It is a bit stupid to call the generic routine so many times and
118  * switch then to the specific one, but the alternative way would be
119  * to replicate some code in the probe/attach routines.
120  */
121
122 struct isa_driver opldriver = {sndprobe, sndattach, "opl"};
123 struct isa_driver trixdriver = {sndprobe, sndattach, "trix"};
124 struct isa_driver trixsbdriver = {sndprobe, sndattach, "trixsb"};
125 struct isa_driver sbdriver = {sndprobe, sndattach, "sb"};
126 struct isa_driver sbxvidriver = {sndprobe, sndattach, "sbxvi"};
127 struct isa_driver sbmididriver = {sndprobe, sndattach, "sbmidi"};
128 struct isa_driver awedriver    = {sndprobe, sndattach, "awe"};
129 struct isa_driver pasdriver = {sndprobe, sndattach, "pas"};
130 struct isa_driver mpudriver = {sndprobe, sndattach, "mpu"};
131 struct isa_driver gusdriver = {sndprobe, sndattach, "gus"};
132 struct isa_driver gusxvidriver = {sndprobe, sndattach, "gusxvi"};
133 struct isa_driver gusmaxdriver = {sndprobe, sndattach, "gusmax"};
134 struct isa_driver uartdriver = {sndprobe, sndattach, "uart"};
135 struct isa_driver mssdriver = {sndprobe, sndattach, "mss"};
136 struct isa_driver cssdriver = {sndprobe, sndattach, "css"};
137 struct isa_driver sscapedriver = {sndprobe, sndattach, "sscape"};
138 struct isa_driver sscape_mssdriver = {sndprobe, sndattach, "sscape_mss"};
139 struct isa_driver nssdriver = {sndprobe, sndattach, "nss"};
140
141 short ipri_to_irq(u_short ipri);
142
143 static ointhand2_t sndintr;
144
145 u_long
146 get_time(void)
147 {
148     struct timeval  timecopy;
149
150     getmicrotime(&timecopy);
151     return timecopy.tv_usec / (1000000 / hz) +
152                 (u_long) timecopy.tv_sec * hz;
153 }
154
155 static int
156 sndmmap( dev_t dev, vm_offset_t offset, int nprot )
157 {
158         struct dma_buffparms * dmap;
159         u_int min = minor(dev) >> 4;
160
161         if (min > 0 ) return (-1);
162
163         dmap =  audio_devs[min]->dmap_out;
164
165         if (nprot & PROT_EXEC)
166                 return( -1 );
167         dmap->mapping_flags |= DMA_MAP_MAPPED ;
168         return( i386_btop(vtophys(dmap->raw_buf) + offset) );
169 }
170
171
172 static int
173 sndread(dev_t dev, struct uio * buf, int flag)
174 {
175     int             count = buf->uio_resid;
176     u_int min = minor(dev);
177
178     FIX_RETURN(sound_read_sw(min, &files[min], buf, count));
179 }
180
181
182 static int
183 sndwrite(dev_t dev, struct uio * buf, int flag)
184 {
185     int             count = buf->uio_resid;
186     u_int min = minor(dev);
187
188     FIX_RETURN(sound_write_sw(min, &files[min], buf, count));
189 }
190
191 static int
192 sndopen(dev_t dev, int flags, int mode, struct proc * p)
193 {
194     int             retval;
195     struct fileinfo tmp_file;
196     u_int min = minor(dev);
197
198     if (!soundcard_configured && min) {
199         printf("SoundCard Error: soundcard system has not been configured\n");
200         return ENODEV ;
201     }
202     tmp_file.mode = 0;
203
204     if (flags & FREAD && flags & FWRITE)
205         tmp_file.mode = OPEN_READWRITE;
206     else if (flags & FREAD)
207         tmp_file.mode = OPEN_READ;
208     else if (flags & FWRITE)
209         tmp_file.mode = OPEN_WRITE;
210
211     selinfo[min >> 4].si_pid = 0;
212     selinfo[min >> 4].si_flags = 0;
213     if ((retval = sound_open_sw(min, &tmp_file)) < 0)
214         FIX_RETURN(retval);
215
216     bcopy((char *) &tmp_file, (char *) &files[min], sizeof(tmp_file));
217
218     FIX_RETURN(retval);
219 }
220
221
222 static int
223 sndclose(dev_t dev, int flags, int mode, struct proc * p)
224 {
225     u_int min = minor(dev);
226
227     sound_release_sw(min, &files[min]);
228     return 0 ;
229 }
230
231 static int
232 sndioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct proc * p)
233 {
234     u_int min = minor(dev);
235     FIX_RETURN(sound_ioctl_sw(min, &files[min], cmd, arg));
236 }
237
238 int
239 sndpoll(dev_t dev, int events, struct proc * p)
240 {
241     u_int min = minor(dev);
242
243     /* printf ("snd_select(dev=%d, rw=%d, pid=%d)\n", min, rw, p->p_pid); */
244 #ifdef ALLOW_POLL
245     switch (min & 0x0f) {
246 #ifdef CONFIG_SEQUENCER
247     case SND_DEV_SEQ:
248     case SND_DEV_SEQ2:
249         return sequencer_poll(min, &files[min], events, p);
250         break;
251 #endif
252
253 #ifdef CONFIG_MIDI
254     case SND_DEV_MIDIN:
255         return MIDIbuf_poll(min, &files[min], events, p);
256         break;
257 #endif
258
259 #ifdef CONFIG_AUDIO
260     case SND_DEV_DSP:
261     case SND_DEV_DSP16:
262     case SND_DEV_AUDIO:
263
264         return audio_poll(min, &files[min], events, p);
265         break;
266 #endif
267
268     default:
269         return 0;
270     }
271
272 #endif  /* ALLOW_POLL */
273     DEB(printf("sound_ioctl(min=%d, cmd=0x%x, arg=0x%x)\n", min, cmd, arg));
274
275     return 0 ;
276 }
277
278 /* XXX this should become ffs(ipri), perhaps -1 lr 970705 */
279 short
280 ipri_to_irq(u_short ipri)
281 {
282     /*
283      * Converts the ipri (bitmask) to the corresponding irq number
284      */
285     int             irq;
286
287     for (irq = 0; irq < 16; irq++)
288         if (ipri == (1 << irq))
289             return irq;
290
291     return -1;          /* Invalid argument */
292 }
293
294 static int
295 driver_to_voxunit(struct isa_driver * driver)
296 {
297     /*
298      * converts a sound driver pointer into the equivalent VoxWare device
299      * unit number
300      */
301     if (driver == &opldriver)
302         return (SNDCARD_ADLIB);
303     else if (driver == &sbdriver)
304         return (SNDCARD_SB);
305     else if (driver == &pasdriver)
306         return (SNDCARD_PAS);
307     else if (driver == &gusdriver)
308         return (SNDCARD_GUS);
309     else if (driver == &mpudriver)
310         return (SNDCARD_MPU401);
311     else if (driver == &sbxvidriver)
312         return (SNDCARD_SB16);
313     else if (driver == &sbmididriver)
314         return (SNDCARD_SB16MIDI);
315     else if(driver == &awedriver)
316         return(SNDCARD_AWE32);
317     else if (driver == &uartdriver)
318         return (SNDCARD_UART6850);
319     else if (driver == &gusdriver)
320         return (SNDCARD_GUS16);
321     else if (driver == &mssdriver)
322         return (SNDCARD_MSS);
323     else if (driver == &cssdriver)
324         return (SNDCARD_CS4232);
325     else if (driver == &sscapedriver)
326         return(SNDCARD_SSCAPE);
327     else if (driver == &sscape_mssdriver)
328         return(SNDCARD_SSCAPE_MSS);
329     else if (driver == &trixdriver)
330         return (SNDCARD_TRXPRO);
331     else if (driver == &trixsbdriver)
332         return (SNDCARD_TRXPRO_SB);
333     else if (driver == &nssdriver)
334         return (SNDCARD_NSS);
335     else
336         return (0);
337 }
338
339 /*
340  * very dirty: tmp_osp is allocated in sndprobe, and used at the next
341  * call in sndattach
342  */
343
344 static sound_os_info *temp_osp;
345
346 /*
347  * sndprobe is called for each isa_device. From here, a voxware unit
348  * number is determined, and the appropriate probe routine is selected.
349  * The parameters from the config line are passed to the hw_config struct.
350  */
351
352 static int
353 sndprobe(struct isa_device * dev)
354 {
355     struct address_info hw_config;
356     int             unit;
357
358     temp_osp = (sound_os_info *)malloc(sizeof(sound_os_info),
359             M_DEVBUF, M_NOWAIT);
360     if (!temp_osp)
361         panic("SOUND: Cannot allocate memory\n");
362
363     /*
364      * get config info from the kernel config. These may be overridden
365      * by the local autoconfiguration routines though (e.g. pnp stuff).
366      */
367
368     hw_config.io_base = dev->id_iobase;
369     hw_config.irq = ipri_to_irq(dev->id_irq);
370     hw_config.dma = dev->id_drq;
371
372     /*
373      * misuse the flags field for read dma. Note that, to use 0 as
374      * read dma channel, one of the high bits should be set.  lr970705 XXX
375      */
376
377     if (dev->id_flags != 0)
378         hw_config.dma2 = dev->id_flags & 0x7;
379     else
380         hw_config.dma2 = -1;
381
382     hw_config.always_detect = 0;
383     hw_config.name = NULL;
384     hw_config.card_subtype = 0;
385
386     temp_osp->unit = dev->id_unit;
387     hw_config.osp = temp_osp;
388     unit = driver_to_voxunit(dev->id_driver);
389
390     if (sndtable_probe(unit, &hw_config)) {
391         dev->id_iobase = hw_config.io_base;
392         dev->id_irq =  hw_config.irq == -1 ? 0 : (1 << hw_config.irq);
393         dev->id_drq = hw_config.dma;
394
395         if (hw_config.dma != hw_config.dma2 && ( hw_config.dma2 != -1))
396             dev->id_flags = hw_config.dma2 | 0x100; /* XXX lr */
397         else
398             dev->id_flags = 0;
399         return TRUE;
400     }
401     return 0;
402 }
403
404 static int
405 sndattach(struct isa_device * dev)
406 {
407     int             unit;
408     static int      midi_initialized = 0;
409     static int      seq_initialized = 0;
410     struct address_info hw_config;
411     char   *dname;
412
413     /*
414      * Associate interrupt handlers with devices.  XXX this may be incomplete.
415      */
416     dname = dev->id_driver->name;
417 #if defined(CONFIG_AD1848)
418     if (strcmp(dname, "css") == 0 || strcmp(dname, "gusxvi") == 0 ||
419         strcmp(dname, "mss") == 0)
420         dev->id_ointr = adintr;
421 #endif
422 #ifdef CONFIG_GUS
423     if (strcmp(dname, "gus") == 0)
424         dev->id_ointr = gusintr;
425 #endif
426 #ifdef CONFIG_PAS
427     if (strcmp(dname, "pas") == 0)
428         dev->id_ointr = pasintr;
429 #endif
430 #if NSB > 0 && (defined(CONFIG_MIDI) || defined(CONFIG_AUDIO))
431     if (strcmp(dname, "sb") == 0)
432         dev->id_ointr = sbintr;
433 #endif
434     if (strcmp(dname, "sscape_mss") == 0)
435         dev->id_ointr = sndintr;
436 #if NSSCAPE > 0
437     if (strcmp(dname, "sscape") == 0 || strcmp(dname, "trix") == 0)
438         dev->id_ointr = sscapeintr;
439 #endif
440 #if NUART > 0
441     if (strcmp(dname, "uart0") == 0)
442         dev->id_ointr = m6850intr;
443 #endif
444 #if NMPU > 0 && defined(CONFIG_MIDI)
445     if (strcmp(dname, "mpu") == 0)
446         dev->id_ointr = mpuintr;
447 #endif
448 #if NNSS > 0
449     if (strcmp(dname, "nss") == 0)
450         dev->id_ointr = nssintr;
451 #endif
452
453     unit = driver_to_voxunit(dev->id_driver);
454     hw_config.io_base = dev->id_iobase;
455     hw_config.irq = ipri_to_irq(dev->id_irq);
456     hw_config.dma = dev->id_drq;
457
458     /* misuse the flags field for read dma */
459     if (dev->id_flags != 0)
460         hw_config.dma2 = dev->id_flags & 0x7;
461     else
462         hw_config.dma2 = -1;
463
464     hw_config.card_subtype = 0;
465     hw_config.osp = temp_osp;
466
467     if (!unit)
468         return FALSE;
469
470     if (!(sndtable_init_card(unit, &hw_config))) {      /* init card */
471         printf(" <Driver not configured>");
472         return FALSE;
473     }
474     /*
475      * Init the high level sound driver
476      */
477
478     if (!(soundcards_installed = sndtable_get_cardcount())) {
479         DDB(printf("No drivers actually installed\n"));
480         return FALSE;   /* No cards detected */
481     }
482     printf("\n");
483
484 #ifdef CONFIG_AUDIO
485     if (num_audiodevs) {        /* Audio devices present */
486         DMAbuf_init();
487         sound_mem_init();
488     }
489     soundcard_configured = 1;
490 #endif
491
492     if (num_midis && !midi_initialized)
493         midi_initialized = 1;
494
495     if ((num_midis + num_synths) && !seq_initialized) {
496         seq_initialized = 1;
497         sequencer_init();
498     }
499
500     cdevsw_add(&snd_cdevsw);
501 #define GID_SND GID_GAMES
502 #define UID_SND UID_ROOT
503 #define PERM_SND 0660
504     /*
505      *  make links to first successfully probed device, don't do it if
506      *  duplicate creation of same node failed (ie. bad cookie returned)
507      */
508     if (dev->id_driver == &opldriver){
509         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_SEQ,
510             UID_SND, GID_SND, PERM_SND, "sequencer%r", dev->id_unit);
511     } else if (dev->id_driver == &mpudriver || 
512                dev->id_driver == &sbmididriver ||
513                dev->id_driver == &uartdriver){
514         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_MIDIN,
515             UID_SND, GID_SND, PERM_SND, "midi%r", dev->id_unit);
516     } else {
517         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_DSP,
518             UID_SND, GID_SND, PERM_SND, "dsp%r", dev->id_unit);
519         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_DSP16,
520             UID_SND, GID_SND, PERM_SND, "dspW%r", dev->id_unit);
521         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_AUDIO,
522             UID_SND, GID_SND, PERM_SND, "audio%r", dev->id_unit);
523         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_CTL,
524             UID_SND, GID_SND, PERM_SND, "mixer%r", dev->id_unit);
525         make_dev(&snd_cdevsw, (dev->id_unit << 4) | SND_DEV_STATUS,
526             UID_SND, GID_SND, PERM_SND, "sndstat%r", dev->id_unit);
527     }
528     return TRUE;
529 }
530
531
532 #ifdef CONFIG_AUDIO
533
534 static void
535 alloc_dmap(int dev, int chan, struct dma_buffparms * dmap)
536 {
537     char           *tmpbuf;
538     int            i;
539
540     tmpbuf = contigmalloc(audio_devs[dev]->buffsize, M_DEVBUF, M_NOWAIT,
541                 0ul, 0xfffffful, 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
542     if (tmpbuf == NULL)
543         printf("soundcard buffer alloc failed \n");
544
545     if (tmpbuf == NULL) {
546         printf("snd: Unable to allocate %d bytes of buffer\n",
547                2 * (int) audio_devs[dev]->buffsize);
548         return;
549     }
550     dmap->raw_buf = tmpbuf;
551     /*
552      * Use virtual address as the physical address, since isa_dmastart
553      * performs the phys address computation.
554      */
555
556     dmap->raw_buf_phys = (uintptr_t) tmpbuf;
557     for (i = 0; i < audio_devs[dev]->buffsize; i++)   *tmpbuf++ = 0x80; 
558
559 }
560
561 static void
562 sound_mem_init(void)
563 {
564     int             dev;
565     static u_long dsp_init_mask = 0;
566
567     for (dev = 0; dev < num_audiodevs; dev++)   /* Enumerate devices */
568         if (!(dsp_init_mask & (1 << dev)))      /* Not already done */
569             if (audio_devs[dev]->dmachan1 >= 0) {
570                 dsp_init_mask |= (1 << dev);
571                 audio_devs[dev]->buffsize = DSP_BUFFSIZE;
572                 /* Now allocate the buffers */
573                 alloc_dmap(dev, audio_devs[dev]->dmachan1,
574                         audio_devs[dev]->dmap_out);
575                 if (audio_devs[dev]->flags & DMA_DUPLEX)
576                     alloc_dmap(dev, audio_devs[dev]->dmachan2,
577                             audio_devs[dev]->dmap_in);
578             }   /* for dev */
579 }
580
581 #endif
582
583
584 int
585 snd_ioctl_return(int *addr, int value)
586 {
587     if (value < 0)
588         return value;   /* Error */
589     suword(addr, value);
590     return 0;
591 }
592
593 #define MAX_UNIT 50
594 typedef void    (*irq_proc_t) (int irq);
595 static irq_proc_t irq_proc[MAX_UNIT] = {NULL};
596 static int      irq_irq[MAX_UNIT] = {0};
597
598 int
599 snd_set_irq_handler(int int_lvl, void (*hndlr) (int), sound_os_info * osp)
600 {
601     if (osp->unit >= MAX_UNIT) {
602         printf("Sound error: Unit number too high (%d)\n", osp->unit);
603         return 0;
604     }
605     irq_proc[osp->unit] = hndlr;
606     irq_irq[osp->unit] = int_lvl;
607     return 1;
608 }
609
610 static void
611 sndintr(int unit)
612 {
613     if ( (unit >= MAX_UNIT) || (irq_proc[unit] == NULL) )
614         return;
615
616     irq_proc[unit] (irq_irq[unit]);     /* Call the installed handler */
617 }
618
619 void
620 conf_printf(char *name, struct address_info * hw_config)
621 {
622     if (!trace_init)
623         return;
624
625     printf("snd0: <%s> ", name);
626 #if 0
627     if (hw_config->io_base != -1 ) 
628     printf("at 0x%03x", hw_config->io_base);
629
630     if (hw_config->irq != -1 )
631         printf(" irq %d", hw_config->irq);
632
633     if (hw_config->dma != -1 || hw_config->dma2 != -1) {
634         printf(" dma %d", hw_config->dma);
635         if (hw_config->dma2 != -1)
636             printf(",%d", hw_config->dma2);
637     }
638 #endif
639
640 }
641
642 void
643 conf_printf2(char *name, int base, int irq, int dma, int dma2)
644 {
645     if (!trace_init)
646         return;
647
648     printf("snd0: <%s> ", name);
649 #if 0
650     if (hw_config->io_base != -1 ) 
651     printf("at 0x%03x", hw_config->io_base);
652
653     if (irq)
654         printf(" irq %d", irq);
655
656     if (dma != -1 || dma2 != -1) {
657         printf(" dma %d", dma);
658         if (dma2 != -1)
659             printf(",%d", dma2);
660     }
661 #endif
662
663 }
664
665
666 void tenmicrosec (int j)
667 {
668   int             i, k;
669   for (k = 0; k < j/10 ; k++) {
670       for (i = 0; i < 16; i++)
671           inb (0x80);
672   }
673 }
674
675 #endif  /* NSND > 0 */
676
677
678
679