soundcard.h revision 1.34 1 /* $NetBSD: soundcard.h,v 1.34 2021/05/09 11:28:25 nia Exp $ */
2
3 /*-
4 * Copyright (c) 1997, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson and Nia Alarie.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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.
18 *
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.
30 */
31
32 /*
33 * WARNING! WARNING!
34 * This is an Open Sound System compatibility layer.
35 * Use the Native NetBSD API in <sys/audioio.h> for developing new code,
36 * and this only for compiling programs written for other operating systems.
37 */
38
39 #ifndef _SOUNDCARD_H_
40 #define _SOUNDCARD_H_
41
42 #ifndef SOUND_VERSION
43 #define SOUND_VERSION 0x030001
44 #endif
45
46 #define SNDCTL_DSP_RESET _IO ('P', 0)
47 #define SNDCTL_DSP_SYNC _IO ('P', 1)
48 #define SNDCTL_DSP_SPEED _IOWR('P', 2, int)
49 #define SOUND_PCM_READ_RATE _IOR ('P', 2, int)
50 #define SNDCTL_DSP_STEREO _IOWR('P', 3, int)
51 #define SNDCTL_DSP_GETBLKSIZE _IOWR('P', 4, int)
52 #define SNDCTL_DSP_SETFMT _IOWR('P', 5, int)
53 #define AFMT_QUERY 0x00000000
54 #define AFMT_MU_LAW 0x00000001
55 #define AFMT_A_LAW 0x00000002
56 #define AFMT_IMA_ADPCM 0x00000004
57 #define AFMT_U8 0x00000008
58 #define AFMT_S16_LE 0x00000010
59 #define AFMT_S16_BE 0x00000020
60 #define AFMT_S8 0x00000040
61 #define AFMT_U16_LE 0x00000080
62 #define AFMT_U16_BE 0x00000100
63 #define AFMT_MPEG 0x00000200 /* Not supported */
64 #define AFMT_AC3 0x00000400
65 #define AFMT_S24_LE 0x00000800 /* Not supported */
66 #define AFMT_S24_BE 0x00001000 /* Not supported */
67 #define AFMT_S32_LE 0x00002000
68 #define AFMT_S32_BE 0x00004000
69 #define AFMT_FLOAT 0x00010000 /* Not supported */
70 #define AFMT_SPDIF_RAW 0x00020000 /* Not supported */
71 #define AFMT_S24_PACKED 0x00040000 /* Not supported */
72 #define AFMT_VORBIS 0x00080000 /* Not supported */
73 #define SNDCTL_DSP_SAMPLESIZE SNDCTL_DSP_SETFMT
74 #define SOUND_PCM_READ_BITS _IOR ('P', 5, int)
75 #define SNDCTL_DSP_CHANNELS _IOWR('P', 6, int)
76 #define SOUND_PCM_WRITE_CHANNELS SNDCTL_DSP_CHANNELS
77 #define SOUND_PCM_READ_CHANNELS _IOR ('P', 6, int)
78 #define SOUND_PCM_WRITE_FILTER _IOWR('P', 7, int)
79 #define SOUND_PCM_READ_FILTER _IOR ('P', 7, int)
80 #define SNDCTL_DSP_POST _IO ('P', 8)
81 #define SNDCTL_DSP_SUBDIVIDE _IOWR('P', 9, int)
82 #define SNDCTL_DSP_SETFRAGMENT _IOWR('P', 10, int)
83 #define SNDCTL_DSP_GETFMTS _IOR ('P', 11, int)
84 #define SNDCTL_DSP_GETOSPACE _IOR ('P',12, struct audio_buf_info)
85 #define SNDCTL_DSP_GETISPACE _IOR ('P',13, struct audio_buf_info)
86 #define SNDCTL_DSP_NONBLOCK _IO ('P',14)
87 #define SNDCTL_DSP_GETCAPS _IOR ('P',15, int)
88 /* PCM_CAP_* were known as DSP_CAP_ before OSS 4.0 */
89 # define DSP_CAP_REVISION PCM_CAP_REVISION
90 # define DSP_CAP_DUPLEX PCM_CAP_DUPLEX
91 # define DSP_CAP_REALTIME PCM_CAP_REALTIME
92 # define DSP_CAP_BATCH PCM_CAP_BATCH
93 # define DSP_CAP_COPROC PCM_CAP_COPROC
94 # define DSP_CAP_TRIGGER PCM_CAP_TRIGGER
95 # define DSP_CAP_MMAP PCM_CAP_MMAP
96 # define DSP_CAP_INPUT PCM_CAP_INPUT
97 # define DSP_CAP_OUTPUT PCM_CAP_OUTPUT
98 # define DSP_CAP_MODEM PCM_CAP_MODEM
99 # define DSP_CAP_HIDDEN PCM_CAP_HIDDEN
100 # define DSP_CAP_VIRTUAL PCM_CAP_VIRTUAL
101 # define DSP_CAP_ANALOGOUT PCM_CAP_ANALOGOUT
102 # define DSP_CAP_ANALOGIN PCM_CAP_ANALOGIN
103 # define DSP_CAP_DIGITALOUT PCM_CAP_DIGITALOUT
104 # define DSP_CAP_DIGITALIN PCM_CAP_DIGITALIN
105 # define DSP_CAP_ADMASK PCM_CAP_ADMASK
106 # define DSP_CAP_FREERATE PCM_CAP_FREERATE
107 # define DSP_CAP_MULTI PCM_CAP_MULTI
108 # define DSP_CAP_BIND PCM_CAP_BIND
109 # define DSP_CAP_SHADOW PCM_CAP_SHADOW
110 # define PCM_CAP_REVISION 0x000000ff /* Unused in NetBSD */
111 # define PCM_CAP_DUPLEX 0x00000100 /* Full duplex */
112 # define PCM_CAP_REALTIME 0x00000200 /* Unused in NetBSD */
113 # define PCM_CAP_BATCH 0x00000400 /* Unused in NetBSD */
114 # define PCM_CAP_COPROC 0x00000800 /* Unused in NetBSD */
115 # define PCM_CAP_TRIGGER 0x00001000 /* Supports SETTRIGGER */
116 # define PCM_CAP_MMAP 0x00002000 /* Supports mmap() */
117 # define PCM_CAP_INPUT 0x00004000 /* Recording device */
118 # define PCM_CAP_OUTPUT 0x00008000 /* Playback device */
119 # define PCM_CAP_MODEM 0x00010000 /* Unused in NetBSD */
120 # define PCM_CAP_HIDDEN 0x00020000 /* Unused in NetBSD */
121 # define PCM_CAP_VIRTUAL 0x00040000 /* Unused in NetBSD */
122 # define PCM_CAP_MULTI 0x00080000 /* Simultaneous open() */
123 # define PCM_CAP_ANALOGOUT 0x00100000 /* Unused in NetBSD */
124 # define PCM_CAP_ANALOGIN 0x00200000 /* Unused in NetBSD */
125 # define PCM_CAP_DIGITALOUT 0x00400000 /* Unused in NetBSD */
126 # define PCM_CAP_DIGITALIN 0x00800000 /* Unused in NetBSD */
127 # define PCM_CAP_ADMASK 0x00f00000 /* Unused in NetBSD */
128 # define PCM_CAP_SPECIAL 0x01000000 /* Unused in NetBSD */
129 # define PCM_CAP_FREERATE 0x10000000 /* Freely set rate */
130 # define PCM_CAP_SHADOW 0x40000000 /* Unused in NetBSD */
131 # define PCM_CAP_BIND 0x80000000 /* Unused in NetBSD */
132 # define DSP_CH_ANY 0x00000000 /* No preferred mode */
133 # define DSP_CH_MONO 0x02000000
134 # define DSP_CH_STEREO 0x04000000
135 # define DSP_CH_MULTI 0x06000000
136 # define DSP_CH_MASK 0x06000000
137 #define SNDCTL_DSP_GETTRIGGER _IOR ('P', 16, int)
138 #define SNDCTL_DSP_SETTRIGGER _IOW ('P', 16, int)
139 # define PCM_ENABLE_INPUT 0x00000001
140 # define PCM_ENABLE_OUTPUT 0x00000002
141 #define SNDCTL_DSP_GETIPTR _IOR ('P', 17, struct count_info)
142 #define SNDCTL_DSP_GETOPTR _IOR ('P', 18, struct count_info)
143 #define SNDCTL_DSP_MAPINBUF _IOR ('P', 19, struct buffmem_desc)
144 #define SNDCTL_DSP_MAPOUTBUF _IOR ('P', 20, struct buffmem_desc)
145 #define SNDCTL_DSP_SETSYNCRO _IO ('P', 21)
146 #define SNDCTL_DSP_SETDUPLEX _IO ('P', 22)
147 #define SNDCTL_DSP_PROFILE _IOW ('P', 23, int)
148 #define SNDCTL_DSP_GETODELAY _IOR ('P', 23, int)
149 #define APF_NORMAL 0
150 #define APF_NETWORK 1
151 #define APF_CPUINTENS 2
152
153 /* Need native 16 bit format which depends on byte order */
154 #include <machine/endian_machdep.h>
155 #if _BYTE_ORDER == _LITTLE_ENDIAN
156 #define AFMT_U16_NE AFMT_U16_LE
157 #define AFMT_U16_OE AFMT_U16_BE
158 #define AFMT_S16_NE AFMT_S16_LE
159 #define AFMT_S16_OE AFMT_S16_BE
160 #define AFMT_S24_NE AFMT_S24_LE
161 #define AFMT_S24_OE AFMT_S24_BE
162 #define AFMT_S32_NE AFMT_S32_LE
163 #define AFMT_S32_OE AFMT_S32_BE
164 #else
165 #define AFMT_U16_NE AFMT_U16_BE
166 #define AFMT_U16_OE AFMT_U16_LE
167 #define AFMT_S16_NE AFMT_S16_BE
168 #define AFMT_S16_OE AFMT_S16_LE
169 #define AFMT_S24_NE AFMT_S24_BE
170 #define AFMT_S24_OE AFMT_S24_LE
171 #define AFMT_S32_NE AFMT_S32_BE
172 #define AFMT_S32_OE AFMT_S32_LE
173 #endif
174
175 /* Aliases */
176 #define SOUND_PCM_WRITE_BITS SNDCTL_DSP_SETFMT
177 #define SOUND_PCM_WRITE_RATE SNDCTL_DSP_SPEED
178 #define SOUND_PCM_POST SNDCTL_DSP_POST
179 #define SOUND_PCM_RESET SNDCTL_DSP_RESET
180 #define SOUND_PCM_SYNC SNDCTL_DSP_SYNC
181 #define SOUND_PCM_SUBDIVIDE SNDCTL_DSP_SUBDIVIDE
182 #define SOUND_PCM_SETFRAGMENT SNDCTL_DSP_SETFRAGMENT
183 #define SOUND_PCM_GETFMTS SNDCTL_DSP_GETFMTS
184 #define SOUND_PCM_SETFMT SNDCTL_DSP_SETFMT
185 #define SOUND_PCM_GETOSPACE SNDCTL_DSP_GETOSPACE
186 #define SOUND_PCM_GETISPACE SNDCTL_DSP_GETISPACE
187 #define SOUND_PCM_NONBLOCK SNDCTL_DSP_NONBLOCK
188 #define SOUND_PCM_GETCAPS SNDCTL_DSP_GETCAPS
189 #define SOUND_PCM_GETTRIGGER SNDCTL_DSP_GETTRIGGER
190 #define SOUND_PCM_SETTRIGGER SNDCTL_DSP_SETTRIGGER
191 #define SOUND_PCM_SETSYNCRO SNDCTL_DSP_SETSYNCRO
192 #define SOUND_PCM_GETIPTR SNDCTL_DSP_GETIPTR
193 #define SOUND_PCM_GETOPTR SNDCTL_DSP_GETOPTR
194 #define SOUND_PCM_MAPINBUF SNDCTL_DSP_MAPINBUF
195 #define SOUND_PCM_MAPOUTBUF SNDCTL_DSP_MAPOUTBUF
196
197 /* Mixer defines */
198 #define SOUND_MIXER_FIRST 0
199 #define SOUND_MIXER_NRDEVICES 25
200
201 #define SOUND_MIXER_VOLUME 0
202 #define SOUND_MIXER_BASS 1
203 #define SOUND_MIXER_TREBLE 2
204 #define SOUND_MIXER_SYNTH 3
205 #define SOUND_MIXER_PCM 4
206 #define SOUND_MIXER_SPEAKER 5
207 #define SOUND_MIXER_LINE 6
208 #define SOUND_MIXER_MIC 7
209 #define SOUND_MIXER_CD 8
210 #define SOUND_MIXER_IMIX 9
211 #define SOUND_MIXER_ALTPCM 10
212 #define SOUND_MIXER_RECLEV 11
213 #define SOUND_MIXER_IGAIN 12
214 #define SOUND_MIXER_OGAIN 13
215 #define SOUND_MIXER_LINE1 14
216 #define SOUND_MIXER_LINE2 15
217 #define SOUND_MIXER_LINE3 16
218 #define SOUND_MIXER_DIGITAL1 17
219 #define SOUND_MIXER_DIGITAL2 18
220 #define SOUND_MIXER_DIGITAL3 19
221 #define SOUND_MIXER_PHONEIN 20
222 #define SOUND_MIXER_PHONEOUT 21
223 #define SOUND_MIXER_VIDEO 22
224 #define SOUND_MIXER_RADIO 23
225 #define SOUND_MIXER_MONITOR 24
226
227 #define SOUND_ONOFF_MIN 28
228 #define SOUND_ONOFF_MAX 30
229
230 #define SOUND_MIXER_NONE 31
231
232 #define SOUND_DEVICE_LABELS {"Vol ", "Bass ", "Trebl", "Synth", "Pcm ", "Spkr ", "Line ", \
233 "Mic ", "CD ", "Mix ", "Pcm2 ", "Rec ", "IGain", "OGain", \
234 "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", \
235 "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor"}
236
237 #define SOUND_DEVICE_NAMES {"vol", "bass", "treble", "synth", "pcm", "speaker", "line", \
238 "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", \
239 "line1", "line2", "line3", "dig1", "dig2", "dig3", \
240 "phin", "phout", "video", "radio", "monitor"}
241
242 #define SOUND_MIXER_RECSRC 0xff
243 #define SOUND_MIXER_DEVMASK 0xfe
244 #define SOUND_MIXER_RECMASK 0xfd
245 #define SOUND_MIXER_CAPS 0xfc
246 #define SOUND_CAP_EXCL_INPUT 1
247 #define SOUND_MIXER_STEREODEVS 0xfb
248
249 #define MIXER_READ(dev) _IOR('M', dev, int)
250
251 #define SOUND_MIXER_READ_RECSRC MIXER_READ(SOUND_MIXER_RECSRC)
252 #define SOUND_MIXER_READ_DEVMASK MIXER_READ(SOUND_MIXER_DEVMASK)
253 #define SOUND_MIXER_READ_RECMASK MIXER_READ(SOUND_MIXER_RECMASK)
254 #define SOUND_MIXER_READ_STEREODEVS MIXER_READ(SOUND_MIXER_STEREODEVS)
255 #define SOUND_MIXER_READ_CAPS MIXER_READ(SOUND_MIXER_CAPS)
256
257 #define SOUND_MIXER_READ_VOLUME MIXER_READ(SOUND_MIXER_VOLUME)
258 #define SOUND_MIXER_READ_BASS MIXER_READ(SOUND_MIXER_BASS)
259 #define SOUND_MIXER_READ_TREBLE MIXER_READ(SOUND_MIXER_TREBLE)
260 #define SOUND_MIXER_READ_SYNTH MIXER_READ(SOUND_MIXER_SYNTH)
261 #define SOUND_MIXER_READ_PCM MIXER_READ(SOUND_MIXER_PCM)
262 #define SOUND_MIXER_READ_SPEAKER MIXER_READ(SOUND_MIXER_SPEAKER)
263 #define SOUND_MIXER_READ_LINE MIXER_READ(SOUND_MIXER_LINE)
264 #define SOUND_MIXER_READ_MIC MIXER_READ(SOUND_MIXER_MIC)
265 #define SOUND_MIXER_READ_CD MIXER_READ(SOUND_MIXER_CD)
266 #define SOUND_MIXER_READ_IMIX MIXER_READ(SOUND_MIXER_IMIX)
267 #define SOUND_MIXER_READ_ALTPCM MIXER_READ(SOUND_MIXER_ALTPCM)
268 #define SOUND_MIXER_READ_RECLEV MIXER_READ(SOUND_MIXER_RECLEV)
269 #define SOUND_MIXER_READ_IGAIN MIXER_READ(SOUND_MIXER_IGAIN)
270 #define SOUND_MIXER_READ_OGAIN MIXER_READ(SOUND_MIXER_OGAIN)
271 #define SOUND_MIXER_READ_LINE1 MIXER_READ(SOUND_MIXER_LINE1)
272 #define SOUND_MIXER_READ_LINE2 MIXER_READ(SOUND_MIXER_LINE2)
273 #define SOUND_MIXER_READ_LINE3 MIXER_READ(SOUND_MIXER_LINE3)
274
275 #define MIXER_WRITE(dev) _IOW ('M', dev, int)
276 #define MIXER_WRITE_R(dev) _IOWR('M', dev, int)
277
278 #define SOUND_MIXER_WRITE_RECSRC MIXER_WRITE(SOUND_MIXER_RECSRC)
279 #define SOUND_MIXER_WRITE_R_RECSRC MIXER_WRITE_R(SOUND_MIXER_RECSRC)
280
281 #define SOUND_MIXER_WRITE_VOLUME MIXER_WRITE(SOUND_MIXER_VOLUME)
282 #define SOUND_MIXER_WRITE_BASS MIXER_WRITE(SOUND_MIXER_BASS)
283 #define SOUND_MIXER_WRITE_TREBLE MIXER_WRITE(SOUND_MIXER_TREBLE)
284 #define SOUND_MIXER_WRITE_SYNTH MIXER_WRITE(SOUND_MIXER_SYNTH)
285 #define SOUND_MIXER_WRITE_PCM MIXER_WRITE(SOUND_MIXER_PCM)
286 #define SOUND_MIXER_WRITE_SPEAKER MIXER_WRITE(SOUND_MIXER_SPEAKER)
287 #define SOUND_MIXER_WRITE_LINE MIXER_WRITE(SOUND_MIXER_LINE)
288 #define SOUND_MIXER_WRITE_MIC MIXER_WRITE(SOUND_MIXER_MIC)
289 #define SOUND_MIXER_WRITE_CD MIXER_WRITE(SOUND_MIXER_CD)
290 #define SOUND_MIXER_WRITE_IMIX MIXER_WRITE(SOUND_MIXER_IMIX)
291 #define SOUND_MIXER_WRITE_ALTPCM MIXER_WRITE(SOUND_MIXER_ALTPCM)
292 #define SOUND_MIXER_WRITE_RECLEV MIXER_WRITE(SOUND_MIXER_RECLEV)
293 #define SOUND_MIXER_WRITE_IGAIN MIXER_WRITE(SOUND_MIXER_IGAIN)
294 #define SOUND_MIXER_WRITE_OGAIN MIXER_WRITE(SOUND_MIXER_OGAIN)
295 #define SOUND_MIXER_WRITE_LINE1 MIXER_WRITE(SOUND_MIXER_LINE1)
296 #define SOUND_MIXER_WRITE_LINE2 MIXER_WRITE(SOUND_MIXER_LINE2)
297 #define SOUND_MIXER_WRITE_LINE3 MIXER_WRITE(SOUND_MIXER_LINE3)
298
299 #define SOUND_MASK_VOLUME (1 << SOUND_MIXER_VOLUME)
300 #define SOUND_MASK_BASS (1 << SOUND_MIXER_BASS)
301 #define SOUND_MASK_TREBLE (1 << SOUND_MIXER_TREBLE)
302 #define SOUND_MASK_SYNTH (1 << SOUND_MIXER_SYNTH)
303 #define SOUND_MASK_PCM (1 << SOUND_MIXER_PCM)
304 #define SOUND_MASK_SPEAKER (1 << SOUND_MIXER_SPEAKER)
305 #define SOUND_MASK_LINE (1 << SOUND_MIXER_LINE)
306 #define SOUND_MASK_MIC (1 << SOUND_MIXER_MIC)
307 #define SOUND_MASK_CD (1 << SOUND_MIXER_CD)
308 #define SOUND_MASK_IMIX (1 << SOUND_MIXER_IMIX)
309 #define SOUND_MASK_ALTPCM (1 << SOUND_MIXER_ALTPCM)
310 #define SOUND_MASK_RECLEV (1 << SOUND_MIXER_RECLEV)
311 #define SOUND_MASK_IGAIN (1 << SOUND_MIXER_IGAIN)
312 #define SOUND_MASK_OGAIN (1 << SOUND_MIXER_OGAIN)
313 #define SOUND_MASK_LINE1 (1 << SOUND_MIXER_LINE1)
314 #define SOUND_MASK_LINE2 (1 << SOUND_MIXER_LINE2)
315 #define SOUND_MASK_LINE3 (1 << SOUND_MIXER_LINE3)
316 #define SOUND_MASK_DIGITAL1 (1 << SOUND_MIXER_DIGITAL1)
317 #define SOUND_MASK_DIGITAL2 (1 << SOUND_MIXER_DIGITAL2)
318 #define SOUND_MASK_DIGITAL3 (1 << SOUND_MIXER_DIGITAL3)
319 #define SOUND_MASK_PHONEIN (1 << SOUND_MIXER_PHONEIN)
320 #define SOUND_MASK_PHONEOUT (1 << SOUND_MIXER_PHONEOUT)
321 #define SOUND_MASK_VIDEO (1 << SOUND_MIXER_VIDEO)
322 #define SOUND_MASK_RADIO (1 << SOUND_MIXER_RADIO)
323 #define SOUND_MASK_MONITOR (1 << SOUND_MIXER_MONITOR)
324
325 typedef struct mixer_info {
326 char id[16];
327 char name[32];
328 int modify_counter;
329 int fillers[10];
330 } mixer_info;
331
332 typedef struct _old_mixer_info {
333 char id[16];
334 char name[32];
335 } _old_mixer_info;
336
337 #define SOUND_MIXER_INFO _IOR('M', 101, mixer_info)
338 #define SOUND_OLD_MIXER_INFO _IOR('M', 101, _old_mixer_info)
339
340 #define OSS_GETVERSION _IOR ('M', 118, int)
341
342 typedef struct audio_buf_info {
343 int fragments;
344 int fragstotal;
345 int fragsize;
346 int bytes;
347 } audio_buf_info;
348
349 typedef struct count_info {
350 int bytes;
351 int blocks;
352 int ptr;
353 } count_info;
354
355 typedef struct buffmem_desc {
356 unsigned int *buffer;
357 int size;
358 } buffmem_desc;
359
360 /* Some OSSv4 calls. */
361
362 /* Why is yet more duplication necessary? Sigh. */
363 #define OSS_OPEN_READ PCM_ENABLE_INPUT
364 #define OSS_OPEN_WRITE PCM_ENABLE_OUTPUT
365 #define OSS_OPEN_READWRITE (OSS_OPEN_READ|OSS_OPEN_WRITE)
366
367 #define OSS_DEVNODE_SIZE 32
368 #define OSS_LABEL_SIZE 16
369 #define OSS_LONGNAME_SIZE 64
370 #define OSS_MAX_AUDIO_DEVS 64
371
372 #define SNDCTL_DSP_GETPLAYVOL _IOR ('P',27, uint)
373 #define SNDCTL_DSP_SETPLAYVOL _IOW ('P',28, uint)
374 #define SNDCTL_DSP_GETRECVOL _IOR ('P',29, uint)
375 #define SNDCTL_DSP_SETRECVOL _IOW ('P',30, uint)
376 #define SNDCTL_DSP_SKIP _IO ('P',31)
377 #define SNDCTL_DSP_SILENCE _IO ('P',32)
378 #define SNDCTL_DSP_COOKEDMODE _IOW ('P',33, int)
379 #define SNDCTL_DSP_GETERROR _IOR ('P',34, struct audio_errinfo)
380 #define SNDCTL_DSP_CURRENT_IPTR _IOR ('P',35, oss_count_t)
381 #define SNDCTL_DSP_CURRENT_OPTR _IOR ('P',36, oss_count_t)
382 #define SNDCTL_DSP_GET_RECSRC_NAMES _IOR ('P',37, oss_mixer_enuminfo)
383 #define SNDCTL_DSP_GET_RECSRC _IOR ('P',38, int)
384 #define SNDCTL_DSP_SET_RECSRC _IOWR ('P',38, int)
385 #define SNDCTL_DSP_GET_PLAYTGT_NAMES _IOR ('P',39, oss_mixer_enuminfo)
386 #define SNDCTL_DSP_GET_PLAYTGT _IOR ('P',40, int)
387 #define SNDCTL_DSP_SET_PLAYTGT _IOWR ('P',40, int)
388
389 #define SNDCTL_DSP_GET_CHNORDER _IOR ('P',42, unsigned long long)
390 #define SNDCTL_DSP_SET_CHNORDER _IOWR ('P',42, unsigned long long)
391
392 #define SNDCTL_DSP_HALT_OUTPUT _IO ('P',70)
393 #define SNDCTL_DSP_RESET_OUTPUT SNDCTL_DSP_HALT_OUTPUT /* Old name */
394 #define SNDCTL_DSP_HALT_INPUT _IO ('P',71)
395 #define SNDCTL_DSP_RESET_INPUT SNDCTL_DSP_HALT_INPUT /* Old name */
396
397 #define CHID_UNDEF 0
398 #define CHID_L 1
399 #define CHID_R 2
400 #define CHID_C 3
401 #define CHID_LFE 4
402 #define CHID_LS 5
403 #define CHID_RS 6
404 #define CHID_LR 7
405 #define CHID_RR 8
406 #define CHNORDER_UNDEF 0x0000000000000000ULL
407 #define CHNORDER_NORMAL 0x0000000087654321ULL
408
409 typedef struct {
410 long long samples;
411 int fifo_samples;
412 int filler[32]; /* "Future use" */
413 } oss_count_t;
414
415 typedef struct audio_errinfo {
416 int play_underruns;
417 int rec_overruns;
418 unsigned int play_ptradjust; /* Obsolete */
419 unsigned int rec_ptradjust; /* Obsolete */
420 int play_errorcount; /* Unused */
421 int rec_errorcount; /* Unused */
422 int play_lasterror; /* Unused */
423 int rec_lasterror; /* Unused */
424 int play_errorparm; /* Unused */
425 int rec_errorparm; /* Unused */
426 int filler[16]; /* Unused */
427 } audio_errinfo;
428
429 typedef struct oss_sysinfo {
430 char product[32];
431 char version[32];
432 int versionnum;
433 char options[128]; /* Future use */
434 int numaudios;
435 int openedaudio[8]; /* Obsolete */
436 int numsynths; /* Obsolete */
437 int nummidis;
438 int numtimers;
439 int nummixers;
440 int openedmidi[8];
441 int numcards;
442 int numaudioengines;
443 char license[16];
444 char revision_info[256]; /* Internal Use */
445 int filler[172]; /* For expansion */
446 } oss_sysinfo;
447
448 typedef struct oss_audioinfo {
449 int dev; /* Set by caller */
450 char name[OSS_LONGNAME_SIZE];
451 int busy;
452 int pid;
453 int caps;
454 int iformats;
455 int oformats;
456 int magic; /* Unused */
457 char cmd[OSS_LONGNAME_SIZE];
458 int card_number;
459 int port_number;
460 int mixer_dev;
461 int legacy_device; /* Obsolete */
462 int enabled;
463 int flags; /* Reserved */
464 int min_rate;
465 int max_rate;
466 int min_channels;
467 int max_channels;
468 int binding; /* Reserved */
469 int rate_source;
470 char handle[32];
471 #define OSS_MAX_SAMPLE_RATES 20
472 int nrates;
473 int rates[OSS_MAX_SAMPLE_RATES];
474 char song_name[OSS_LONGNAME_SIZE];
475 char label[OSS_LABEL_SIZE];
476 int latency; /* In usecs -1 = unknown */
477 char devnode[OSS_DEVNODE_SIZE];
478 int next_play_engine;
479 int next_rec_engine;
480 int filler[184]; /* For expansion */
481 } oss_audioinfo;
482
483 typedef struct oss_card_info {
484 int card;
485 char shortname[16];
486 char longname[128];
487 int flags;
488 char hw_info[400];
489 int intr_count;
490 int ack_count;
491 int filler[154];
492 } oss_card_info;
493
494 #define SNDCTL_SYSINFO _IOR ('X', 1, oss_sysinfo)
495 #define OSS_SYSINFO SNDCTL_SYSINFO /* Old name */
496 #define SNDCTL_MIX_NRMIX _IOR ('X',2, int)
497 #define SNDCTL_MIX_NREXT _IOWR ('X',3, int)
498 #define SNDCTL_MIX_EXTINFO _IOWR ('X',4, oss_mixext)
499 #define SNDCTL_MIX_READ _IOWR ('X',5, oss_mixer_value)
500 #define SNDCTL_MIX_WRITE _IOWR ('X',6, oss_mixer_value)
501 #define SNDCTL_AUDIOINFO _IOWR ('X',7, oss_audioinfo)
502 #define SNDCTL_MIX_ENUMINFO _IOWR ('X',8, oss_mixer_enuminfo)
503 #define SNDCTL_MIXERINFO _IOWR ('X',10, oss_mixerinfo)
504 #define SNDCTL_CARDINFO _IOWR ('X',11, oss_card_info)
505 #define SNDCTL_ENGINEINFO _IOWR ('X',12, oss_audioinfo)
506 #define SNDCTL_AUDIOINFO_EX _IOWR ('X',13, oss_audioinfo)
507 #define SNDCTL_MIX_DESCRIPTION _IOWR ('X',14, oss_mixer_enuminfo)
508
509 #define MIXT_DEVROOT 0 /* Used for default classes */
510 #define MIXT_GROUP 1 /* Used for classes */
511 #define MIXT_ONOFF 2 /* Used for mute controls */
512 #define MIXT_ENUM 3 /* Used for enum controls */
513 #define MIXT_MONOSLIDER 4 /* Used for mono and surround controls */
514 #define MIXT_STEREOSLIDER 5 /* Used for stereo controls */
515 #define MIXT_MESSAGE 6 /* OSS compat, unused on NetBSD */
516 #define MIXT_MONOVU 7 /* OSS compat, unused on NetBSD */
517 #define MIXT_STEREOVU 8 /* OSS compat, unused on NetBSD */
518 #define MIXT_MONOPEAK 9 /* OSS compat, unused on NetBSD */
519 #define MIXT_STEREOPEAK 10 /* OSS compat, unused on NetBSD */
520 #define MIXT_RADIOGROUP 11 /* OSS compat, unused on NetBSD */
521 #define MIXT_MARKER 12 /* OSS compat, unused on NetBSD */
522 #define MIXT_VALUE 13 /* OSS compat, unused on NetBSD */
523 #define MIXT_HEXVALUE 14 /* OSS compat, unused on NetBSD */
524 #define MIXT_MONODB 15 /* OSS compat, unused on NetBSD */
525 #define MIXT_STEREODB 16 /* OSS compat, unused on NetBSD */
526 #define MIXT_SLIDER 17 /* OSS compat, unused on NetBSD */
527 #define MIXT_3D 18 /* OSS compat, unused on NetBSD */
528 #define MIXT_MONOSLIDER16 19 /* OSS compat, unused on NetBSD */
529 #define MIXT_STEREOSLIDER16 20 /* OSS compat, unused on NetBSD */
530 #define MIXT_MUTE 21 /* OSS compat, unused on NetBSD */
531 /*
532 * Should be used for Set controls.
533 * In practice nothing uses this because it's "reserved for Sun's
534 * implementation".
535 */
536 #define MIXT_ENUM_MULTI 22
537
538 #define MIXF_READABLE 0x00000001 /* Value is readable: always true */
539 #define MIXF_WRITEABLE 0x00000002 /* Value is writable: always true */
540 #define MIXF_POLL 0x00000004 /* Can change between reads: always true */
541 #define MIXF_HZ 0x00000008 /* OSS compat, unused on NetBSD */
542 #define MIXF_STRING 0x00000010 /* OSS compat, unused on NetBSD */
543 #define MIXF_DYNAMIC 0x00000010 /* OSS compat, unused on NetBSD */
544 #define MIXF_OKFAIL 0x00000020 /* OSS compat, unused on NetBSD */
545 #define MIXF_FLAT 0x00000040 /* OSS compat, unused on NetBSD */
546 #define MIXF_LEGACY 0x00000080 /* OSS compat, unused on NetBSD */
547 #define MIXF_CENTIBEL 0x00000100 /* OSS compat, unused on NetBSD */
548 #define MIXF_DECIBEL 0x00000200 /* OSS compat, unused on NetBSD */
549 #define MIXF_MAINVOL 0x00000400 /* OSS compat, unused on NetBSD */
550 #define MIXF_PCMVOL 0x00000800 /* OSS compat, unused on NetBSD */
551 #define MIXF_RECVOL 0x00001000 /* OSS compat, unused on NetBSD */
552 #define MIXF_MONVOL 0x00002000 /* OSS compat, unused on NetBSD */
553 #define MIXF_WIDE 0x00004000 /* OSS compat, unused on NetBSD */
554 #define MIXF_DESCR 0x00008000 /* OSS compat, unused on NetBSD */
555 #define MIXF_DISABLED 0x00010000 /* OSS compat, unused on NetBSD */
556
557 /* None of the mixer capabilities are set on NetBSD. */
558 #define MIXER_CAP_VIRTUAL 0x00000001 /* Virtual device */
559 #define MIXER_CAP_LAYOUT_B 0x00000002 /* "Internal use only" */
560 #define MIXER_CAP_NARROW 0x00000004 /* "Conserve screen space" */
561
562 #define OSS_ID_SIZE 16
563 typedef char oss_id_t[OSS_ID_SIZE];
564 #define OSS_DEVNODE_SIZE 32
565 typedef char oss_devnode_t[OSS_DEVNODE_SIZE];
566 #define OSS_HANDLE_SIZE 32
567 typedef char oss_handle_t[OSS_HANDLE_SIZE];
568 #define OSS_LONGNAME_SIZE 64
569 typedef char oss_longname_t[OSS_LONGNAME_SIZE];
570 #define OSS_LABEL_SIZE 16
571 typedef char oss_label_t[OSS_LABEL_SIZE];
572
573 typedef struct oss_mixext_root {
574 oss_id_t id;
575 char name[48];
576 } oss_mixext_root;
577
578 typedef struct oss_mixerinfo {
579 int dev;
580 oss_id_t id;
581 char name[32];
582 int modify_counter;
583 int card_number;
584 int port_number;
585 oss_handle_t handle;
586 int magic; /* "Reserved for internal use" */
587 int enabled;
588 int caps;
589 int flags; /* "Reserved for internal use" */
590 int nrext;
591 int priority;
592 oss_devnode_t devnode;
593 int legacy_device;
594 int filler[245];
595 } oss_mixerinfo;
596
597 typedef struct oss_mixer_value {
598 int dev; /* Set by caller */
599 int ctrl; /* Set by caller */
600 int value;
601 int flags; /* Reserved for "future use" */
602 int timestamp;
603 int filler[8]; /* Reserved for "future use" */
604 } oss_mixer_value;
605
606 #define OSS_ENUM_MAXVALUE 255
607 #define OSS_ENUM_STRINGSIZE 3000
608
609 typedef struct oss_mixer_enuminfo {
610 int dev; /* Set by caller */
611 int ctrl; /* Set by caller */
612 int nvalues;
613 int version;
614 short strindex[OSS_ENUM_MAXVALUE];
615 char strings[OSS_ENUM_STRINGSIZE];
616 } oss_mixer_enuminfo;
617
618 typedef struct oss_mixext {
619 int dev;
620 int ctrl;
621 int type;
622 int maxvalue;
623 int minvalue;
624 int flags;
625 oss_id_t id;
626 int parent;
627 int dummy;
628 int timestamp;
629 char data[64];
630 unsigned char enum_present[32];
631 int control_no;
632 unsigned int desc;
633 char extname[32];
634 int update_counter;
635 int rgbcolor;
636 int filler[6];
637 } oss_mixext;
638
639
640 /*
641 * These are no-ops on FreeBSD, NetBSD, and Solaris,
642 * but are defined for compatibility with OSSv4.
643 */
644 #define SNDCTL_SETSONG _IOW ('Y',2, oss_longname_t)
645 #define SNDCTL_GETSONG _IOR ('Y',2, oss_longname_t)
646 #define SNDCTL_SETNAME _IOW ('Y',3, oss_longname_t)
647 #define SNDCTL_SETLABEL _IOW ('Y',4, oss_label_t)
648 #define SNDCTL_GETLABEL _IOR ('Y',4, oss_label_t)
649
650 #define ioctl _oss_ioctl
651 /*
652 * If we already included <sys/ioctl.h>, then we define our own prototype,
653 * else we depend on <sys/ioctl.h> to do it for us. We do it this way, so
654 * that we don't define the prototype twice.
655 */
656 #ifndef _SYS_IOCTL_H_
657 #include <sys/ioctl.h>
658 #else
659 __BEGIN_DECLS
660 int _oss_ioctl(int, unsigned long, ...);
661 __END_DECLS
662 #endif
663
664 #endif /* !_SOUNDCARD_H_ */
665