Path: blob/master/thirdparty/linuxbsd_headers/alsa/control_external.h
9903 views
/**1* \file include/control_external.h2* \brief External control plugin SDK3* \author Takashi Iwai <[email protected]>4* \date 20055*6* External control plugin SDK.7*/89/*10* This library is free software; you can redistribute it and/or modify11* it under the terms of the GNU Lesser General Public License as12* published by the Free Software Foundation; either version 2.1 of13* the License, or (at your option) any later version.14*15* This program is distributed in the hope that it will be useful,16* but WITHOUT ANY WARRANTY; without even the implied warranty of17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the18* GNU Lesser General Public License for more details.19*20* You should have received a copy of the GNU Lesser General Public21* License along with this library; if not, write to the Free Software22* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA23*24*/25#ifndef __ALSA_CONTROL_EXTERNAL_H26#define __ALSA_CONTROL_EXTERNAL_H2728#include "control.h"2930#ifdef __cplusplus31extern "C" {32#endif3334/**35* \defgroup CtlPlugin_SDK External Control Plugin SDK36* \{37*/3839/**40* Define the object entry for external control plugins41*/42#define SND_CTL_PLUGIN_ENTRY(name) _snd_ctl_##name##_open4344/**45* Define the symbols of the given control plugin with versions46*/47#define SND_CTL_PLUGIN_SYMBOL(name) SND_DLSYM_BUILD_VERSION(SND_CTL_PLUGIN_ENTRY(name), SND_CONTROL_DLSYM_VERSION);4849/**50* Define the control plugin51*/52#define SND_CTL_PLUGIN_DEFINE_FUNC(plugin) \53int SND_CTL_PLUGIN_ENTRY(plugin) (snd_ctl_t **handlep, const char *name,\54snd_config_t *root, snd_config_t *conf, int mode)5556/** External control plugin handle */57typedef struct snd_ctl_ext snd_ctl_ext_t;58/** Callback table of control ext */59typedef struct snd_ctl_ext_callback snd_ctl_ext_callback_t;60/** Key to access a control pointer */61typedef unsigned long snd_ctl_ext_key_t;62#ifdef DOC_HIDDEN63/* redefine typedef's for stupid doxygen */64typedef snd_ctl_ext snd_ctl_ext_t;65typedef snd_ctl_ext_callback snd_ctl_ext_callback_t;66#endif67/** Callback to handle TLV commands. */68typedef int (snd_ctl_ext_tlv_rw_t)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int op_flag, unsigned int numid,69unsigned int *tlv, unsigned int tlv_size);7071/*72* Protocol version73*/74#define SND_CTL_EXT_VERSION_MAJOR 1 /**< Protocol major version */75#define SND_CTL_EXT_VERSION_MINOR 0 /**< Protocol minor version */76#define SND_CTL_EXT_VERSION_TINY 1 /**< Protocol tiny version */77/**78* external plugin protocol version79*/80#define SND_CTL_EXT_VERSION ((SND_CTL_EXT_VERSION_MAJOR<<16) |\81(SND_CTL_EXT_VERSION_MINOR<<8) |\82(SND_CTL_EXT_VERSION_TINY))8384/** Handle of control ext */85struct snd_ctl_ext {86/**87* protocol version; #SND_CTL_EXT_VERSION must be filled here88* before calling #snd_ctl_ext_create()89*/90unsigned int version;91/**92* Index of this card; must be filled before calling #snd_ctl_ext_create()93*/94int card_idx;95/**96* ID string of this card; must be filled before calling #snd_ctl_ext_create()97*/98char id[16];99/**100* Driver name of this card; must be filled before calling #snd_ctl_ext_create()101*/102char driver[16];103/**104* short name of this card; must be filled before calling #snd_ctl_ext_create()105*/106char name[32];107/**108* Long name of this card; must be filled before calling #snd_ctl_ext_create()109*/110char longname[80];111/**112* Mixer name of this card; must be filled before calling #snd_ctl_ext_create()113*/114char mixername[80];115/**116* poll descriptor117*/118int poll_fd;119120/**121* callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()122*/123const snd_ctl_ext_callback_t *callback;124/**125* private data, which can be used freely in the driver callbacks126*/127void *private_data;128/**129* control handle filled by #snd_ctl_ext_create()130*/131snd_ctl_t *handle;132133int nonblock; /**< non-block mode; read-only */134int subscribed; /**< events subscribed; read-only */135136/**137* optional TLV data for the control (since protocol 1.0.1)138*/139union {140snd_ctl_ext_tlv_rw_t *c;141const unsigned int *p;142} tlv;143};144145/** Callback table of ext. */146struct snd_ctl_ext_callback {147/**148* close the control handle; optional149*/150void (*close)(snd_ctl_ext_t *ext);151/**152* return the total number of elements; required153*/154int (*elem_count)(snd_ctl_ext_t *ext);155/**156* return the element id of the given offset (array index); required157*/158int (*elem_list)(snd_ctl_ext_t *ext, unsigned int offset, snd_ctl_elem_id_t *id);159/**160* convert the element id to a search key; required161*/162snd_ctl_ext_key_t (*find_elem)(snd_ctl_ext_t *ext, const snd_ctl_elem_id_t *id);163/**164* the destructor of the key; optional165*/166void (*free_key)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key);167/**168* get the attribute of the element; required169*/170int (*get_attribute)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,171int *type, unsigned int *acc, unsigned int *count);172/**173* get the element information of integer type174*/175int (*get_integer_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,176long *imin, long *imax, long *istep);177/**178* get the element information of integer64 type179*/180int (*get_integer64_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,181int64_t *imin, int64_t *imax, int64_t *istep);182/**183* get the element information of enumerated type184*/185int (*get_enumerated_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);186/**187* get the name of the enumerated item188*/189int (*get_enumerated_name)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int item,190char *name, size_t name_max_len);191/**192* read the current values of integer type193*/194int (*read_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);195/**196* read the current values of integer64 type197*/198int (*read_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);199/**200* read the current values of enumerated type201*/202int (*read_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);203/**204* read the current values of bytes type205*/206int (*read_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,207size_t max_bytes);208/**209* read the current values of iec958 type210*/211int (*read_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);212/**213* update the current values of integer type with the given values214*/215int (*write_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);216/**217* update the current values of integer64 type with the given values218*/219int (*write_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);220/**221* update the current values of enumerated type with the given values222*/223int (*write_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);224/**225* update the current values of bytes type with the given values226*/227int (*write_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,228size_t max_bytes);229/**230* update the current values of iec958 type with the given values231*/232int (*write_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);233/**234* subscribe/unsubscribe the event notification; optional235*/236void (*subscribe_events)(snd_ctl_ext_t *ext, int subscribe);237/**238* read a pending notification event; optional239*/240int (*read_event)(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id, unsigned int *event_mask);241/**242* return the number of poll descriptors; optional243*/244int (*poll_descriptors_count)(snd_ctl_ext_t *ext);245/**246* fill the poll descriptors; optional247*/248int (*poll_descriptors)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int space);249/**250* mangle the revents of poll descriptors251*/252int (*poll_revents)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);253};254255/**256* The access type bits stored in get_attribute callback257*/258typedef enum snd_ctl_ext_access {259SND_CTL_EXT_ACCESS_READ = (1<<0),260SND_CTL_EXT_ACCESS_WRITE = (1<<1),261SND_CTL_EXT_ACCESS_READWRITE = (3<<0),262SND_CTL_EXT_ACCESS_VOLATILE = (1<<2),263SND_CTL_EXT_ACCESS_TLV_READ = (1<<4),264SND_CTL_EXT_ACCESS_TLV_WRITE = (1<<5),265SND_CTL_EXT_ACCESS_TLV_READWRITE = (3<<4),266SND_CTL_EXT_ACCESS_TLV_COMMAND = (1<<6),267SND_CTL_EXT_ACCESS_INACTIVE = (1<<8),268SND_CTL_EXT_ACCESS_TLV_CALLBACK = (1<<28),269} snd_ctl_ext_access_t;270271/**272* find_elem callback returns this if no matching control element is found273*/274#define SND_CTL_EXT_KEY_NOT_FOUND (snd_ctl_ext_key_t)(-1)275276int snd_ctl_ext_create(snd_ctl_ext_t *ext, const char *name, int mode);277int snd_ctl_ext_delete(snd_ctl_ext_t *ext);278279/** \} */280281#ifdef __cplusplus282}283#endif284285#endif /* __ALSA_CONTROL_EXTERNAL_H */286287288