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