Path: blob/master/thirdparty/linuxbsd_headers/alsa/mixer.h
9898 views
/**1* \file include/mixer.h2* \brief Application interface library for the ALSA driver3* \author Jaroslav Kysela <[email protected]>4* \author Abramo Bagnara <[email protected]>5* \author Takashi Iwai <[email protected]>6* \date 1998-20017*8* Application interface library for the ALSA driver9*/10/*11* This library is free software; you can redistribute it and/or modify12* it under the terms of the GNU Lesser General Public License as13* published by the Free Software Foundation; either version 2.1 of14* the License, or (at your option) any later version.15*16* This program is distributed in the hope that it will be useful,17* but WITHOUT ANY WARRANTY; without even the implied warranty of18* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19* GNU Lesser General Public License for more details.20*21* You should have received a copy of the GNU Lesser General Public22* License along with this library; if not, write to the Free Software23* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24*25*/2627#ifndef __ALSA_MIXER_H28#define __ALSA_MIXER_H2930#ifdef __cplusplus31extern "C" {32#endif3334/**35* \defgroup Mixer Mixer Interface36* The mixer interface.37* \{38*/3940/** Mixer handle */41typedef struct _snd_mixer snd_mixer_t;42/** Mixer elements class handle */43typedef struct _snd_mixer_class snd_mixer_class_t;44/** Mixer element handle */45typedef struct _snd_mixer_elem snd_mixer_elem_t;4647/**48* \brief Mixer callback function49* \param mixer Mixer handle50* \param mask event mask51* \param elem related mixer element (if any)52* \return 0 on success otherwise a negative error code53*/54typedef int (*snd_mixer_callback_t)(snd_mixer_t *ctl,55unsigned int mask,56snd_mixer_elem_t *elem);5758/**59* \brief Mixer element callback function60* \param elem Mixer element61* \param mask event mask62* \return 0 on success otherwise a negative error code63*/64typedef int (*snd_mixer_elem_callback_t)(snd_mixer_elem_t *elem,65unsigned int mask);6667/**68* \brief Compare function for sorting mixer elements69* \param e1 First element70* \param e2 Second element71* \return -1 if e1 < e2, 0 if e1 == e2, 1 if e1 > e272*/73typedef int (*snd_mixer_compare_t)(const snd_mixer_elem_t *e1,74const snd_mixer_elem_t *e2);7576/**77* \brief Event callback for the mixer class78* \param class_ Mixer class79* \param mask Event mask (SND_CTL_EVENT_*)80* \param helem HCTL element which invoked the event81* \param melem Mixer element associated to HCTL element82* \return zero if success, otherwise a negative error value83*/84typedef int (*snd_mixer_event_t)(snd_mixer_class_t *class_, unsigned int mask,85snd_hctl_elem_t *helem, snd_mixer_elem_t *melem);868788/** Mixer element type */89typedef enum _snd_mixer_elem_type {90/* Simple mixer elements */91SND_MIXER_ELEM_SIMPLE,92SND_MIXER_ELEM_LAST = SND_MIXER_ELEM_SIMPLE93} snd_mixer_elem_type_t;9495int snd_mixer_open(snd_mixer_t **mixer, int mode);96int snd_mixer_close(snd_mixer_t *mixer);97snd_mixer_elem_t *snd_mixer_first_elem(snd_mixer_t *mixer);98snd_mixer_elem_t *snd_mixer_last_elem(snd_mixer_t *mixer);99int snd_mixer_handle_events(snd_mixer_t *mixer);100int snd_mixer_attach(snd_mixer_t *mixer, const char *name);101int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl);102int snd_mixer_detach(snd_mixer_t *mixer, const char *name);103int snd_mixer_detach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl);104int snd_mixer_get_hctl(snd_mixer_t *mixer, const char *name, snd_hctl_t **hctl);105int snd_mixer_poll_descriptors_count(snd_mixer_t *mixer);106int snd_mixer_poll_descriptors(snd_mixer_t *mixer, struct pollfd *pfds, unsigned int space);107int snd_mixer_poll_descriptors_revents(snd_mixer_t *mixer, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);108int snd_mixer_load(snd_mixer_t *mixer);109void snd_mixer_free(snd_mixer_t *mixer);110int snd_mixer_wait(snd_mixer_t *mixer, int timeout);111int snd_mixer_set_compare(snd_mixer_t *mixer, snd_mixer_compare_t msort);112void snd_mixer_set_callback(snd_mixer_t *obj, snd_mixer_callback_t val);113void * snd_mixer_get_callback_private(const snd_mixer_t *obj);114void snd_mixer_set_callback_private(snd_mixer_t *obj, void * val);115unsigned int snd_mixer_get_count(const snd_mixer_t *obj);116int snd_mixer_class_unregister(snd_mixer_class_t *clss);117118snd_mixer_elem_t *snd_mixer_elem_next(snd_mixer_elem_t *elem);119snd_mixer_elem_t *snd_mixer_elem_prev(snd_mixer_elem_t *elem);120void snd_mixer_elem_set_callback(snd_mixer_elem_t *obj, snd_mixer_elem_callback_t val);121void * snd_mixer_elem_get_callback_private(const snd_mixer_elem_t *obj);122void snd_mixer_elem_set_callback_private(snd_mixer_elem_t *obj, void * val);123snd_mixer_elem_type_t snd_mixer_elem_get_type(const snd_mixer_elem_t *obj);124125int snd_mixer_class_register(snd_mixer_class_t *class_, snd_mixer_t *mixer);126int snd_mixer_elem_new(snd_mixer_elem_t **elem,127snd_mixer_elem_type_t type,128int compare_weight,129void *private_data,130void (*private_free)(snd_mixer_elem_t *elem));131int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class_);132int snd_mixer_elem_remove(snd_mixer_elem_t *elem);133void snd_mixer_elem_free(snd_mixer_elem_t *elem);134int snd_mixer_elem_info(snd_mixer_elem_t *elem);135int snd_mixer_elem_value(snd_mixer_elem_t *elem);136int snd_mixer_elem_attach(snd_mixer_elem_t *melem, snd_hctl_elem_t *helem);137int snd_mixer_elem_detach(snd_mixer_elem_t *melem, snd_hctl_elem_t *helem);138int snd_mixer_elem_empty(snd_mixer_elem_t *melem);139void *snd_mixer_elem_get_private(const snd_mixer_elem_t *melem);140141size_t snd_mixer_class_sizeof(void);142/** \hideinitializer143* \brief allocate an invalid #snd_mixer_class_t using standard alloca144* \param ptr returned pointer145*/146#define snd_mixer_class_alloca(ptr) __snd_alloca(ptr, snd_mixer_class)147int snd_mixer_class_malloc(snd_mixer_class_t **ptr);148void snd_mixer_class_free(snd_mixer_class_t *obj);149void snd_mixer_class_copy(snd_mixer_class_t *dst, const snd_mixer_class_t *src);150snd_mixer_t *snd_mixer_class_get_mixer(const snd_mixer_class_t *class_);151snd_mixer_event_t snd_mixer_class_get_event(const snd_mixer_class_t *class_);152void *snd_mixer_class_get_private(const snd_mixer_class_t *class_);153snd_mixer_compare_t snd_mixer_class_get_compare(const snd_mixer_class_t *class_);154int snd_mixer_class_set_event(snd_mixer_class_t *class_, snd_mixer_event_t event);155int snd_mixer_class_set_private(snd_mixer_class_t *class_, void *private_data);156int snd_mixer_class_set_private_free(snd_mixer_class_t *class_, void (*private_free)(snd_mixer_class_t *));157int snd_mixer_class_set_compare(snd_mixer_class_t *class_, snd_mixer_compare_t compare);158159/**160* \defgroup SimpleMixer Simple Mixer Interface161* \ingroup Mixer162* The simple mixer interface.163* \{164*/165166/* Simple mixer elements API */167168/** Mixer simple element channel identifier */169typedef enum _snd_mixer_selem_channel_id {170/** Unknown */171SND_MIXER_SCHN_UNKNOWN = -1,172/** Front left */173SND_MIXER_SCHN_FRONT_LEFT = 0,174/** Front right */175SND_MIXER_SCHN_FRONT_RIGHT,176/** Rear left */177SND_MIXER_SCHN_REAR_LEFT,178/** Rear right */179SND_MIXER_SCHN_REAR_RIGHT,180/** Front center */181SND_MIXER_SCHN_FRONT_CENTER,182/** Woofer */183SND_MIXER_SCHN_WOOFER,184/** Side Left */185SND_MIXER_SCHN_SIDE_LEFT,186/** Side Right */187SND_MIXER_SCHN_SIDE_RIGHT,188/** Rear Center */189SND_MIXER_SCHN_REAR_CENTER,190SND_MIXER_SCHN_LAST = 31,191/** Mono (Front left alias) */192SND_MIXER_SCHN_MONO = SND_MIXER_SCHN_FRONT_LEFT193} snd_mixer_selem_channel_id_t;194195/** Mixer simple element - register options - abstraction level */196enum snd_mixer_selem_regopt_abstract {197/** no abstraction - try use all universal controls from driver */198SND_MIXER_SABSTRACT_NONE = 0,199/** basic abstraction - Master,PCM,CD,Aux,Record-Gain etc. */200SND_MIXER_SABSTRACT_BASIC,201};202203/** Mixer simple element - register options */204struct snd_mixer_selem_regopt {205/** structure version */206int ver;207/** v1: abstract layer selection */208enum snd_mixer_selem_regopt_abstract abstract;209/** v1: device name (must be NULL when playback_pcm or capture_pcm != NULL) */210const char *device;211/** v1: playback PCM connected to mixer device (NULL == none) */212snd_pcm_t *playback_pcm;213/** v1: capture PCM connected to mixer device (NULL == none) */214snd_pcm_t *capture_pcm;215};216217/** Mixer simple element identifier */218typedef struct _snd_mixer_selem_id snd_mixer_selem_id_t;219220const char *snd_mixer_selem_channel_name(snd_mixer_selem_channel_id_t channel);221222int snd_mixer_selem_register(snd_mixer_t *mixer,223struct snd_mixer_selem_regopt *options,224snd_mixer_class_t **classp);225void snd_mixer_selem_get_id(snd_mixer_elem_t *element,226snd_mixer_selem_id_t *id);227const char *snd_mixer_selem_get_name(snd_mixer_elem_t *elem);228unsigned int snd_mixer_selem_get_index(snd_mixer_elem_t *elem);229snd_mixer_elem_t *snd_mixer_find_selem(snd_mixer_t *mixer,230const snd_mixer_selem_id_t *id);231232int snd_mixer_selem_is_active(snd_mixer_elem_t *elem);233int snd_mixer_selem_is_playback_mono(snd_mixer_elem_t *elem);234int snd_mixer_selem_has_playback_channel(snd_mixer_elem_t *obj, snd_mixer_selem_channel_id_t channel);235int snd_mixer_selem_is_capture_mono(snd_mixer_elem_t *elem);236int snd_mixer_selem_has_capture_channel(snd_mixer_elem_t *obj, snd_mixer_selem_channel_id_t channel);237int snd_mixer_selem_get_capture_group(snd_mixer_elem_t *elem);238int snd_mixer_selem_has_common_volume(snd_mixer_elem_t *elem);239int snd_mixer_selem_has_playback_volume(snd_mixer_elem_t *elem);240int snd_mixer_selem_has_playback_volume_joined(snd_mixer_elem_t *elem);241int snd_mixer_selem_has_capture_volume(snd_mixer_elem_t *elem);242int snd_mixer_selem_has_capture_volume_joined(snd_mixer_elem_t *elem);243int snd_mixer_selem_has_common_switch(snd_mixer_elem_t *elem);244int snd_mixer_selem_has_playback_switch(snd_mixer_elem_t *elem);245int snd_mixer_selem_has_playback_switch_joined(snd_mixer_elem_t *elem);246int snd_mixer_selem_has_capture_switch(snd_mixer_elem_t *elem);247int snd_mixer_selem_has_capture_switch_joined(snd_mixer_elem_t *elem);248int snd_mixer_selem_has_capture_switch_exclusive(snd_mixer_elem_t *elem);249250int snd_mixer_selem_ask_playback_vol_dB(snd_mixer_elem_t *elem, long value, long *dBvalue);251int snd_mixer_selem_ask_capture_vol_dB(snd_mixer_elem_t *elem, long value, long *dBvalue);252int snd_mixer_selem_ask_playback_dB_vol(snd_mixer_elem_t *elem, long dBvalue, int dir, long *value);253int snd_mixer_selem_ask_capture_dB_vol(snd_mixer_elem_t *elem, long dBvalue, int dir, long *value);254int snd_mixer_selem_get_playback_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value);255int snd_mixer_selem_get_capture_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value);256int snd_mixer_selem_get_playback_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value);257int snd_mixer_selem_get_capture_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long *value);258int snd_mixer_selem_get_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int *value);259int snd_mixer_selem_get_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int *value);260int snd_mixer_selem_set_playback_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value);261int snd_mixer_selem_set_capture_volume(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value);262int snd_mixer_selem_set_playback_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value, int dir);263int snd_mixer_selem_set_capture_dB(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, long value, int dir);264int snd_mixer_selem_set_playback_volume_all(snd_mixer_elem_t *elem, long value);265int snd_mixer_selem_set_capture_volume_all(snd_mixer_elem_t *elem, long value);266int snd_mixer_selem_set_playback_dB_all(snd_mixer_elem_t *elem, long value, int dir);267int snd_mixer_selem_set_capture_dB_all(snd_mixer_elem_t *elem, long value, int dir);268int snd_mixer_selem_set_playback_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value);269int snd_mixer_selem_set_capture_switch(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, int value);270int snd_mixer_selem_set_playback_switch_all(snd_mixer_elem_t *elem, int value);271int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value);272int snd_mixer_selem_get_playback_volume_range(snd_mixer_elem_t *elem,273long *min, long *max);274int snd_mixer_selem_get_playback_dB_range(snd_mixer_elem_t *elem,275long *min, long *max);276int snd_mixer_selem_set_playback_volume_range(snd_mixer_elem_t *elem,277long min, long max);278int snd_mixer_selem_get_capture_volume_range(snd_mixer_elem_t *elem,279long *min, long *max);280int snd_mixer_selem_get_capture_dB_range(snd_mixer_elem_t *elem,281long *min, long *max);282int snd_mixer_selem_set_capture_volume_range(snd_mixer_elem_t *elem,283long min, long max);284285int snd_mixer_selem_is_enumerated(snd_mixer_elem_t *elem);286int snd_mixer_selem_is_enum_playback(snd_mixer_elem_t *elem);287int snd_mixer_selem_is_enum_capture(snd_mixer_elem_t *elem);288int snd_mixer_selem_get_enum_items(snd_mixer_elem_t *elem);289int snd_mixer_selem_get_enum_item_name(snd_mixer_elem_t *elem, unsigned int idx, size_t maxlen, char *str);290int snd_mixer_selem_get_enum_item(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, unsigned int *idxp);291int snd_mixer_selem_set_enum_item(snd_mixer_elem_t *elem, snd_mixer_selem_channel_id_t channel, unsigned int idx);292293size_t snd_mixer_selem_id_sizeof(void);294/** \hideinitializer295* \brief allocate an invalid #snd_mixer_selem_id_t using standard alloca296* \param ptr returned pointer297*/298#define snd_mixer_selem_id_alloca(ptr) __snd_alloca(ptr, snd_mixer_selem_id)299int snd_mixer_selem_id_malloc(snd_mixer_selem_id_t **ptr);300void snd_mixer_selem_id_free(snd_mixer_selem_id_t *obj);301void snd_mixer_selem_id_copy(snd_mixer_selem_id_t *dst, const snd_mixer_selem_id_t *src);302const char *snd_mixer_selem_id_get_name(const snd_mixer_selem_id_t *obj);303unsigned int snd_mixer_selem_id_get_index(const snd_mixer_selem_id_t *obj);304void snd_mixer_selem_id_set_name(snd_mixer_selem_id_t *obj, const char *val);305void snd_mixer_selem_id_set_index(snd_mixer_selem_id_t *obj, unsigned int val);306307/** \} */308309/** \} */310311#ifdef __cplusplus312}313#endif314315#endif /* __ALSA_MIXER_H */316317318319