control.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 identifier list container */
  52. typedef struct _snd_ctl_elem_list snd_ctl_elem_list_t;
  53. /** CTL element info container */
  54. typedef struct _snd_ctl_elem_info snd_ctl_elem_info_t;
  55. /** CTL element value container */
  56. typedef struct _snd_ctl_elem_value snd_ctl_elem_value_t;
  57. /** CTL event container */
  58. typedef struct _snd_ctl_event snd_ctl_event_t;
  59. /** CTL element type */
  60. typedef enum _snd_ctl_elem_type {
  61. /** Invalid type */
  62. SND_CTL_ELEM_TYPE_NONE = 0,
  63. /** Boolean contents */
  64. SND_CTL_ELEM_TYPE_BOOLEAN,
  65. /** Integer contents */
  66. SND_CTL_ELEM_TYPE_INTEGER,
  67. /** Enumerated contents */
  68. SND_CTL_ELEM_TYPE_ENUMERATED,
  69. /** Bytes contents */
  70. SND_CTL_ELEM_TYPE_BYTES,
  71. /** IEC958 (S/PDIF) setting content */
  72. SND_CTL_ELEM_TYPE_IEC958,
  73. /** 64-bit integer contents */
  74. SND_CTL_ELEM_TYPE_INTEGER64,
  75. SND_CTL_ELEM_TYPE_LAST = SND_CTL_ELEM_TYPE_INTEGER64
  76. } snd_ctl_elem_type_t;
  77. /** CTL related interface */
  78. typedef enum _snd_ctl_elem_iface {
  79. /** Card level */
  80. SND_CTL_ELEM_IFACE_CARD = 0,
  81. /** Hardware dependent device */
  82. SND_CTL_ELEM_IFACE_HWDEP,
  83. /** Mixer */
  84. SND_CTL_ELEM_IFACE_MIXER,
  85. /** PCM */
  86. SND_CTL_ELEM_IFACE_PCM,
  87. /** RawMidi */
  88. SND_CTL_ELEM_IFACE_RAWMIDI,
  89. /** Timer */
  90. SND_CTL_ELEM_IFACE_TIMER,
  91. /** Sequencer */
  92. SND_CTL_ELEM_IFACE_SEQUENCER,
  93. SND_CTL_ELEM_IFACE_LAST = SND_CTL_ELEM_IFACE_SEQUENCER
  94. } snd_ctl_elem_iface_t;
  95. /** Event class */
  96. typedef enum _snd_ctl_event_type {
  97. /** Elements related event */
  98. SND_CTL_EVENT_ELEM = 0,
  99. SND_CTL_EVENT_LAST = SND_CTL_EVENT_ELEM
  100. }snd_ctl_event_type_t;
  101. /** Element has been removed (Warning: test this first and if set don't
  102. * test the other masks) \hideinitializer */
  103. #define SND_CTL_EVENT_MASK_REMOVE (~0U)
  104. /** Element value has been changed \hideinitializer */
  105. #define SND_CTL_EVENT_MASK_VALUE (1<<0)
  106. /** Element info has been changed \hideinitializer */
  107. #define SND_CTL_EVENT_MASK_INFO (1<<1)
  108. /** Element has been added \hideinitializer */
  109. #define SND_CTL_EVENT_MASK_ADD (1<<2)
  110. /** Element's TLV value has been changed \hideinitializer */
  111. #define SND_CTL_EVENT_MASK_TLV (1<<3)
  112. /** CTL name helper */
  113. #define SND_CTL_NAME_NONE ""
  114. /** CTL name helper */
  115. #define SND_CTL_NAME_PLAYBACK "Playback "
  116. /** CTL name helper */
  117. #define SND_CTL_NAME_CAPTURE "Capture "
  118. /** CTL name helper */
  119. #define SND_CTL_NAME_IEC958_NONE ""
  120. /** CTL name helper */
  121. #define SND_CTL_NAME_IEC958_SWITCH "Switch"
  122. /** CTL name helper */
  123. #define SND_CTL_NAME_IEC958_VOLUME "Volume"
  124. /** CTL name helper */
  125. #define SND_CTL_NAME_IEC958_DEFAULT "Default"
  126. /** CTL name helper */
  127. #define SND_CTL_NAME_IEC958_MASK "Mask"
  128. /** CTL name helper */
  129. #define SND_CTL_NAME_IEC958_CON_MASK "Con Mask"
  130. /** CTL name helper */
  131. #define SND_CTL_NAME_IEC958_PRO_MASK "Pro Mask"
  132. /** CTL name helper */
  133. #define SND_CTL_NAME_IEC958_PCM_STREAM "PCM Stream"
  134. /** Element name for IEC958 (S/PDIF) */
  135. #define SND_CTL_NAME_IEC958(expl,direction,what) "IEC958 " expl SND_CTL_NAME_##direction SND_CTL_NAME_IEC958_##what
  136. /** Mask for the major Power State identifier */
  137. #define SND_CTL_POWER_MASK 0xff00
  138. /** ACPI/PCI Power State D0 */
  139. #define SND_CTL_POWER_D0 0x0000
  140. /** ACPI/PCI Power State D1 */
  141. #define SND_CTL_POWER_D1 0x0100
  142. /** ACPI/PCI Power State D2 */
  143. #define SND_CTL_POWER_D2 0x0200
  144. /** ACPI/PCI Power State D3 */
  145. #define SND_CTL_POWER_D3 0x0300
  146. /** ACPI/PCI Power State D3hot */
  147. #define SND_CTL_POWER_D3hot (SND_CTL_POWER_D3|0x0000)
  148. /** ACPI/PCI Power State D3cold */
  149. #define SND_CTL_POWER_D3cold (SND_CTL_POWER_D3|0x0001)
  150. /** TLV type - Container */
  151. #define SND_CTL_TLVT_CONTAINER 0x0000
  152. /** TLV type - basic dB scale */
  153. #define SND_CTL_TLVT_DB_SCALE 0x0001
  154. /** TLV type - linear volume */
  155. #define SND_CTL_TLVT_DB_LINEAR 0x0002
  156. /** TLV type - dB range container */
  157. #define SND_CTL_TLVT_DB_RANGE 0x0003
  158. /** TLV type - dB scale specified by min/max values */
  159. #define SND_CTL_TLVT_DB_MINMAX 0x0004
  160. /** TLV type - dB scale specified by min/max values (with mute) */
  161. #define SND_CTL_TLVT_DB_MINMAX_MUTE 0x0005
  162. /** Mute state */
  163. #define SND_CTL_TLV_DB_GAIN_MUTE -9999999
  164. /** TLV type - fixed channel map positions */
  165. #define SND_CTL_TLVT_CHMAP_FIXED 0x00101
  166. /** TLV type - freely swappable channel map positions */
  167. #define SND_CTL_TLVT_CHMAP_VAR 0x00102
  168. /** TLV type - pair-wise swappable channel map positions */
  169. #define SND_CTL_TLVT_CHMAP_PAIRED 0x00103
  170. /** CTL type */
  171. typedef enum _snd_ctl_type {
  172. /** Kernel level CTL */
  173. SND_CTL_TYPE_HW,
  174. /** Shared memory client CTL */
  175. SND_CTL_TYPE_SHM,
  176. /** INET client CTL (not yet implemented) */
  177. SND_CTL_TYPE_INET,
  178. /** External control plugin */
  179. SND_CTL_TYPE_EXT
  180. } snd_ctl_type_t;
  181. /** Non blocking mode (flag for open mode) \hideinitializer */
  182. #define SND_CTL_NONBLOCK 0x0001
  183. /** Async notification (flag for open mode) \hideinitializer */
  184. #define SND_CTL_ASYNC 0x0002
  185. /** Read only (flag for open mode) \hideinitializer */
  186. #define SND_CTL_READONLY 0x0004
  187. /** CTL handle */
  188. typedef struct _snd_ctl snd_ctl_t;
  189. /** Don't destroy the ctl handle when close */
  190. #define SND_SCTL_NOFREE 0x0001
  191. /** SCTL type */
  192. typedef struct _snd_sctl snd_sctl_t;
  193. int snd_card_load(int card);
  194. int snd_card_next(int *card);
  195. int snd_card_get_index(const char *name);
  196. int snd_card_get_name(int card, char **name);
  197. int snd_card_get_longname(int card, char **name);
  198. int snd_device_name_hint(int card, const char *iface, void ***hints);
  199. int snd_device_name_free_hint(void **hints);
  200. char *snd_device_name_get_hint(const void *hint, const char *id);
  201. int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode);
  202. int snd_ctl_open_lconf(snd_ctl_t **ctl, const char *name, int mode, snd_config_t *lconf);
  203. int snd_ctl_open_fallback(snd_ctl_t **ctl, snd_config_t *root, const char *name, const char *orig_name, int mode);
  204. int snd_ctl_close(snd_ctl_t *ctl);
  205. int snd_ctl_nonblock(snd_ctl_t *ctl, int nonblock);
  206. static __inline__ int snd_ctl_abort(snd_ctl_t *ctl) { return snd_ctl_nonblock(ctl, 2); }
  207. int snd_async_add_ctl_handler(snd_async_handler_t **handler, snd_ctl_t *ctl,
  208. snd_async_callback_t callback, void *private_data);
  209. snd_ctl_t *snd_async_handler_get_ctl(snd_async_handler_t *handler);
  210. int snd_ctl_poll_descriptors_count(snd_ctl_t *ctl);
  211. int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space);
  212. int snd_ctl_poll_descriptors_revents(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
  213. int snd_ctl_subscribe_events(snd_ctl_t *ctl, int subscribe);
  214. int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info);
  215. int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list);
  216. int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info);
  217. int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *data);
  218. int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *data);
  219. int snd_ctl_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  220. int snd_ctl_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  221. int snd_ctl_elem_tlv_read(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  222. unsigned int *tlv, unsigned int tlv_size);
  223. int snd_ctl_elem_tlv_write(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  224. const unsigned int *tlv);
  225. int snd_ctl_elem_tlv_command(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  226. const unsigned int *tlv);
  227. #ifdef __ALSA_HWDEP_H
  228. int snd_ctl_hwdep_next_device(snd_ctl_t *ctl, int * device);
  229. int snd_ctl_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info);
  230. #endif
  231. #ifdef __ALSA_PCM_H
  232. int snd_ctl_pcm_next_device(snd_ctl_t *ctl, int *device);
  233. int snd_ctl_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info);
  234. int snd_ctl_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev);
  235. #endif
  236. #ifdef __ALSA_RAWMIDI_H
  237. int snd_ctl_rawmidi_next_device(snd_ctl_t *ctl, int * device);
  238. int snd_ctl_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info);
  239. int snd_ctl_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev);
  240. #endif
  241. int snd_ctl_set_power_state(snd_ctl_t *ctl, unsigned int state);
  242. int snd_ctl_get_power_state(snd_ctl_t *ctl, unsigned int *state);
  243. int snd_ctl_read(snd_ctl_t *ctl, snd_ctl_event_t *event);
  244. int snd_ctl_wait(snd_ctl_t *ctl, int timeout);
  245. const char *snd_ctl_name(snd_ctl_t *ctl);
  246. snd_ctl_type_t snd_ctl_type(snd_ctl_t *ctl);
  247. const char *snd_ctl_elem_type_name(snd_ctl_elem_type_t type);
  248. const char *snd_ctl_elem_iface_name(snd_ctl_elem_iface_t iface);
  249. const char *snd_ctl_event_type_name(snd_ctl_event_type_t type);
  250. unsigned int snd_ctl_event_elem_get_mask(const snd_ctl_event_t *obj);
  251. unsigned int snd_ctl_event_elem_get_numid(const snd_ctl_event_t *obj);
  252. void snd_ctl_event_elem_get_id(const snd_ctl_event_t *obj, snd_ctl_elem_id_t *ptr);
  253. snd_ctl_elem_iface_t snd_ctl_event_elem_get_interface(const snd_ctl_event_t *obj);
  254. unsigned int snd_ctl_event_elem_get_device(const snd_ctl_event_t *obj);
  255. unsigned int snd_ctl_event_elem_get_subdevice(const snd_ctl_event_t *obj);
  256. const char *snd_ctl_event_elem_get_name(const snd_ctl_event_t *obj);
  257. unsigned int snd_ctl_event_elem_get_index(const snd_ctl_event_t *obj);
  258. int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries);
  259. void snd_ctl_elem_list_free_space(snd_ctl_elem_list_t *obj);
  260. char *snd_ctl_ascii_elem_id_get(snd_ctl_elem_id_t *id);
  261. int snd_ctl_ascii_elem_id_parse(snd_ctl_elem_id_t *dst, const char *str);
  262. int snd_ctl_ascii_value_parse(snd_ctl_t *handle,
  263. snd_ctl_elem_value_t *dst,
  264. snd_ctl_elem_info_t *info,
  265. const char *value);
  266. size_t snd_ctl_elem_id_sizeof(void);
  267. /** \hideinitializer
  268. * \brief allocate an invalid #snd_ctl_elem_id_t using standard alloca
  269. * \param ptr returned pointer
  270. */
  271. #define snd_ctl_elem_id_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_id)
  272. int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr);
  273. void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj);
  274. void snd_ctl_elem_id_clear(snd_ctl_elem_id_t *obj);
  275. void snd_ctl_elem_id_copy(snd_ctl_elem_id_t *dst, const snd_ctl_elem_id_t *src);
  276. unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj);
  277. snd_ctl_elem_iface_t snd_ctl_elem_id_get_interface(const snd_ctl_elem_id_t *obj);
  278. unsigned int snd_ctl_elem_id_get_device(const snd_ctl_elem_id_t *obj);
  279. unsigned int snd_ctl_elem_id_get_subdevice(const snd_ctl_elem_id_t *obj);
  280. const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj);
  281. unsigned int snd_ctl_elem_id_get_index(const snd_ctl_elem_id_t *obj);
  282. void snd_ctl_elem_id_set_numid(snd_ctl_elem_id_t *obj, unsigned int val);
  283. void snd_ctl_elem_id_set_interface(snd_ctl_elem_id_t *obj, snd_ctl_elem_iface_t val);
  284. void snd_ctl_elem_id_set_device(snd_ctl_elem_id_t *obj, unsigned int val);
  285. void snd_ctl_elem_id_set_subdevice(snd_ctl_elem_id_t *obj, unsigned int val);
  286. void snd_ctl_elem_id_set_name(snd_ctl_elem_id_t *obj, const char *val);
  287. void snd_ctl_elem_id_set_index(snd_ctl_elem_id_t *obj, unsigned int val);
  288. size_t snd_ctl_card_info_sizeof(void);
  289. /** \hideinitializer
  290. * \brief allocate an invalid #snd_ctl_card_info_t using standard alloca
  291. * \param ptr returned pointer
  292. */
  293. #define snd_ctl_card_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_card_info)
  294. int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr);
  295. void snd_ctl_card_info_free(snd_ctl_card_info_t *obj);
  296. void snd_ctl_card_info_clear(snd_ctl_card_info_t *obj);
  297. void snd_ctl_card_info_copy(snd_ctl_card_info_t *dst, const snd_ctl_card_info_t *src);
  298. int snd_ctl_card_info_get_card(const snd_ctl_card_info_t *obj);
  299. const char *snd_ctl_card_info_get_id(const snd_ctl_card_info_t *obj);
  300. const char *snd_ctl_card_info_get_driver(const snd_ctl_card_info_t *obj);
  301. const char *snd_ctl_card_info_get_name(const snd_ctl_card_info_t *obj);
  302. const char *snd_ctl_card_info_get_longname(const snd_ctl_card_info_t *obj);
  303. const char *snd_ctl_card_info_get_mixername(const snd_ctl_card_info_t *obj);
  304. const char *snd_ctl_card_info_get_components(const snd_ctl_card_info_t *obj);
  305. size_t snd_ctl_event_sizeof(void);
  306. /** \hideinitializer
  307. * \brief allocate an invalid #snd_ctl_event_t using standard alloca
  308. * \param ptr returned pointer
  309. */
  310. #define snd_ctl_event_alloca(ptr) __snd_alloca(ptr, snd_ctl_event)
  311. int snd_ctl_event_malloc(snd_ctl_event_t **ptr);
  312. void snd_ctl_event_free(snd_ctl_event_t *obj);
  313. void snd_ctl_event_clear(snd_ctl_event_t *obj);
  314. void snd_ctl_event_copy(snd_ctl_event_t *dst, const snd_ctl_event_t *src);
  315. snd_ctl_event_type_t snd_ctl_event_get_type(const snd_ctl_event_t *obj);
  316. size_t snd_ctl_elem_list_sizeof(void);
  317. /** \hideinitializer
  318. * \brief allocate an invalid #snd_ctl_elem_list_t using standard alloca
  319. * \param ptr returned pointer
  320. */
  321. #define snd_ctl_elem_list_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_list)
  322. int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr);
  323. void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj);
  324. void snd_ctl_elem_list_clear(snd_ctl_elem_list_t *obj);
  325. void snd_ctl_elem_list_copy(snd_ctl_elem_list_t *dst, const snd_ctl_elem_list_t *src);
  326. void snd_ctl_elem_list_set_offset(snd_ctl_elem_list_t *obj, unsigned int val);
  327. unsigned int snd_ctl_elem_list_get_used(const snd_ctl_elem_list_t *obj);
  328. unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj);
  329. void snd_ctl_elem_list_get_id(const snd_ctl_elem_list_t *obj, unsigned int idx, snd_ctl_elem_id_t *ptr);
  330. unsigned int snd_ctl_elem_list_get_numid(const snd_ctl_elem_list_t *obj, unsigned int idx);
  331. snd_ctl_elem_iface_t snd_ctl_elem_list_get_interface(const snd_ctl_elem_list_t *obj, unsigned int idx);
  332. unsigned int snd_ctl_elem_list_get_device(const snd_ctl_elem_list_t *obj, unsigned int idx);
  333. unsigned int snd_ctl_elem_list_get_subdevice(const snd_ctl_elem_list_t *obj, unsigned int idx);
  334. const char *snd_ctl_elem_list_get_name(const snd_ctl_elem_list_t *obj, unsigned int idx);
  335. unsigned int snd_ctl_elem_list_get_index(const snd_ctl_elem_list_t *obj, unsigned int idx);
  336. size_t snd_ctl_elem_info_sizeof(void);
  337. /** \hideinitializer
  338. * \brief allocate an invalid #snd_ctl_elem_info_t using standard alloca
  339. * \param ptr returned pointer
  340. */
  341. #define snd_ctl_elem_info_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_info)
  342. int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr);
  343. void snd_ctl_elem_info_free(snd_ctl_elem_info_t *obj);
  344. void snd_ctl_elem_info_clear(snd_ctl_elem_info_t *obj);
  345. void snd_ctl_elem_info_copy(snd_ctl_elem_info_t *dst, const snd_ctl_elem_info_t *src);
  346. snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj);
  347. int snd_ctl_elem_info_is_readable(const snd_ctl_elem_info_t *obj);
  348. int snd_ctl_elem_info_is_writable(const snd_ctl_elem_info_t *obj);
  349. int snd_ctl_elem_info_is_volatile(const snd_ctl_elem_info_t *obj);
  350. int snd_ctl_elem_info_is_inactive(const snd_ctl_elem_info_t *obj);
  351. int snd_ctl_elem_info_is_locked(const snd_ctl_elem_info_t *obj);
  352. int snd_ctl_elem_info_is_tlv_readable(const snd_ctl_elem_info_t *obj);
  353. int snd_ctl_elem_info_is_tlv_writable(const snd_ctl_elem_info_t *obj);
  354. int snd_ctl_elem_info_is_tlv_commandable(const snd_ctl_elem_info_t *obj);
  355. int snd_ctl_elem_info_is_owner(const snd_ctl_elem_info_t *obj);
  356. int snd_ctl_elem_info_is_user(const snd_ctl_elem_info_t *obj);
  357. pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj);
  358. unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj);
  359. long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj);
  360. long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj);
  361. long snd_ctl_elem_info_get_step(const snd_ctl_elem_info_t *obj);
  362. long long snd_ctl_elem_info_get_min64(const snd_ctl_elem_info_t *obj);
  363. long long snd_ctl_elem_info_get_max64(const snd_ctl_elem_info_t *obj);
  364. long long snd_ctl_elem_info_get_step64(const snd_ctl_elem_info_t *obj);
  365. unsigned int snd_ctl_elem_info_get_items(const snd_ctl_elem_info_t *obj);
  366. void snd_ctl_elem_info_set_item(snd_ctl_elem_info_t *obj, unsigned int val);
  367. const char *snd_ctl_elem_info_get_item_name(const snd_ctl_elem_info_t *obj);
  368. int snd_ctl_elem_info_get_dimensions(const snd_ctl_elem_info_t *obj);
  369. int snd_ctl_elem_info_get_dimension(const snd_ctl_elem_info_t *obj, unsigned int idx);
  370. int snd_ctl_elem_info_set_dimension(snd_ctl_elem_info_t *info,
  371. const int dimension[4]);
  372. void snd_ctl_elem_info_get_id(const snd_ctl_elem_info_t *obj, snd_ctl_elem_id_t *ptr);
  373. unsigned int snd_ctl_elem_info_get_numid(const snd_ctl_elem_info_t *obj);
  374. snd_ctl_elem_iface_t snd_ctl_elem_info_get_interface(const snd_ctl_elem_info_t *obj);
  375. unsigned int snd_ctl_elem_info_get_device(const snd_ctl_elem_info_t *obj);
  376. unsigned int snd_ctl_elem_info_get_subdevice(const snd_ctl_elem_info_t *obj);
  377. const char *snd_ctl_elem_info_get_name(const snd_ctl_elem_info_t *obj);
  378. unsigned int snd_ctl_elem_info_get_index(const snd_ctl_elem_info_t *obj);
  379. void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr);
  380. void snd_ctl_elem_info_set_numid(snd_ctl_elem_info_t *obj, unsigned int val);
  381. void snd_ctl_elem_info_set_interface(snd_ctl_elem_info_t *obj, snd_ctl_elem_iface_t val);
  382. void snd_ctl_elem_info_set_device(snd_ctl_elem_info_t *obj, unsigned int val);
  383. void snd_ctl_elem_info_set_subdevice(snd_ctl_elem_info_t *obj, unsigned int val);
  384. void snd_ctl_elem_info_set_name(snd_ctl_elem_info_t *obj, const char *val);
  385. void snd_ctl_elem_info_set_index(snd_ctl_elem_info_t *obj, unsigned int val);
  386. int snd_ctl_add_integer_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  387. unsigned int element_count,
  388. unsigned int member_count,
  389. long min, long max, long step);
  390. int snd_ctl_add_integer64_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  391. unsigned int element_count,
  392. unsigned int member_count,
  393. long long min, long long max,
  394. long long step);
  395. int snd_ctl_add_boolean_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  396. unsigned int element_count,
  397. unsigned int member_count);
  398. int snd_ctl_add_enumerated_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  399. unsigned int element_count,
  400. unsigned int member_count,
  401. unsigned int items,
  402. const char *const labels[]);
  403. int snd_ctl_add_bytes_elem_set(snd_ctl_t *ctl, snd_ctl_elem_info_t *info,
  404. unsigned int element_count,
  405. unsigned int member_count);
  406. 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);
  407. 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);
  408. int snd_ctl_elem_add_boolean(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id, unsigned int count);
  409. 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[]);
  410. int snd_ctl_elem_add_iec958(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id);
  411. int snd_ctl_elem_remove(snd_ctl_t *ctl, snd_ctl_elem_id_t *id);
  412. size_t snd_ctl_elem_value_sizeof(void);
  413. /** \hideinitializer
  414. * \brief allocate an invalid #snd_ctl_elem_value_t using standard alloca
  415. * \param ptr returned pointer
  416. */
  417. #define snd_ctl_elem_value_alloca(ptr) __snd_alloca(ptr, snd_ctl_elem_value)
  418. int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr);
  419. void snd_ctl_elem_value_free(snd_ctl_elem_value_t *obj);
  420. void snd_ctl_elem_value_clear(snd_ctl_elem_value_t *obj);
  421. void snd_ctl_elem_value_copy(snd_ctl_elem_value_t *dst, const snd_ctl_elem_value_t *src);
  422. int snd_ctl_elem_value_compare(snd_ctl_elem_value_t *left, const snd_ctl_elem_value_t *right);
  423. void snd_ctl_elem_value_get_id(const snd_ctl_elem_value_t *obj, snd_ctl_elem_id_t *ptr);
  424. unsigned int snd_ctl_elem_value_get_numid(const snd_ctl_elem_value_t *obj);
  425. snd_ctl_elem_iface_t snd_ctl_elem_value_get_interface(const snd_ctl_elem_value_t *obj);
  426. unsigned int snd_ctl_elem_value_get_device(const snd_ctl_elem_value_t *obj);
  427. unsigned int snd_ctl_elem_value_get_subdevice(const snd_ctl_elem_value_t *obj);
  428. const char *snd_ctl_elem_value_get_name(const snd_ctl_elem_value_t *obj);
  429. unsigned int snd_ctl_elem_value_get_index(const snd_ctl_elem_value_t *obj);
  430. void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr);
  431. void snd_ctl_elem_value_set_numid(snd_ctl_elem_value_t *obj, unsigned int val);
  432. void snd_ctl_elem_value_set_interface(snd_ctl_elem_value_t *obj, snd_ctl_elem_iface_t val);
  433. void snd_ctl_elem_value_set_device(snd_ctl_elem_value_t *obj, unsigned int val);
  434. void snd_ctl_elem_value_set_subdevice(snd_ctl_elem_value_t *obj, unsigned int val);
  435. void snd_ctl_elem_value_set_name(snd_ctl_elem_value_t *obj, const char *val);
  436. void snd_ctl_elem_value_set_index(snd_ctl_elem_value_t *obj, unsigned int val);
  437. int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx);
  438. long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx);
  439. long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsigned int idx);
  440. unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx);
  441. unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx);
  442. void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
  443. void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val);
  444. void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int idx, long long val);
  445. void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val);
  446. void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val);
  447. void snd_ctl_elem_set_bytes(snd_ctl_elem_value_t *obj, void *data, size_t size);
  448. const void * snd_ctl_elem_value_get_bytes(const snd_ctl_elem_value_t *obj);
  449. void snd_ctl_elem_value_get_iec958(const snd_ctl_elem_value_t *obj, snd_aes_iec958_t *ptr);
  450. void snd_ctl_elem_value_set_iec958(snd_ctl_elem_value_t *obj, const snd_aes_iec958_t *ptr);
  451. int snd_tlv_parse_dB_info(unsigned int *tlv, unsigned int tlv_size,
  452. unsigned int **db_tlvp);
  453. int snd_tlv_get_dB_range(unsigned int *tlv, long rangemin, long rangemax,
  454. long *min, long *max);
  455. int snd_tlv_convert_to_dB(unsigned int *tlv, long rangemin, long rangemax,
  456. long volume, long *db_gain);
  457. int snd_tlv_convert_from_dB(unsigned int *tlv, long rangemin, long rangemax,
  458. long db_gain, long *value, int xdir);
  459. int snd_ctl_get_dB_range(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  460. long *min, long *max);
  461. int snd_ctl_convert_to_dB(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  462. long volume, long *db_gain);
  463. int snd_ctl_convert_from_dB(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
  464. long db_gain, long *value, int xdir);
  465. /**
  466. * \defgroup HControl High level Control Interface
  467. * \ingroup Control
  468. * The high level control interface.
  469. * See \ref hcontrol page for more details.
  470. * \{
  471. */
  472. /** HCTL element handle */
  473. typedef struct _snd_hctl_elem snd_hctl_elem_t;
  474. /** HCTL handle */
  475. typedef struct _snd_hctl snd_hctl_t;
  476. /**
  477. * \brief Compare function for sorting HCTL elements
  478. * \param e1 First element
  479. * \param e2 Second element
  480. * \return -1 if e1 < e2, 0 if e1 == e2, 1 if e1 > e2
  481. */
  482. typedef int (*snd_hctl_compare_t)(const snd_hctl_elem_t *e1,
  483. const snd_hctl_elem_t *e2);
  484. int snd_hctl_compare_fast(const snd_hctl_elem_t *c1,
  485. const snd_hctl_elem_t *c2);
  486. /**
  487. * \brief HCTL callback function
  488. * \param hctl HCTL handle
  489. * \param mask event mask
  490. * \param elem related HCTL element (if any)
  491. * \return 0 on success otherwise a negative error code
  492. */
  493. typedef int (*snd_hctl_callback_t)(snd_hctl_t *hctl,
  494. unsigned int mask,
  495. snd_hctl_elem_t *elem);
  496. /**
  497. * \brief HCTL element callback function
  498. * \param elem HCTL element
  499. * \param mask event mask
  500. * \return 0 on success otherwise a negative error code
  501. */
  502. typedef int (*snd_hctl_elem_callback_t)(snd_hctl_elem_t *elem,
  503. unsigned int mask);
  504. int snd_hctl_open(snd_hctl_t **hctl, const char *name, int mode);
  505. int snd_hctl_open_ctl(snd_hctl_t **hctlp, snd_ctl_t *ctl);
  506. int snd_hctl_close(snd_hctl_t *hctl);
  507. int snd_hctl_nonblock(snd_hctl_t *hctl, int nonblock);
  508. static __inline__ int snd_hctl_abort(snd_hctl_t *hctl) { return snd_hctl_nonblock(hctl, 2); }
  509. int snd_hctl_poll_descriptors_count(snd_hctl_t *hctl);
  510. int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space);
  511. int snd_hctl_poll_descriptors_revents(snd_hctl_t *ctl, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
  512. unsigned int snd_hctl_get_count(snd_hctl_t *hctl);
  513. int snd_hctl_set_compare(snd_hctl_t *hctl, snd_hctl_compare_t hsort);
  514. snd_hctl_elem_t *snd_hctl_first_elem(snd_hctl_t *hctl);
  515. snd_hctl_elem_t *snd_hctl_last_elem(snd_hctl_t *hctl);
  516. snd_hctl_elem_t *snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id);
  517. void snd_hctl_set_callback(snd_hctl_t *hctl, snd_hctl_callback_t callback);
  518. void snd_hctl_set_callback_private(snd_hctl_t *hctl, void *data);
  519. void *snd_hctl_get_callback_private(snd_hctl_t *hctl);
  520. int snd_hctl_load(snd_hctl_t *hctl);
  521. int snd_hctl_free(snd_hctl_t *hctl);
  522. int snd_hctl_handle_events(snd_hctl_t *hctl);
  523. const char *snd_hctl_name(snd_hctl_t *hctl);
  524. int snd_hctl_wait(snd_hctl_t *hctl, int timeout);
  525. snd_ctl_t *snd_hctl_ctl(snd_hctl_t *hctl);
  526. snd_hctl_elem_t *snd_hctl_elem_next(snd_hctl_elem_t *elem);
  527. snd_hctl_elem_t *snd_hctl_elem_prev(snd_hctl_elem_t *elem);
  528. int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t * info);
  529. int snd_hctl_elem_read(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
  530. int snd_hctl_elem_write(snd_hctl_elem_t *elem, snd_ctl_elem_value_t * value);
  531. int snd_hctl_elem_tlv_read(snd_hctl_elem_t *elem, unsigned int *tlv, unsigned int tlv_size);
  532. int snd_hctl_elem_tlv_write(snd_hctl_elem_t *elem, const unsigned int *tlv);
  533. int snd_hctl_elem_tlv_command(snd_hctl_elem_t *elem, const unsigned int *tlv);
  534. snd_hctl_t *snd_hctl_elem_get_hctl(snd_hctl_elem_t *elem);
  535. void snd_hctl_elem_get_id(const snd_hctl_elem_t *obj, snd_ctl_elem_id_t *ptr);
  536. unsigned int snd_hctl_elem_get_numid(const snd_hctl_elem_t *obj);
  537. snd_ctl_elem_iface_t snd_hctl_elem_get_interface(const snd_hctl_elem_t *obj);
  538. unsigned int snd_hctl_elem_get_device(const snd_hctl_elem_t *obj);
  539. unsigned int snd_hctl_elem_get_subdevice(const snd_hctl_elem_t *obj);
  540. const char *snd_hctl_elem_get_name(const snd_hctl_elem_t *obj);
  541. unsigned int snd_hctl_elem_get_index(const snd_hctl_elem_t *obj);
  542. void snd_hctl_elem_set_callback(snd_hctl_elem_t *obj, snd_hctl_elem_callback_t val);
  543. void * snd_hctl_elem_get_callback_private(const snd_hctl_elem_t *obj);
  544. void snd_hctl_elem_set_callback_private(snd_hctl_elem_t *obj, void * val);
  545. /** \} */
  546. /** \} */
  547. /**
  548. * \defgroup SControl Setup Control Interface
  549. * \ingroup Control
  550. * The setup control interface - set or modify control elements from a configuration file.
  551. * \{
  552. */
  553. int snd_sctl_build(snd_sctl_t **ctl, snd_ctl_t *handle, snd_config_t *config,
  554. snd_config_t *private_data, int mode);
  555. int snd_sctl_free(snd_sctl_t *handle);
  556. int snd_sctl_install(snd_sctl_t *handle);
  557. int snd_sctl_remove(snd_sctl_t *handle);
  558. /** \} */
  559. #ifdef __cplusplus
  560. }
  561. #endif
  562. #endif /* __ALSA_CONTROL_H */