1 /* $NetBSD: soundcard.h,v 1.17 2008/03/15 20:18:20 bjs Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
34 * This is an OSS (Linux) audio emulator.
35 * Use the Native NetBSD API for developing new code, and this
36 * only for compiling Linux programs.
42 #define SOUND_VERSION 0x030001
44 #define SNDCTL_DSP_RESET _IO ('P', 0)
45 #define SNDCTL_DSP_SYNC _IO ('P', 1)
46 #define SNDCTL_DSP_SPEED _IOWR('P', 2, int)
47 #define SOUND_PCM_READ_RATE _IOR ('P', 2, int)
48 #define SNDCTL_DSP_STEREO _IOWR('P', 3, int)
49 #define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int)
50 #define SNDCTL_DSP_SETFMT _IOWR('P', 5, int)
51 #define AFMT_QUERY 0x00000000
52 #define AFMT_MU_LAW 0x00000001
53 #define AFMT_A_LAW 0x00000002
54 #define AFMT_IMA_ADPCM 0x00000004
55 #define AFMT_U8 0x00000008
56 #define AFMT_S16_LE 0x00000010
57 #define AFMT_S16_BE 0x00000020
58 #define AFMT_S8 0x00000040
59 #define AFMT_U16_LE 0x00000080
60 #define AFMT_U16_BE 0x00000100
61 #define AFMT_MPEG 0x00000200
62 #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
63 #define SOUND_PCM_READ_BITS _IOR ('P', 5, int)
64 #define SNDCTL_DSP_CHANNELS _IOWR('P', 6, int)
65 #define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
66 #define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int)
67 #define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int)
68 #define SOUND_PCM_READ_FILTER _IOR ('P', 7, int)
69 #define SNDCTL_DSP_POST _IO ('P', 8)
70 #define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int)
71 #define SNDCTL_DSP_SETFRAGMENT _IOWR('P', 10, int)
72 #define SNDCTL_DSP_GETFMTS _IOR ('P', 11, int)
73 #define SNDCTL_DSP_GETOSPACE _IOR ('P',12, struct audio_buf_info)
74 #define SNDCTL_DSP_GETISPACE _IOR ('P',13, struct audio_buf_info)
75 #define SNDCTL_DSP_NONBLOCK _IO ('P',14)
76 #define SNDCTL_DSP_GETCAPS _IOR ('P',15, int)
77 # define DSP_CAP_REVISION 0x000000ff
78 # define DSP_CAP_DUPLEX 0x00000100
79 # define DSP_CAP_REALTIME 0x00000200
80 # define DSP_CAP_BATCH 0x00000400
81 # define DSP_CAP_COPROC 0x00000800
82 # define DSP_CAP_TRIGGER 0x00001000
83 # define DSP_CAP_MMAP 0x00002000
84 #define SNDCTL_DSP_GETTRIGGER _IOR ('P', 16, int)
85 #define SNDCTL_DSP_SETTRIGGER _IOW ('P', 16, int)
86 # define PCM_ENABLE_INPUT 0x00000001
87 # define PCM_ENABLE_OUTPUT 0x00000002
88 #define SNDCTL_DSP_GETIPTR _IOR ('P', 17, struct count_info)
89 #define SNDCTL_DSP_GETOPTR _IOR ('P', 18, struct count_info)
90 #define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, struct buffmem_desc)
91 #define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, struct buffmem_desc)
92 #define SNDCTL_DSP_SETSYNCRO _IO ('P', 21)
93 #define SNDCTL_DSP_SETDUPLEX _IO ('P', 22)
94 #define SNDCTL_DSP_PROFILE _IOW ('P', 23, int)
95 #define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
98 #define APF_CPUINTENS 2
100 /* Need native 16 bit format which depends on byte order */
101 #include <machine/endian_machdep.h>
102 #if _BYTE_ORDER == _LITTLE_ENDIAN
103 #define AFMT_S16_NE AFMT_S16_LE
105 #define AFMT_S16_NE AFMT_S16_BE
109 #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
110 #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
111 #define SOUND_PCM_POST SNDCTL_DSP_POST
112 #define SOUND_PCM_RESET SNDCTL_DSP_RESET
113 #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
114 #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
115 #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
116 #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
117 #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
118 #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
119 #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
120 #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
121 #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
122 #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
123 #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
124 #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
125 #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
126 #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
127 #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
128 #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
131 #define SOUND_MIXER_FIRST 0
132 #define SOUND_MIXER_NRDEVICES 25
134 #define SOUND_MIXER_VOLUME 0
135 #define SOUND_MIXER_BASS 1
136 #define SOUND_MIXER_TREBLE 2
137 #define SOUND_MIXER_SYNTH 3
138 #define SOUND_MIXER_PCM 4
139 #define SOUND_MIXER_SPEAKER 5
140 #define SOUND_MIXER_LINE 6
141 #define SOUND_MIXER_MIC 7
142 #define SOUND_MIXER_CD 8
143 #define SOUND_MIXER_IMIX 9
144 #define SOUND_MIXER_ALTPCM 10
145 #define SOUND_MIXER_RECLEV 11
146 #define SOUND_MIXER_IGAIN 12
147 #define SOUND_MIXER_OGAIN 13
148 #define SOUND_MIXER_LINE1 14
149 #define SOUND_MIXER_LINE2 15
150 #define SOUND_MIXER_LINE3 16
151 #define SOUND_MIXER_DIGITAL1 17
152 #define SOUND_MIXER_DIGITAL2 18
153 #define SOUND_MIXER_DIGITAL3 19
154 #define SOUND_MIXER_PHONEIN 20
155 #define SOUND_MIXER_PHONEOUT 21
156 #define SOUND_MIXER_VIDEO 22
157 #define SOUND_MIXER_RADIO 23
158 #define SOUND_MIXER_MONITOR 24
160 #define SOUND_ONOFF_MIN 28
161 #define SOUND_ONOFF_MAX 30
163 #define SOUND_MIXER_NONE 31
165 #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
166 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
167 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
168 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
170 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
171 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
172 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
173 "phin", "phout", "video", "radio", "monitor"}
175 #define SOUND_MIXER_RECSRC 0xff
176 #define SOUND_MIXER_DEVMASK 0xfe
177 #define SOUND_MIXER_RECMASK 0xfd
178 #define SOUND_MIXER_CAPS 0xfc
179 #define SOUND_CAP_EXCL_INPUT 1
180 #define SOUND_MIXER_STEREODEVS 0xfb
182 #define MIXER_READ(dev) _IOR('M', dev, int)
184 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
185 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
186 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
187 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
188 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
190 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
191 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
192 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
193 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
194 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
195 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
196 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
197 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
198 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
199 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
200 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
201 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
202 #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
203 #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
204 #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
205 #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
206 #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
208 #define MIXER_WRITE(dev) _IOW ('M', dev, int)
209 #define MIXER_WRITE_R(dev) _IOWR('M', dev, int)
211 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
212 #define SOUND_MIXER_WRITE_R_RECSRC MIXER_WRITE_R(SOUND_MIXER_RECSRC)
214 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
215 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
216 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
217 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
218 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
219 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
220 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
221 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
222 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
223 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
224 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
225 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
226 #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
227 #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
228 #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
229 #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
230 #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
232 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
233 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
234 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
235 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
236 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
237 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
238 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
239 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
240 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
241 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
242 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
243 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
244 #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
245 #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
246 #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
247 #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
248 #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
249 #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
250 #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
251 #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
252 #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
253 #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
254 #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
255 #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
256 #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
258 typedef struct mixer_info
{
265 typedef struct _old_mixer_info
{
270 #define SOUND_MIXER_INFO _IOR('M', 101, mixer_info)
271 #define SOUND_OLD_MIXER_INFO _IOR('M', 101, _old_mixer_info)
273 #define OSS_GETVERSION _IOR ('M', 118, int)
275 typedef struct audio_buf_info
{
282 typedef struct count_info
{
288 typedef struct buffmem_desc
{
289 unsigned int *buffer
;
294 /* This is what we'd like to have, but it causes prototype conflicts. */
295 #define ioctl _oss_ioctl
298 * XXX force inclusion of <sys/ioctl.h> before we redefine
299 * ioctl() to avoid a prototype conflict.
300 * Its multiple inclusion protection will keep this from
301 * happening if it is pulled in later.
303 #include <sys/ioctl.h>
304 #define ioctl(x,y,z) _oss_ioctl(x,y,z)
307 #include <sys/cdefs.h>
310 int _oss_ioctl(int fd
, unsigned long com
, void *argp
);
313 #endif /* !_SOUNDCARD_H_ */