source: contrib/API/tools/asound1.h@ 578

Last change on this file since 578 was 578, checked in by David Azarewicz, 11 years ago

API updates

File size: 17.0 KB
Line 
1/*
2 * Advanced Linux Sound Architecture - ALSA - Driver
3 * Copyright (c) 1994-2003 by Jaroslav Kysela <perex@suse.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#include <linux/ioctl.h>
28#include <endian.h>
29#if __BYTE_ORDER == __LITTLE_ENDIAN
30#define SNDRV_LITTLE_ENDIAN
31#elif __BYTE_ORDER == __BIG_ENDIAN
32#define SNDRV_BIG_ENDIAN
33#else
34#error "Unsupported endian..."
35#endif
36#endif
37#ifndef __KERNEL__
38#include <sys/time.h>
39#include <sys/types.h>
40#endif
41
42
43
44
45struct iovec {
46 char *iov_base; /* Base address. */
47#ifdef __32BIT__
48 size_t iov_len; /* Length. */
49#else
50 long iov_len; /* Length. */
51#endif
52};
53
54/*
55 * protocol version
56 */
57
58
59#define SNDRV_PROTOCOL_VERSION(major, minor, subminor) (((major)<<16)|((minor)<<8)|(subminor))
60#define SNDRV_PROTOCOL_MAJOR(version) (((version)>>16)&0xffff)
61#define SNDRV_PROTOCOL_MINOR(version) (((version)>>8)&0xff)
62#define SNDRV_PROTOCOL_MICRO(version) ((version)&0xff)
63#define SNDRV_PROTOCOL_INCOMPATIBLE(kversion, uversion) \
64 (SNDRV_PROTOCOL_MAJOR(kversion) != SNDRV_PROTOCOL_MAJOR(uversion) || \
65 (SNDRV_PROTOCOL_MAJOR(kversion) == SNDRV_PROTOCOL_MAJOR(uversion) && \
66 SNDRV_PROTOCOL_MINOR(kversion) != SNDRV_PROTOCOL_MINOR(uversion)))
67
68
69/****************************************************************************
70 * *
71 * Section for driver hardware dependent interface - /dev/snd/hw? *
72 * *
73 ****************************************************************************/
74
75#define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1)
76
77enum sndrv_hwdep_iface {
78 SNDRV_HWDEP_IFACE_OPL2 = 0,
79 SNDRV_HWDEP_IFACE_OPL3,
80 SNDRV_HWDEP_IFACE_OPL4,
81 SNDRV_HWDEP_IFACE_SB16CSP, /* Creative Signal Processor */
82 SNDRV_HWDEP_IFACE_EMU10K1, /* FX8010 processor in EMU10K1 chip */
83 SNDRV_HWDEP_IFACE_YSS225, /* Yamaha FX processor */
84 SNDRV_HWDEP_IFACE_ICS2115, /* Wavetable synth */
85 SNDRV_HWDEP_IFACE_SSCAPE, /* Ensoniq SoundScape ISA card (MC68EC000) */
86 SNDRV_HWDEP_IFACE_VX, /* Digigram VX cards */
87 SNDRV_HWDEP_IFACE_MIXART, /* Digigram miXart cards */
88 SNDRV_HWDEP_IFACE_USX2Y, /* Tascam US122, US224 & US428 usb */
89
90 /* Don't forget to change the following: */
91 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_USX2Y,
92};
93
94struct sndrv_hwdep_info {
95 unsigned int device; /* WR: device number */
96 int card; /* R: card number */
97 unsigned char id[64]; /* ID (user selectable) */
98 unsigned char name[80]; /* hwdep name */
99 enum sndrv_hwdep_iface iface; /* hwdep interface */
100 unsigned char reserved[64]; /* reserved for future */
101};
102
103/* generic DSP loader */
104struct sndrv_hwdep_dsp_status {
105 unsigned int version; /* R: driver-specific version */
106 unsigned char id[32]; /* R: driver-specific ID string */
107 unsigned int num_dsps; /* R: number of DSP images to transfer */
108 unsigned int dsp_loaded; /* R: bit flags indicating the loaded DSPs */
109 unsigned int chip_ready; /* R: 1 = initialization finished */
110 unsigned char reserved[16]; /* reserved for future use */
111};
112
113struct sndrv_hwdep_dsp_image {
114 unsigned int index; /* W: DSP index */
115 unsigned char name[64]; /* W: ID (e.g. file name) */
116 unsigned char *image; /* W: binary image */
117 size_t length; /* W: size of image in bytes */
118 unsigned long driver_data; /* W: driver-specific data */
119};
120
121
122/*****************************************************************************
123 * *
124 * Digital Audio (PCM) interface - /dev/snd/pcm?? *
125 * *
126 *****************************************************************************/
127
128#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 6)
129
130
131enum sndrv_pcm_class {
132 SNDRV_PCM_CLASS_GENERIC = 0, /* standard mono or stereo device */
133 SNDRV_PCM_CLASS_MULTI, /* multichannel device */
134 SNDRV_PCM_CLASS_MODEM, /* software modem class */
135 SNDRV_PCM_CLASS_DIGITIZER, /* digitizer class */
136 /* Don't forget to change the following: */
137 SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER,
138};
139
140enum sndrv_pcm_subclass {
141 SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */
142 SNDRV_PCM_SUBCLASS_MULTI_MIX, /* multichannel subdevices are mixed together */
143 /* Don't forget to change the following: */
144 SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX,
145};
146
147
148enum {
149 SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000,
150 SNDRV_PCM_MMAP_OFFSET_STATUS = 0x80000000,
151 SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000,
152};
153
154union sndrv_pcm_sync_id {
155 unsigned char id[16];
156 unsigned short id16[8];
157 unsigned int id32[4];
158};
159
160
161
162struct sndrv_pcm_channel_info {
163 unsigned int channel;
164 off_t offset; /* mmap offset */
165 unsigned int first; /* offset to first sample in bits */
166 unsigned int step; /* samples distance in bits */
167};
168
169
170struct sndrv_pcm_mmap_status {
171 enum sndrv_pcm_state state; /* RO: state - SNDRV_PCM_STATE_XXXX */
172 int pad1; /* Needed for 64 bit alignment */
173 sndrv_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
174 struct timespec tstamp; /* Timestamp */
175 enum sndrv_pcm_state suspended_state; /* RO: suspended stream state */
176};
177
178struct sndrv_pcm_mmap_control {
179 sndrv_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
180 sndrv_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
181};
182
183struct sndrv_xferi {
184 sndrv_pcm_sframes_t result;
185 void *buf;
186 sndrv_pcm_uframes_t frames;
187};
188
189struct sndrv_xfern {
190 sndrv_pcm_sframes_t result;
191 void **bufs;
192 sndrv_pcm_uframes_t frames;
193};
194
195#ifdef TARGET_OS2
196#define SNDRV_PCM_VOL_FRONT_LEFT 0
197#define SNDRV_PCM_VOL_FRONT_RIGHT 1
198#define SNDRV_PCM_VOL_REAR_LEFT 2
199#define SNDRV_PCM_VOL_REAR_RIGHT 3
200#define SNDRV_PCM_VOL_CENTER 4
201#define SNDRV_PCM_VOL_LFE 5
202
203#define SNDRV_PCM_VOL_MAX 100
204
205struct snd_pcm_volume {
206 int nrchannels;
207 int volume[6];
208};
209#endif
210
211
212/* Trick to make alsa-lib/acinclude.m4 happy */
213#define SNDRV_PCM_IOCTL_REWIND SNDRV_PCM_IOCTL_REWIND
214
215/*****************************************************************************
216 * *
217 * MIDI v1.0 interface *
218 * *
219 *****************************************************************************/
220
221/*
222 * Raw MIDI section - /dev/snd/midi??
223 */
224
225#define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0)
226
227enum sndrv_rawmidi_stream {
228 SNDRV_RAWMIDI_STREAM_OUTPUT = 0,
229 SNDRV_RAWMIDI_STREAM_INPUT,
230 SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT,
231};
232
233#define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001
234#define SNDRV_RAWMIDI_INFO_INPUT 0x00000002
235#define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004
236
237struct sndrv_rawmidi_info {
238 unsigned int device; /* RO/WR (control): device number */
239 unsigned int subdevice; /* RO/WR (control): subdevice number */
240 enum sndrv_rawmidi_stream stream; /* WR: stream */
241 int card; /* R: card number */
242 unsigned int flags; /* SNDRV_RAWMIDI_INFO_XXXX */
243 unsigned char id[64]; /* ID (user selectable) */
244 unsigned char name[80]; /* name of device */
245 unsigned char subname[32]; /* name of active or selected subdevice */
246 unsigned int subdevices_count;
247 unsigned int subdevices_avail;
248 unsigned char reserved[64]; /* reserved for future use */
249};
250
251struct sndrv_rawmidi_params {
252 enum sndrv_rawmidi_stream stream;
253 size_t buffer_size; /* queue size in bytes */
254 size_t avail_min; /* minimum avail bytes for wakeup */
255 unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */
256 unsigned char reserved[16]; /* reserved for future use */
257};
258
259struct sndrv_rawmidi_status {
260 enum sndrv_rawmidi_stream stream;
261 struct timespec tstamp; /* Timestamp */
262 size_t avail; /* available bytes */
263 size_t xruns; /* count of overruns since last status (in bytes) */
264 unsigned char reserved[16]; /* reserved for future use */
265};
266
267/*
268 * Timer section - /dev/snd/timer
269 */
270
271#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 1)
272
273enum sndrv_timer_class {
274 SNDRV_TIMER_CLASS_NONE = -1,
275 SNDRV_TIMER_CLASS_SLAVE = 0,
276 SNDRV_TIMER_CLASS_GLOBAL,
277 SNDRV_TIMER_CLASS_CARD,
278 SNDRV_TIMER_CLASS_PCM,
279 SNDRV_TIMER_CLASS_LAST = SNDRV_TIMER_CLASS_PCM,
280};
281
282/* slave timer classes */
283enum sndrv_timer_slave_class {
284 SNDRV_TIMER_SCLASS_NONE = 0,
285 SNDRV_TIMER_SCLASS_APPLICATION,
286 SNDRV_TIMER_SCLASS_SEQUENCER, /* alias */
287 SNDRV_TIMER_SCLASS_OSS_SEQUENCER, /* alias */
288 SNDRV_TIMER_SCLASS_LAST = SNDRV_TIMER_SCLASS_OSS_SEQUENCER,
289};
290
291/* global timers (device member) */
292#define SNDRV_TIMER_GLOBAL_SYSTEM 0
293#define SNDRV_TIMER_GLOBAL_RTC 1
294
295/* info flags */
296#define SNDRV_TIMER_FLG_SLAVE (1<<0) /* cannot be controlled */
297
298struct sndrv_timer_id {
299 enum sndrv_timer_class dev_class;
300 enum sndrv_timer_slave_class dev_sclass;
301 int card;
302 int device;
303 int subdevice;
304};
305
306struct sndrv_timer_ginfo {
307 struct sndrv_timer_id tid; /* requested timer ID */
308 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
309 int card; /* card number */
310 unsigned char id[64]; /* timer identification */
311 unsigned char name[80]; /* timer name */
312 unsigned long reserved0; /* reserved for future use */
313 unsigned long resolution; /* average period resolution in ns */
314 unsigned long resolution_min; /* minimal period resolution in ns */
315 unsigned long resolution_max; /* maximal period resolution in ns */
316 unsigned int clients; /* active timer clients */
317 unsigned char reserved[32];
318};
319
320struct sndrv_timer_gparams {
321 struct sndrv_timer_id tid; /* requested timer ID */
322 unsigned long period_num; /* requested precise period duration (in seconds) - numerator */
323 unsigned long period_den; /* requested precise period duration (in seconds) - denominator */
324 unsigned char reserved[32];
325};
326
327struct sndrv_timer_gstatus {
328 struct sndrv_timer_id tid; /* requested timer ID */
329 unsigned long resolution; /* current period resolution in ns */
330 unsigned long resolution_num; /* precise current period resolution (in seconds) - numerator */
331 unsigned long resolution_den; /* precise current period resolution (in seconds) - denominator */
332 unsigned char reserved[32];
333};
334
335struct sndrv_timer_select {
336 struct sndrv_timer_id id; /* bind to timer ID */
337 unsigned char reserved[32]; /* reserved */
338};
339
340struct sndrv_timer_info {
341 unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */
342 int card; /* card number */
343 unsigned char id[64]; /* timer identificator */
344 unsigned char name[80]; /* timer name */
345 unsigned long reserved0; /* reserved for future use */
346 unsigned long resolution; /* average period resolution in ns */
347 unsigned char reserved[64]; /* reserved */
348};
349
350#define SNDRV_TIMER_PSFLG_AUTO (1<<0) /* auto start, otherwise one-shot */
351#define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) /* exclusive use, precise start/stop/pause/continue */
352
353struct sndrv_timer_params {
354 unsigned int flags; /* flags - SNDRV_MIXER_PSFLG_* */
355 unsigned int ticks; /* requested resolution in ticks */
356 unsigned int queue_size; /* total size of queue (32-1024) */
357 unsigned int reserved0; /* reserved, was: failure locations */
358 unsigned int filter; /* event filter (bitmask of SNDRV_TIMER_EVENT_*) */
359 unsigned char reserved[60]; /* reserved */
360};
361
362struct sndrv_timer_status {
363 struct timespec tstamp; /* Timestamp - last update */
364 unsigned int resolution; /* current period resolution in ns */
365 unsigned int lost; /* counter of master tick lost */
366 unsigned int overrun; /* count of read queue overruns */
367 unsigned int queue; /* used queue size */
368 unsigned char reserved[64]; /* reserved */
369};
370
371
372struct sndrv_timer_read {
373 unsigned int resolution;
374 unsigned int ticks;
375};
376
377enum sndrv_timer_event {
378 SNDRV_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */
379 SNDRV_TIMER_EVENT_TICK, /* val = ticks */
380 SNDRV_TIMER_EVENT_START, /* val = resolution in ns */
381 SNDRV_TIMER_EVENT_STOP, /* val = 0 */
382 SNDRV_TIMER_EVENT_CONTINUE, /* val = resolution in ns */
383 SNDRV_TIMER_EVENT_PAUSE, /* val = 0 */
384 /* master timer events for slave timer instances */
385 SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
386 SNDRV_TIMER_EVENT_MSTOP = SNDRV_TIMER_EVENT_STOP + 10,
387 SNDRV_TIMER_EVENT_MCONTINUE = SNDRV_TIMER_EVENT_CONTINUE + 10,
388 SNDRV_TIMER_EVENT_MPAUSE = SNDRV_TIMER_EVENT_PAUSE + 10,
389};
390
391struct sndrv_timer_tread {
392 enum sndrv_timer_event event;
393 struct timespec tstamp;
394 unsigned int val;
395};
396
397/****************************************************************************
398 * *
399 * Section for driver control interface - /dev/snd/control? *
400 * *
401 ****************************************************************************/
402
403#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 3)
404
405
406
407
408#define SNDRV_CTL_ELEM_ACCESS_READ (1<<0)
409#define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1)
410#define SNDRV_CTL_ELEM_ACCESS_READWRITE (SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE)
411#define SNDRV_CTL_ELEM_ACCESS_VOLATILE (1<<2) /* control value may be changed without a notification */
412#define SNDRV_CTL_ELEM_ACCESS_TIMESTAMP (1<<2) /* when was control changed */
413#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */
414#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */
415#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
416#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
417#define SNDRV_CTL_ELEM_ACCESS_DINDIRECT (1<<30) /* indirect access for matrix dimensions in the info structure */
418#define SNDRV_CTL_ELEM_ACCESS_INDIRECT (1<<31) /* indirect access for element value in the value structure */
419
420/* for further details see the ACPI and PCI power management specification */
421#define SNDRV_CTL_POWER_D0 0x0000 /* full On */
422#define SNDRV_CTL_POWER_D1 0x0100 /* partial On */
423#define SNDRV_CTL_POWER_D2 0x0200 /* partial On */
424#define SNDRV_CTL_POWER_D3 0x0300 /* Off */
425#define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) /* Off, with power */
426#define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) /* Off, without power */
427
428
429
430/*
431 * Read interface.
432 */
433
434enum sndrv_ctl_event_type {
435 SNDRV_CTL_EVENT_ELEM = 0,
436 SNDRV_CTL_EVENT_LAST = SNDRV_CTL_EVENT_ELEM,
437};
438
439#define SNDRV_CTL_EVENT_MASK_VALUE (1<<0) /* element value was changed */
440#define SNDRV_CTL_EVENT_MASK_INFO (1<<1) /* element info was changed */
441#define SNDRV_CTL_EVENT_MASK_ADD (1<<2) /* element was added */
442#define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) /* element was removed */
443
444struct sndrv_ctl_event {
445 enum sndrv_ctl_event_type type; /* event type - SNDRV_CTL_EVENT_* */
446 union {
447 struct {
448 unsigned int mask;
449 struct sndrv_ctl_elem_id id;
450 } elem;
451 unsigned char data8[60];
452 } data;
453};
454
455/*
456 * Control names
457 */
458
459#define SNDRV_CTL_NAME_NONE ""
460#define SNDRV_CTL_NAME_PLAYBACK "Playback "
461#define SNDRV_CTL_NAME_CAPTURE "Capture "
462
463#define SNDRV_CTL_NAME_IEC958_NONE ""
464#define SNDRV_CTL_NAME_IEC958_SWITCH "Switch"
465#define SNDRV_CTL_NAME_IEC958_VOLUME "Volume"
466#define SNDRV_CTL_NAME_IEC958_DEFAULT "Default"
467#define SNDRV_CTL_NAME_IEC958_MASK "Mask"
468#define SNDRV_CTL_NAME_IEC958_CON_MASK "Con Mask"
469#define SNDRV_CTL_NAME_IEC958_PRO_MASK "Pro Mask"
470#define SNDRV_CTL_NAME_IEC958_PCM_STREAM "PCM Stream"
471#define SNDRV_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SNDRV_CTL_NAME_##direction SNDRV_CTL_NAME_IEC958_##what
472
473/*
474 *
475 */
476
477struct sndrv_xferv {
478 const struct iovec *vector;
479 unsigned long count;
480};
481
482
483#endif /* __SOUND_ASOUND_H */
Note: See TracBrowser for help on using the repository browser.