FreeBSD/Linux Kernel Cross Reference
sys/sys/audioio.h
1 /* $NetBSD: audioio.h,v 1.32.44.1 2009/10/16 05:43:38 snj 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
136 typedef struct audio_encoding {
137 int index;
138 char name[MAX_AUDIO_DEV_LEN];
139 int encoding;
140 int precision;
141 int flags;
142 #define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
143 } audio_encoding_t;
144
145 /*
146 * Balance settings.
147 */
148 #define AUDIO_LEFT_BALANCE 0 /* left channel only */
149 #define AUDIO_MID_BALANCE 32 /* equal left/right channel */
150 #define AUDIO_RIGHT_BALANCE 64 /* right channel only */
151 #define AUDIO_BALANCE_SHIFT 3
152
153 /*
154 * Output ports
155 */
156 #define AUDIO_SPEAKER 0x01 /* built-in speaker */
157 #define AUDIO_HEADPHONE 0x02 /* headphone jack */
158 #define AUDIO_LINE_OUT 0x04 /* line out */
159
160 /*
161 * Input ports
162 */
163 #define AUDIO_MICROPHONE 0x01 /* microphone */
164 #define AUDIO_LINE_IN 0x02 /* line in */
165 #define AUDIO_CD 0x04 /* on-board CD inputs */
166 #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* internal CDROM */
167
168 /*
169 * Audio device operations
170 */
171 #define AUDIO_GETINFO _IOR('A', 21, struct audio_info)
172 #define AUDIO_SETINFO _IOWR('A', 22, struct audio_info)
173 #define AUDIO_DRAIN _IO('A', 23)
174 #define AUDIO_FLUSH _IO('A', 24)
175 #define AUDIO_WSEEK _IOR('A', 25, u_long)
176 #define AUDIO_RERROR _IOR('A', 26, int)
177 #define AUDIO_GETDEV _IOR('A', 27, struct audio_device)
178 #define AUDIO_GETENC _IOWR('A', 28, struct audio_encoding)
179 #define AUDIO_GETFD _IOR('A', 29, int)
180 #define AUDIO_SETFD _IOWR('A', 30, int)
181 #define AUDIO_PERROR _IOR('A', 31, int)
182 #define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset)
183 #define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset)
184 #define AUDIO_GETPROPS _IOR('A', 34, int)
185 #define AUDIO_PROP_FULLDUPLEX 0x01
186 #define AUDIO_PROP_MMAP 0x02
187 #define AUDIO_PROP_INDEPENDENT 0x04
188 #define AUDIO_PROP_PLAYBACK 0x10
189 #define AUDIO_PROP_CAPTURE 0x20
190 #define AUDIO_GETBUFINFO _IOR('A', 35, struct audio_info)
191
192 /*
193 * Mixer device
194 */
195 #define AUDIO_MIN_GAIN 0
196 #define AUDIO_MAX_GAIN 255
197
198 typedef struct mixer_level {
199 int num_channels;
200 u_char level[8]; /* [num_channels] */
201 } mixer_level_t;
202 #define AUDIO_MIXER_LEVEL_MONO 0
203 #define AUDIO_MIXER_LEVEL_LEFT 0
204 #define AUDIO_MIXER_LEVEL_RIGHT 1
205
206 /*
207 * Device operations
208 */
209
210 typedef struct audio_mixer_name {
211 char name[MAX_AUDIO_DEV_LEN];
212 int msg_id;
213 } audio_mixer_name_t;
214
215 typedef struct mixer_devinfo {
216 int index;
217 audio_mixer_name_t label;
218 int type;
219 #define AUDIO_MIXER_CLASS 0
220 #define AUDIO_MIXER_ENUM 1
221 #define AUDIO_MIXER_SET 2
222 #define AUDIO_MIXER_VALUE 3
223 int mixer_class;
224 int next, prev;
225 #define AUDIO_MIXER_LAST -1
226 union {
227 struct audio_mixer_enum {
228 int num_mem;
229 struct {
230 audio_mixer_name_t label;
231 int ord;
232 } member[32];
233 } e;
234 struct audio_mixer_set {
235 int num_mem;
236 struct {
237 audio_mixer_name_t label;
238 int mask;
239 } member[32];
240 } s;
241 struct audio_mixer_value {
242 audio_mixer_name_t units;
243 int num_channels;
244 int delta;
245 } v;
246 } un;
247 } mixer_devinfo_t;
248
249
250 typedef struct mixer_ctrl {
251 int dev;
252 int type;
253 union {
254 int ord; /* enum */
255 int mask; /* set */
256 mixer_level_t value; /* value */
257 } un;
258 } mixer_ctrl_t;
259
260 /*
261 * Mixer operations
262 */
263 #define AUDIO_MIXER_READ _IOWR('M', 0, mixer_ctrl_t)
264 #define AUDIO_MIXER_WRITE _IOWR('M', 1, mixer_ctrl_t)
265 #define AUDIO_MIXER_DEVINFO _IOWR('M', 2, mixer_devinfo_t)
266
267 /*
268 * Well known device names
269 */
270 #define AudioNmicrophone "mic"
271 #define AudioNline "line"
272 #define AudioNcd "cd"
273 #define AudioNdac "dac"
274 #define AudioNaux "aux"
275 #define AudioNrecord "record"
276 #define AudioNvolume "volume"
277 #define AudioNmonitor "monitor"
278 #define AudioNtreble "treble"
279 #define AudioNmid "mid"
280 #define AudioNbass "bass"
281 #define AudioNbassboost "bassboost"
282 #define AudioNspeaker "speaker"
283 #define AudioNheadphone "headphones"
284 #define AudioNoutput "output"
285 #define AudioNinput "input"
286 #define AudioNmaster "master"
287 #define AudioNstereo "stereo"
288 #define AudioNmono "mono"
289 #define AudioNloudness "loudness"
290 #define AudioNspatial "spatial"
291 #define AudioNsurround "surround"
292 #define AudioNpseudo "pseudo"
293 #define AudioNmute "mute"
294 #define AudioNenhanced "enhanced"
295 #define AudioNpreamp "preamp"
296 #define AudioNon "on"
297 #define AudioNoff "off"
298 #define AudioNmode "mode"
299 #define AudioNsource "source"
300 #define AudioNfmsynth "fmsynth"
301 #define AudioNwave "wave"
302 #define AudioNmidi "midi"
303 #define AudioNmixerout "mixerout"
304 #define AudioNswap "swap" /* swap left and right channels */
305 #define AudioNagc "agc"
306 #define AudioNdelay "delay"
307 #define AudioNselect "select" /* select destination */
308 #define AudioNvideo "video"
309 #define AudioNcenter "center"
310 #define AudioNdepth "depth"
311 #define AudioNlfe "lfe"
312
313 #define AudioEmulaw "mulaw"
314 #define AudioEalaw "alaw"
315 #define AudioEadpcm "adpcm"
316 #define AudioEslinear "slinear"
317 #define AudioEslinear_le "slinear_le"
318 #define AudioEslinear_be "slinear_be"
319 #define AudioEulinear "ulinear"
320 #define AudioEulinear_le "ulinear_le"
321 #define AudioEulinear_be "ulinear_be"
322 #define AudioEmpeg_l1_stream "mpeg_l1_stream"
323 #define AudioEmpeg_l1_packets "mpeg_l1_packets"
324 #define AudioEmpeg_l1_system "mpeg_l1_system"
325 #define AudioEmpeg_l2_stream "mpeg_l2_stream"
326 #define AudioEmpeg_l2_packets "mpeg_l2_packets"
327 #define AudioEmpeg_l2_system "mpeg_l2_system"
328
329 #define AudioCinputs "inputs"
330 #define AudioCoutputs "outputs"
331 #define AudioCrecord "record"
332 #define AudioCmonitor "monitor"
333 #define AudioCequalization "equalization"
334 #define AudioCmodem "modem"
335
336 #endif /* !_SYS_AUDIOIO_H_ */
Cache object: 62096da7e4462d1a6957afe1c73f0dbb
|