1/*	$OpenBSD: audioio.h,v 1.27 2016/09/14 06:12:20 ratchov Exp $	*/
2/*	$NetBSD: audioio.h,v 1.24 1998/08/13 06:28:41 mrg Exp $	*/
3
4/*
5 * Copyright (c) 1991-1993 Regents of the University of California.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by the Computer Systems
19 *	Engineering Group at Lawrence Berkeley Laboratory.
20 * 4. Neither the name of the University nor of the Laboratory may be used
21 *    to endorse or promote products derived from this software without
22 *    specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 */
37
38#ifndef _SYS_AUDIOIO_H_
39#define _SYS_AUDIOIO_H_
40
41#define AUMODE_PLAY	0x01
42#define AUMODE_RECORD	0x02
43
44#define AUDIO_INITPAR(p) \
45	(void)memset((void *)(p), 0xff, sizeof(struct audio_swpar))
46
47/*
48 * argument to AUDIO_SETPAR and AUDIO_GETPAR ioctls
49 */
50struct audio_swpar {
51	unsigned int sig;		/* if 1, encoding is signed */
52	unsigned int le;		/* if 1, encoding is little-endian */
53	unsigned int bits;		/* bits per sample */
54	unsigned int bps;		/* bytes per sample */
55	unsigned int msb;		/* if 1, bits are msb-aligned */
56	unsigned int rate;		/* common play & rec sample rate */
57	unsigned int pchan;		/* play channels */
58	unsigned int rchan;		/* rec channels */
59	unsigned int nblks;		/* number of blocks in play buffer */
60	unsigned int round;		/* common frames per block */
61	unsigned int _spare[6];
62};
63
64/*
65 * argument to AUDIO_GETSTATUS
66 */
67struct audio_status {
68	int mode;
69	int pause;
70	int active;
71	int _spare[5];
72};
73
74/*
75 * Parameter for the AUDIO_GETDEV ioctl to determine current
76 * audio devices.
77 */
78#define MAX_AUDIO_DEV_LEN	16
79typedef struct audio_device {
80	char name[MAX_AUDIO_DEV_LEN];
81	char version[MAX_AUDIO_DEV_LEN];
82	char config[MAX_AUDIO_DEV_LEN];
83} audio_device_t;
84
85struct audio_pos {
86	unsigned int play_pos;	/* total bytes played */
87	unsigned int play_xrun;	/* bytes of silence inserted */
88	unsigned int rec_pos;	/* total bytes recorded */
89	unsigned int rec_xrun;	/* bytes dropped */
90};
91
92/*
93 * Audio device operations
94 */
95#define AUDIO_GETDEV	_IOR('A', 27, struct audio_device)
96#define AUDIO_GETPOS	_IOR('A', 35, struct audio_pos)
97#define AUDIO_GETPAR	_IOR('A', 36, struct audio_swpar)
98#define AUDIO_SETPAR	_IOWR('A', 37, struct audio_swpar)
99#define AUDIO_START	_IO('A', 38)
100#define AUDIO_STOP	_IO('A', 39)
101#define AUDIO_GETSTATUS	_IOR('A', 40, struct audio_status)
102
103/*
104 * Mixer device
105 */
106#define AUDIO_MIN_GAIN	0
107#define AUDIO_MAX_GAIN	255
108
109typedef struct mixer_level {
110	int num_channels;
111	u_char level[8];	/* [num_channels] */
112} mixer_level_t;
113#define AUDIO_MIXER_LEVEL_MONO	0
114#define AUDIO_MIXER_LEVEL_LEFT	0
115#define AUDIO_MIXER_LEVEL_RIGHT	1
116
117/*
118 * Device operations
119 */
120
121typedef struct audio_mixer_name {
122	char name[MAX_AUDIO_DEV_LEN];
123	int msg_id;
124} audio_mixer_name_t;
125
126typedef struct mixer_devinfo {
127	int index;
128	audio_mixer_name_t label;
129	int type;
130#define AUDIO_MIXER_CLASS	0
131#define AUDIO_MIXER_ENUM	1
132#define AUDIO_MIXER_SET		2
133#define AUDIO_MIXER_VALUE	3
134	int mixer_class;
135	int next, prev;
136#define AUDIO_MIXER_LAST	-1
137	union {
138		struct audio_mixer_enum {
139			int num_mem;
140			struct {
141				audio_mixer_name_t label;
142				int ord;
143			} member[32];
144		} e;
145		struct audio_mixer_set {
146			int num_mem;
147			struct {
148				audio_mixer_name_t label;
149				int mask;
150			} member[32];
151		} s;
152		struct audio_mixer_value {
153			audio_mixer_name_t units;
154			int num_channels;
155			int delta;
156		} v;
157	} un;
158} mixer_devinfo_t;
159
160
161typedef struct mixer_ctrl {
162	int dev;
163	int type;
164	union {
165		int ord;		/* enum */
166		int mask;		/* set */
167		mixer_level_t value;	/* value */
168	} un;
169} mixer_ctrl_t;
170
171/*
172 * Mixer operations
173 */
174#define AUDIO_MIXER_READ		_IOWR('M', 0, mixer_ctrl_t)
175#define AUDIO_MIXER_WRITE		_IOWR('M', 1, mixer_ctrl_t)
176#define AUDIO_MIXER_DEVINFO		_IOWR('M', 2, mixer_devinfo_t)
177
178/*
179 * Well known device names
180 */
181#define AudioNmicrophone	"mic"
182#define AudioNline	"line"
183#define AudioNcd	"cd"
184#define AudioNdac	"dac"
185#define AudioNaux	"aux"
186#define AudioNrecord	"record"
187#define AudioNvolume	"volume"
188#define AudioNmonitor	"monitor"
189#define AudioNtreble	"treble"
190#define AudioNmid	"mid"
191#define AudioNbass	"bass"
192#define AudioNbassboost	"bassboost"
193#define AudioNspeaker	"spkr"
194#define AudioNheadphone	"hp"
195#define AudioNoutput	"output"
196#define AudioNinput	"input"
197#define AudioNmaster	"master"
198#define AudioNstereo	"stereo"
199#define AudioNmono	"mono"
200#define AudioNloudness	"loudness"
201#define AudioNspatial	"spatial"
202#define AudioNsurround	"surround"
203#define AudioNpseudo	"pseudo"
204#define AudioNmute	"mute"
205#define AudioNenhanced	"enhanced"
206#define AudioNpreamp	"preamp"
207#define AudioNon	"on"
208#define AudioNoff	"off"
209#define AudioNmode	"mode"
210#define AudioNsource	"source"
211#define AudioNfmsynth	"fmsynth"
212#define AudioNwave	"wave"
213#define AudioNmidi	"midi"
214#define AudioNmixerout	"mixerout"
215#define AudioNswap	"swap"	/* swap left and right channels */
216#define AudioNagc	"agc"
217#define AudioNdelay	"delay"
218#define AudioNselect	"select" /* select destination */
219#define AudioNvideo	"video"
220#define AudioNcenter	"center"
221#define AudioNdepth	"depth"
222#define AudioNlfe	"lfe"
223#define AudioNextamp	"extamp"
224
225#define AudioCinputs	"inputs"
226#define AudioCoutputs	"outputs"
227#define AudioCrecord	"record"
228#define AudioCmonitor	"monitor"
229#define AudioCequalization	"equalization"
230
231#endif /* !_SYS_AUDIOIO_H_ */
232