1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  *  Advanced Linux Sound Architecture - ALSA - Driver
4  *  Copyright (c) 1994-2003 by Jaroslav Kysela <perex@perex.cz>,
5  *                             Abramo Bagnara <abramo@alsa-project.org>
6  *
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  *
22  */
23 
24 #ifndef __SOUND_ASOUND_H
25 #define __SOUND_ASOUND_H
26 
27 #if defined(__KERNEL__) || defined(__linux__)
28 #include <linux/types.h>
29 #else
30 #include <sys/ioctl.h>
31 #endif
32 
33 #include <stdlib.h>
34 
35 /*
36  *  protocol version
37  */
38 
39 #define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor))
40 #define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff)
41 #define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff)
42 #define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff)
43 #define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) \
44 	(SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || \
45 	 (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && \
46 	   SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion)))
47 
48 /****************************************************************************
49  *                                                                          *
50  *        Digital audio interface					    *
51  *                                                                          *
52  ****************************************************************************/
53 
54 struct snd_aes_iec958 {
55 	unsigned char status[24];	/* AES/IEC958 channel status bits */
56 	unsigned char subcode[147];	/* AES/IEC958 subcode bits */
57 	unsigned char pad;		/* nothing */
58 	unsigned char dig_subframe[4];	/* AES/IEC958 subframe bits */
59 };
60 
61 /****************************************************************************
62  *                                                                          *
63  *        CEA-861 Audio InfoFrame. Used in HDMI and DisplayPort		    *
64  *                                                                          *
65  ****************************************************************************/
66 
67 struct snd_cea_861_aud_if {
68 	unsigned char db1_ct_cc; /* coding type and channel count */
69 	unsigned char db2_sf_ss; /* sample frequency and size */
70 	unsigned char db3; /* not used, all zeros */
71 	unsigned char db4_ca; /* channel allocation code */
72 	unsigned char db5_dminh_lsv; /* downmix inhibit & level-shit values */
73 };
74 
75 /****************************************************************************
76  *                                                                          *
77  *      Section for driver hardware dependent interface - /dev/snd/hw?      *
78  *                                                                          *
79  ****************************************************************************/
80 
81 #define SNDRV_HWDEP_VERSION		SNDRV_PROTOCOL_VERSION(1, 0, 1)
82 
83 enum {
84 	SNDRV_HWDEP_IFACE_OPL2 = 0,
85 	SNDRV_HWDEP_IFACE_OPL3,
86 	SNDRV_HWDEP_IFACE_OPL4,
87 	SNDRV_HWDEP_IFACE_SB16CSP,	/* Creative Signal Processor */
88 	SNDRV_HWDEP_IFACE_EMU10K1,	/* FX8010 processor in EMU10K1 chip */
89 	SNDRV_HWDEP_IFACE_YSS225,	/* Yamaha FX processor */
90 	SNDRV_HWDEP_IFACE_ICS2115,	/* Wavetable synth */
91 	SNDRV_HWDEP_IFACE_SSCAPE,	/* Ensoniq SoundScape ISA card (MC68EC000) */
92 	SNDRV_HWDEP_IFACE_VX,		/* Digigram VX cards */
93 	SNDRV_HWDEP_IFACE_MIXART,	/* Digigram miXart cards */
94 	SNDRV_HWDEP_IFACE_USX2Y,	/* Tascam US122, US224 & US428 usb */
95 	SNDRV_HWDEP_IFACE_EMUX_WAVETABLE, /* EmuX wavetable */
96 	SNDRV_HWDEP_IFACE_BLUETOOTH,	/* Bluetooth audio */
97 	SNDRV_HWDEP_IFACE_USX2Y_PCM,	/* Tascam US122, US224 & US428 rawusb pcm */
98 	SNDRV_HWDEP_IFACE_PCXHR,	/* Digigram PCXHR */
99 	SNDRV_HWDEP_IFACE_SB_RC,	/* SB Extigy/Audigy2NX remote control */
100 	SNDRV_HWDEP_IFACE_HDA,		/* HD-audio */
101 	SNDRV_HWDEP_IFACE_USB_STREAM,	/* direct access to usb stream */
102 	SNDRV_HWDEP_IFACE_FW_DICE,	/* TC DICE FireWire device */
103 	SNDRV_HWDEP_IFACE_FW_FIREWORKS,	/* Echo Audio Fireworks based device */
104 	SNDRV_HWDEP_IFACE_FW_BEBOB,	/* BridgeCo BeBoB based device */
105 	SNDRV_HWDEP_IFACE_FW_OXFW,	/* Oxford OXFW970/971 based device */
106 	SNDRV_HWDEP_IFACE_FW_DIGI00X,	/* Digidesign Digi 002/003 family */
107 	SNDRV_HWDEP_IFACE_FW_TASCAM,	/* TASCAM FireWire series */
108 	SNDRV_HWDEP_IFACE_LINE6,	/* Line6 USB processors */
109 	SNDRV_HWDEP_IFACE_FW_MOTU,	/* MOTU FireWire series */
110 	SNDRV_HWDEP_IFACE_FW_FIREFACE,	/* RME Fireface series */
111 	SNDRV_HWDEP_IFACE_AUDIO_BE,	/* Backend Audio Control */
112 	SNDRV_HWDEP_IFACE_AUDIO_CODEC,  /* codec Audio Control */
113 
114 	/* Don't forget to change the following: */
115 	SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_AUDIO_CODEC
116 };
117 
118 #define SNDRV_HWDEP_IFACE_AUDIO_BE SNDRV_HWDEP_IFACE_AUDIO_BE
119 #define SNDRV_HWDEP_IFACE_AUDIO_CODEC SNDRV_HWDEP_IFACE_AUDIO_CODEC
120 
121 struct snd_hwdep_info {
122 	unsigned int device;		/* WR: device number */
123 	int card;			/* R: card number */
124 	unsigned char id[64];		/* ID (user selectable) */
125 	unsigned char name[80];		/* hwdep name */
126 	int iface;			/* hwdep interface */
127 	unsigned char reserved[64];	/* reserved for future */
128 };
129 
130 /* generic DSP loader */
131 struct snd_hwdep_dsp_status {
132 	unsigned int version;		/* R: driver-specific version */
133 	unsigned char id[32];		/* R: driver-specific ID string */
134 	unsigned int num_dsps;		/* R: number of DSP images to transfer */
135 	unsigned int dsp_loaded;	/* R: bit flags indicating the loaded DSPs */
136 	unsigned int chip_ready;	/* R: 1 = initialization finished */
137 	unsigned char reserved[16];	/* reserved for future use */
138 };
139 
140 struct snd_hwdep_dsp_image {
141 	unsigned int index;		/* W: DSP index */
142 	unsigned char name[64];		/* W: ID (e.g. file name) */
143 	unsigned char *image;	/* W: binary image */
144 	size_t length;			/* W: size of image in bytes */
145 	unsigned long driver_data;	/* W: driver-specific data */
146 };
147 
148 #define SNDRV_HWDEP_IOCTL_PVERSION	_IOR ('H', 0x00, int)
149 #define SNDRV_HWDEP_IOCTL_INFO		_IOR ('H', 0x01, struct snd_hwdep_info)
150 #define SNDRV_HWDEP_IOCTL_DSP_STATUS	_IOR('H', 0x02, struct snd_hwdep_dsp_status)
151 #define SNDRV_HWDEP_IOCTL_DSP_LOAD	_IOW('H', 0x03, struct snd_hwdep_dsp_image)
152 
153 /*****************************************************************************
154  *                                                                           *
155  *             Digital Audio (PCM) interface - /dev/snd/pcm??                *
156  *                                                                           *
157  *****************************************************************************/
158 
159 #define SNDRV_PCM_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 14)
160 
161 typedef unsigned long snd_pcm_uframes_t;
162 typedef signed long snd_pcm_sframes_t;
163 
164 enum {
165 	SNDRV_PCM_CLASS_GENERIC = 0,	/* standard mono or stereo device */
166 	SNDRV_PCM_CLASS_MULTI,		/* multichannel device */
167 	SNDRV_PCM_CLASS_MODEM,		/* software modem class */
168 	SNDRV_PCM_CLASS_DIGITIZER,	/* digitizer class */
169 	/* Don't forget to change the following: */
170 	SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER,
171 };
172 
173 enum {
174 	SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */
175 	SNDRV_PCM_SUBCLASS_MULTI_MIX,	/* multichannel subdevices are mixed together */
176 	/* Don't forget to change the following: */
177 	SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX,
178 };
179 
180 enum {
181 	SNDRV_PCM_STREAM_PLAYBACK = 0,
182 	SNDRV_PCM_STREAM_CAPTURE,
183 	SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE,
184 };
185 
186 typedef int __bitwise snd_pcm_access_t;
187 #define	SNDRV_PCM_ACCESS_MMAP_INTERLEAVED	((snd_pcm_access_t) 0) /* interleaved mmap */
188 #define	SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED	((snd_pcm_access_t) 1) /* noninterleaved mmap */
189 #define	SNDRV_PCM_ACCESS_MMAP_COMPLEX		((snd_pcm_access_t) 2) /* complex mmap */
190 #define	SNDRV_PCM_ACCESS_RW_INTERLEAVED		((snd_pcm_access_t) 3) /* readi/writei */
191 #define	SNDRV_PCM_ACCESS_RW_NONINTERLEAVED	((snd_pcm_access_t) 4) /* readn/writen */
192 #define	SNDRV_PCM_ACCESS_LAST		SNDRV_PCM_ACCESS_RW_NONINTERLEAVED
193 
194 typedef int __bitwise snd_pcm_format_t;
195 #define	SNDRV_PCM_FORMAT_S8	((snd_pcm_format_t) 0)
196 #define	SNDRV_PCM_FORMAT_U8	((snd_pcm_format_t) 1)
197 #define	SNDRV_PCM_FORMAT_S16_LE	((snd_pcm_format_t) 2)
198 #define	SNDRV_PCM_FORMAT_S16_BE	((snd_pcm_format_t) 3)
199 #define	SNDRV_PCM_FORMAT_U16_LE	((snd_pcm_format_t) 4)
200 #define	SNDRV_PCM_FORMAT_U16_BE	((snd_pcm_format_t) 5)
201 #define	SNDRV_PCM_FORMAT_S24_LE	((snd_pcm_format_t) 6) /* low three bytes */
202 #define	SNDRV_PCM_FORMAT_S24_BE	((snd_pcm_format_t) 7) /* low three bytes */
203 #define	SNDRV_PCM_FORMAT_U24_LE	((snd_pcm_format_t) 8) /* low three bytes */
204 #define	SNDRV_PCM_FORMAT_U24_BE	((snd_pcm_format_t) 9) /* low three bytes */
205 #define	SNDRV_PCM_FORMAT_S32_LE	((snd_pcm_format_t) 10)
206 #define	SNDRV_PCM_FORMAT_S32_BE	((snd_pcm_format_t) 11)
207 #define	SNDRV_PCM_FORMAT_U32_LE	((snd_pcm_format_t) 12)
208 #define	SNDRV_PCM_FORMAT_U32_BE	((snd_pcm_format_t) 13)
209 #define	SNDRV_PCM_FORMAT_FLOAT_LE	((snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
210 #define	SNDRV_PCM_FORMAT_FLOAT_BE	((snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */
211 #define	SNDRV_PCM_FORMAT_FLOAT64_LE	((snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
212 #define	SNDRV_PCM_FORMAT_FLOAT64_BE	((snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */
213 #define	SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */
214 #define	SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */
215 #define	SNDRV_PCM_FORMAT_MU_LAW		((snd_pcm_format_t) 20)
216 #define	SNDRV_PCM_FORMAT_A_LAW		((snd_pcm_format_t) 21)
217 #define	SNDRV_PCM_FORMAT_IMA_ADPCM	((snd_pcm_format_t) 22)
218 #define	SNDRV_PCM_FORMAT_MPEG		((snd_pcm_format_t) 23)
219 #define	SNDRV_PCM_FORMAT_GSM		((snd_pcm_format_t) 24)
220 #define	SNDRV_PCM_FORMAT_S20_LE	((snd_pcm_format_t) 25) /* in four bytes, LSB justified */
221 #define	SNDRV_PCM_FORMAT_S20_BE	((snd_pcm_format_t) 26) /* in four bytes, LSB justified */
222 #define	SNDRV_PCM_FORMAT_U20_LE	((snd_pcm_format_t) 27) /* in four bytes, LSB justified */
223 #define	SNDRV_PCM_FORMAT_U20_BE	((snd_pcm_format_t) 28) /* in four bytes, LSB justified */
224 /* gap in the numbering for a future standard linear format */
225 #define	SNDRV_PCM_FORMAT_SPECIAL	((snd_pcm_format_t) 31)
226 #define	SNDRV_PCM_FORMAT_S24_3LE	((snd_pcm_format_t) 32)	/* in three bytes */
227 #define	SNDRV_PCM_FORMAT_S24_3BE	((snd_pcm_format_t) 33)	/* in three bytes */
228 #define	SNDRV_PCM_FORMAT_U24_3LE	((snd_pcm_format_t) 34)	/* in three bytes */
229 #define	SNDRV_PCM_FORMAT_U24_3BE	((snd_pcm_format_t) 35)	/* in three bytes */
230 #define	SNDRV_PCM_FORMAT_S20_3LE	((snd_pcm_format_t) 36)	/* in three bytes */
231 #define	SNDRV_PCM_FORMAT_S20_3BE	((snd_pcm_format_t) 37)	/* in three bytes */
232 #define	SNDRV_PCM_FORMAT_U20_3LE	((snd_pcm_format_t) 38)	/* in three bytes */
233 #define	SNDRV_PCM_FORMAT_U20_3BE	((snd_pcm_format_t) 39)	/* in three bytes */
234 #define	SNDRV_PCM_FORMAT_S18_3LE	((snd_pcm_format_t) 40)	/* in three bytes */
235 #define	SNDRV_PCM_FORMAT_S18_3BE	((snd_pcm_format_t) 41)	/* in three bytes */
236 #define	SNDRV_PCM_FORMAT_U18_3LE	((snd_pcm_format_t) 42)	/* in three bytes */
237 #define	SNDRV_PCM_FORMAT_U18_3BE	((snd_pcm_format_t) 43)	/* in three bytes */
238 #define	SNDRV_PCM_FORMAT_G723_24	((snd_pcm_format_t) 44) /* 8 samples in 3 bytes */
239 #define	SNDRV_PCM_FORMAT_G723_24_1B	((snd_pcm_format_t) 45) /* 1 sample in 1 byte */
240 #define	SNDRV_PCM_FORMAT_G723_40	((snd_pcm_format_t) 46) /* 8 Samples in 5 bytes */
241 #define	SNDRV_PCM_FORMAT_G723_40_1B	((snd_pcm_format_t) 47) /* 1 sample in 1 byte */
242 #define	SNDRV_PCM_FORMAT_DSD_U8		((snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */
243 #define	SNDRV_PCM_FORMAT_DSD_U16_LE	((snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */
244 #define	SNDRV_PCM_FORMAT_DSD_U32_LE	((snd_pcm_format_t) 50) /* DSD, 4-byte samples DSD (x32), little endian */
245 #define	SNDRV_PCM_FORMAT_DSD_U16_BE	((snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */
246 #define	SNDRV_PCM_FORMAT_DSD_U32_BE	((snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */
247 #define	SNDRV_PCM_FORMAT_LAST		SNDRV_PCM_FORMAT_DSD_U32_BE
248 #define	SNDRV_PCM_FORMAT_FIRST		SNDRV_PCM_FORMAT_S8
249 
250 #ifdef SNDRV_LITTLE_ENDIAN
251 #define	SNDRV_PCM_FORMAT_S16		SNDRV_PCM_FORMAT_S16_LE
252 #define	SNDRV_PCM_FORMAT_U16		SNDRV_PCM_FORMAT_U16_LE
253 #define	SNDRV_PCM_FORMAT_S24		SNDRV_PCM_FORMAT_S24_LE
254 #define	SNDRV_PCM_FORMAT_U24		SNDRV_PCM_FORMAT_U24_LE
255 #define	SNDRV_PCM_FORMAT_S32		SNDRV_PCM_FORMAT_S32_LE
256 #define	SNDRV_PCM_FORMAT_U32		SNDRV_PCM_FORMAT_U32_LE
257 #define	SNDRV_PCM_FORMAT_FLOAT		SNDRV_PCM_FORMAT_FLOAT_LE
258 #define	SNDRV_PCM_FORMAT_FLOAT64	SNDRV_PCM_FORMAT_FLOAT64_LE
259 #define	SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE
260 #define	SNDRV_PCM_FORMAT_S20		SNDRV_PCM_FORMAT_S20_LE
261 #define	SNDRV_PCM_FORMAT_U20		SNDRV_PCM_FORMAT_U20_LE
262 #endif
263 #ifdef SNDRV_BIG_ENDIAN
264 #define	SNDRV_PCM_FORMAT_S16		SNDRV_PCM_FORMAT_S16_BE
265 #define	SNDRV_PCM_FORMAT_U16		SNDRV_PCM_FORMAT_U16_BE
266 #define	SNDRV_PCM_FORMAT_S24		SNDRV_PCM_FORMAT_S24_BE
267 #define	SNDRV_PCM_FORMAT_U24		SNDRV_PCM_FORMAT_U24_BE
268 #define	SNDRV_PCM_FORMAT_S32		SNDRV_PCM_FORMAT_S32_BE
269 #define	SNDRV_PCM_FORMAT_U32		SNDRV_PCM_FORMAT_U32_BE
270 #define	SNDRV_PCM_FORMAT_FLOAT		SNDRV_PCM_FORMAT_FLOAT_BE
271 #define	SNDRV_PCM_FORMAT_FLOAT64	SNDRV_PCM_FORMAT_FLOAT64_BE
272 #define	SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE
273 #define	SNDRV_PCM_FORMAT_S20		SNDRV_PCM_FORMAT_S20_BE
274 #define	SNDRV_PCM_FORMAT_U20		SNDRV_PCM_FORMAT_U20_BE
275 #endif
276 
277 typedef int __bitwise snd_pcm_subformat_t;
278 #define	SNDRV_PCM_SUBFORMAT_STD		((snd_pcm_subformat_t) 0)
279 #define	SNDRV_PCM_SUBFORMAT_LAST	SNDRV_PCM_SUBFORMAT_STD
280 
281 #define SNDRV_PCM_INFO_MMAP		0x00000001	/* hardware supports mmap */
282 #define SNDRV_PCM_INFO_MMAP_VALID	0x00000002	/* period data are valid during transfer */
283 #define SNDRV_PCM_INFO_DOUBLE		0x00000004	/* Double buffering needed for PCM start/stop */
284 #define SNDRV_PCM_INFO_BATCH		0x00000010	/* double buffering */
285 #define SNDRV_PCM_INFO_SYNC_APPLPTR	0x00000020	/* need the explicit sync of appl_ptr update */
286 #define SNDRV_PCM_INFO_INTERLEAVED	0x00000100	/* channels are interleaved */
287 #define SNDRV_PCM_INFO_NONINTERLEAVED	0x00000200	/* channels are not interleaved */
288 #define SNDRV_PCM_INFO_COMPLEX		0x00000400	/* complex frame organization (mmap only) */
289 #define SNDRV_PCM_INFO_BLOCK_TRANSFER	0x00010000	/* hardware transfer block of samples */
290 #define SNDRV_PCM_INFO_OVERRANGE	0x00020000	/* hardware supports ADC (capture) overrange detection */
291 #define SNDRV_PCM_INFO_RESUME		0x00040000	/* hardware supports stream resume after suspend */
292 #define SNDRV_PCM_INFO_PAUSE		0x00080000	/* pause ioctl is supported */
293 #define SNDRV_PCM_INFO_HALF_DUPLEX	0x00100000	/* only half duplex */
294 #define SNDRV_PCM_INFO_JOINT_DUPLEX	0x00200000	/* playback and capture stream are somewhat correlated */
295 #define SNDRV_PCM_INFO_SYNC_START	0x00400000	/* pcm support some kind of sync go */
296 #define SNDRV_PCM_INFO_NO_PERIOD_WAKEUP	0x00800000	/* period wakeup can be disabled */
297 #define SNDRV_PCM_INFO_HAS_WALL_CLOCK   0x01000000      /* (Deprecated)has audio wall clock for audio/system time sync */
298 #define SNDRV_PCM_INFO_HAS_LINK_ATIME              0x01000000  /* report hardware link audio time, reset on startup */
299 #define SNDRV_PCM_INFO_HAS_LINK_ABSOLUTE_ATIME     0x02000000  /* report absolute hardware link audio time, not reset on startup */
300 #define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME    0x04000000  /* report estimated link audio time */
301 #define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000  /* report synchronized audio/system time */
302 
303 #define SNDRV_PCM_INFO_DRAIN_TRIGGER	0x40000000		/* internal kernel flag - trigger in drain */
304 #define SNDRV_PCM_INFO_FIFO_IN_FRAMES	0x80000000	/* internal kernel flag - FIFO size is in frames */
305 
306 
307 
308 typedef int __bitwise snd_pcm_state_t;
309 #define	SNDRV_PCM_STATE_OPEN		((snd_pcm_state_t) 0) /* stream is open */
310 #define	SNDRV_PCM_STATE_SETUP		((snd_pcm_state_t) 1) /* stream has a setup */
311 #define	SNDRV_PCM_STATE_PREPARED	((snd_pcm_state_t) 2) /* stream is ready to start */
312 #define	SNDRV_PCM_STATE_RUNNING		((snd_pcm_state_t) 3) /* stream is running */
313 #define	SNDRV_PCM_STATE_XRUN		((snd_pcm_state_t) 4) /* stream reached an xrun */
314 #define	SNDRV_PCM_STATE_DRAINING	((snd_pcm_state_t) 5) /* stream is draining */
315 #define	SNDRV_PCM_STATE_PAUSED		((snd_pcm_state_t) 6) /* stream is paused */
316 #define	SNDRV_PCM_STATE_SUSPENDED	((snd_pcm_state_t) 7) /* hardware is suspended */
317 #define	SNDRV_PCM_STATE_DISCONNECTED	((snd_pcm_state_t) 8) /* hardware is disconnected */
318 #define	SNDRV_PCM_STATE_LAST		SNDRV_PCM_STATE_DISCONNECTED
319 
320 enum {
321 	SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
322 	SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
323 	SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
324 };
325 
326 union snd_pcm_sync_id {
327 	unsigned char id[16];
328 	unsigned short id16[8];
329 	unsigned int id32[4];
330 };
331 
332 struct snd_pcm_info {
333 	unsigned int device;		/* RO/WR (control): device number */
334 	unsigned int subdevice;		/* RO/WR (control): subdevice number */
335 	int stream;			/* RO/WR (control): stream direction */
336 	int card;			/* R: card number */
337 	unsigned char id[64];		/* ID (user selectable) */
338 	unsigned char name[80];		/* name of this device */
339 	unsigned char subname[32];	/* subdevice name */
340 	int dev_class;			/* SNDRV_PCM_CLASS_* */
341 	int dev_subclass;		/* SNDRV_PCM_SUBCLASS_* */
342 	unsigned int subdevices_count;
343 	unsigned int subdevices_avail;
344 	union snd_pcm_sync_id sync;	/* hardware synchronization ID */
345 	unsigned char reserved[64];	/* reserved for future... */
346 };
347 
348 typedef int snd_pcm_hw_param_t;
349 #define	SNDRV_PCM_HW_PARAM_ACCESS	0	/* Access type */
350 #define	SNDRV_PCM_HW_PARAM_FORMAT	1	/* Format */
351 #define	SNDRV_PCM_HW_PARAM_SUBFORMAT	2	/* Subformat */
352 #define	SNDRV_PCM_HW_PARAM_FIRST_MASK	SNDRV_PCM_HW_PARAM_ACCESS
353 #define	SNDRV_PCM_HW_PARAM_LAST_MASK	SNDRV_PCM_HW_PARAM_SUBFORMAT
354 
355 #define	SNDRV_PCM_HW_PARAM_SAMPLE_BITS	8	/* Bits per sample */
356 #define	SNDRV_PCM_HW_PARAM_FRAME_BITS	9	/* Bits per frame */
357 #define	SNDRV_PCM_HW_PARAM_CHANNELS	10	/* Channels */
358 #define	SNDRV_PCM_HW_PARAM_RATE		11	/* Approx rate */
359 #define	SNDRV_PCM_HW_PARAM_PERIOD_TIME	12	/* Approx distance between
360 						 * interrupts in us
361 						 */
362 #define	SNDRV_PCM_HW_PARAM_PERIOD_SIZE	13	/* Approx frames between
363 						 * interrupts
364 						 */
365 #define	SNDRV_PCM_HW_PARAM_PERIOD_BYTES	14	/* Approx bytes between
366 						 * interrupts
367 						 */
368 #define	SNDRV_PCM_HW_PARAM_PERIODS	15	/* Approx interrupts per
369 						 * buffer
370 						 */
371 #define	SNDRV_PCM_HW_PARAM_BUFFER_TIME	16	/* Approx duration of buffer
372 						 * in us
373 						 */
374 #define	SNDRV_PCM_HW_PARAM_BUFFER_SIZE	17	/* Size of buffer in frames */
375 #define	SNDRV_PCM_HW_PARAM_BUFFER_BYTES	18	/* Size of buffer in bytes */
376 #define	SNDRV_PCM_HW_PARAM_TICK_TIME	19	/* Approx tick duration in us */
377 #define	SNDRV_PCM_HW_PARAM_FIRST_INTERVAL	SNDRV_PCM_HW_PARAM_SAMPLE_BITS
378 #define	SNDRV_PCM_HW_PARAM_LAST_INTERVAL	SNDRV_PCM_HW_PARAM_TICK_TIME
379 
380 #define SNDRV_PCM_HW_PARAMS_NORESAMPLE	(1<<0)	/* avoid rate resampling */
381 #define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER	(1<<1)	/* export buffer */
382 #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP	(1<<2)	/* disable period wakeups */
383 
384 struct snd_interval {
385 	unsigned int min, max;
386 	unsigned int openmin:1,
387 		     openmax:1,
388 		     integer:1,
389 		     empty:1;
390 };
391 
392 #define SNDRV_MASK_MAX	256
393 
394 struct snd_mask {
395 	__u32 bits[(SNDRV_MASK_MAX+31)/32];
396 };
397 
398 struct snd_pcm_hw_params {
399 	unsigned int flags;
400 	struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
401 			       SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
402 	struct snd_mask mres[5];	/* reserved masks */
403 	struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
404 				        SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
405 	struct snd_interval ires[9];	/* reserved intervals */
406 	unsigned int rmask;		/* W: requested masks */
407 	unsigned int cmask;		/* R: changed masks */
408 	unsigned int info;		/* R: Info flags for returned setup */
409 	unsigned int msbits;		/* R: used most significant bits */
410 	unsigned int rate_num;		/* R: rate numerator */
411 	unsigned int rate_den;		/* R: rate denominator */
412 	snd_pcm_uframes_t fifo_size;	/* R: chip FIFO size in frames */
413 	unsigned char reserved[64];	/* reserved for future */
414 };
415 
416 enum {
417 	SNDRV_PCM_TSTAMP_NONE = 0,
418 	SNDRV_PCM_TSTAMP_ENABLE,
419 	SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
420 };
421 
422 struct snd_pcm_sw_params {
423 	int tstamp_mode;			/* timestamp mode */
424 	unsigned int period_step;
425 	unsigned int sleep_min;			/* min ticks to sleep */
426 	snd_pcm_uframes_t avail_min;		/* min avail frames for wakeup */
427 	snd_pcm_uframes_t xfer_align;		/* obsolete: xfer size need to be a multiple */
428 	snd_pcm_uframes_t start_threshold;	/* min hw_avail frames for automatic start */
429 	snd_pcm_uframes_t stop_threshold;	/* min avail frames for automatic stop */
430 	snd_pcm_uframes_t silence_threshold;	/* min distance from noise for silence filling */
431 	snd_pcm_uframes_t silence_size;		/* silence block size */
432 	snd_pcm_uframes_t boundary;		/* pointers wrap point */
433 	unsigned int proto;			/* protocol version */
434 	unsigned int tstamp_type;		/* timestamp type (req. proto >= 2.0.12) */
435 	unsigned char reserved[56];		/* reserved for future */
436 };
437 
438 struct snd_pcm_channel_info {
439 	unsigned int channel;
440 	__kernel_off_t offset;		/* mmap offset */
441 	unsigned int first;		/* offset to first sample in bits */
442 	unsigned int step;		/* samples distance in bits */
443 };
444 
445 enum {
446 	/*
447 	 *  first definition for backwards compatibility only,
448 	 *  maps to wallclock/link time for HDAudio playback and DEFAULT/DMA time for everything else
449 	 */
450 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_COMPAT = 0,
451 
452 	/* timestamp definitions */
453 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT = 1,           /* DMA time, reported as per hw_ptr */
454 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK = 2,	           /* link time reported by sample or wallclock counter, reset on startup */
455 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ABSOLUTE = 3,	   /* link time reported by sample or wallclock counter, not reset on startup */
456 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_ESTIMATED = 4,    /* link time estimated indirectly */
457 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED = 5, /* link time synchronized with system time */
458 	SNDRV_PCM_AUDIO_TSTAMP_TYPE_LAST = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED
459 };
460 
461 struct snd_pcm_status {
462 	snd_pcm_state_t state;		/* stream state */
463 	struct timespec trigger_tstamp;	/* time when stream was started/stopped/paused */
464 	struct timespec tstamp;		/* reference timestamp */
465 	snd_pcm_uframes_t appl_ptr;	/* appl ptr */
466 	snd_pcm_uframes_t hw_ptr;	/* hw ptr */
467 	snd_pcm_sframes_t delay;	/* current delay in frames */
468 	snd_pcm_uframes_t avail;	/* number of frames available */
469 	snd_pcm_uframes_t avail_max;	/* max frames available on hw since last status */
470 	snd_pcm_uframes_t overrange;	/* count of ADC (capture) overrange detections from last status */
471 	snd_pcm_state_t suspended_state; /* suspended stream state */
472 	__u32 audio_tstamp_data;	 /* needed for 64-bit alignment, used for configs/report to/from userspace */
473 	struct timespec audio_tstamp;	/* sample counter, wall clock, PHC or on-demand sync'ed */
474 	struct timespec driver_tstamp;	/* useful in case reference system tstamp is reported with delay */
475 	__u32 audio_tstamp_accuracy;	/* in ns units, only valid if indicated in audio_tstamp_data */
476 	unsigned char reserved[52-2*sizeof(struct timespec)]; /* must be filled with zero */
477 };
478 
479 struct snd_pcm_mmap_status {
480 	snd_pcm_state_t state;		/* RO: state - SNDRV_PCM_STATE_XXXX */
481 	int pad1;			/* Needed for 64 bit alignment */
482 	snd_pcm_uframes_t hw_ptr;	/* RO: hw ptr (0...boundary-1) */
483 	struct timespec tstamp;		/* Timestamp */
484 	snd_pcm_state_t suspended_state; /* RO: suspended stream state */
485 	struct timespec audio_tstamp;	/* from sample counter or wall clock */
486 };
487 
488 struct snd_pcm_mmap_control {
489 	snd_pcm_uframes_t appl_ptr;	/* RW: appl ptr (0...boundary-1) */
490 	snd_pcm_uframes_t avail_min;	/* RW: min available frames for wakeup */
491 };
492 
493 #define SNDRV_PCM_SYNC_PTR_HWSYNC	(1<<0)	/* execute hwsync */
494 #define SNDRV_PCM_SYNC_PTR_APPL		(1<<1)	/* get appl_ptr from driver (r/w op) */
495 #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN	(1<<2)	/* get avail_min from driver */
496 
497 struct snd_pcm_sync_ptr {
498 	unsigned int flags;
499 	union {
500 		struct snd_pcm_mmap_status status;
501 		unsigned char reserved[64];
502 	} s;
503 	union {
504 		struct snd_pcm_mmap_control control;
505 		unsigned char reserved[64];
506 	} c;
507 };
508 
509 struct snd_xferi {
510 	snd_pcm_sframes_t result;
511 	void *buf;
512 	snd_pcm_uframes_t frames;
513 };
514 
515 struct snd_xfern {
516 	snd_pcm_sframes_t result;
517 	void * *bufs;
518 	snd_pcm_uframes_t frames;
519 };
520 
521 enum {
522 	SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0,	/* gettimeofday equivalent */
523 	SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,	/* posix_clock_monotonic equivalent */
524 	SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW,    /* monotonic_raw (no NTP) */
525 	SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC_RAW,
526 };
527 
528 /* channel positions */
529 enum {
530 	SNDRV_CHMAP_UNKNOWN = 0,
531 	SNDRV_CHMAP_NA,		/* N/A, silent */
532 	SNDRV_CHMAP_MONO,	/* mono stream */
533 	/* this follows the alsa-lib mixer channel value + 3 */
534 	SNDRV_CHMAP_FL,		/* front left */
535 	SNDRV_CHMAP_FR,		/* front right */
536 	SNDRV_CHMAP_RL,		/* rear left */
537 	SNDRV_CHMAP_RR,		/* rear right */
538 	SNDRV_CHMAP_FC,		/* front center */
539 	SNDRV_CHMAP_LFE,	/* LFE */
540 	SNDRV_CHMAP_SL,		/* side left */
541 	SNDRV_CHMAP_SR,		/* side right */
542 	SNDRV_CHMAP_RC,		/* rear center */
543 	/* new definitions */
544 	SNDRV_CHMAP_FLC,	/* front left center */
545 	SNDRV_CHMAP_FRC,	/* front right center */
546 	SNDRV_CHMAP_RLC,	/* rear left center */
547 	SNDRV_CHMAP_RRC,	/* rear right center */
548 	SNDRV_CHMAP_FLW,	/* front left wide */
549 	SNDRV_CHMAP_FRW,	/* front right wide */
550 	SNDRV_CHMAP_FLH,	/* front left high */
551 	SNDRV_CHMAP_FCH,	/* front center high */
552 	SNDRV_CHMAP_FRH,	/* front right high */
553 	SNDRV_CHMAP_TC,		/* top center */
554 	SNDRV_CHMAP_TFL,	/* top front left */
555 	SNDRV_CHMAP_TFR,	/* top front right */
556 	SNDRV_CHMAP_TFC,	/* top front center */
557 	SNDRV_CHMAP_TRL,	/* top rear left */
558 	SNDRV_CHMAP_TRR,	/* top rear right */
559 	SNDRV_CHMAP_TRC,	/* top rear center */
560 	/* new definitions for UAC2 */
561 	SNDRV_CHMAP_TFLC,	/* top front left center */
562 	SNDRV_CHMAP_TFRC,	/* top front right center */
563 	SNDRV_CHMAP_TSL,	/* top side left */
564 	SNDRV_CHMAP_TSR,	/* top side right */
565 	SNDRV_CHMAP_LLFE,	/* left LFE */
566 	SNDRV_CHMAP_RLFE,	/* right LFE */
567 	SNDRV_CHMAP_BC,		/* bottom center */
568 	SNDRV_CHMAP_BLC,	/* bottom left center */
569 	SNDRV_CHMAP_BRC,	/* bottom right center */
570 	SNDRV_CHMAP_LAST = SNDRV_CHMAP_BRC,
571 };
572 
573 #define SNDRV_CHMAP_POSITION_MASK	0xffff
574 #define SNDRV_CHMAP_PHASE_INVERSE	(0x01 << 16)
575 #define SNDRV_CHMAP_DRIVER_SPEC		(0x02 << 16)
576 
577 #define SNDRV_PCM_IOCTL_PVERSION	_IOR('A', 0x00, int)
578 #define SNDRV_PCM_IOCTL_INFO		_IOR('A', 0x01, struct snd_pcm_info)
579 #define SNDRV_PCM_IOCTL_TSTAMP		_IOW('A', 0x02, int)
580 #define SNDRV_PCM_IOCTL_TTSTAMP		_IOW('A', 0x03, int)
581 #define SNDRV_PCM_IOCTL_USER_PVERSION	_IOW('A', 0x04, int)
582 #define SNDRV_PCM_IOCTL_HW_REFINE	_IOWR('A', 0x10, struct snd_pcm_hw_params)
583 #define SNDRV_PCM_IOCTL_HW_PARAMS	_IOWR('A', 0x11, struct snd_pcm_hw_params)
584 #define SNDRV_PCM_IOCTL_HW_FREE		_IO('A', 0x12)
585 #define SNDRV_PCM_IOCTL_SW_PARAMS	_IOWR('A', 0x13, struct snd_pcm_sw_params)
586 #define SNDRV_PCM_IOCTL_STATUS		_IOR('A', 0x20, struct snd_pcm_status)
587 #define SNDRV_PCM_IOCTL_DELAY		_IOR('A', 0x21, snd_pcm_sframes_t)
588 #define SNDRV_PCM_IOCTL_HWSYNC		_IO('A', 0x22)
589 #define SNDRV_PCM_IOCTL_SYNC_PTR	_IOWR('A', 0x23, struct snd_pcm_sync_ptr)
590 #define SNDRV_PCM_IOCTL_STATUS_EXT	_IOWR('A', 0x24, struct snd_pcm_status)
591 #define SNDRV_PCM_IOCTL_CHANNEL_INFO	_IOR('A', 0x32, struct snd_pcm_channel_info)
592 #define SNDRV_PCM_IOCTL_PREPARE		_IO('A', 0x40)
593 #define SNDRV_PCM_IOCTL_RESET		_IO('A', 0x41)
594 #define SNDRV_PCM_IOCTL_START		_IO('A', 0x42)
595 #define SNDRV_PCM_IOCTL_DROP		_IO('A', 0x43)
596 #define SNDRV_PCM_IOCTL_DRAIN		_IO('A', 0x44)
597 #define SNDRV_PCM_IOCTL_PAUSE		_IOW('A', 0x45, int)
598 #define SNDRV_PCM_IOCTL_REWIND		_IOW('A', 0x46, snd_pcm_uframes_t)
599 #define SNDRV_PCM_IOCTL_RESUME		_IO('A', 0x47)
600 #define SNDRV_PCM_IOCTL_XRUN		_IO('A', 0x48)
601 #define SNDRV_PCM_IOCTL_FORWARD		_IOW('A', 0x49, snd_pcm_uframes_t)
602 #define SNDRV_PCM_IOCTL_WRITEI_FRAMES	_IOW('A', 0x50, struct snd_xferi)
603 #define SNDRV_PCM_IOCTL_READI_FRAMES	_IOR('A', 0x51, struct snd_xferi)
604 #define SNDRV_PCM_IOCTL_WRITEN_FRAMES	_IOW('A', 0x52, struct snd_xfern)
605 #define SNDRV_PCM_IOCTL_READN_FRAMES	_IOR('A', 0x53, struct snd_xfern)
606 #define SNDRV_PCM_IOCTL_LINK		_IOW('A', 0x60, int)
607 #define SNDRV_PCM_IOCTL_UNLINK		_IO('A', 0x61)
608 
609 /*****************************************************************************
610  *                                                                           *
611  *                            MIDI v1.0 interface                            *
612  *                                                                           *
613  *****************************************************************************/
614 
615 /*
616  *  Raw MIDI section - /dev/snd/midi??
617  */
618 
619 #define SNDRV_RAWMIDI_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 0)
620 
621 enum {
622 	SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
623 	SNDRV_RAWMIDI_STREAM_INPUT,
624 	SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT,
625 };
626 
627 #define SNDRV_RAWMIDI_INFO_OUTPUT		0x00000001
628 #define SNDRV_RAWMIDI_INFO_INPUT		0x00000002
629 #define SNDRV_RAWMIDI_INFO_DUPLEX		0x00000004
630 
631 struct snd_rawmidi_info {
632 	unsigned int device;		/* RO/WR (control): device number */
633 	unsigned int subdevice;		/* RO/WR (control): subdevice number */
634 	int stream;			/* WR: stream */
635 	int card;			/* R: card number */
636 	unsigned int flags;		/* SNDRV_RAWMIDI_INFO_XXXX */
637 	unsigned char id[64];		/* ID (user selectable) */
638 	unsigned char name[80];		/* name of device */
639 	unsigned char subname[32];	/* name of active or selected subdevice */
640 	unsigned int subdevices_count;
641 	unsigned int subdevices_avail;
642 	unsigned char reserved[64];	/* reserved for future use */
643 };
644 
645 struct snd_rawmidi_params {
646 	int stream;
647 	size_t buffer_size;		/* queue size in bytes */
648 	size_t avail_min;		/* minimum avail bytes for wakeup */
649 	unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */
650 	unsigned char reserved[16];	/* reserved for future use */
651 };
652 
653 struct snd_rawmidi_status {
654 	int stream;
655 	struct timespec tstamp;		/* Timestamp */
656 	size_t avail;			/* available bytes */
657 	size_t xruns;			/* count of overruns since last status (in bytes) */
658 	unsigned char reserved[16];	/* reserved for future use */
659 };
660 
661 #define SNDRV_RAWMIDI_IOCTL_PVERSION	_IOR('W', 0x00, int)
662 #define SNDRV_RAWMIDI_IOCTL_INFO	_IOR('W', 0x01, struct snd_rawmidi_info)
663 #define SNDRV_RAWMIDI_IOCTL_PARAMS	_IOWR('W', 0x10, struct snd_rawmidi_params)
664 #define SNDRV_RAWMIDI_IOCTL_STATUS	_IOWR('W', 0x20, struct snd_rawmidi_status)
665 #define SNDRV_RAWMIDI_IOCTL_DROP	_IOW('W', 0x30, int)
666 #define SNDRV_RAWMIDI_IOCTL_DRAIN	_IOW('W', 0x31, int)
667 
668 /*
669  *  Timer section - /dev/snd/timer
670  */
671 
672 #define SNDRV_TIMER_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 6)
673 
674 enum {
675 	SNDRV_TIMER_CLASS_NONE = -1,
676 	SNDRV_TIMER_CLASS_SLAVE = 0,
677 	SNDRV_TIMER_CLASS_GLOBAL,
678 	SNDRV_TIMER_CLASS_CARD,
679 	SNDRV_TIMER_CLASS_PCM,
680 	SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM,
681 };
682 
683 /* slave timer classes */
684 enum {
685 	SNDRV_TIMER_SCLASS_NONE = 0,
686 	SNDRV_TIMER_SCLASS_APPLICATION,
687 	SNDRV_TIMER_SCLASS_SEQUENCER,		/* alias */
688 	SNDRV_TIMER_SCLASS_OSS_SEQUENCER,	/* alias */
689 	SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER,
690 };
691 
692 /* global timers (device member) */
693 #define SNDRV_TIMER_GLOBAL_SYSTEM	0
694 #define SNDRV_TIMER_GLOBAL_RTC		1	/* unused */
695 #define SNDRV_TIMER_GLOBAL_HPET		2
696 #define SNDRV_TIMER_GLOBAL_HRTIMER	3
697 
698 /* info flags */
699 #define SNDRV_TIMER_FLG_SLAVE		(1<<0)	/* cannot be controlled */
700 
701 struct snd_timer_id {
702 	int dev_class;
703 	int dev_sclass;
704 	int card;
705 	int device;
706 	int subdevice;
707 };
708 
709 struct snd_timer_ginfo {
710 	struct snd_timer_id tid;	/* requested timer ID */
711 	unsigned int flags;		/* timer flags - SNDRV_TIMER_FLG_* */
712 	int card;			/* card number */
713 	unsigned char id[64];		/* timer identification */
714 	unsigned char name[80];		/* timer name */
715 	unsigned long reserved0;	/* reserved for future use */
716 	unsigned long resolution;	/* average period resolution in ns */
717 	unsigned long resolution_min;	/* minimal period resolution in ns */
718 	unsigned long resolution_max;	/* maximal period resolution in ns */
719 	unsigned int clients;		/* active timer clients */
720 	unsigned char reserved[32];
721 };
722 
723 struct snd_timer_gparams {
724 	struct snd_timer_id tid;	/* requested timer ID */
725 	unsigned long period_num;	/* requested precise period duration (in seconds) - numerator */
726 	unsigned long period_den;	/* requested precise period duration (in seconds) - denominator */
727 	unsigned char reserved[32];
728 };
729 
730 struct snd_timer_gstatus {
731 	struct snd_timer_id tid;	/* requested timer ID */
732 	unsigned long resolution;	/* current period resolution in ns */
733 	unsigned long resolution_num;	/* precise current period resolution (in seconds) - numerator */
734 	unsigned long resolution_den;	/* precise current period resolution (in seconds) - denominator */
735 	unsigned char reserved[32];
736 };
737 
738 struct snd_timer_select {
739 	struct snd_timer_id id;	/* bind to timer ID */
740 	unsigned char reserved[32];	/* reserved */
741 };
742 
743 struct snd_timer_info {
744 	unsigned int flags;		/* timer flags - SNDRV_TIMER_FLG_* */
745 	int card;			/* card number */
746 	unsigned char id[64];		/* timer identificator */
747 	unsigned char name[80];		/* timer name */
748 	unsigned long reserved0;	/* reserved for future use */
749 	unsigned long resolution;	/* average period resolution in ns */
750 	unsigned char reserved[64];	/* reserved */
751 };
752 
753 #define SNDRV_TIMER_PSFLG_AUTO		(1<<0)	/* auto start, otherwise one-shot */
754 #define SNDRV_TIMER_PSFLG_EXCLUSIVE	(1<<1)	/* exclusive use, precise start/stop/pause/continue */
755 #define SNDRV_TIMER_PSFLG_EARLY_EVENT	(1<<2)	/* write early event to the poll queue */
756 
757 struct snd_timer_params {
758 	unsigned int flags;		/* flags - SNDRV_MIXER_PSFLG_* */
759 	unsigned int ticks;		/* requested resolution in ticks */
760 	unsigned int queue_size;	/* total size of queue (32-1024) */
761 	unsigned int reserved0;		/* reserved, was: failure locations */
762 	unsigned int filter;		/* event filter (bitmask of SNDRV_TIMER_EVENT_*) */
763 	unsigned char reserved[60];	/* reserved */
764 };
765 
766 struct snd_timer_status {
767 	struct timespec tstamp;		/* Timestamp - last update */
768 	unsigned int resolution;	/* current period resolution in ns */
769 	unsigned int lost;		/* counter of master tick lost */
770 	unsigned int overrun;		/* count of read queue overruns */
771 	unsigned int queue;		/* used queue size */
772 	unsigned char reserved[64];	/* reserved */
773 };
774 
775 #define SNDRV_TIMER_IOCTL_PVERSION	_IOR('T', 0x00, int)
776 #define SNDRV_TIMER_IOCTL_NEXT_DEVICE	_IOWR('T', 0x01, struct snd_timer_id)
777 #define SNDRV_TIMER_IOCTL_TREAD		_IOW('T', 0x02, int)
778 #define SNDRV_TIMER_IOCTL_GINFO		_IOWR('T', 0x03, struct snd_timer_ginfo)
779 #define SNDRV_TIMER_IOCTL_GPARAMS	_IOW('T', 0x04, struct snd_timer_gparams)
780 #define SNDRV_TIMER_IOCTL_GSTATUS	_IOWR('T', 0x05, struct snd_timer_gstatus)
781 #define SNDRV_TIMER_IOCTL_SELECT	_IOW('T', 0x10, struct snd_timer_select)
782 #define SNDRV_TIMER_IOCTL_INFO		_IOR('T', 0x11, struct snd_timer_info)
783 #define SNDRV_TIMER_IOCTL_PARAMS	_IOW('T', 0x12, struct snd_timer_params)
784 #define SNDRV_TIMER_IOCTL_STATUS	_IOR('T', 0x14, struct snd_timer_status)
785 /* The following four ioctls are changed since 1.0.9 due to confliction */
786 #define SNDRV_TIMER_IOCTL_START		_IO('T', 0xa0)
787 #define SNDRV_TIMER_IOCTL_STOP		_IO('T', 0xa1)
788 #define SNDRV_TIMER_IOCTL_CONTINUE	_IO('T', 0xa2)
789 #define SNDRV_TIMER_IOCTL_PAUSE		_IO('T', 0xa3)
790 
791 struct snd_timer_read {
792 	unsigned int resolution;
793 	unsigned int ticks;
794 };
795 
796 enum {
797 	SNDRV_TIMER_EVENT_RESOLUTION = 0,	/* val = resolution in ns */
798 	SNDRV_TIMER_EVENT_TICK,			/* val = ticks */
799 	SNDRV_TIMER_EVENT_START,		/* val = resolution in ns */
800 	SNDRV_TIMER_EVENT_STOP,			/* val = 0 */
801 	SNDRV_TIMER_EVENT_CONTINUE,		/* val = resolution in ns */
802 	SNDRV_TIMER_EVENT_PAUSE,		/* val = 0 */
803 	SNDRV_TIMER_EVENT_EARLY,		/* val = 0, early event */
804 	SNDRV_TIMER_EVENT_SUSPEND,		/* val = 0 */
805 	SNDRV_TIMER_EVENT_RESUME,		/* val = resolution in ns */
806 	/* master timer events for slave timer instances */
807 	SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
808 	SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,
809 	SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10,
810 	SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10,
811 	SNDRV_TIMER_EVENT_MSUSPEND = SNDRV_TIMER_EVENT_SUSPEND + 10,
812 	SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10,
813 };
814 
815 struct snd_timer_tread {
816 	int event;
817 	struct timespec tstamp;
818 	unsigned int val;
819 };
820 
821 /****************************************************************************
822  *                                                                          *
823  *        Section for driver control interface - /dev/snd/control?          *
824  *                                                                          *
825  ****************************************************************************/
826 
827 #define SNDRV_CTL_VERSION		SNDRV_PROTOCOL_VERSION(2, 0, 7)
828 
829 struct snd_ctl_card_info {
830 	int card;			/* card number */
831 	int pad;			/* reserved for future (was type) */
832 	unsigned char id[16];		/* ID of card (user selectable) */
833 	unsigned char driver[16];	/* Driver name */
834 	unsigned char name[32];		/* Short name of soundcard */
835 	unsigned char longname[80];	/* name + info text about soundcard */
836 	unsigned char reserved_[16];	/* reserved for future (was ID of mixer) */
837 	unsigned char mixername[80];	/* visual mixer identification */
838 	unsigned char components[128];	/* card components / fine identification, delimited with one space (AC97 etc..) */
839 };
840 
841 typedef int __bitwise snd_ctl_elem_type_t;
842 #define	SNDRV_CTL_ELEM_TYPE_NONE	((snd_ctl_elem_type_t) 0) /* invalid */
843 #define	SNDRV_CTL_ELEM_TYPE_BOOLEAN	((snd_ctl_elem_type_t) 1) /* boolean type */
844 #define	SNDRV_CTL_ELEM_TYPE_INTEGER	((snd_ctl_elem_type_t) 2) /* integer type */
845 #define	SNDRV_CTL_ELEM_TYPE_ENUMERATED	((snd_ctl_elem_type_t) 3) /* enumerated type */
846 #define	SNDRV_CTL_ELEM_TYPE_BYTES	((snd_ctl_elem_type_t) 4) /* byte array */
847 #define	SNDRV_CTL_ELEM_TYPE_IEC958	((snd_ctl_elem_type_t) 5) /* IEC958 (S/PDIF) setup */
848 #define	SNDRV_CTL_ELEM_TYPE_INTEGER64	((snd_ctl_elem_type_t) 6) /* 64-bit integer type */
849 #define	SNDRV_CTL_ELEM_TYPE_LAST	SNDRV_CTL_ELEM_TYPE_INTEGER64
850 
851 typedef int __bitwise snd_ctl_elem_iface_t;
852 #define	SNDRV_CTL_ELEM_IFACE_CARD	((snd_ctl_elem_iface_t) 0) /* global control */
853 #define	SNDRV_CTL_ELEM_IFACE_HWDEP	((snd_ctl_elem_iface_t) 1) /* hardware dependent device */
854 #define	SNDRV_CTL_ELEM_IFACE_MIXER	((snd_ctl_elem_iface_t) 2) /* virtual mixer device */
855 #define	SNDRV_CTL_ELEM_IFACE_PCM	((snd_ctl_elem_iface_t) 3) /* PCM device */
856 #define	SNDRV_CTL_ELEM_IFACE_RAWMIDI	((snd_ctl_elem_iface_t) 4) /* RawMidi device */
857 #define	SNDRV_CTL_ELEM_IFACE_TIMER	((snd_ctl_elem_iface_t) 5) /* timer device */
858 #define	SNDRV_CTL_ELEM_IFACE_SEQUENCER	((snd_ctl_elem_iface_t) 6) /* sequencer client */
859 #define	SNDRV_CTL_ELEM_IFACE_LAST	SNDRV_CTL_ELEM_IFACE_SEQUENCER
860 
861 #define SNDRV_CTL_ELEM_ACCESS_READ		(1<<0)
862 #define SNDRV_CTL_ELEM_ACCESS_WRITE		(1<<1)
863 #define SNDRV_CTL_ELEM_ACCESS_READWRITE		(SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
864 #define SNDRV_CTL_ELEM_ACCESS_VOLATILE		(1<<2)	/* control value may be changed without a notification */
865 #define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP		(1<<3)	/* when was control changed */
866 #define SNDRV_CTL_ELEM_ACCESS_TLV_READ		(1<<4)	/* TLV read is possible */
867 #define SNDRV_CTL_ELEM_ACCESS_TLV_WRITE		(1<<5)	/* TLV write is possible */
868 #define SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE	(SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
869 #define SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND	(1<<6)	/* TLV command is possible */
870 #define SNDRV_CTL_ELEM_ACCESS_INACTIVE		(1<<8)	/* control does actually nothing, but may be updated */
871 #define SNDRV_CTL_ELEM_ACCESS_LOCK		(1<<9)	/* write lock */
872 #define SNDRV_CTL_ELEM_ACCESS_OWNER		(1<<10)	/* write lock owner */
873 #define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK	(1<<28)	/* kernel use a TLV callback */
874 #define SNDRV_CTL_ELEM_ACCESS_USER		(1<<29) /* user space element */
875 /* bits 30 and 31 are obsoleted (for indirect access) */
876 
877 /* for further details see the ACPI and PCI power management specification */
878 #define SNDRV_CTL_POWER_D0		0x0000	/* full On */
879 #define SNDRV_CTL_POWER_D1		0x0100	/* partial On */
880 #define SNDRV_CTL_POWER_D2		0x0200	/* partial On */
881 #define SNDRV_CTL_POWER_D3		0x0300	/* Off */
882 #define SNDRV_CTL_POWER_D3hot		(SNDRV_CTL_POWER_D3|0x0000)	/* Off, with power */
883 #define SNDRV_CTL_POWER_D3cold		(SNDRV_CTL_POWER_D3|0x0001)	/* Off, without power */
884 
885 #define SNDRV_CTL_ELEM_ID_NAME_MAXLEN	44
886 
887 struct snd_ctl_elem_id {
888 	unsigned int numid;		/* numeric identifier, zero = invalid */
889 	snd_ctl_elem_iface_t iface;	/* interface identifier */
890 	unsigned int device;		/* device/client number */
891 	unsigned int subdevice;		/* subdevice (substream) number */
892 	unsigned char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];		/* ASCII name of item */
893 	unsigned int index;		/* index of item */
894 };
895 
896 struct snd_ctl_elem_list {
897 	unsigned int offset;		/* W: first element ID to get */
898 	unsigned int space;		/* W: count of element IDs to get */
899 	unsigned int used;		/* R: count of element IDs set */
900 	unsigned int count;		/* R: count of all elements */
901 	struct snd_ctl_elem_id *pids; /* R: IDs */
902 	unsigned char reserved[50];
903 };
904 
905 struct snd_ctl_elem_info {
906 	struct snd_ctl_elem_id id;	/* W: element ID */
907 	snd_ctl_elem_type_t type;	/* R: value type - SNDRV_CTL_ELEM_TYPE_* */
908 	unsigned int access;		/* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */
909 	unsigned int count;		/* count of values */
910 	__kernel_pid_t owner;		/* owner's PID of this control */
911 	union {
912 		struct {
913 			long min;		/* R: minimum value */
914 			long max;		/* R: maximum value */
915 			long step;		/* R: step (0 variable) */
916 		} integer;
917 		struct {
918 			long long min;		/* R: minimum value */
919 			long long max;		/* R: maximum value */
920 			long long step;		/* R: step (0 variable) */
921 		} integer64;
922 		struct {
923 			unsigned int items;	/* R: number of items */
924 			unsigned int item;	/* W: item number */
925 			char name[64];		/* R: value name */
926 			__u64 names_ptr;	/* W: names list (ELEM_ADD only) */
927 			unsigned int names_length;
928 		} enumerated;
929 		unsigned char reserved[128];
930 	} value;
931 	union {
932 		unsigned short d[4];		/* dimensions */
933 		unsigned short *d_ptr;		/* indirect - obsoleted */
934 	} dimen;
935 	unsigned char reserved[64-4*sizeof(unsigned short)];
936 };
937 
938 struct snd_ctl_elem_value {
939 	struct snd_ctl_elem_id id;	/* W: element ID */
940 	unsigned int indirect: 1;	/* W: indirect access - obsoleted */
941 	union {
942 		union {
943 			long value[128];
944 			long *value_ptr;	/* obsoleted */
945 		} integer;
946 		union {
947 			long long value[64];
948 			long long *value_ptr;	/* obsoleted */
949 		} integer64;
950 		union {
951 			unsigned int item[128];
952 			unsigned int *item_ptr;	/* obsoleted */
953 		} enumerated;
954 		union {
955 			unsigned char data[512];
956 			unsigned char *data_ptr;	/* obsoleted */
957 		} bytes;
958 		struct snd_aes_iec958 iec958;
959 	} value;		/* RO */
960 	struct timespec tstamp;
961 	unsigned char reserved[128-sizeof(struct timespec)];
962 };
963 
964 struct snd_ctl_tlv {
965 	unsigned int numid;	/* control element numeric identification */
966 	unsigned int length;	/* in bytes aligned to 4 */
967 	unsigned int tlv[0];	/* first TLV */
968 };
969 
970 #define SNDRV_CTL_IOCTL_PVERSION	_IOR('U', 0x00, int)
971 #define SNDRV_CTL_IOCTL_CARD_INFO	_IOR('U', 0x01, struct snd_ctl_card_info)
972 #define SNDRV_CTL_IOCTL_ELEM_LIST	_IOWR('U', 0x10, struct snd_ctl_elem_list)
973 #define SNDRV_CTL_IOCTL_ELEM_INFO	_IOWR('U', 0x11, struct snd_ctl_elem_info)
974 #define SNDRV_CTL_IOCTL_ELEM_READ	_IOWR('U', 0x12, struct snd_ctl_elem_value)
975 #define SNDRV_CTL_IOCTL_ELEM_WRITE	_IOWR('U', 0x13, struct snd_ctl_elem_value)
976 #define SNDRV_CTL_IOCTL_ELEM_LOCK	_IOW('U', 0x14, struct snd_ctl_elem_id)
977 #define SNDRV_CTL_IOCTL_ELEM_UNLOCK	_IOW('U', 0x15, struct snd_ctl_elem_id)
978 #define SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS _IOWR('U', 0x16, int)
979 #define SNDRV_CTL_IOCTL_ELEM_ADD	_IOWR('U', 0x17, struct snd_ctl_elem_info)
980 #define SNDRV_CTL_IOCTL_ELEM_REPLACE	_IOWR('U', 0x18, struct snd_ctl_elem_info)
981 #define SNDRV_CTL_IOCTL_ELEM_REMOVE	_IOWR('U', 0x19, struct snd_ctl_elem_id)
982 #define SNDRV_CTL_IOCTL_TLV_READ	_IOWR('U', 0x1a, struct snd_ctl_tlv)
983 #define SNDRV_CTL_IOCTL_TLV_WRITE	_IOWR('U', 0x1b, struct snd_ctl_tlv)
984 #define SNDRV_CTL_IOCTL_TLV_COMMAND	_IOWR('U', 0x1c, struct snd_ctl_tlv)
985 #define SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE _IOWR('U', 0x20, int)
986 #define SNDRV_CTL_IOCTL_HWDEP_INFO	_IOR('U', 0x21, struct snd_hwdep_info)
987 #define SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE	_IOR('U', 0x30, int)
988 #define SNDRV_CTL_IOCTL_PCM_INFO	_IOWR('U', 0x31, struct snd_pcm_info)
989 #define SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE _IOW('U', 0x32, int)
990 #define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int)
991 #define SNDRV_CTL_IOCTL_RAWMIDI_INFO	_IOWR('U', 0x41, struct snd_rawmidi_info)
992 #define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int)
993 #define SNDRV_CTL_IOCTL_POWER		_IOWR('U', 0xd0, int)
994 #define SNDRV_CTL_IOCTL_POWER_STATE	_IOR('U', 0xd1, int)
995 
996 /*
997  *  Read interface.
998  */
999 
1000 enum sndrv_ctl_event_type {
1001 	SNDRV_CTL_EVENT_ELEM = 0,
1002 	SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
1003 };
1004 
1005 #define SNDRV_CTL_EVENT_MASK_VALUE	(1<<0)	/* element value was changed */
1006 #define SNDRV_CTL_EVENT_MASK_INFO	(1<<1)	/* element info was changed */
1007 #define SNDRV_CTL_EVENT_MASK_ADD	(1<<2)	/* element was added */
1008 #define SNDRV_CTL_EVENT_MASK_TLV	(1<<3)	/* element TLV tree was changed */
1009 #define SNDRV_CTL_EVENT_MASK_REMOVE	(~0U)	/* element was removed */
1010 
1011 struct snd_ctl_event {
1012 	int type;	/* event type - SNDRV_CTL_EVENT_* */
1013 	union {
1014 		struct {
1015 			unsigned int mask;
1016 			struct snd_ctl_elem_id id;
1017 		} elem;
1018 		unsigned char data8[60];
1019 	} data;
1020 };
1021 
1022 /*
1023  *  Control names
1024  */
1025 
1026 #define SNDRV_CTL_NAME_NONE				""
1027 #define SNDRV_CTL_NAME_PLAYBACK				"Playback "
1028 #define SNDRV_CTL_NAME_CAPTURE				"Capture "
1029 
1030 #define SNDRV_CTL_NAME_IEC958_NONE			""
1031 #define SNDRV_CTL_NAME_IEC958_SWITCH			"Switch"
1032 #define SNDRV_CTL_NAME_IEC958_VOLUME			"Volume"
1033 #define SNDRV_CTL_NAME_IEC958_DEFAULT			"Default"
1034 #define SNDRV_CTL_NAME_IEC958_MASK			"Mask"
1035 #define SNDRV_CTL_NAME_IEC958_CON_MASK			"Con Mask"
1036 #define SNDRV_CTL_NAME_IEC958_PRO_MASK			"Pro Mask"
1037 #define SNDRV_CTL_NAME_IEC958_PCM_STREAM		"PCM Stream"
1038 #define SNDRV_CTL_NAME_IEC958(expl,direction,what)	"IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what
1039 
1040 #endif /* __SOUND_ASOUND_H */
1041