OSDN Git Service

Control API encapsulation. Better names for kernel API. Simpler PCM hw_params API...
[android-x86/external-alsa-lib.git] / include / control.h
1 /****************************************************************************
2  *                                                                          *
3  *                              control.h                                   *
4  *                          Control Interface                               *
5  *                                                                          *
6  ****************************************************************************/
7
8 typedef struct sndrv_aes_iec958 snd_aes_iec958_t;
9 typedef struct _snd_ctl_info snd_ctl_info_t;
10 typedef struct _snd_control_id snd_control_id_t;
11 typedef struct _snd_control_list snd_control_list_t;
12 typedef struct _snd_control_info snd_control_info_t;
13 typedef struct _snd_control snd_control_t;
14 typedef struct _snd_ctl_event snd_ctl_event_t;
15
16 #ifdef SND_ENUM_TYPECHECK
17 typedef struct __snd_card_type *snd_card_type_t;
18 typedef struct __snd_control_type *snd_control_type_t;
19 typedef struct __snd_control_iface *snd_control_iface_t;
20 typedef struct __snd_ctl_event_type *snd_ctl_event_type_t;
21 #else
22 typedef enum sndrv_card_type snd_card_type_t;
23 typedef enum sndrv_control_type snd_control_type_t;
24 typedef enum sndrv_control_iface snd_control_iface_t;
25 typedef enum sndrv_ctl_event_type snd_ctl_event_type_t;
26 #endif
27
28 #define SND_CARD_TYPE_GUS_CLASSIC ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_CLASSIC)
29 #define SND_CARD_TYPE_GUS_EXTREME ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_EXTREME)
30 #define SND_CARD_TYPE_GUS_ACE ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_ACE)
31 #define SND_CARD_TYPE_GUS_MAX ((snd_card_type_t) SNDRV_CARD_TYPE_GUS_MAX)
32 #define SND_CARD_TYPE_AMD_INTERWAVE ((snd_card_type_t) SNDRV_CARD_TYPE_AMD_INTERWAVE)
33 #define SND_CARD_TYPE_SB_10 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_10)
34 #define SND_CARD_TYPE_SB_20 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_20)
35 #define SND_CARD_TYPE_SB_PRO ((snd_card_type_t) SNDRV_CARD_TYPE_SB_PRO)
36 #define SND_CARD_TYPE_SB_16 ((snd_card_type_t) SNDRV_CARD_TYPE_SB_16)
37 #define SND_CARD_TYPE_SB_AWE ((snd_card_type_t) SNDRV_CARD_TYPE_SB_AWE)
38 #define SND_CARD_TYPE_ESS_ES1688 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1688)
39 #define SND_CARD_TYPE_OPL3_SA2 ((snd_card_type_t) SNDRV_CARD_TYPE_OPL3_SA2)
40 #define SND_CARD_TYPE_MOZART ((snd_card_type_t) SNDRV_CARD_TYPE_MOZART)
41 #define SND_CARD_TYPE_S3_SONICVIBES ((snd_card_type_t) SNDRV_CARD_TYPE_S3_SONICVIBES)
42 #define SND_CARD_TYPE_ENS1370 ((snd_card_type_t) SNDRV_CARD_TYPE_ENS1370)
43 #define SND_CARD_TYPE_ENS1371 ((snd_card_type_t) SNDRV_CARD_TYPE_ENS1371)
44 #define SND_CARD_TYPE_CS4232 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4232)
45 #define SND_CARD_TYPE_CS4236 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4236)
46 #define SND_CARD_TYPE_AMD_INTERWAVE_STB ((snd_card_type_t) SNDRV_CARD_TYPE_AMD_INTERWAVE_STB)
47 #define SND_CARD_TYPE_ESS_ES1938 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1938)
48 #define SND_CARD_TYPE_ESS_ES18XX ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES18XX)
49 #define SND_CARD_TYPE_CS4231 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4231)
50 #define SND_CARD_TYPE_OPTI92X ((snd_card_type_t) SNDRV_CARD_TYPE_OPTI92X)
51 #define SND_CARD_TYPE_SERIAL ((snd_card_type_t) SNDRV_CARD_TYPE_SERIAL)
52 #define SND_CARD_TYPE_AD1848 ((snd_card_type_t) SNDRV_CARD_TYPE_AD1848)
53 #define SND_CARD_TYPE_TRID4DWAVEDX ((snd_card_type_t) SNDRV_CARD_TYPE_TRID4DWAVEDX)
54 #define SND_CARD_TYPE_TRID4DWAVENX ((snd_card_type_t) SNDRV_CARD_TYPE_TRID4DWAVENX)
55 #define SND_CARD_TYPE_SGALAXY ((snd_card_type_t) SNDRV_CARD_TYPE_SGALAXY)
56 #define SND_CARD_TYPE_CS46XX ((snd_card_type_t) SNDRV_CARD_TYPE_CS46XX)
57 #define SND_CARD_TYPE_WAVEFRONT ((snd_card_type_t) SNDRV_CARD_TYPE_WAVEFRONT)
58 #define SND_CARD_TYPE_TROPEZ ((snd_card_type_t) SNDRV_CARD_TYPE_TROPEZ)
59 #define SND_CARD_TYPE_TROPEZPLUS ((snd_card_type_t) SNDRV_CARD_TYPE_TROPEZPLUS)
60 #define SND_CARD_TYPE_MAUI ((snd_card_type_t) SNDRV_CARD_TYPE_MAUI)
61 #define SND_CARD_TYPE_CMI8330 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8330)
62 #define SND_CARD_TYPE_DUMMY ((snd_card_type_t) SNDRV_CARD_TYPE_DUMMY)
63 #define SND_CARD_TYPE_ALS100 ((snd_card_type_t) SNDRV_CARD_TYPE_ALS100)
64 #define SND_CARD_TYPE_SHARE ((snd_card_type_t) SNDRV_CARD_TYPE_SHARE)
65 #define SND_CARD_TYPE_SI_7018 ((snd_card_type_t) SNDRV_CARD_TYPE_SI_7018)
66 #define SND_CARD_TYPE_OPTI93X ((snd_card_type_t) SNDRV_CARD_TYPE_OPTI93X)
67 #define SND_CARD_TYPE_MTPAV ((snd_card_type_t) SNDRV_CARD_TYPE_MTPAV)
68 #define SND_CARD_TYPE_VIRMIDI ((snd_card_type_t) SNDRV_CARD_TYPE_VIRMIDI)
69 #define SND_CARD_TYPE_EMU10K1 ((snd_card_type_t) SNDRV_CARD_TYPE_EMU10K1)
70 #define SND_CARD_TYPE_HAMMERFALL ((snd_card_type_t) SNDRV_CARD_TYPE_HAMMERFALL)
71 #define SND_CARD_TYPE_HAMMERFALL_LIGHT ((snd_card_type_t) SNDRV_CARD_TYPE_HAMMERFALL_LIGHT)
72 #define SND_CARD_TYPE_ICE1712 ((snd_card_type_t) SNDRV_CARD_TYPE_ICE1712)
73 #define SND_CARD_TYPE_CMI8338 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8338)
74 #define SND_CARD_TYPE_CMI8738 ((snd_card_type_t) SNDRV_CARD_TYPE_CMI8738)
75 #define SND_CARD_TYPE_AD1816A ((snd_card_type_t) SNDRV_CARD_TYPE_AD1816A)
76 #define SND_CARD_TYPE_INTEL8X0 ((snd_card_type_t) SNDRV_CARD_TYPE_INTEL8X0)
77 #define SND_CARD_TYPE_ESS_ESOLDM1 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ESOLDM1)
78 #define SND_CARD_TYPE_ESS_ES1968 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1968)
79 #define SND_CARD_TYPE_ESS_ES1978 ((snd_card_type_t) SNDRV_CARD_TYPE_ESS_ES1978)
80 #define SND_CARD_TYPE_DIGI96 ((snd_card_type_t) SNDRV_CARD_TYPE_DIGI96)
81 #define SND_CARD_TYPE_VIA82C686A ((snd_card_type_t) SNDRV_CARD_TYPE_VIA82C686A)
82 #define SND_CARD_TYPE_FM801 ((snd_card_type_t) SNDRV_CARD_TYPE_FM801)
83 #define SND_CARD_TYPE_AZT2320 ((snd_card_type_t) SNDRV_CARD_TYPE_AZT2320)
84 #define SND_CARD_TYPE_PRODIF_PLUS ((snd_card_type_t) SNDRV_CARD_TYPE_PRODIF_PLUS)
85 #define SND_CARD_TYPE_YMFPCI ((snd_card_type_t) SNDRV_CARD_TYPE_YMFPCI)
86 #define SND_CARD_TYPE_CS4281 ((snd_card_type_t) SNDRV_CARD_TYPE_CS4281)
87 #define SND_CARD_TYPE_MPU401_UART ((snd_card_type_t) SNDRV_CARD_TYPE_MPU401_UART)
88 #define SND_CARD_TYPE_ALS4000 ((snd_card_type_t) SNDRV_CARD_TYPE_ALS4000)
89 #define SND_CARD_TYPE_ALLEGRO_1 ((snd_card_type_t) SNDRV_CARD_TYPE_ALLEGRO_1)
90 #define SND_CARD_TYPE_ALLEGRO ((snd_card_type_t) SNDRV_CARD_TYPE_ALLEGRO)
91 #define SND_CARD_TYPE_MAESTRO3 ((snd_card_type_t) SNDRV_CARD_TYPE_MAESTRO3)
92 #define SND_CARD_TYPE_AWACS ((snd_card_type_t) SNDRV_CARD_TYPE_AWACS)
93 #define SND_CARD_TYPE_NM256AV ((snd_card_type_t) SNDRV_CARD_TYPE_NM256AV)
94 #define SND_CARD_TYPE_NM256ZX ((snd_card_type_t) SNDRV_CARD_TYPE_NM256ZX)
95 #define SND_CARD_TYPE_VIA8233 ((snd_card_type_t) SNDRV_CARD_TYPE_VIA8233)
96 #define SND_CARD_TYPE_LAST ((snd_card_type_t) SNDRV_CARD_TYPE_LAST)
97
98 #define SND_CONTROL_TYPE_NONE ((snd_control_type_t) SNDRV_CONTROL_TYPE_NONE)
99 #define SND_CONTROL_TYPE_BOOLEAN ((snd_control_type_t) SNDRV_CONTROL_TYPE_BOOLEAN)
100 #define SND_CONTROL_TYPE_INTEGER ((snd_control_type_t) SNDRV_CONTROL_TYPE_INTEGER)
101 #define SND_CONTROL_TYPE_ENUMERATED ((snd_control_type_t) SNDRV_CONTROL_TYPE_ENUMERATED)
102 #define SND_CONTROL_TYPE_BYTES ((snd_control_type_t) SNDRV_CONTROL_TYPE_BYTES)
103 #define SND_CONTROL_TYPE_IEC958 ((snd_control_type_t) SNDRV_CONTROL_TYPE_IEC958)
104 #define SND_CONTROL_TYPE_LAST ((snd_control_type_t) SNDRV_CONTROL_TYPE_LAST)
105
106 #define SND_CONTROL_IFACE_CARD ((snd_control_iface_t) SNDRV_CONTROL_IFACE_CARD)
107 #define SND_CONTROL_IFACE_HWDEP ((snd_control_iface_t) SNDRV_CONTROL_IFACE_HWDEP)
108 #define SND_CONTROL_IFACE_MIXER ((snd_control_iface_t) SNDRV_CONTROL_IFACE_MIXER)
109 #define SND_CONTROL_IFACE_PCM ((snd_control_iface_t) SNDRV_CONTROL_IFACE_PCM)
110 #define SND_CONTROL_IFACE_RAWMIDI ((snd_control_iface_t) SNDRV_CONTROL_IFACE_RAWMIDI)
111 #define SND_CONTROL_IFACE_TIMER ((snd_control_iface_t) SNDRV_CONTROL_IFACE_TIMER)
112 #define SND_CONTROL_IFACE_SEQUENCER ((snd_control_iface_t) SNDRV_CONTROL_IFACE_SEQUENCER)
113 #define SND_CONTROL_IFACE_LAST ((snd_control_iface_t) SNDRV_CONTROL_IFACE_LAST)
114
115 #define SND_CTL_EVENT_REBUILD ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_REBUILD)
116 #define SND_CTL_EVENT_VALUE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_VALUE)
117 #define SND_CTL_EVENT_CHANGE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_CHANGE)
118 #define SND_CTL_EVENT_ADD ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_ADD)
119 #define SND_CTL_EVENT_REMOVE ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_REMOVE)
120 #define SND_CTL_EVENT_LAST ((snd_ctl_event_type_t) SNDRV_CTL_EVENT_LAST)
121
122 enum _snd_ctl_type {
123         SND_CTL_TYPE_HW,
124         SND_CTL_TYPE_SHM,
125         SND_CTL_TYPE_INET
126 };
127
128 #ifdef SND_ENUM_TYPECHECK
129 typedef struct __snd_ctl_type *snd_ctl_type_t;
130 #else
131 typedef enum _snd_ctl_type snd_ctl_type_t;
132 #endif
133
134 #define SND_CTL_TYPE_HW ((snd_ctl_type_t) SND_CTL_TYPE_HW)
135 #define SND_CTL_TYPE_SHM ((snd_ctl_type_t) SND_CTL_TYPE_SHM)
136 #define SND_CTL_TYPE_INET ((snd_ctl_type_t) SND_CTL_TYPE_INET)
137
138 typedef struct _snd_ctl snd_ctl_t;
139 typedef struct _snd_ctl_callbacks snd_ctl_callbacks_t;
140
141 #ifdef __cplusplus
142 extern "C" {
143 #endif
144
145 int snd_card_load(int card);
146 int snd_card_next(int *card);
147 int snd_card_get_index(const char *name);
148 int snd_card_get_name(int card, char **name);
149 int snd_card_get_longname(int card, char **name);
150
151 int snd_defaults_card(void);
152 int snd_defaults_mixer_card(void);
153 int snd_defaults_pcm_card(void);
154 int snd_defaults_pcm_device(void);
155 int snd_defaults_rawmidi_card(void);
156 int snd_defaults_rawmidi_device(void);
157
158 snd_ctl_type_t snd_ctl_type(snd_ctl_t *handle);
159 int snd_ctl_open(snd_ctl_t **handle, char *name);
160 int snd_ctl_close(snd_ctl_t *handle);
161 int snd_ctl_card(snd_ctl_t *handle);
162 int snd_ctl_poll_descriptor(snd_ctl_t *handle);
163 int snd_ctl_info(snd_ctl_t *handle, snd_ctl_info_t *info);
164 int snd_ctl_clist(snd_ctl_t *handle, snd_control_list_t * list);
165 int snd_ctl_cinfo(snd_ctl_t *handle, snd_control_info_t * sw);
166 int snd_ctl_cread(snd_ctl_t *handle, snd_control_t * control);
167 int snd_ctl_cwrite(snd_ctl_t *handle, snd_control_t * control);
168 int snd_ctl_hwdep_next_device(snd_ctl_t *handle, int * device);
169 int snd_ctl_hwdep_info(snd_ctl_t *handle, snd_hwdep_info_t * info);
170 int snd_ctl_pcm_next_device(snd_ctl_t *handle, int *device);
171 int snd_ctl_pcm_info(snd_ctl_t *handle, snd_pcm_info_t * info);
172 int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *handle, int subdev);
173 int snd_ctl_rawmidi_next_device(snd_ctl_t *handle, int * device);
174 int snd_ctl_rawmidi_info(snd_ctl_t *handle, snd_rawmidi_info_t * info);
175 int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *handle, int subdev);
176
177 int snd_ctl_read(snd_ctl_t *handle, snd_ctl_callbacks_t * callbacks);
178
179 void snd_control_set_bytes(snd_control_t *obj, void *data, size_t size);
180
181 const char *snd_control_type_name(snd_control_type_t type);
182 const char *snd_control_iface_name(snd_control_iface_t iface);
183 const char *snd_ctl_event_type_name(snd_ctl_event_type_t type);
184
185 int snd_control_list_alloc_space(snd_control_list_t *obj, unsigned int entries);
186 void snd_control_list_free_space(snd_control_list_t *obj);
187
188 #ifdef __cplusplus
189 }
190 #endif
191
192 /*
193  *  Highlevel API for controls
194  */
195
196 typedef struct _snd_hcontrol_list snd_hcontrol_list_t;
197 typedef struct _snd_hcontrol snd_hcontrol_t;
198
199 #ifdef __cplusplus
200 extern "C" {
201 #endif
202
203 typedef int (*snd_ctl_hsort_t)(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
204 typedef void (*snd_ctl_hcallback_rebuild_t)(snd_ctl_t *handle, void *private_data);
205 typedef void (*snd_ctl_hcallback_add_t)(snd_ctl_t *handle, void *private_data, snd_hcontrol_t *hcontrol);
206 typedef void (*snd_hcontrol_callback_t)(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
207 typedef void (*snd_hcontrol_private_free_t)(snd_hcontrol_t *hcontrol);
208
209 int snd_ctl_hbuild(snd_ctl_t *handle, snd_ctl_hsort_t csort);
210 int snd_ctl_hfree(snd_ctl_t *handle);
211 snd_hcontrol_t *snd_ctl_hfirst(snd_ctl_t *handle);
212 snd_hcontrol_t *snd_ctl_hlast(snd_ctl_t *handle);
213 snd_hcontrol_t *snd_ctl_hnext(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
214 snd_hcontrol_t *snd_ctl_hprev(snd_ctl_t *handle, snd_hcontrol_t *hcontrol);
215 int snd_ctl_hcount(snd_ctl_t *handle);
216 snd_hcontrol_t *snd_ctl_hfind(snd_ctl_t *handle, snd_control_id_t *id);
217 int snd_ctl_hlist(snd_ctl_t *handle, snd_hcontrol_list_t *hlist);
218 int snd_ctl_hsort(const snd_hcontrol_t *c1, const snd_hcontrol_t *c2);
219 int snd_ctl_hresort(snd_ctl_t *handle, snd_ctl_hsort_t csort);
220 int snd_ctl_hcallback_rebuild(snd_ctl_t *handle, snd_ctl_hcallback_rebuild_t callback, void *private_data);
221 int snd_ctl_hcallback_add(snd_ctl_t *handle, snd_ctl_hcallback_add_t callback, void *private_data);
222 int snd_ctl_hevent(snd_ctl_t *handle);
223
224 int snd_ctl_hbag_create(void **bag);
225 int snd_ctl_hbag_destroy(void **bag, void (*hcontrol_free)(snd_hcontrol_t *hcontrol));
226 int snd_ctl_hbag_add(void **bag, snd_hcontrol_t *hcontrol);
227 int snd_ctl_hbag_del(void **bag, snd_hcontrol_t *hcontrol);
228 snd_hcontrol_t *snd_ctl_hbag_find(void **bag, snd_control_id_t *id);
229 int snd_hcontrol_list_alloc_space(snd_hcontrol_list_t *obj, unsigned int entries);
230 void snd_hcontrol_list_free_space(snd_hcontrol_list_t *obj);
231
232 #ifdef __cplusplus
233 }
234 #endif
235