Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / platform / pc32 / include / ultrasound.h
1 #ifndef _ULTRASOUND_H_
2 #define _ULTRASOUND_H_
3 /*
4  * Copyright by Hannu Savolainen 1993
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * $FreeBSD: src/sys/i386/include/ultrasound.h,v 1.7.6.1 2000/08/03 01:01:19 peter Exp $
28  */
29
30 /*
31  *      ultrasound.h - Macros for programming the Gravis Ultrasound
32  *                      These macros are extremely device dependent
33  *                      and not portable.
34  */
35
36 /*
37  *      Private events for Gravis Ultrasound (GUS)
38  *
39  *      Format:
40  *              byte 0          - SEQ_PRIVATE (0xfe)
41  *              byte 1          - Synthesizer device number (0-N)
42  *              byte 2          - Command (see below)
43  *              byte 3          - Voice number (0-31)
44  *              bytes 4 and 5   - parameter P1 (unsigned short)
45  *              bytes 6 and 7   - parameter P2 (unsigned short)
46  *
47  *      Commands:
48  *              Each command affects one voice defined in byte 3.
49  *              Unused parameters (P1 and/or P2 *MUST* be initialized to zero).
50  *              _GUS_NUMVOICES  - Sets max. number of concurrent voices (P1=14-31, default 16)
51  *              _GUS_VOICESAMPLE- ************ OBSOLETE *************
52  *              _GUS_VOICEON    - Starts voice (P1=voice mode)
53  *              _GUS_VOICEOFF   - Stops voice (no parameters)
54  *              _GUS_VOICEFADE  - Stops the voice smoothly.
55  *              _GUS_VOICEMODE  - Alters the voice mode, don't start or stop voice (P1=voice mode)
56  *              _GUS_VOICEBALA  - Sets voice balance (P1, 0=left, 7=middle and 15=right, default 7)
57  *              _GUS_VOICEFREQ  - Sets voice (sample) playback frequency (P1=Hz)
58  *              _GUS_VOICEVOL   - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
59  *              _GUS_VOICEVOL2  - Sets voice volume (P1=volume, 0xfff=max, 0xeff=half, 0x000=off)
60  *                                (Like GUS_VOICEVOL but doesn't change the hw
61  *                                volume. It just updates volume in the voice table).
62  *
63  *              _GUS_RAMPRANGE  - Sets limits for volume ramping (P1=low volume, P2=high volume)
64  *              _GUS_RAMPRATE   - Sets the speed for volume ramping (P1=scale, P2=rate)
65  *              _GUS_RAMPMODE   - Sets the volume ramping mode (P1=ramping mode)
66  *              _GUS_RAMPON     - Starts volume ramping (no parameters)
67  *              _GUS_RAMPOFF    - Stops volume ramping (no parameters)
68  *              _GUS_VOLUME_SCALE - Changes the volume calculation constants
69  *                                for all voices.
70  */
71
72 #define _GUS_NUMVOICES          0x00
73 #define _GUS_VOICESAMPLE        0x01    /* OBSOLETE */
74 #define _GUS_VOICEON            0x02
75 #define _GUS_VOICEOFF           0x03
76 #define _GUS_VOICEMODE          0x04
77 #define _GUS_VOICEBALA          0x05
78 #define _GUS_VOICEFREQ          0x06
79 #define _GUS_VOICEVOL           0x07
80 #define _GUS_RAMPRANGE          0x08
81 #define _GUS_RAMPRATE           0x09
82 #define _GUS_RAMPMODE           0x0a
83 #define _GUS_RAMPON             0x0b
84 #define _GUS_RAMPOFF            0x0c
85 #define _GUS_VOICEFADE          0x0d
86 #define _GUS_VOLUME_SCALE       0x0e
87 #define _GUS_VOICEVOL2          0x0f
88 #define _GUS_VOICE_POS          0x10
89
90 /*
91  *      GUS API macros
92  */
93
94 #define _GUS_CMD(chn, voice, cmd, p1, p2) \
95                                         {_SEQ_NEEDBUF(8); _seqbuf[_seqbufptr] = SEQ_PRIVATE;\
96                                         _seqbuf[_seqbufptr+1] = (chn); _seqbuf[_seqbufptr+2] = cmd;\
97                                         _seqbuf[_seqbufptr+3] = voice;\
98                                         *(unsigned short*)&_seqbuf[_seqbufptr+4] = p1;\
99                                         *(unsigned short*)&_seqbuf[_seqbufptr+6] = p2;\
100                                         _SEQ_ADVBUF(8);}
101
102 #define GUS_NUMVOICES(chn, p1)                  _GUS_CMD(chn, 0, _GUS_NUMVOICES, (p1), 0)
103 #define GUS_VOICESAMPLE(chn, voice, p1)         _GUS_CMD(chn, voice, _GUS_VOICESAMPLE, (p1), 0) /* OBSOLETE */
104 #define GUS_VOICEON(chn, voice, p1)             _GUS_CMD(chn, voice, _GUS_VOICEON, (p1), 0)
105 #define GUS_VOICEOFF(chn, voice)                _GUS_CMD(chn, voice, _GUS_VOICEOFF, 0, 0)
106 #define GUS_VOICEFADE(chn, voice)               _GUS_CMD(chn, voice, _GUS_VOICEFADE, 0, 0)
107 #define GUS_VOICEMODE(chn, voice, p1)           _GUS_CMD(chn, voice, _GUS_VOICEMODE, (p1), 0)
108 #define GUS_VOICEBALA(chn, voice, p1)           _GUS_CMD(chn, voice, _GUS_VOICEBALA, (p1), 0)
109 #define GUS_VOICEFREQ(chn, voice, p)            _GUS_CMD(chn, voice, _GUS_VOICEFREQ, \
110                                                         (p) & 0xffff, ((p) >> 16) & 0xffff)
111 #define GUS_VOICEVOL(chn, voice, p1)            _GUS_CMD(chn, voice, _GUS_VOICEVOL, (p1), 0)
112 #define GUS_VOICEVOL2(chn, voice, p1)           _GUS_CMD(chn, voice, _GUS_VOICEVOL2, (p1), 0)
113 #define GUS_RAMPRANGE(chn, voice, low, high)    _GUS_CMD(chn, voice, _GUS_RAMPRANGE, (low), (high))
114 #define GUS_RAMPRATE(chn, voice, p1, p2)        _GUS_CMD(chn, voice, _GUS_RAMPRATE, (p1), (p2))
115 #define GUS_RAMPMODE(chn, voice, p1)            _GUS_CMD(chn, voice, _GUS_RAMPMODE, (p1), 0)
116 #define GUS_RAMPON(chn, voice, p1)              _GUS_CMD(chn, voice, _GUS_RAMPON, (p1), 0)
117 #define GUS_RAMPOFF(chn, voice)                 _GUS_CMD(chn, voice, _GUS_RAMPOFF, 0, 0)
118 #define GUS_VOLUME_SCALE(chn, voice, p1, p2)    _GUS_CMD(chn, voice, _GUS_VOLUME_SCALE, (p1), (p2))
119 #define GUS_VOICE_POS(chn, voice, p)            _GUS_CMD(chn, voice, _GUS_VOICE_POS, \
120                                                         (p) & 0xffff, ((p) >> 16) & 0xffff)
121
122 #endif