root / lab4 / .minix-src / include / sys / audioio.h @ 13
History | View | Annotate | Download (10.4 KB)
1 |
/* $NetBSD: audioio.h,v 1.34 2011/09/06 01:16:43 jmcneill Exp $ */
|
---|---|
2 |
|
3 |
/*
|
4 |
* Copyright (c) 1991-1993 Regents of the University of California.
|
5 |
* All rights reserved.
|
6 |
*
|
7 |
* Redistribution and use in source and binary forms, with or without
|
8 |
* modification, are permitted provided that the following conditions
|
9 |
* are met:
|
10 |
* 1. Redistributions of source code must retain the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer.
|
12 |
* 2. Redistributions in binary form must reproduce the above copyright
|
13 |
* notice, this list of conditions and the following disclaimer in the
|
14 |
* documentation and/or other materials provided with the distribution.
|
15 |
* 3. All advertising materials mentioning features or use of this software
|
16 |
* must display the following acknowledgement:
|
17 |
* This product includes software developed by the Computer Systems
|
18 |
* Engineering Group at Lawrence Berkeley Laboratory.
|
19 |
* 4. Neither the name of the University nor of the Laboratory may be used
|
20 |
* to endorse or promote products derived from this software without
|
21 |
* specific prior written permission.
|
22 |
*
|
23 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
24 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
27 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
29 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
30 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
31 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
32 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
33 |
* SUCH DAMAGE.
|
34 |
*
|
35 |
*/
|
36 |
|
37 |
#ifndef _SYS_AUDIOIO_H_
|
38 |
#define _SYS_AUDIOIO_H_
|
39 |
|
40 |
#include <sys/types.h> |
41 |
#include <sys/ioccom.h> |
42 |
|
43 |
#ifndef _KERNEL
|
44 |
#include <string.h> /* Required for memset(3) prototype (AUDIO_INITINFO) */ |
45 |
#endif /* _KERNEL */ |
46 |
|
47 |
/*
|
48 |
* Audio device
|
49 |
*/
|
50 |
struct audio_prinfo {
|
51 |
u_int sample_rate; /* sample rate in bit/s */
|
52 |
u_int channels; /* number of channels, usually 1 or 2 */
|
53 |
u_int precision; /* number of bits/sample */
|
54 |
u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */
|
55 |
u_int gain; /* volume level */
|
56 |
u_int port; /* selected I/O port */
|
57 |
u_int seek; /* BSD extension */
|
58 |
u_int avail_ports; /* available I/O ports */
|
59 |
u_int buffer_size; /* total size audio buffer */
|
60 |
u_int _ispare[1];
|
61 |
/* Current state of device: */
|
62 |
u_int samples; /* number of samples */
|
63 |
u_int eof; /* End Of File (zero-size writes) counter */
|
64 |
u_char pause; /* non-zero if paused, zero to resume */
|
65 |
u_char error; /* non-zero if underflow/overflow ocurred */
|
66 |
u_char waiting; /* non-zero if another process hangs in open */
|
67 |
u_char balance; /* stereo channel balance */
|
68 |
u_char cspare[2];
|
69 |
u_char open; /* non-zero if currently open */
|
70 |
u_char active; /* non-zero if I/O is currently active */
|
71 |
}; |
72 |
typedef struct audio_prinfo audio_prinfo_t; |
73 |
|
74 |
struct audio_info {
|
75 |
struct audio_prinfo play; /* Info for play (output) side */ |
76 |
struct audio_prinfo record; /* Info for record (input) side */ |
77 |
|
78 |
u_int monitor_gain; /* input to output mix */
|
79 |
/* BSD extensions */
|
80 |
u_int blocksize; /* H/W read/write block size */
|
81 |
u_int hiwat; /* output high water mark */
|
82 |
u_int lowat; /* output low water mark */
|
83 |
u_int _ispare1; |
84 |
u_int mode; /* current device mode */
|
85 |
#define AUMODE_PLAY 0x01 |
86 |
#define AUMODE_RECORD 0x02 |
87 |
#define AUMODE_PLAY_ALL 0x04 /* don't do real-time correction */ |
88 |
}; |
89 |
typedef struct audio_info audio_info_t; |
90 |
|
91 |
#define AUDIO_INITINFO(p) \
|
92 |
(void)memset((void *)(p), 0xff, sizeof(struct audio_info)) |
93 |
|
94 |
/*
|
95 |
* Parameter for the AUDIO_GETDEV ioctl to determine current
|
96 |
* audio devices.
|
97 |
*/
|
98 |
#define MAX_AUDIO_DEV_LEN 16 |
99 |
typedef struct audio_device { |
100 |
char name[MAX_AUDIO_DEV_LEN];
|
101 |
char version[MAX_AUDIO_DEV_LEN];
|
102 |
char config[MAX_AUDIO_DEV_LEN];
|
103 |
} audio_device_t; |
104 |
|
105 |
typedef struct audio_offset { |
106 |
u_int samples; /* Total number of bytes transferred */
|
107 |
u_int deltablks; /* Blocks transferred since last checked */
|
108 |
u_int offset; /* Physical transfer offset in buffer */
|
109 |
} audio_offset_t; |
110 |
|
111 |
/*
|
112 |
* Supported audio encodings
|
113 |
*/
|
114 |
/* Encoding ID's */
|
115 |
#define AUDIO_ENCODING_NONE 0 /* no encoding assigned */ |
116 |
#define AUDIO_ENCODING_ULAW 1 /* ITU G.711 mu-law */ |
117 |
#define AUDIO_ENCODING_ALAW 2 /* ITU G.711 A-law */ |
118 |
#define AUDIO_ENCODING_PCM16 3 /* signed linear PCM, obsolete */ |
119 |
#define AUDIO_ENCODING_LINEAR AUDIO_ENCODING_PCM16 /* SunOS compat */ |
120 |
#define AUDIO_ENCODING_PCM8 4 /* unsigned linear PCM, obsolete */ |
121 |
#define AUDIO_ENCODING_LINEAR8 AUDIO_ENCODING_PCM8 /* SunOS compat */ |
122 |
#define AUDIO_ENCODING_ADPCM 5 /* adaptive differential PCM */ |
123 |
#define AUDIO_ENCODING_SLINEAR_LE 6 |
124 |
#define AUDIO_ENCODING_SLINEAR_BE 7 |
125 |
#define AUDIO_ENCODING_ULINEAR_LE 8 |
126 |
#define AUDIO_ENCODING_ULINEAR_BE 9 |
127 |
#define AUDIO_ENCODING_SLINEAR 10 |
128 |
#define AUDIO_ENCODING_ULINEAR 11 |
129 |
#define AUDIO_ENCODING_MPEG_L1_STREAM 12 |
130 |
#define AUDIO_ENCODING_MPEG_L1_PACKETS 13 |
131 |
#define AUDIO_ENCODING_MPEG_L1_SYSTEM 14 |
132 |
#define AUDIO_ENCODING_MPEG_L2_STREAM 15 |
133 |
#define AUDIO_ENCODING_MPEG_L2_PACKETS 16 |
134 |
#define AUDIO_ENCODING_MPEG_L2_SYSTEM 17 |
135 |
#define AUDIO_ENCODING_AC3 18 |
136 |
|
137 |
typedef struct audio_encoding { |
138 |
int index;
|
139 |
char name[MAX_AUDIO_DEV_LEN];
|
140 |
int encoding;
|
141 |
int precision;
|
142 |
int flags;
|
143 |
#define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */ |
144 |
} audio_encoding_t; |
145 |
|
146 |
/*
|
147 |
* Balance settings.
|
148 |
*/
|
149 |
#define AUDIO_LEFT_BALANCE 0 /* left channel only */ |
150 |
#define AUDIO_MID_BALANCE 32 /* equal left/right channel */ |
151 |
#define AUDIO_RIGHT_BALANCE 64 /* right channel only */ |
152 |
#define AUDIO_BALANCE_SHIFT 3 |
153 |
|
154 |
/*
|
155 |
* Output ports
|
156 |
*/
|
157 |
#define AUDIO_SPEAKER 0x01 /* built-in speaker */ |
158 |
#define AUDIO_HEADPHONE 0x02 /* headphone jack */ |
159 |
#define AUDIO_LINE_OUT 0x04 /* line out */ |
160 |
|
161 |
/*
|
162 |
* Input ports
|
163 |
*/
|
164 |
#define AUDIO_MICROPHONE 0x01 /* microphone */ |
165 |
#define AUDIO_LINE_IN 0x02 /* line in */ |
166 |
#define AUDIO_CD 0x04 /* on-board CD inputs */ |
167 |
#define AUDIO_INTERNAL_CD_IN AUDIO_CD /* internal CDROM */ |
168 |
|
169 |
/*
|
170 |
* Audio device operations
|
171 |
*/
|
172 |
#define AUDIO_GETINFO _IOR('A', 21, struct audio_info) |
173 |
#define AUDIO_SETINFO _IOWR('A', 22, struct audio_info) |
174 |
#define AUDIO_DRAIN _IO('A', 23) |
175 |
#define AUDIO_FLUSH _IO('A', 24) |
176 |
#define AUDIO_WSEEK _IOR('A', 25, u_long) |
177 |
#define AUDIO_RERROR _IOR('A', 26, int) |
178 |
#define AUDIO_GETDEV _IOR('A', 27, struct audio_device) |
179 |
#define AUDIO_GETENC _IOWR('A', 28, struct audio_encoding) |
180 |
#define AUDIO_GETFD _IOR('A', 29, int) |
181 |
#define AUDIO_SETFD _IOWR('A', 30, int) |
182 |
#define AUDIO_PERROR _IOR('A', 31, int) |
183 |
#define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset) |
184 |
#define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset) |
185 |
#define AUDIO_GETPROPS _IOR('A', 34, int) |
186 |
#define AUDIO_PROP_FULLDUPLEX 0x01 |
187 |
#define AUDIO_PROP_MMAP 0x02 |
188 |
#define AUDIO_PROP_INDEPENDENT 0x04 |
189 |
#define AUDIO_PROP_PLAYBACK 0x10 |
190 |
#define AUDIO_PROP_CAPTURE 0x20 |
191 |
#define AUDIO_GETBUFINFO _IOR('A', 35, struct audio_info) |
192 |
|
193 |
/*
|
194 |
* Mixer device
|
195 |
*/
|
196 |
#define AUDIO_MIN_GAIN 0 |
197 |
#define AUDIO_MAX_GAIN 255 |
198 |
|
199 |
typedef struct mixer_level { |
200 |
int num_channels;
|
201 |
u_char level[8]; /* [num_channels] */ |
202 |
} mixer_level_t; |
203 |
#define AUDIO_MIXER_LEVEL_MONO 0 |
204 |
#define AUDIO_MIXER_LEVEL_LEFT 0 |
205 |
#define AUDIO_MIXER_LEVEL_RIGHT 1 |
206 |
|
207 |
/*
|
208 |
* Device operations
|
209 |
*/
|
210 |
|
211 |
typedef struct audio_mixer_name { |
212 |
char name[MAX_AUDIO_DEV_LEN];
|
213 |
int msg_id;
|
214 |
} audio_mixer_name_t; |
215 |
|
216 |
typedef struct mixer_devinfo { |
217 |
int index;
|
218 |
audio_mixer_name_t label; |
219 |
int type;
|
220 |
#define AUDIO_MIXER_CLASS 0 |
221 |
#define AUDIO_MIXER_ENUM 1 |
222 |
#define AUDIO_MIXER_SET 2 |
223 |
#define AUDIO_MIXER_VALUE 3 |
224 |
int mixer_class;
|
225 |
int next, prev;
|
226 |
#define AUDIO_MIXER_LAST -1 |
227 |
union {
|
228 |
struct audio_mixer_enum {
|
229 |
int num_mem;
|
230 |
struct {
|
231 |
audio_mixer_name_t label; |
232 |
int ord;
|
233 |
} member[32];
|
234 |
} e; |
235 |
struct audio_mixer_set {
|
236 |
int num_mem;
|
237 |
struct {
|
238 |
audio_mixer_name_t label; |
239 |
int mask;
|
240 |
} member[32];
|
241 |
} s; |
242 |
struct audio_mixer_value {
|
243 |
audio_mixer_name_t units; |
244 |
int num_channels;
|
245 |
int delta;
|
246 |
} v; |
247 |
} un; |
248 |
} mixer_devinfo_t; |
249 |
|
250 |
|
251 |
typedef struct mixer_ctrl { |
252 |
int dev;
|
253 |
int type;
|
254 |
union {
|
255 |
int ord; /* enum */ |
256 |
int mask; /* set */ |
257 |
mixer_level_t value; /* value */
|
258 |
} un; |
259 |
} mixer_ctrl_t; |
260 |
|
261 |
/*
|
262 |
* Mixer operations
|
263 |
*/
|
264 |
#define AUDIO_MIXER_READ _IOWR('M', 0, mixer_ctrl_t) |
265 |
#define AUDIO_MIXER_WRITE _IOWR('M', 1, mixer_ctrl_t) |
266 |
#define AUDIO_MIXER_DEVINFO _IOWR('M', 2, mixer_devinfo_t) |
267 |
|
268 |
/*
|
269 |
* Well known device names
|
270 |
*/
|
271 |
#define AudioNmicrophone "mic" |
272 |
#define AudioNline "line" |
273 |
#define AudioNcd "cd" |
274 |
#define AudioNdac "dac" |
275 |
#define AudioNaux "aux" |
276 |
#define AudioNrecord "record" |
277 |
#define AudioNvolume "volume" |
278 |
#define AudioNmonitor "monitor" |
279 |
#define AudioNtreble "treble" |
280 |
#define AudioNmid "mid" |
281 |
#define AudioNbass "bass" |
282 |
#define AudioNbassboost "bassboost" |
283 |
#define AudioNspeaker "speaker" |
284 |
#define AudioNheadphone "headphones" |
285 |
#define AudioNoutput "output" |
286 |
#define AudioNinput "input" |
287 |
#define AudioNmaster "master" |
288 |
#define AudioNstereo "stereo" |
289 |
#define AudioNmono "mono" |
290 |
#define AudioNloudness "loudness" |
291 |
#define AudioNspatial "spatial" |
292 |
#define AudioNsurround "surround" |
293 |
#define AudioNpseudo "pseudo" |
294 |
#define AudioNmute "mute" |
295 |
#define AudioNenhanced "enhanced" |
296 |
#define AudioNpreamp "preamp" |
297 |
#define AudioNon "on" |
298 |
#define AudioNoff "off" |
299 |
#define AudioNmode "mode" |
300 |
#define AudioNsource "source" |
301 |
#define AudioNfmsynth "fmsynth" |
302 |
#define AudioNwave "wave" |
303 |
#define AudioNmidi "midi" |
304 |
#define AudioNmixerout "mixerout" |
305 |
#define AudioNswap "swap" /* swap left and right channels */ |
306 |
#define AudioNagc "agc" |
307 |
#define AudioNdelay "delay" |
308 |
#define AudioNselect "select" /* select destination */ |
309 |
#define AudioNvideo "video" |
310 |
#define AudioNcenter "center" |
311 |
#define AudioNdepth "depth" |
312 |
#define AudioNlfe "lfe" |
313 |
|
314 |
#define AudioEmulaw "mulaw" |
315 |
#define AudioEalaw "alaw" |
316 |
#define AudioEadpcm "adpcm" |
317 |
#define AudioEslinear "slinear" |
318 |
#define AudioEslinear_le "slinear_le" |
319 |
#define AudioEslinear_be "slinear_be" |
320 |
#define AudioEulinear "ulinear" |
321 |
#define AudioEulinear_le "ulinear_le" |
322 |
#define AudioEulinear_be "ulinear_be" |
323 |
#define AudioEmpeg_l1_stream "mpeg_l1_stream" |
324 |
#define AudioEmpeg_l1_packets "mpeg_l1_packets" |
325 |
#define AudioEmpeg_l1_system "mpeg_l1_system" |
326 |
#define AudioEmpeg_l2_stream "mpeg_l2_stream" |
327 |
#define AudioEmpeg_l2_packets "mpeg_l2_packets" |
328 |
#define AudioEmpeg_l2_system "mpeg_l2_system" |
329 |
#define AudioEac3 "ac3" |
330 |
|
331 |
#define AudioCinputs "inputs" |
332 |
#define AudioCoutputs "outputs" |
333 |
#define AudioCrecord "record" |
334 |
#define AudioCmonitor "monitor" |
335 |
#define AudioCequalization "equalization" |
336 |
#define AudioCmodem "modem" |
337 |
|
338 |
#endif /* !_SYS_AUDIOIO_H_ */ |