FreeBSD/Linux Kernel Cross Reference
sys/sys/audioio.h
1 /* $NetBSD: audioio.h,v 1.26 2002/10/12 07:39:00 kent 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 /*
41 * Audio device
42 */
43 struct audio_prinfo {
44 u_int sample_rate; /* sample rate in bit/s */
45 u_int channels; /* number of channels, usually 1 or 2 */
46 u_int precision; /* number of bits/sample */
47 u_int encoding; /* data encoding (AUDIO_ENCODING_* below) */
48 u_int gain; /* volume level */
49 u_int port; /* selected I/O port */
50 u_int seek; /* BSD extension */
51 u_int avail_ports; /* available I/O ports */
52 u_int buffer_size; /* total size audio buffer */
53 u_int _ispare[1];
54 /* Current state of device: */
55 u_int samples; /* number of samples */
56 u_int eof; /* End Of File (zero-size writes) counter */
57 u_char pause; /* non-zero if paused, zero to resume */
58 u_char error; /* non-zero if underflow/overflow ocurred */
59 u_char waiting; /* non-zero if another process hangs in open */
60 u_char balance; /* stereo channel balance */
61 u_char cspare[2];
62 u_char open; /* non-zero if currently open */
63 u_char active; /* non-zero if I/O is currently active */
64 };
65 typedef struct audio_prinfo audio_prinfo_t;
66
67 struct audio_info {
68 struct audio_prinfo play; /* Info for play (output) side */
69 struct audio_prinfo record; /* Info for record (input) side */
70
71 u_int monitor_gain; /* input to output mix */
72 /* BSD extensions */
73 u_int blocksize; /* H/W read/write block size */
74 u_int hiwat; /* output high water mark */
75 u_int lowat; /* output low water mark */
76 u_int _ispare1;
77 u_int mode; /* current device mode */
78 #define AUMODE_PLAY 0x01
79 #define AUMODE_RECORD 0x02
80 #define AUMODE_PLAY_ALL 0x04 /* don't do real-time correction */
81 };
82 typedef struct audio_info audio_info_t;
83
84 #define AUDIO_INITINFO(p) \
85 (void)memset((void *)(p), 0xff, sizeof(struct audio_info))
86
87 /*
88 * Parameter for the AUDIO_GETDEV ioctl to determine current
89 * audio devices.
90 */
91 #define MAX_AUDIO_DEV_LEN 16
92 typedef struct audio_device {
93 char name[MAX_AUDIO_DEV_LEN];
94 char version[MAX_AUDIO_DEV_LEN];
95 char config[MAX_AUDIO_DEV_LEN];
96 } audio_device_t;
97
98 typedef struct audio_offset {
99 u_int samples; /* Total number of bytes transferred */
100 u_int deltablks; /* Blocks transferred since last checked */
101 u_int offset; /* Physical transfer offset in buffer */
102 } audio_offset_t;
103
104 /*
105 * Supported audio encodings
106 */
107 /* Encoding ID's */
108 #define AUDIO_ENCODING_NONE 0 /* no encoding assigned */
109 #define AUDIO_ENCODING_ULAW 1 /* ITU G.711 mu-law */
110 #define AUDIO_ENCODING_ALAW 2 /* ITU G.711 A-law */
111 #define AUDIO_ENCODING_PCM16 3 /* signed linear PCM, obsolete */
112 #define AUDIO_ENCODING_LINEAR AUDIO_ENCODING_PCM16 /* SunOS compat */
113 #define AUDIO_ENCODING_PCM8 4 /* unsigned linear PCM, obsolete */
114 #define AUDIO_ENCODING_LINEAR8 AUDIO_ENCODING_PCM8 /* SunOS compat */
115 #define AUDIO_ENCODING_ADPCM 5 /* adaptive differential PCM */
116 #define AUDIO_ENCODING_SLINEAR_LE 6
117 #define AUDIO_ENCODING_SLINEAR_BE 7
118 #define AUDIO_ENCODING_ULINEAR_LE 8
119 #define AUDIO_ENCODING_ULINEAR_BE 9
120 #define AUDIO_ENCODING_SLINEAR 10
121 #define AUDIO_ENCODING_ULINEAR 11
122 #define AUDIO_ENCODING_MPEG_L1_STREAM 12
123 #define AUDIO_ENCODING_MPEG_L1_PACKETS 13
124 #define AUDIO_ENCODING_MPEG_L1_SYSTEM 14
125 #define AUDIO_ENCODING_MPEG_L2_STREAM 15
126 #define AUDIO_ENCODING_MPEG_L2_PACKETS 16
127 #define AUDIO_ENCODING_MPEG_L2_SYSTEM 17
128
129 typedef struct audio_encoding {
130 int index;
131 char name[MAX_AUDIO_DEV_LEN];
132 int encoding;
133 int precision;
134 int flags;
135 #define AUDIO_ENCODINGFLAG_EMULATED 1 /* software emulation mode */
136 } audio_encoding_t;
137
138 /*
139 * Balance settings.
140 */
141 #define AUDIO_LEFT_BALANCE 0 /* left channel only */
142 #define AUDIO_MID_BALANCE 32 /* equal left/right channel */
143 #define AUDIO_RIGHT_BALANCE 64 /* right channel only */
144 #define AUDIO_BALANCE_SHIFT 3
145
146 /*
147 * Output ports
148 */
149 #define AUDIO_SPEAKER 0x01 /* built-in speaker */
150 #define AUDIO_HEADPHONE 0x02 /* headphone jack */
151 #define AUDIO_LINE_OUT 0x04 /* line out */
152
153 /*
154 * Input ports
155 */
156 #define AUDIO_MICROPHONE 0x01 /* microphone */
157 #define AUDIO_LINE_IN 0x02 /* line in */
158 #define AUDIO_CD 0x04 /* on-board CD inputs */
159 #define AUDIO_INTERNAL_CD_IN AUDIO_CD /* internal CDROM */
160
161 /*
162 * Audio device operations
163 */
164 #define AUDIO_GETINFO _IOR('A', 21, struct audio_info)
165 #define AUDIO_SETINFO _IOWR('A', 22, struct audio_info)
166 #define AUDIO_DRAIN _IO('A', 23)
167 #define AUDIO_FLUSH _IO('A', 24)
168 #define AUDIO_WSEEK _IOR('A', 25, u_long)
169 #define AUDIO_RERROR _IOR('A', 26, int)
170 #define AUDIO_GETDEV _IOR('A', 27, struct audio_device)
171 #define AUDIO_GETENC _IOWR('A', 28, struct audio_encoding)
172 #define AUDIO_GETFD _IOR('A', 29, int)
173 #define AUDIO_SETFD _IOWR('A', 30, int)
174 #define AUDIO_PERROR _IOR('A', 31, int)
175 #define AUDIO_GETIOFFS _IOR('A', 32, struct audio_offset)
176 #define AUDIO_GETOOFFS _IOR('A', 33, struct audio_offset)
177 #define AUDIO_GETPROPS _IOR('A', 34, int)
178 #define AUDIO_PROP_FULLDUPLEX 0x01
179 #define AUDIO_PROP_MMAP 0x02
180 #define AUDIO_PROP_INDEPENDENT 0x04
181
182 /*
183 * Mixer device
184 */
185 #define AUDIO_MIN_GAIN 0
186 #define AUDIO_MAX_GAIN 255
187
188 typedef struct mixer_level {
189 int num_channels;
190 u_char level[8]; /* [num_channels] */
191 } mixer_level_t;
192 #define AUDIO_MIXER_LEVEL_MONO 0
193 #define AUDIO_MIXER_LEVEL_LEFT 0
194 #define AUDIO_MIXER_LEVEL_RIGHT 1
195
196 /*
197 * Device operations
198 */
199
200 typedef struct audio_mixer_name {
201 char name[MAX_AUDIO_DEV_LEN];
202 int msg_id;
203 } audio_mixer_name_t;
204
205 typedef struct mixer_devinfo {
206 int index;
207 audio_mixer_name_t label;
208 int type;
209 #define AUDIO_MIXER_CLASS 0
210 #define AUDIO_MIXER_ENUM 1
211 #define AUDIO_MIXER_SET 2
212 #define AUDIO_MIXER_VALUE 3
213 int mixer_class;
214 int next, prev;
215 #define AUDIO_MIXER_LAST -1
216 union {
217 struct audio_mixer_enum {
218 int num_mem;
219 struct {
220 audio_mixer_name_t label;
221 int ord;
222 } member[32];
223 } e;
224 struct audio_mixer_set {
225 int num_mem;
226 struct {
227 audio_mixer_name_t label;
228 int mask;
229 } member[32];
230 } s;
231 struct audio_mixer_value {
232 audio_mixer_name_t units;
233 int num_channels;
234 int delta;
235 } v;
236 } un;
237 } mixer_devinfo_t;
238
239
240 typedef struct mixer_ctrl {
241 int dev;
242 int type;
243 union {
244 int ord; /* enum */
245 int mask; /* set */
246 mixer_level_t value; /* value */
247 } un;
248 } mixer_ctrl_t;
249
250 /*
251 * Mixer operations
252 */
253 #define AUDIO_MIXER_READ _IOWR('M', 0, mixer_ctrl_t)
254 #define AUDIO_MIXER_WRITE _IOWR('M', 1, mixer_ctrl_t)
255 #define AUDIO_MIXER_DEVINFO _IOWR('M', 2, mixer_devinfo_t)
256
257 /*
258 * Well known device names
259 */
260 #define AudioNmicrophone "mic"
261 #define AudioNline "line"
262 #define AudioNcd "cd"
263 #define AudioNdac "dac"
264 #define AudioNaux "aux"
265 #define AudioNrecord "record"
266 #define AudioNvolume "volume"
267 #define AudioNmonitor "monitor"
268 #define AudioNtreble "treble"
269 #define AudioNmid "mid"
270 #define AudioNbass "bass"
271 #define AudioNbassboost "bassboost"
272 #define AudioNspeaker "speaker"
273 #define AudioNheadphone "headphones"
274 #define AudioNoutput "output"
275 #define AudioNinput "input"
276 #define AudioNmaster "master"
277 #define AudioNstereo "stereo"
278 #define AudioNmono "mono"
279 #define AudioNloudness "loudness"
280 #define AudioNspatial "spatial"
281 #define AudioNsurround "surround"
282 #define AudioNpseudo "pseudo"
283 #define AudioNmute "mute"
284 #define AudioNenhanced "enhanced"
285 #define AudioNpreamp "preamp"
286 #define AudioNon "on"
287 #define AudioNoff "off"
288 #define AudioNmode "mode"
289 #define AudioNsource "source"
290 #define AudioNfmsynth "fmsynth"
291 #define AudioNwave "wave"
292 #define AudioNmidi "midi"
293 #define AudioNmixerout "mixerout"
294 #define AudioNswap "swap" /* swap left and right channels */
295 #define AudioNagc "agc"
296 #define AudioNdelay "delay"
297 #define AudioNselect "select" /* select destination */
298 #define AudioNvideo "video"
299 #define AudioNcenter "center"
300 #define AudioNdepth "depth"
301 #define AudioNlfe "lfe"
302
303 #define AudioEmulaw "mulaw"
304 #define AudioEalaw "alaw"
305 #define AudioEadpcm "adpcm"
306 #define AudioEslinear "slinear"
307 #define AudioEslinear_le "slinear_le"
308 #define AudioEslinear_be "slinear_be"
309 #define AudioEulinear "ulinear"
310 #define AudioEulinear_le "ulinear_le"
311 #define AudioEulinear_be "ulinear_be"
312 #define AudioEmpeg_l1_stream "mpeg_l1_stream"
313 #define AudioEmpeg_l1_packets "mpeg_l1_packets"
314 #define AudioEmpeg_l1_system "mpeg_l1_system"
315 #define AudioEmpeg_l2_stream "mpeg_l2_stream"
316 #define AudioEmpeg_l2_packets "mpeg_l2_packets"
317 #define AudioEmpeg_l2_system "mpeg_l2_system"
318
319 #define AudioCinputs "inputs"
320 #define AudioCoutputs "outputs"
321 #define AudioCrecord "record"
322 #define AudioCmonitor "monitor"
323 #define AudioCequalization "equalization"
324
325 #endif /* !_SYS_AUDIOIO_H_ */
Cache object: 82ddd997228137d8efe3bc1c810101b1
|