OSDN Git Service

Added snd_ prefix to mask and interval. Divided header.h wrappers
[android-x86/external-alsa-lib.git] / include / control.h
1 /****************************************************************************
2  *                                                                          *
3  *                              control.h                                   *
4  *                          Control Interface                               *
5  *                                                                          *
6  ****************************************************************************/
7
8 /* sndrv aliasing */
9
10 typedef struct sndrv_aes_iec958 snd_aes_iec958_t;
11 typedef union sndrv_digital_audio snd_digital_audio_t;
12 typedef enum sndrv_card_type snd_card_type;
13 typedef struct sndrv_ctl_hw_info snd_ctl_hw_info_t;
14 typedef enum sndrv_control_type snd_control_type_t;
15 typedef enum sndrv_control_iface snd_control_iface_t;
16 typedef struct sndrv_control_id snd_control_id_t;
17 typedef struct sndrv_control_list snd_control_list_t;
18 typedef struct sndrv_control_info snd_control_info_t;
19 typedef struct sndrv_control snd_control_t;
20 typedef enum sndrv_ctl_event_type snd_ctl_event_type_t;
21 typedef struct sndrv_ctl_event snd_ctl_event_t;
22 #define SND_CARD_TYPE_GUS_CLASSIC SNDRV_CARD_TYPE_GUS_CLASSIC
23 #define SND_CARD_TYPE_GUS_EXTREME SNDRV_CARD_TYPE_GUS_EXTREME
24 #define SND_CARD_TYPE_GUS_ACE SNDRV_CARD_TYPE_GUS_ACE
25 #define SND_CARD_TYPE_GUS_MAX SNDRV_CARD_TYPE_GUS_MAX
26 #define SND_CARD_TYPE_AMD_INTERWAVE SNDRV_CARD_TYPE_AMD_INTERWAVE
27 #define SND_CARD_TYPE_SB_10 SNDRV_CARD_TYPE_SB_10
28 #define SND_CARD_TYPE_SB_20 SNDRV_CARD_TYPE_SB_20
29 #define SND_CARD_TYPE_SB_PRO SNDRV_CARD_TYPE_SB_PRO
30 #define SND_CARD_TYPE_SB_16 SNDRV_CARD_TYPE_SB_16
31 #define SND_CARD_TYPE_SB_AWE SNDRV_CARD_TYPE_SB_AWE
32 #define SND_CARD_TYPE_ESS_ES1688 SNDRV_CARD_TYPE_ESS_ES1688
33 #define SND_CARD_TYPE_OPL3_SA2 SNDRV_CARD_TYPE_OPL3_SA2
34 #define SND_CARD_TYPE_MOZART SNDRV_CARD_TYPE_MOZART
35 #define SND_CARD_TYPE_S3_SONICVIBES SNDRV_CARD_TYPE_S3_SONICVIBES
36 #define SND_CARD_TYPE_ENS1370 SNDRV_CARD_TYPE_ENS1370
37 #define SND_CARD_TYPE_ENS1371 SNDRV_CARD_TYPE_ENS1371
38 #define SND_CARD_TYPE_CS4232 SNDRV_CARD_TYPE_CS4232
39 #define SND_CARD_TYPE_CS4236 SNDRV_CARD_TYPE_CS4236
40 #define SND_CARD_TYPE_AMD_INTERWAVE_STB SNDRV_CARD_TYPE_AMD_INTERWAVE_STB
41 #define SND_CARD_TYPE_ESS_ES1938 SNDRV_CARD_TYPE_ESS_ES1938
42 #define SND_CARD_TYPE_ESS_ES18XX SNDRV_CARD_TYPE_ESS_ES18XX
43 #define SND_CARD_TYPE_CS4231 SNDRV_CARD_TYPE_CS4231
44 #define SND_CARD_TYPE_OPTI92X SNDRV_CARD_TYPE_OPTI92X
45 #define SND_CARD_TYPE_SERIAL SNDRV_CARD_TYPE_SERIAL
46 #define SND_CARD_TYPE_AD1848 SNDRV_CARD_TYPE_AD1848
47 #define SND_CARD_TYPE_TRID4DWAVEDX SNDRV_CARD_TYPE_TRID4DWAVEDX
48 #define SND_CARD_TYPE_TRID4DWAVENX SNDRV_CARD_TYPE_TRID4DWAVENX
49 #define SND_CARD_TYPE_SGALAXY SNDRV_CARD_TYPE_SGALAXY
50 #define SND_CARD_TYPE_CS46XX SNDRV_CARD_TYPE_CS46XX
51 #define SND_CARD_TYPE_WAVEFRONT SNDRV_CARD_TYPE_WAVEFRONT
52 #define SND_CARD_TYPE_TROPEZ SNDRV_CARD_TYPE_TROPEZ
53 #define SND_CARD_TYPE_TROPEZPLUS SNDRV_CARD_TYPE_TROPEZPLUS
54 #define SND_CARD_TYPE_MAUI SNDRV_CARD_TYPE_MAUI
55 #define SND_CARD_TYPE_CMI8330 SNDRV_CARD_TYPE_CMI8330
56 #define SND_CARD_TYPE_DUMMY SNDRV_CARD_TYPE_DUMMY
57 #define SND_CARD_TYPE_ALS100 SNDRV_CARD_TYPE_ALS100
58 #define SND_CARD_TYPE_SHARE SNDRV_CARD_TYPE_SHARE
59 #define SND_CARD_TYPE_SI_7018 SNDRV_CARD_TYPE_SI_7018
60 #define SND_CARD_TYPE_OPTI93X SNDRV_CARD_TYPE_OPTI93X
61 #define SND_CARD_TYPE_MTPAV SNDRV_CARD_TYPE_MTPAV
62 #define SND_CARD_TYPE_VIRMIDI SNDRV_CARD_TYPE_VIRMIDI
63 #define SND_CARD_TYPE_EMU10K1 SNDRV_CARD_TYPE_EMU10K1
64 #define SND_CARD_TYPE_HAMMERFALL SNDRV_CARD_TYPE_HAMMERFALL
65 #define SND_CARD_TYPE_HAMMERFALL_LIGHT SNDRV_CARD_TYPE_HAMMERFALL_LIGHT
66 #define SND_CARD_TYPE_ICE1712 SNDRV_CARD_TYPE_ICE1712
67 #define SND_CARD_TYPE_CMI8338 SNDRV_CARD_TYPE_CMI8338
68 #define SND_CARD_TYPE_CMI8738 SNDRV_CARD_TYPE_CMI8738
69 #define SND_CARD_TYPE_AD1816A SNDRV_CARD_TYPE_AD1816A
70 #define SND_CARD_TYPE_INTEL8X0 SNDRV_CARD_TYPE_INTEL8X0
71 #define SND_CARD_TYPE_ESS_ESOLDM1 SNDRV_CARD_TYPE_ESS_ESOLDM1
72 #define SND_CARD_TYPE_ESS_ES1968 SNDRV_CARD_TYPE_ESS_ES1968
73 #define SND_CARD_TYPE_ESS_ES1978 SNDRV_CARD_TYPE_ESS_ES1978
74 #define SND_CARD_TYPE_DIGI96 SNDRV_CARD_TYPE_DIGI96
75 #define SND_CARD_TYPE_VIA82C686A SNDRV_CARD_TYPE_VIA82C686A
76 #define SND_CARD_TYPE_FM801 SNDRV_CARD_TYPE_FM801
77 #define SND_CARD_TYPE_AZT2320 SNDRV_CARD_TYPE_AZT2320
78 #define SND_CARD_TYPE_PRODIF_PLUS SNDRV_CARD_TYPE_PRODIF_PLUS
79 #define SND_CARD_TYPE_YMFPCI SNDRV_CARD_TYPE_YMFPCI
80 #define SND_CARD_TYPE_CS4281 SNDRV_CARD_TYPE_CS4281
81 #define SND_CARD_TYPE_MPU401_UART SNDRV_CARD_TYPE_MPU401_UART
82 #define SND_CARD_TYPE_ALS4000 SNDRV_CARD_TYPE_ALS4000
83 #define SND_CARD_TYPE_ALLEGRO_1 SNDRV_CARD_TYPE_ALLEGRO_1
84 #define SND_CARD_TYPE_ALLEGRO SNDRV_CARD_TYPE_ALLEGRO
85 #define SND_CARD_TYPE_MAESTRO3 SNDRV_CARD_TYPE_MAESTRO3
86 #define SND_CARD_TYPE_AWACS SNDRV_CARD_TYPE_AWACS
87 #define SND_CARD_TYPE_NM256AV SNDRV_CARD_TYPE_NM256AV
88 #define SND_CARD_TYPE_NM256ZX SNDRV_CARD_TYPE_NM256ZX
89 #define SND_CARD_TYPE_VIA8233 SNDRV_CARD_TYPE_VIA8233
90 #define SND_CARD_TYPE_LAST SNDRV_CARD_TYPE_LAST
91 #define SND_CONTROL_TYPE_NONE SNDRV_CONTROL_TYPE_NONE
92 #define SND_CONTROL_TYPE_BOOLEAN SNDRV_CONTROL_TYPE_BOOLEAN
93 #define SND_CONTROL_TYPE_INTEGER SNDRV_CONTROL_TYPE_INTEGER
94 #define SND_CONTROL_TYPE_ENUMERATED SNDRV_CONTROL_TYPE_ENUMERATED
95 #define SND_CONTROL_TYPE_BYTES SNDRV_CONTROL_TYPE_BYTES
96 #define SND_CONTROL_TYPE_IEC958 SNDRV_CONTROL_TYPE_IEC958
97 #define SND_CONTROL_IFACE_CARD SNDRV_CONTROL_IFACE_CARD
98 #define SND_CONTROL_IFACE_HWDEP SNDRV_CONTROL_IFACE_HWDEP
99 #define SND_CONTROL_IFACE_MIXER SNDRV_CONTROL_IFACE_MIXER
100 #define SND_CONTROL_IFACE_PCM SNDRV_CONTROL_IFACE_PCM
101 #define SND_CONTROL_IFACE_RAWMIDI SNDRV_CONTROL_IFACE_RAWMIDI
102 #define SND_CONTROL_IFACE_TIMER SNDRV_CONTROL_IFACE_TIMER
103 #define SND_CONTROL_IFACE_SEQUENCER SNDRV_CONTROL_IFACE_SEQUENCER
104 #define SND_CONTROL_ACCESS_READ SNDRV_CONTROL_ACCESS_READ
105 #define SND_CONTROL_ACCESS_WRITE SNDRV_CONTROL_ACCESS_WRITE
106 #define SND_CONTROL_ACCESS_READWRITE SNDRV_CONTROL_ACCESS_READWRITE
107 #define SND_CONTROL_ACCESS_VOLATILE SNDRV_CONTROL_ACCESS_VOLATILE
108 #define SND_CONTROL_ACCESS_INACTIVE SNDRV_CONTROL_ACCESS_INACTIVE
109 #define SND_CONTROL_ACCESS_LOCK SNDRV_CONTROL_ACCESS_LOCK
110 #define SND_CONTROL_ACCESS_INDIRECT SNDRV_CONTROL_ACCESS_INDIRECT
111 #define SND_CTL_EVENT_REBUILD SNDRV_CTL_EVENT_REBUILD
112 #define SND_CTL_EVENT_VALUE SNDRV_CTL_EVENT_VALUE
113 #define SND_CTL_EVENT_CHANGE SNDRV_CTL_EVENT_CHANGE
114 #define SND_CTL_EVENT_ADD SNDRV_CTL_EVENT_ADD
115 #define SND_CTL_EVENT_REMOVE SNDRV_CTL_EVENT_REMOVE
116
117 typedef struct _snd_ctl snd_ctl_t;
118
119 typedef enum _snd_ctl_type { SND_CTL_TYPE_HW,
120                SND_CTL_TYPE_SHM,
121                SND_CTL_TYPE_INET
122  } snd_ctl_type_t;
123
124 typedef struct _snd_ctl_callbacks {
125         void *private_data;     /* may be used by an application */
126         void (*rebuild) (snd_ctl_t *handle, void *private_data);
127         void (*value) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
128         void (*change) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
129         void (*add) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
130         void (*remove) (snd_ctl_t *handle, void *private_data, snd_control_id_t * id);
131         void *reserved[58];     /* reserved for the future use - must be NULL!!! */
132 } snd_ctl_callbacks_t;
133
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137
138 int snd_card_load(int card);
139 int snd_card_next(int *card);
140 int snd_card_get_index(const char *name);
141 int snd_card_get_name(int card, char **name);
142 int snd_card_get_longname(int card, char **name);
143
144 int snd_defaults_card(void);
145 int snd_defaults_mixer_card(void);
146 int snd_defaults_pcm_card(void);
147 int snd_defaults_pcm_device(void);
148 int snd_defaults_rawmidi_card(void);
149 int snd_defaults_rawmidi_device(void);
150
151 snd_ctl_type_t snd_ctl_type(snd_ctl_t *handle);
152 int snd_ctl_open(snd_ctl_t **handle, char *name);
153 int snd_ctl_close(snd_ctl_t *handle);
154 int snd_ctl_card(snd_ctl_t *handle);
155 int snd_ctl_poll_descriptor(snd_ctl_t *handle);
156 int snd_ctl_hw_info(snd_ctl_t *handle, snd_ctl_hw_info_t *info);
157 int snd_ctl_clist(snd_ctl_t *handle, snd_control_list_t * list);
158 int snd_ctl_cinfo(snd_ctl_t *handle, snd_control_info_t * sw);
159 int snd_ctl_cread(snd_ctl_t *handle, snd_control_t * control);
160 int snd_ctl_cwrite(snd_ctl_t *handle, snd_control_t * control);
161 int snd_ctl_hwdep_next_device(snd_ctl_t *handle, int * device);
162 int snd_ctl_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info);
163 int snd_ctl_pcm_next_device(snd_ctl_t *handle, int *device);
164 int snd_ctl_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info);
165 int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev);
166 int snd_ctl_rawmidi_next_device(snd_ctl_t *handle, int * device);
167 int snd_ctl_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info);
168 int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev);
169
170 int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 /*
177  *  Highlevel API for controls
178  */
179
180 #define LIST_HEAD_IS_DEFINED
181 struct list_head {
182         struct list_head *next, *prev;
183 };        
184
185 /**
186  * list_entry - get the struct for this entry
187  * @ptr:        the &struct list_head pointer.
188  * @type:       the type of the struct this is embedded in.
189  * @member:     the name of the list_struct within the struct.
190  */
191 #define list_entry(ptr, type, member) \
192         ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
193
194
195 typedef struct _snd_hcontrol_list snd_hcontrol_list_t;
196 typedef struct _snd_hcontrol snd_hcontrol_t;
197
198 struct _snd_hcontrol_list {
199         unsigned int controls_offset;   /* W: first control ID to get */
200         unsigned int controls_request;  /* W: count of control IDs to get */
201         unsigned int controls_count;    /* R: count of available (set) controls */
202         unsigned int controls;          /* R: count of all available controls */
203         snd_control_id_t *pids;         /* W: IDs */
204 };
205
206 struct _snd_hcontrol {
207         snd_control_id_t id;    /* must be always on top */
208         struct list_head list;  /* links for list of all hcontrols */
209         int change: 1,          /* structure change */
210             value: 1;           /* value change */
211         /* event callbacks */
212         void (*event_change)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
213         void (*event_value)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
214         void (*event_remove)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
215         /* private data */
216         void *private_data;
217         void (*private_free)(void *private_data);
218         /* links */
219         snd_ctl_t *handle;      /* associated handle */
220 };
221
222 #ifdef __cplusplus
223 extern "C" {
224 #endif
225
226 typedef int (snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
227 typedef void (snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
228 typedef void (snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
229
230 int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
231 int snd_ctl_hfree(snd_ctl_t *handle);
232 snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle);
233 snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle);
234 snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
235 snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
236 int snd_ctl_hcount(snd_ctl_t *handle);
237 snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
238 int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
239 int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
240 int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t *csort);
241 int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t *callback, void *private_data);
242 int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t *callback, void *private_data);
243 int snd_ctl_hevent(snd_ctl_t *handle);
244
245 int snd_ctl_hbag_create(void **bag);
246 int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol));
247 int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol);
248 int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol);
249 snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id);
250
251 #ifdef __cplusplus
252 }
253 #endif
254