jpayne@69
|
1 /**
|
jpayne@69
|
2 * \file include/control_external.h
|
jpayne@69
|
3 * \brief External control plugin SDK
|
jpayne@69
|
4 * \author Takashi Iwai <tiwai@suse.de>
|
jpayne@69
|
5 * \date 2005
|
jpayne@69
|
6 *
|
jpayne@69
|
7 * External control plugin SDK.
|
jpayne@69
|
8 */
|
jpayne@69
|
9
|
jpayne@69
|
10 /*
|
jpayne@69
|
11 * This library is free software; you can redistribute it and/or modify
|
jpayne@69
|
12 * it under the terms of the GNU Lesser General Public License as
|
jpayne@69
|
13 * published by the Free Software Foundation; either version 2.1 of
|
jpayne@69
|
14 * the License, or (at your option) any later version.
|
jpayne@69
|
15 *
|
jpayne@69
|
16 * This program is distributed in the hope that it will be useful,
|
jpayne@69
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jpayne@69
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jpayne@69
|
19 * GNU Lesser General Public License for more details.
|
jpayne@69
|
20 *
|
jpayne@69
|
21 * You should have received a copy of the GNU Lesser General Public
|
jpayne@69
|
22 * License along with this library; if not, write to the Free Software
|
jpayne@69
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
jpayne@69
|
24 *
|
jpayne@69
|
25 */
|
jpayne@69
|
26 #ifndef __ALSA_CONTROL_EXTERNAL_H
|
jpayne@69
|
27 #define __ALSA_CONTROL_EXTERNAL_H
|
jpayne@69
|
28
|
jpayne@69
|
29 #include "control.h"
|
jpayne@69
|
30
|
jpayne@69
|
31 #ifdef __cplusplus
|
jpayne@69
|
32 extern "C" {
|
jpayne@69
|
33 #endif
|
jpayne@69
|
34
|
jpayne@69
|
35 /**
|
jpayne@69
|
36 * \defgroup CtlPlugin_SDK External Control Plugin SDK
|
jpayne@69
|
37 * \{
|
jpayne@69
|
38 */
|
jpayne@69
|
39
|
jpayne@69
|
40 /**
|
jpayne@69
|
41 * Define the object entry for external control plugins
|
jpayne@69
|
42 */
|
jpayne@69
|
43 #define SND_CTL_PLUGIN_ENTRY(name) _snd_ctl_##name##_open
|
jpayne@69
|
44
|
jpayne@69
|
45 /**
|
jpayne@69
|
46 * Define the symbols of the given control plugin with versions
|
jpayne@69
|
47 */
|
jpayne@69
|
48 #define SND_CTL_PLUGIN_SYMBOL(name) SND_DLSYM_BUILD_VERSION(SND_CTL_PLUGIN_ENTRY(name), SND_CONTROL_DLSYM_VERSION);
|
jpayne@69
|
49
|
jpayne@69
|
50 /**
|
jpayne@69
|
51 * Define the control plugin
|
jpayne@69
|
52 */
|
jpayne@69
|
53 #define SND_CTL_PLUGIN_DEFINE_FUNC(plugin) \
|
jpayne@69
|
54 int SND_CTL_PLUGIN_ENTRY(plugin) (snd_ctl_t **handlep, const char *name,\
|
jpayne@69
|
55 snd_config_t *root, snd_config_t *conf, int mode)
|
jpayne@69
|
56
|
jpayne@69
|
57 /** External control plugin handle */
|
jpayne@69
|
58 typedef struct snd_ctl_ext snd_ctl_ext_t;
|
jpayne@69
|
59 /** Callback table of control ext */
|
jpayne@69
|
60 typedef struct snd_ctl_ext_callback snd_ctl_ext_callback_t;
|
jpayne@69
|
61 /** Key to access a control pointer */
|
jpayne@69
|
62 typedef unsigned long snd_ctl_ext_key_t;
|
jpayne@69
|
63 #ifdef DOC_HIDDEN
|
jpayne@69
|
64 /* redefine typedef's for stupid doxygen */
|
jpayne@69
|
65 typedef snd_ctl_ext snd_ctl_ext_t;
|
jpayne@69
|
66 typedef snd_ctl_ext_callback snd_ctl_ext_callback_t;
|
jpayne@69
|
67 #endif
|
jpayne@69
|
68 /** Callback to handle TLV commands. */
|
jpayne@69
|
69 typedef int (snd_ctl_ext_tlv_rw_t)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int op_flag, unsigned int numid,
|
jpayne@69
|
70 unsigned int *tlv, unsigned int tlv_size);
|
jpayne@69
|
71
|
jpayne@69
|
72 /*
|
jpayne@69
|
73 * Protocol version
|
jpayne@69
|
74 */
|
jpayne@69
|
75 #define SND_CTL_EXT_VERSION_MAJOR 1 /**< Protocol major version */
|
jpayne@69
|
76 #define SND_CTL_EXT_VERSION_MINOR 0 /**< Protocol minor version */
|
jpayne@69
|
77 #define SND_CTL_EXT_VERSION_TINY 1 /**< Protocol tiny version */
|
jpayne@69
|
78 /**
|
jpayne@69
|
79 * external plugin protocol version
|
jpayne@69
|
80 */
|
jpayne@69
|
81 #define SND_CTL_EXT_VERSION ((SND_CTL_EXT_VERSION_MAJOR<<16) |\
|
jpayne@69
|
82 (SND_CTL_EXT_VERSION_MINOR<<8) |\
|
jpayne@69
|
83 (SND_CTL_EXT_VERSION_TINY))
|
jpayne@69
|
84
|
jpayne@69
|
85 /** Handle of control ext */
|
jpayne@69
|
86 struct snd_ctl_ext {
|
jpayne@69
|
87 /**
|
jpayne@69
|
88 * protocol version; #SND_CTL_EXT_VERSION must be filled here
|
jpayne@69
|
89 * before calling #snd_ctl_ext_create()
|
jpayne@69
|
90 */
|
jpayne@69
|
91 unsigned int version;
|
jpayne@69
|
92 /**
|
jpayne@69
|
93 * Index of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
94 */
|
jpayne@69
|
95 int card_idx;
|
jpayne@69
|
96 /**
|
jpayne@69
|
97 * ID string of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
98 */
|
jpayne@69
|
99 char id[16];
|
jpayne@69
|
100 /**
|
jpayne@69
|
101 * Driver name of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
102 */
|
jpayne@69
|
103 char driver[16];
|
jpayne@69
|
104 /**
|
jpayne@69
|
105 * short name of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
106 */
|
jpayne@69
|
107 char name[32];
|
jpayne@69
|
108 /**
|
jpayne@69
|
109 * Long name of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
110 */
|
jpayne@69
|
111 char longname[80];
|
jpayne@69
|
112 /**
|
jpayne@69
|
113 * Mixer name of this card; must be filled before calling #snd_ctl_ext_create()
|
jpayne@69
|
114 */
|
jpayne@69
|
115 char mixername[80];
|
jpayne@69
|
116 /**
|
jpayne@69
|
117 * poll descriptor
|
jpayne@69
|
118 */
|
jpayne@69
|
119 int poll_fd;
|
jpayne@69
|
120
|
jpayne@69
|
121 /**
|
jpayne@69
|
122 * callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()
|
jpayne@69
|
123 */
|
jpayne@69
|
124 const snd_ctl_ext_callback_t *callback;
|
jpayne@69
|
125 /**
|
jpayne@69
|
126 * private data, which can be used freely in the driver callbacks
|
jpayne@69
|
127 */
|
jpayne@69
|
128 void *private_data;
|
jpayne@69
|
129 /**
|
jpayne@69
|
130 * control handle filled by #snd_ctl_ext_create()
|
jpayne@69
|
131 */
|
jpayne@69
|
132 snd_ctl_t *handle;
|
jpayne@69
|
133
|
jpayne@69
|
134 int nonblock; /**< non-block mode; read-only */
|
jpayne@69
|
135 int subscribed; /**< events subscribed; read-only */
|
jpayne@69
|
136
|
jpayne@69
|
137 /**
|
jpayne@69
|
138 * optional TLV data for the control (since protocol 1.0.1)
|
jpayne@69
|
139 */
|
jpayne@69
|
140 union {
|
jpayne@69
|
141 snd_ctl_ext_tlv_rw_t *c;
|
jpayne@69
|
142 const unsigned int *p;
|
jpayne@69
|
143 } tlv;
|
jpayne@69
|
144 };
|
jpayne@69
|
145
|
jpayne@69
|
146 /** Callback table of ext. */
|
jpayne@69
|
147 struct snd_ctl_ext_callback {
|
jpayne@69
|
148 /**
|
jpayne@69
|
149 * close the control handle; optional
|
jpayne@69
|
150 */
|
jpayne@69
|
151 void (*close)(snd_ctl_ext_t *ext);
|
jpayne@69
|
152 /**
|
jpayne@69
|
153 * return the total number of elements; required
|
jpayne@69
|
154 */
|
jpayne@69
|
155 int (*elem_count)(snd_ctl_ext_t *ext);
|
jpayne@69
|
156 /**
|
jpayne@69
|
157 * return the element id of the given offset (array index); required
|
jpayne@69
|
158 */
|
jpayne@69
|
159 int (*elem_list)(snd_ctl_ext_t *ext, unsigned int offset, snd_ctl_elem_id_t *id);
|
jpayne@69
|
160 /**
|
jpayne@69
|
161 * convert the element id to a search key; required
|
jpayne@69
|
162 */
|
jpayne@69
|
163 snd_ctl_ext_key_t (*find_elem)(snd_ctl_ext_t *ext, const snd_ctl_elem_id_t *id);
|
jpayne@69
|
164 /**
|
jpayne@69
|
165 * the destructor of the key; optional
|
jpayne@69
|
166 */
|
jpayne@69
|
167 void (*free_key)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key);
|
jpayne@69
|
168 /**
|
jpayne@69
|
169 * get the attribute of the element; required
|
jpayne@69
|
170 */
|
jpayne@69
|
171 int (*get_attribute)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
|
jpayne@69
|
172 int *type, unsigned int *acc, unsigned int *count);
|
jpayne@69
|
173 /**
|
jpayne@69
|
174 * get the element information of integer type
|
jpayne@69
|
175 */
|
jpayne@69
|
176 int (*get_integer_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
|
jpayne@69
|
177 long *imin, long *imax, long *istep);
|
jpayne@69
|
178 /**
|
jpayne@69
|
179 * get the element information of integer64 type
|
jpayne@69
|
180 */
|
jpayne@69
|
181 int (*get_integer64_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
|
jpayne@69
|
182 int64_t *imin, int64_t *imax, int64_t *istep);
|
jpayne@69
|
183 /**
|
jpayne@69
|
184 * get the element information of enumerated type
|
jpayne@69
|
185 */
|
jpayne@69
|
186 int (*get_enumerated_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
|
jpayne@69
|
187 /**
|
jpayne@69
|
188 * get the name of the enumerated item
|
jpayne@69
|
189 */
|
jpayne@69
|
190 int (*get_enumerated_name)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int item,
|
jpayne@69
|
191 char *name, size_t name_max_len);
|
jpayne@69
|
192 /**
|
jpayne@69
|
193 * read the current values of integer type
|
jpayne@69
|
194 */
|
jpayne@69
|
195 int (*read_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);
|
jpayne@69
|
196 /**
|
jpayne@69
|
197 * read the current values of integer64 type
|
jpayne@69
|
198 */
|
jpayne@69
|
199 int (*read_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);
|
jpayne@69
|
200 /**
|
jpayne@69
|
201 * read the current values of enumerated type
|
jpayne@69
|
202 */
|
jpayne@69
|
203 int (*read_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
|
jpayne@69
|
204 /**
|
jpayne@69
|
205 * read the current values of bytes type
|
jpayne@69
|
206 */
|
jpayne@69
|
207 int (*read_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,
|
jpayne@69
|
208 size_t max_bytes);
|
jpayne@69
|
209 /**
|
jpayne@69
|
210 * read the current values of iec958 type
|
jpayne@69
|
211 */
|
jpayne@69
|
212 int (*read_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);
|
jpayne@69
|
213 /**
|
jpayne@69
|
214 * update the current values of integer type with the given values
|
jpayne@69
|
215 */
|
jpayne@69
|
216 int (*write_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);
|
jpayne@69
|
217 /**
|
jpayne@69
|
218 * update the current values of integer64 type with the given values
|
jpayne@69
|
219 */
|
jpayne@69
|
220 int (*write_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);
|
jpayne@69
|
221 /**
|
jpayne@69
|
222 * update the current values of enumerated type with the given values
|
jpayne@69
|
223 */
|
jpayne@69
|
224 int (*write_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
|
jpayne@69
|
225 /**
|
jpayne@69
|
226 * update the current values of bytes type with the given values
|
jpayne@69
|
227 */
|
jpayne@69
|
228 int (*write_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,
|
jpayne@69
|
229 size_t max_bytes);
|
jpayne@69
|
230 /**
|
jpayne@69
|
231 * update the current values of iec958 type with the given values
|
jpayne@69
|
232 */
|
jpayne@69
|
233 int (*write_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);
|
jpayne@69
|
234 /**
|
jpayne@69
|
235 * subscribe/unsubscribe the event notification; optional
|
jpayne@69
|
236 */
|
jpayne@69
|
237 void (*subscribe_events)(snd_ctl_ext_t *ext, int subscribe);
|
jpayne@69
|
238 /**
|
jpayne@69
|
239 * read a pending notification event; optional
|
jpayne@69
|
240 */
|
jpayne@69
|
241 int (*read_event)(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id, unsigned int *event_mask);
|
jpayne@69
|
242 /**
|
jpayne@69
|
243 * return the number of poll descriptors; optional
|
jpayne@69
|
244 */
|
jpayne@69
|
245 int (*poll_descriptors_count)(snd_ctl_ext_t *ext);
|
jpayne@69
|
246 /**
|
jpayne@69
|
247 * fill the poll descriptors; optional
|
jpayne@69
|
248 */
|
jpayne@69
|
249 int (*poll_descriptors)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int space);
|
jpayne@69
|
250 /**
|
jpayne@69
|
251 * mangle the revents of poll descriptors
|
jpayne@69
|
252 */
|
jpayne@69
|
253 int (*poll_revents)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
|
jpayne@69
|
254 };
|
jpayne@69
|
255
|
jpayne@69
|
256 /**
|
jpayne@69
|
257 * The access type bits stored in get_attribute callback
|
jpayne@69
|
258 */
|
jpayne@69
|
259 typedef enum snd_ctl_ext_access {
|
jpayne@69
|
260 SND_CTL_EXT_ACCESS_READ = (1<<0),
|
jpayne@69
|
261 SND_CTL_EXT_ACCESS_WRITE = (1<<1),
|
jpayne@69
|
262 SND_CTL_EXT_ACCESS_READWRITE = (3<<0),
|
jpayne@69
|
263 SND_CTL_EXT_ACCESS_VOLATILE = (1<<2),
|
jpayne@69
|
264 SND_CTL_EXT_ACCESS_TLV_READ = (1<<4),
|
jpayne@69
|
265 SND_CTL_EXT_ACCESS_TLV_WRITE = (1<<5),
|
jpayne@69
|
266 SND_CTL_EXT_ACCESS_TLV_READWRITE = (3<<4),
|
jpayne@69
|
267 SND_CTL_EXT_ACCESS_TLV_COMMAND = (1<<6),
|
jpayne@69
|
268 SND_CTL_EXT_ACCESS_INACTIVE = (1<<8),
|
jpayne@69
|
269 SND_CTL_EXT_ACCESS_TLV_CALLBACK = (1<<28),
|
jpayne@69
|
270 } snd_ctl_ext_access_t;
|
jpayne@69
|
271
|
jpayne@69
|
272 /**
|
jpayne@69
|
273 * find_elem callback returns this if no matching control element is found
|
jpayne@69
|
274 */
|
jpayne@69
|
275 #define SND_CTL_EXT_KEY_NOT_FOUND (snd_ctl_ext_key_t)(-1)
|
jpayne@69
|
276
|
jpayne@69
|
277 int snd_ctl_ext_create(snd_ctl_ext_t *ext, const char *name, int mode);
|
jpayne@69
|
278 int snd_ctl_ext_delete(snd_ctl_ext_t *ext);
|
jpayne@69
|
279
|
jpayne@69
|
280 /** \} */
|
jpayne@69
|
281
|
jpayne@69
|
282 #ifdef __cplusplus
|
jpayne@69
|
283 }
|
jpayne@69
|
284 #endif
|
jpayne@69
|
285
|
jpayne@69
|
286 #endif /* __ALSA_CONTROL_EXTERNAL_H */
|