OSDN Git Service

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