control.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /**
  2. * \file include/control.h
  3. * \brief Application interface library for the ALSA driver
  4. * \author Jaroslav Kysela <perex@perex.cz>
  5. * \author Abramo Bagnara <abramo@alsa-project.org>
  6. * \author Takashi Iwai <tiwai@suse.de>
  7. * \date 1998-2001
  8. *
  9. * Application interface library for the ALSA driver
  10. */
  11. /*
  12. * This library is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU Lesser General Public License as
  14. * published by the Free Software Foundation; either version 2.1 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with this library; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. *
  26. */
  27. #ifndef __ALSA_CONTROL_H
  28. #define __ALSA_CONTROL_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /**
  33. * \defgroup Control Control Interface
  34. * The control interface.
  35. * See \ref control page for more details.
  36. * \{
  37. */
  38. /** dlsym version for interface entry callback */
  39. #define SND_CONTROL_DLSYM_VERSION _dlsym_control_001
  40. /** IEC958 structure */
  41. typedef struct snd_aes_iec958 {
  42. unsigned char status[24]; /**< AES/IEC958 channel status bits */
  43. unsigned char subcode[147]; /**< AES/IEC958 subcode bits */
  44. unsigned char pad; /**< nothing */
  45. unsigned char dig_subframe[4]; /**< AES/IEC958 subframe bits */
  46. } snd_aes_iec958_t;
  47. /** CTL card info container */
  48. typedef struct _snd_ctl_card_info snd_ctl_card_info_t;
  49. /** CTL element identifier container */
  50. typedef struct _snd_ctl_elem_id snd_ctl_elem_id_t;
  51. /** CTL element list container
  52. *
  53. * This is a list of CTL elements. The list contains management
  54. * information (e.g. how many elements the sound card has) as well as
  55. * the element identifiers. All functions which operate on the list
  56. * are named snd_ctl_elem_list_*().
  57. *
  58. * \par Memory management
  59. *
  60. * There are two memory areas to deal with: The list container itself
  61. * and the memory for the element identifiers.
  62. *
  63. * To manage the area for the list container, the following functions
  64. * are used:
  65. *
  66. * - snd_ctl_elem_list_malloc() / snd_ctl_elem_list_free() to allocate
  67. * and free memory on the heap, or
  68. * - snd_ctl_elem_list_alloca() to allocate the memory on the
  69. * stack. This memory is auto-released when the stack is unwound.
  70. *
  71. * To manage the space for the element identifiers, the
  72. * snd_ctl_elem_list_alloc_space() and snd_ctl_elem_list_free_space()
  73. * are used. Allocating the right amount of space can be achieved by
  74. * first obtaining the number of elements and then calling
  75. * snd_ctl_elem_list_alloc_space():
  76. *
  77. * \code
  78. * snd_ctl_elem_list_t* list;
  79. * int count;
  80. *
  81. * // Initialise list
  82. * snd_ctl_elem_list_malloc(&list);
  83. *
  84. * // Get number of elements
  85. * snd_ctl_elem_list(ctl, list);
  86. * count = snd_ctl_elem_list_get_count(list);
  87. *
  88. * // Allocate space for identifiers
  89. * snd_ctl_elem_list_alloc_space(list, count);
  90. *
  91. * // Get identifiers
  92. * snd_ctl_elem_list(ctl, list); // yes, this is same as above :)
  93. *
  94. * // Do something useful with the list...
  95. *
  96. * // Cleanup
  97. * snd_ctl_elem_list_free_space(list);
  98. * snd_ctl_elem_list_free(list);
  99. * \endcode
  100. *
  101. *
  102. * \par The Elements
  103. *
  104. * The elements in the list are accessed using an index. This index is
  105. * the location in the list; Don't confuse it with the 'index' of the
  106. * element identifier. For example:
  107. *
  108. * \code
  109. * snd_ctl_elem_list_t list;
  110. * unsigned int element_index;
  111. *
  112. * // Allocate space, fill list ...
  113. *
  114. * element_index = snd_ctl_elem_list_get_index(&list, 2);
  115. * \endcode
  116. *
  117. * This will access the 3rd element in the list (index=2) and get the
  118. * elements index from the driver (which might be 13, for example).
  119. */
  120. typedef struct _snd_ctl_elem_list snd_ctl_elem_list_t;
  121. /** CTL element info container */
  122. typedef struct _snd_ctl_elem_info snd_ctl_elem_info_t;
  123. /** CTL element value container
  124. *
  125. * Contains the value(s) (i.e. members) of a single element. All
  126. * values of a given element are of the same type.
  127. *
  128. * \par Memory management
  129. *
  130. * To access a value, a snd_ctl_elem_value_t must be allocated using
  131. * snd_ctl_elem_value_alloca() or snd_ctl_elem_value_malloc(). When
  132. * using the latter, it must be freed again using
  133. * snd_ctl_elem_value_free().
  134. *
  135. * \par Identifier
  136. *
  137. * Then, the ID must be filled. It is sufficient to fill only the
  138. * numid, if known. Otherwise, interface type, device, subdevice,
  139. * name, index must all be given. The following functions can be used
  140. * to fill the ID:
  141. *
  142. * - snd_ctl_elem_value_set_id(): Set the ID. Requires an
  143. * snd_ctl_elem_id_t object.
  144. * - snd_ctl_elem_value_set_numid(): Set the numid.
  145. * - Or use all of the following:
  146. *
  147. * - snd_ctl_elem_value_set_interface()
  148. * - snd_ctl_elem_value_set_device()
  149. * - snd_ctl_elem_value_set_subdevice()
  150. * - snd_ctl_elem_value_set_name()
  151. * - snd_ctl_elem_value_set_index()
  152. *
  153. * When communicating with the driver (snd_ctl_elem_read(),
  154. * snd_ctl_elem_write()), and the numid was given, the interface,
  155. * device, ... are filled (even if you set the before). When the numid
  156. * is unset (i.e. it is 0), it is filled.
  157. *
  158. * \par Communicating with the driver
  159. *
  160. * After the value container was created and filled with the ID of the
  161. * desired element, the value(s) can be fetched from the driver (and
  162. * thus from the hardware) or written to the driver.
  163. *
  164. * To fetch a value, use snd_ctl_elem_read(). Thereafter, use the
  165. * snd_ctl_elem_value_get_*() functions to obtain the actual value.
  166. *
  167. * To write a new value, first use a snd_ctl_elem_value_set_*() to set
  168. * it, then call snd_ctl_elem_write() to write it to the driver.
  169. */
  170. typedef struct _snd_ctl_elem_value snd_ctl_elem_value_t;
  171. /** CTL event container */
  172. typedef struct _snd_ctl_event snd_ctl_event_t;
  173. /** CTL element type */
  174. typedef enum _snd_ctl_elem_type {
  175. /** Invalid type */
  176. SND_CTL_ELEM_TYPE_NONE = 0,
  177. /** Boolean contents */
  178. SND_CTL_ELEM_TYPE_BOOLEAN,
  179. /** Integer contents */
  180. SND_CTL_ELEM_TYPE_INTEGER,
  181. /** Enumerated contents */
  182. SND_CTL_ELEM_TYPE_ENUMERATED,
  183. /** Bytes contents */
  184. SND_CTL_ELEM_TYPE_BYTES,
  185. /** IEC958 (S/PDIF) setting content */
  186. SND_CTL_ELEM_TYPE_IEC958,
  187. /** 64-bit integer contents */
  188. SND_CTL_ELEM_TYPE_INTEGER64,
  189. SND_CTL_ELEM_TYPE_LAST = SND_CTL_ELEM_TYPE_INTEGER64
  190. } snd_ctl_elem_type_t;
  191. /** CTL related interface */
  192. typedef enum _snd_ctl_elem_iface {
  193. /** Card level */
  194. SND_CTL_ELEM_IFACE_CARD = 0,
  195. /** Hardware dependent device */
  196. SND_CTL_ELEM_IFACE_HWDEP,
  197. /** Mixer */
  198. SND_CTL_ELEM_IFACE_MIXER,
  199. /** PCM */
  200. SND_CTL_ELEM_IFACE_PCM,
  201. /** RawMidi */
  202. SND_CTL_ELEM_IFACE_RAWMIDI,
  203. /** Timer */
  204. SND_CTL_ELEM_IFACE_TIMER,
  205. /** Sequencer */
  206. SND_CTL_ELEM_IFACE_SEQUENCER,
  207. SND_CTL_ELEM_IFACE_LAST = SND_CTL_ELEM_IFACE_SEQUENCER
  208. } snd_ctl_elem_iface_t;
  209. /** Event class */
  210. typedef enum _snd_ctl_event_type {
  211. /** Elements related event */
  212. SND_CTL_EVENT_ELEM = 0,
  213. SND_CTL_EVENT_LAST = SND_CTL_EVENT_ELEM
  214. }snd_ctl_event_type_t;
  215. /** Element has been removed (Warning: test this first and if set don't
  216. * test the other masks) \hideinitializer */
  217. #define SND_CTL_EVENT_MASK_REMOVE (~0U)
  218. /** Element value has been changed \hideinitializer */
  219. #define SND_CTL_EVENT_MASK_VALUE (1<<0)
  220. /** Element info has been changed \hideinitializer */
  221. #define SND_CTL_EVENT_MASK_INFO (1<<1)
  222. /** Element has been added \hideinitializer */
  223. #define SND_CTL_EVENT_MASK_ADD (1<<2)
  224. /** Element's TLV value has been changed \hideinitializer */
  225. #define SND_CTL_EVENT_MASK_TLV (1<<3)
  226. /** CTL name helper */
  227. #define SND_CTL_NAME_NONE ""
  228. /** CTL name helper */
  229. #define SND_CTL_NAME_PLAYBACK "Playback "
  230. /** CTL name helper */
  231. #define SND_CTL_NAME_CAPTURE "Capture "
  232. /** CTL name helper */
  233. #define SND_CTL_NAME_IEC958_NONE ""
  234. /** CTL name helper */
  235. #define SND_CTL_NAME_IEC958_SWITCH "Switch"
  236. /** CTL name helper */
  237. #define SND_CTL_NAME_IEC958_VOLUME "Volume"
  238. /** CTL name helper */
  239. #define SND_CTL_NAME_IEC958_DEFAULT "Default"
  240. /** CTL name helper */
  241. #define SND_CTL_NAME_IEC958_MASK "Mask"
  242. /** CTL name helper */
  243. #define SND_CTL_NAME_IEC958_CON_MASK "Con Mask"
  244. /** CTL name helper */
  245. #define SND_CTL_NAME_IEC958_PRO_MASK "Pro Mask"
  246. /** CTL name helper */
  247. #define SND_CTL_NAME_IEC958_PCM_STREAM "PCM Stream"
  248. /** Element name for IEC958 (S/PDIF) */
  249. #define SND_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SND_CTL_NAME_##direction SND_CTL_NAME_IEC958_##what
  250. /** Mask for the major Power State identifier */
  251. #define SND_CTL_POWER_MASK 0xff00
  252. /** ACPI/PCI Power State D0 */
  253. #define SND_CTL_POWER_D0 0x0000
  254. /** ACPI/PCI Power State D1 */
  255. #define SND_CTL_POWER_D1 0x0100
  256. /** ACPI/PCI Power State D2 */
  257. #define SND_CTL_POWER_D2 0x0200
  258. /** ACPI/PCI Power State D3 */
  259. #define SND_CTL_POWER_D3 0x0300
  260. /** ACPI/PCI Power State D3hot */
  261. #define SND_CTL_POWER_D3hot (SND_CTL_POWER_D3|0x0000)
  262. /** ACPI/PCI Power State D3cold */
  263. #define SND_CTL_POWER_D3cold (SND_CTL_POWER_D3|0x0001)
  264. /** TLV type - Container */
  265. #define SND_CTL_TLVT_CONTAINER 0x0000
  266. /** TLV type - basic dB scale */
  267. #define SND_CTL_TLVT_DB_SCALE 0x0001
  268. /** TLV type - linear volume */
  269. #define SND_CTL_TLVT_DB_LINEAR 0x0002
  270. /** TLV type - dB range container */
  271. #define SND_CTL_TLVT_DB_RANGE 0x0003
  272. /** TLV type - dB scale specified by min/max values */
  273. #define SND_CTL_TLVT_DB_MINMAX 0x0004
  274. /** TLV type - dB scale specified by min/max values (with mute) */
  275. #define SND_CTL_TLVT_DB_MINMAX_MUTE 0x0005
  276. /** Mute state */
  277. #define SND_CTL_TLV_DB_GAIN_MUTE -9999999
  278. /** TLV type - fixed channel map positions */
  279. #define SND_CTL_TLVT_CHMAP_FIXED 0x00101
  280. /** TLV type - freely swappable channel map positions */
  281. #define SND_CTL_TLVT_CHMAP_VAR 0x00102
  282. /** TLV type - pair-wise swappable channel map positions */
  283. #define SND_CTL_TLVT_CHMAP_PAIRED 0x00103
  284. /** CTL type */
  285. typedef enum _snd_ctl_type {
  286. /** Kernel level CTL */
  287. SND_CTL_TYPE_HW,
  288. /** Shared memory client CTL */
  289. SND_CTL_TYPE_SHM,
  290. /** INET client CTL (not yet implemented) */
  291. SND_CTL_TYPE_INET,
  292. /** External control plugin */
  293. SND_CTL_TYPE_EXT
  294. } snd_ctl_type_t;
  295. /** Non blocking mode (flag for open mode) \hideinitializer */
  296. #define SND_CTL_NONBLOCK 0x0001
  297. /** Async notification (flag for open mode) \hideinitializer */
  298. #define SND_CTL_ASYNC 0x0002
  299. /** Read only (flag for open mode) \hideinitializer */
  300. #define SND_CTL_READONLY 0x0004
  301. /** CTL handle */
  302. typedef struct _snd_ctl snd_ctl_t;
  303. /** Don't destroy the ctl handle when close */
  304. #define SND_SCTL_NOFREE 0x0001
  305. /** SCTL type */
  306. typedef struct _snd_sctl snd_sctl_t;
  307. int snd_card_load(int card);
  308. int snd_card_next(int *card);
  309. int snd_card_get_index(const char *name);
  310. int snd_card_get_name(int card, char **name);
  311. int snd_card_get_longname(int card, char **name);
  312. int snd_device_name_hint(int card, const char *iface, void ***hints);
  313. int snd_device_name_free_hint(void **hints);
  314. char *snd_device_name_get_hint(const void *hint, const char *id);
  315. int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode);
  316. int snd_ctl_open_lconf(snd_ctl_t **ctl, const char *name, int mode, snd_config_t *lconf);
  317. int snd_ctl_open_fallback(snd_ctl_t **ctl, snd_config_t *root, const char *name, const char *orig_name, int mode);
  318. int snd_ctl_close(snd_ctl_t *ctl);
  319. int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
  320. static __inline__ int snd_ctl_abort(snd_ctl_t *ctl) { return snd_ctl_nonblock(ctl, 2); }
  321. int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
  322. snd_async_callback_t callback, void *private_data);
  323. snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler);
  324. int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl);
  325. int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space);
  326. int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
  327. int snd_ctl_subscribe_events(snd_ctl_t *ctl, int subscribe);
  328. int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info);
  329. int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list);
  330. int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info);
  331. int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *data);
  332. int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *data);
  333. int snd_ctl_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  334. int snd_ctl_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  335. int snd_ctl_elem_tlv_read(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  336. unsigned int *tlv, unsigned int tlv_size);
  337. int snd_ctl_elem_tlv_write(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  338. const unsigned int *tlv);
  339. int snd_ctl_elem_tlv_command(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  340. const unsigned int *tlv);
  341. #ifdef __ALSA_HWDEP_H
  342. int snd_ctl_hwdep_next_device(snd_ctl_t *ctl, int * device);
  343. int snd_ctl_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info);
  344. #endif
  345. #ifdef __ALSA_PCM_H
  346. int snd_ctl_pcm_next_device(snd_ctl_t *ctl, int *device);
  347. int snd_ctl_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info);
  348. int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev);
  349. #endif
  350. #ifdef __ALSA_RAWMIDI_H
  351. int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device);
  352. int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info);
  353. int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev);
  354. #endif
  355. int snd_ctl_set_power_state(snd_ctl_t *ctl, unsigned int state);
  356. int snd_ctl_get_power_state(snd_ctl_t *ctl, unsigned int *state);
  357. int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event);
  358. int snd_ctl_wait(snd_ctl_t *ctl, int timeout);
  359. const char *snd_ctl_name(snd_ctl_t *ctl);
  360. snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl);
  361. const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type);
  362. const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface);
  363. const char *snd_ctl_event_type_name(snd_ctl_event_type_t type);
  364. unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj);
  365. unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj);
  366. void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr);
  367. snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj);
  368. unsigned int snd_ctl_event_elem_get_device(const snd_ctl_event_t *obj);
  369. unsigned int snd_ctl_event_elem_get_subdevice(const snd_ctl_event_t *obj);
  370. const char *snd_ctl_event_elem_get_name(const snd_ctl_event_t *obj);
  371. unsigned int snd_ctl_event_elem_get_index(const snd_ctl_event_t *obj);
  372. int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries);
  373. void snd_ctl_elem_list_free_space(snd_ctl_elem_list_t *obj);
  374. char *snd_ctl_ascii_elem_id_get(snd_ctl_elem_id_t *id);
  375. int snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str);
  376. int snd_ctl_ascii_value_parse(snd_ctl_t *handle,
  377. snd_ctl_elem_value_t *dst,
  378. snd_ctl_elem_info_t *info,
  379. const char *value);
  380. size_t snd_ctl_elem_id_sizeof(void);
  381. /** \hideinitializer
  382. * \brief allocate an invalid #snd_ctl_elem_id_t using standard alloca
  383. * \param ptr returned pointer
  384. */
  385. #define snd_ctl_elem_id_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_id)
  386. int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr);
  387. void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj);
  388. void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj);
  389. void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src);
  390. unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj);
  391. snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj);
  392. unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj);
  393. unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj);
  394. const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj);
  395. unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj);
  396. void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val);
  397. void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val);
  398. void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val);
  399. void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val);
  400. void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val);
  401. void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val);
  402. size_t snd_ctl_card_info_sizeof(void);
  403. /** \hideinitializer
  404. * \brief allocate an invalid #snd_ctl_card_info_t using standard alloca
  405. * \param ptr returned pointer
  406. */
  407. #define snd_ctl_card_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_card_info)
  408. int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr);
  409. void snd_ctl_card_info_free(snd_ctl_card_info_t *obj);
  410. void snd_ctl_card_info_clear(snd_ctl_card_info_t *obj);
  411. void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src);
  412. int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj);
  413. const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj);
  414. const char *snd_ctl_card_info_get_driver(const snd_ctl_card_info_t *obj);
  415. const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj);
  416. const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj);
  417. const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj);
  418. const char *snd_ctl_card_info_get_components(const snd_ctl_card_info_t *obj);
  419. size_t snd_ctl_event_sizeof(void);
  420. /** \hideinitializer
  421. * \brief allocate an invalid #snd_ctl_event_t using standard alloca
  422. * \param ptr returned pointer
  423. */
  424. #define snd_ctl_event_alloca(ptr) __snd_alloca(ptr, snd_ctl_event)
  425. int snd_ctl_event_malloc(snd_ctl_event_t **ptr);
  426. void snd_ctl_event_free(snd_ctl_event_t *obj);
  427. void snd_ctl_event_clear(snd_ctl_event_t *obj);
  428. void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src);
  429. snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj);
  430. size_t snd_ctl_elem_list_sizeof(void);
  431. /** \hideinitializer
  432. *
  433. * \brief Allocate a #snd_ctl_elem_list_t using standard alloca.
  434. *
  435. * The memory is allocated on the stack and will automatically be
  436. * released when the stack unwinds (i.e. no free() is needed).
  437. *
  438. * \param ptr Pointer to allocated memory.
  439. */
  440. #define snd_ctl_elem_list_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_list)
  441. int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr);
  442. void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj);
  443. void snd_ctl_elem_list_clear(snd_ctl_elem_list_t *obj);
  444. void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src);
  445. void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val);
  446. unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj);
  447. unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj);
  448. void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr);
  449. unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx);
  450. snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx);
  451. unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx);
  452. unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx);
  453. const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx);
  454. unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx);
  455. size_t snd_ctl_elem_info_sizeof(void);
  456. /** \hideinitializer
  457. * \brief allocate an invalid #snd_ctl_elem_info_t using standard alloca
  458. * \param ptr returned pointer
  459. */
  460. #define snd_ctl_elem_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_info)
  461. int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr);
  462. void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj);
  463. void snd_ctl_elem_info_clear(snd_ctl_elem_info_t *obj);
  464. void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src);
  465. snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj);
  466. int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj);
  467. int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj);
  468. int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj);
  469. int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj);
  470. int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj);
  471. int snd_ctl_elem_info_is_tlv_readable(const snd_ctl_elem_info_t *obj);
  472. int snd_ctl_elem_info_is_tlv_writable(const snd_ctl_elem_info_t *obj);
  473. int snd_ctl_elem_info_is_tlv_commandable(const snd_ctl_elem_info_t *obj);
  474. int snd_ctl_elem_info_is_owner(const snd_ctl_elem_info_t *obj);
  475. int snd_ctl_elem_info_is_user(const snd_ctl_elem_info_t *obj);
  476. pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj);
  477. unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj);
  478. long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj);
  479. long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj);
  480. long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj);
  481. long long snd_ctl_elem_info_get_min64(const snd_ctl_elem_info_t *obj);
  482. long long snd_ctl_elem_info_get_max64(const snd_ctl_elem_info_t *obj);
  483. long long snd_ctl_elem_info_get_step64(const snd_ctl_elem_info_t *obj);
  484. unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj);
  485. void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val);
  486. const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj);
  487. int snd_ctl_elem_info_get_dimensions(const snd_ctl_elem_info_t *obj);
  488. int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int idx);
  489. int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
  490. const int dimension[4]);
  491. void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr);
  492. unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj);
  493. snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj);
  494. unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj);
  495. unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj);
  496. const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj);
  497. unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj);
  498. void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr);
  499. void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val);
  500. void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val);
  501. void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val);
  502. void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val);
  503. void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val);
  504. void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val);
  505. int snd_ctl_add_integer_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  506. unsigned int element_count,
  507. unsigned int member_count,
  508. long min, long max, long step);
  509. int snd_ctl_add_integer64_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  510. unsigned int element_count,
  511. unsigned int member_count,
  512. long long min, long long max,
  513. long long step);
  514. int snd_ctl_add_boolean_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  515. unsigned int element_count,
  516. unsigned int member_count);
  517. int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  518. unsigned int element_count,
  519. unsigned int member_count,
  520. unsigned int items,
  521. const char *const labels[]);
  522. int snd_ctl_add_bytes_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  523. unsigned int element_count,
  524. unsigned int member_count);
  525. int snd_ctl_elem_add_integer(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, unsigned int count, long imin, long imax, long istep);
  526. int snd_ctl_elem_add_integer64(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, unsigned int count, long long imin, long long imax, long long istep);
  527. int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, unsigned int count);
  528. int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, unsigned int count, unsigned int items, const char *const names[]);
  529. int snd_ctl_elem_add_iec958(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id);
  530. int snd_ctl_elem_remove(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  531. size_t snd_ctl_elem_value_sizeof(void);
  532. /** \hideinitializer
  533. * \brief Allocate an invalid #snd_ctl_elem_value_t on the stack.
  534. *
  535. * Allocate space for a value object on the stack. The allocated
  536. * memory need not be freed, because is on the stack.
  537. *
  538. * See snd_ctl_elem_value_t for details.
  539. *
  540. * \param ptr Pointer to a snd_ctl_elem_value_t pointer. The address
  541. * of the allocated space will returned here.
  542. */
  543. #define snd_ctl_elem_value_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_value)
  544. int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr);
  545. void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj);
  546. void snd_ctl_elem_value_clear(snd_ctl_elem_value_t *obj);
  547. void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src);
  548. int snd_ctl_elem_value_compare(snd_ctl_elem_value_t *left, const snd_ctl_elem_value_t *right);
  549. void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr);
  550. unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj);
  551. snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj);
  552. unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj);
  553. unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj);
  554. const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj);
  555. unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj);
  556. void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr);
  557. void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val);
  558. void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val);
  559. void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val);
  560. void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val);
  561. void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val);
  562. void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val);
  563. int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx);
  564. long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx);
  565. long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsigned int idx);
  566. unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx);
  567. unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx);
  568. void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
  569. void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
  570. void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int idx, long long val);
  571. void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val);
  572. void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val);
  573. void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size);
  574. const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj);
  575. void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr);
  576. void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr);
  577. int snd_tlv_parse_dB_info(unsigned int *tlv, unsigned int tlv_size,
  578. unsigned int **db_tlvp);
  579. int snd_tlv_get_dB_range(unsigned int *tlv, long rangemin, long rangemax,
  580. long *min, long *max);
  581. int snd_tlv_convert_to_dB(unsigned int *tlv, long rangemin, long rangemax,
  582. long volume, long *db_gain);
  583. int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax,
  584. long db_gain, long *value, int xdir);
  585. int snd_ctl_get_dB_range(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  586. long *min, long *max);
  587. int snd_ctl_convert_to_dB(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  588. long volume, long *db_gain);
  589. int snd_ctl_convert_from_dB(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  590. long db_gain, long *value, int xdir);
  591. /**
  592. * \defgroup HControl High level Control Interface
  593. * \ingroup Control
  594. * The high level control interface.
  595. * See \ref hcontrol page for more details.
  596. * \{
  597. */
  598. /** HCTL element handle */
  599. typedef struct _snd_hctl_elem snd_hctl_elem_t;
  600. /** HCTL handle */
  601. typedef struct _snd_hctl snd_hctl_t;
  602. /**
  603. * \brief Compare function for sorting HCTL elements
  604. * \param e1 First element
  605. * \param e2 Second element
  606. * \return -1 if e1 < e2, 0 if e1 == e2, 1 if e1 > e2
  607. */
  608. typedef int (*snd_hctl_compare_t)(const snd_hctl_elem_t *e1,
  609. const snd_hctl_elem_t *e2);
  610. int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
  611. const snd_hctl_elem_t *c2);
  612. /**
  613. * \brief HCTL callback function
  614. * \param hctl HCTL handle
  615. * \param mask event mask
  616. * \param elem related HCTL element (if any)
  617. * \return 0 on success otherwise a negative error code
  618. */
  619. typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl,
  620. unsigned int mask,
  621. snd_hctl_elem_t *elem);
  622. /**
  623. * \brief HCTL element callback function
  624. * \param elem HCTL element
  625. * \param mask event mask
  626. * \return 0 on success otherwise a negative error code
  627. */
  628. typedef int (*snd_hctl_elem_callback_t)(snd_hctl_elem_t *elem,
  629. unsigned int mask);
  630. int snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode);
  631. int snd_hctl_open_ctl(snd_hctl_t **hctlp, snd_ctl_t *ctl);
  632. int snd_hctl_close(snd_hctl_t *hctl);
  633. int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock);
  634. static __inline__ int snd_hctl_abort(snd_hctl_t *hctl) { return snd_hctl_nonblock(hctl, 2); }
  635. int snd_hctl_poll_descriptors_count(snd_hctl_t *hctl);
  636. int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space);
  637. int snd_hctl_poll_descriptors_revents(snd_hctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
  638. unsigned int snd_hctl_get_count(snd_hctl_t *hctl);
  639. int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort);
  640. snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl);
  641. snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl);
  642. snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id);
  643. void snd_hctl_set_callback(snd_hctl_t *hctl, snd_hctl_callback_t callback);
  644. void snd_hctl_set_callback_private(snd_hctl_t *hctl, void *data);
  645. void *snd_hctl_get_callback_private(snd_hctl_t *hctl);
  646. int snd_hctl_load(snd_hctl_t *hctl);
  647. int snd_hctl_free(snd_hctl_t *hctl);
  648. int snd_hctl_handle_events(snd_hctl_t *hctl);
  649. const char *snd_hctl_name(snd_hctl_t *hctl);
  650. int snd_hctl_wait(snd_hctl_t *hctl, int timeout);
  651. snd_ctl_t *snd_hctl_ctl(snd_hctl_t *hctl);
  652. snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
  653. snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
  654. int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t * info);
  655. int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
  656. int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
  657. int snd_hctl_elem_tlv_read(snd_hctl_elem_t *elem, unsigned int *tlv, unsigned int tlv_size);
  658. int snd_hctl_elem_tlv_write(snd_hctl_elem_t *elem, const unsigned int *tlv);
  659. int snd_hctl_elem_tlv_command(snd_hctl_elem_t *elem, const unsigned int *tlv);
  660. snd_hctl_t *snd_hctl_elem_get_hctl(snd_hctl_elem_t *elem);
  661. void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr);
  662. unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj);
  663. snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj);
  664. unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj);
  665. unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj);
  666. const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj);
  667. unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj);
  668. void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val);
  669. void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj);
  670. void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val);
  671. /** \} */
  672. /** \} */
  673. /**
  674. * \defgroup SControl Setup Control Interface
  675. * \ingroup Control
  676. * The setup control interface - set or modify control elements from a configuration file.
  677. * \{
  678. */
  679. int snd_sctl_build(snd_sctl_t **ctl, snd_ctl_t *handle, snd_config_t *config,
  680. snd_config_t *private_data, int mode);
  681. int snd_sctl_free(snd_sctl_t *handle);
  682. int snd_sctl_install(snd_sctl_t *handle);
  683. int snd_sctl_remove(snd_sctl_t *handle);
  684. /** \} */
  685. #ifdef __cplusplus
  686. }
  687. #endif
  688. #endif /* __ALSA_CONTROL_H */