Blame include/control_external.h

Packit 4a16fb
/**
Packit 4a16fb
 * \file include/control_external.h
Packit 4a16fb
 * \brief External control plugin SDK
Packit 4a16fb
 * \author Takashi Iwai <tiwai@suse.de>
Packit 4a16fb
 * \date 2005
Packit 4a16fb
 *
Packit 4a16fb
 * External control plugin SDK.
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
/*
Packit 4a16fb
 *   This library is free software; you can redistribute it and/or modify
Packit 4a16fb
 *   it under the terms of the GNU Lesser General Public License as
Packit 4a16fb
 *   published by the Free Software Foundation; either version 2.1 of
Packit 4a16fb
 *   the License, or (at your option) any later version.
Packit 4a16fb
 *
Packit 4a16fb
 *   This program is distributed in the hope that it will be useful,
Packit 4a16fb
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4a16fb
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 4a16fb
 *   GNU Lesser General Public License for more details.
Packit 4a16fb
 *
Packit 4a16fb
 *   You should have received a copy of the GNU Lesser General Public
Packit 4a16fb
 *   License along with this library; if not, write to the Free Software
Packit 4a16fb
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 4a16fb
 *
Packit 4a16fb
 */
Packit 4a16fb
#ifndef __ALSA_CONTROL_EXTERNAL_H
Packit 4a16fb
#define __ALSA_CONTROL_EXTERNAL_H
Packit 4a16fb
Packit 4a16fb
#include "control.h"
Packit 4a16fb
Packit 4a16fb
#ifdef __cplusplus
Packit 4a16fb
extern "C" {
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 *  \defgroup CtlPlugin_SDK External Control Plugin SDK
Packit 4a16fb
 *  \{
Packit 4a16fb
 */
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * Define the object entry for external control plugins
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_PLUGIN_ENTRY(name) _snd_ctl_##name##_open
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * Define the symbols of the given control plugin with versions
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_PLUGIN_SYMBOL(name) SND_DLSYM_BUILD_VERSION(SND_CTL_PLUGIN_ENTRY(name), SND_CONTROL_DLSYM_VERSION);
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * Define the control plugin
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_PLUGIN_DEFINE_FUNC(plugin) \
Packit 4a16fb
int SND_CTL_PLUGIN_ENTRY(plugin) (snd_ctl_t **handlep, const char *name,\
Packit 4a16fb
				  snd_config_t *root, snd_config_t *conf, int mode)
Packit 4a16fb
Packit 4a16fb
/** External control plugin handle */
Packit 4a16fb
typedef struct snd_ctl_ext snd_ctl_ext_t;
Packit 4a16fb
/** Callback table of control ext */
Packit 4a16fb
typedef struct snd_ctl_ext_callback snd_ctl_ext_callback_t;
Packit 4a16fb
/** Key to access a control pointer */
Packit 4a16fb
typedef unsigned long snd_ctl_ext_key_t;
Packit 4a16fb
#ifdef DOC_HIDDEN
Packit 4a16fb
/* redefine typedef's for stupid doxygen */
Packit 4a16fb
typedef snd_ctl_ext snd_ctl_ext_t;
Packit 4a16fb
typedef snd_ctl_ext_callback snd_ctl_ext_callback_t;
Packit 4a16fb
#endif
Packit 4a16fb
/** Callback to handle TLV commands. */
Packit 4a16fb
typedef int (snd_ctl_ext_tlv_rw_t)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int op_flag, unsigned int numid,
Packit 4a16fb
				   unsigned int *tlv, unsigned int tlv_size);
Packit 4a16fb
Packit 4a16fb
/*
Packit 4a16fb
 * Protocol version
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_EXT_VERSION_MAJOR	1	/**< Protocol major version */
Packit 4a16fb
#define SND_CTL_EXT_VERSION_MINOR	0	/**< Protocol minor version */
Packit 4a16fb
#define SND_CTL_EXT_VERSION_TINY	1	/**< Protocol tiny version */
Packit 4a16fb
/**
Packit 4a16fb
 * external plugin protocol version
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_EXT_VERSION		((SND_CTL_EXT_VERSION_MAJOR<<16) |\
Packit 4a16fb
					 (SND_CTL_EXT_VERSION_MINOR<<8) |\
Packit 4a16fb
					 (SND_CTL_EXT_VERSION_TINY))
Packit 4a16fb
Packit 4a16fb
/** Handle of control ext */
Packit 4a16fb
struct snd_ctl_ext {
Packit 4a16fb
	/**
Packit 4a16fb
	 * protocol version; #SND_CTL_EXT_VERSION must be filled here
Packit 4a16fb
	 * before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	unsigned int version;
Packit 4a16fb
	/**
Packit 4a16fb
	 * Index of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	int card_idx;
Packit 4a16fb
	/**
Packit 4a16fb
	 * ID string of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	char id[16];
Packit 4a16fb
	/**
Packit 4a16fb
	 * Driver name of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	char driver[16];
Packit 4a16fb
	/**
Packit 4a16fb
	 * short name of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	char name[32];
Packit 4a16fb
	/**
Packit 4a16fb
	 * Long name of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	char longname[80];
Packit 4a16fb
	/**
Packit 4a16fb
	 * Mixer name of this card; must be filled before calling #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	char mixername[80];
Packit 4a16fb
	/**
Packit 4a16fb
	 * poll descriptor
Packit 4a16fb
	 */
Packit 4a16fb
	int poll_fd;
Packit 4a16fb
Packit 4a16fb
	/**
Packit 4a16fb
	 * callbacks of this plugin; must be filled before calling #snd_pcm_ioplug_create()
Packit 4a16fb
	 */
Packit 4a16fb
	const snd_ctl_ext_callback_t *callback;
Packit 4a16fb
	/**
Packit 4a16fb
	 * private data, which can be used freely in the driver callbacks
Packit 4a16fb
	 */
Packit 4a16fb
	void *private_data;
Packit 4a16fb
	/**
Packit 4a16fb
	 * control handle filled by #snd_ctl_ext_create()
Packit 4a16fb
	 */
Packit 4a16fb
	snd_ctl_t *handle;
Packit 4a16fb
Packit 4a16fb
	int nonblock;			/**< non-block mode; read-only */
Packit 4a16fb
	int subscribed;			/**< events subscribed; read-only */
Packit 4a16fb
Packit 4a16fb
	/**
Packit 4a16fb
	 * optional TLV data for the control (since protocol 1.0.1)
Packit 4a16fb
	 */
Packit 4a16fb
	union {
Packit 4a16fb
		snd_ctl_ext_tlv_rw_t *c;
Packit 4a16fb
		const unsigned int *p;
Packit 4a16fb
	} tlv;
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
/** Callback table of ext. */
Packit 4a16fb
struct snd_ctl_ext_callback {
Packit 4a16fb
	/**
Packit 4a16fb
	 * close the control handle; optional
Packit 4a16fb
	 */
Packit 4a16fb
	void (*close)(snd_ctl_ext_t *ext);
Packit 4a16fb
	/**
Packit 4a16fb
	 * return the total number of elements; required
Packit 4a16fb
	 */
Packit 4a16fb
	int (*elem_count)(snd_ctl_ext_t *ext);
Packit 4a16fb
	/**
Packit 4a16fb
	 * return the element id of the given offset (array index); required
Packit 4a16fb
	 */
Packit 4a16fb
	int (*elem_list)(snd_ctl_ext_t *ext, unsigned int offset, snd_ctl_elem_id_t *id);
Packit 4a16fb
	/**
Packit 4a16fb
	 * convert the element id to a search key; required
Packit 4a16fb
	 */
Packit 4a16fb
	snd_ctl_ext_key_t (*find_elem)(snd_ctl_ext_t *ext, const snd_ctl_elem_id_t *id);
Packit 4a16fb
	/**
Packit 4a16fb
	 * the destructor of the key; optional
Packit 4a16fb
	 */
Packit 4a16fb
	void (*free_key)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key);
Packit 4a16fb
	/**
Packit 4a16fb
	 * get the attribute of the element; required
Packit 4a16fb
	 */
Packit 4a16fb
	int (*get_attribute)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
Packit 4a16fb
			     int *type, unsigned int *acc, unsigned int *count);
Packit 4a16fb
	/**
Packit 4a16fb
	 * get the element information of integer type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*get_integer_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
Packit 4a16fb
				long *imin, long *imax, long *istep);
Packit 4a16fb
	/**
Packit 4a16fb
	 * get the element information of integer64 type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*get_integer64_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
Packit 4a16fb
				  int64_t *imin, int64_t *imax, int64_t *istep);
Packit 4a16fb
	/**
Packit 4a16fb
	 * get the element information of enumerated type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*get_enumerated_info)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
Packit 4a16fb
	/**
Packit 4a16fb
	 * get the name of the enumerated item
Packit 4a16fb
	 */
Packit 4a16fb
	int (*get_enumerated_name)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int item,
Packit 4a16fb
				   char *name, size_t name_max_len);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read the current values of integer type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read the current values of integer64 type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read the current values of enumerated type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read the current values of bytes type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,
Packit 4a16fb
			  size_t max_bytes);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read the current values of iec958 type
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);
Packit 4a16fb
	/**
Packit 4a16fb
	 * update the current values of integer type with the given values
Packit 4a16fb
	 */
Packit 4a16fb
	int (*write_integer)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, long *value);
Packit 4a16fb
	/**
Packit 4a16fb
	 * update the current values of integer64 type with the given values
Packit 4a16fb
	 */
Packit 4a16fb
	int (*write_integer64)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, int64_t *value);
Packit 4a16fb
	/**
Packit 4a16fb
	 * update the current values of enumerated type with the given values
Packit 4a16fb
	 */
Packit 4a16fb
	int (*write_enumerated)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned int *items);
Packit 4a16fb
	/**
Packit 4a16fb
	 * update the current values of bytes type with the given values
Packit 4a16fb
	 */
Packit 4a16fb
	int (*write_bytes)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, unsigned char *data,
Packit 4a16fb
			   size_t max_bytes);
Packit 4a16fb
	/**
Packit 4a16fb
	 * update the current values of iec958 type with the given values
Packit 4a16fb
	 */
Packit 4a16fb
	int (*write_iec958)(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key, snd_aes_iec958_t *iec958);
Packit 4a16fb
	/**
Packit 4a16fb
	 * subscribe/unsubscribe the event notification; optional
Packit 4a16fb
	 */
Packit 4a16fb
	void (*subscribe_events)(snd_ctl_ext_t *ext, int subscribe);
Packit 4a16fb
	/**
Packit 4a16fb
	 * read a pending notification event; optional
Packit 4a16fb
	 */
Packit 4a16fb
	int (*read_event)(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id, unsigned int *event_mask);
Packit 4a16fb
	/**
Packit 4a16fb
	 * return the number of poll descriptors; optional
Packit 4a16fb
	 */
Packit 4a16fb
	int (*poll_descriptors_count)(snd_ctl_ext_t *ext);
Packit 4a16fb
	/**
Packit 4a16fb
	 * fill the poll descriptors; optional
Packit 4a16fb
	 */
Packit 4a16fb
	int (*poll_descriptors)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int space);
Packit 4a16fb
	/**
Packit 4a16fb
	 * mangle the revents of poll descriptors
Packit 4a16fb
	 */
Packit 4a16fb
	int (*poll_revents)(snd_ctl_ext_t *ext, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
Packit 4a16fb
};
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * The access type bits stored in get_attribute callback
Packit 4a16fb
 */
Packit 4a16fb
typedef enum snd_ctl_ext_access {
Packit 4a16fb
	SND_CTL_EXT_ACCESS_READ = (1<<0),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_WRITE = (1<<1),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_READWRITE = (3<<0),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_VOLATILE = (1<<2),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_TLV_READ = (1<<4),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_TLV_WRITE = (1<<5),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_TLV_READWRITE = (3<<4),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_TLV_COMMAND = (1<<6),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_INACTIVE = (1<<8),
Packit 4a16fb
	SND_CTL_EXT_ACCESS_TLV_CALLBACK = (1<<28),
Packit 4a16fb
} snd_ctl_ext_access_t;
Packit 4a16fb
Packit 4a16fb
/**
Packit 4a16fb
 * find_elem callback returns this if no matching control element is found
Packit 4a16fb
 */
Packit 4a16fb
#define SND_CTL_EXT_KEY_NOT_FOUND	(snd_ctl_ext_key_t)(-1)
Packit 4a16fb
Packit 4a16fb
int snd_ctl_ext_create(snd_ctl_ext_t *ext, const char *name, int mode);
Packit 4a16fb
int snd_ctl_ext_delete(snd_ctl_ext_t *ext);
Packit 4a16fb
Packit 4a16fb
/** \} */
Packit 4a16fb
Packit 4a16fb
#ifdef __cplusplus
Packit 4a16fb
}
Packit 4a16fb
#endif
Packit 4a16fb
Packit 4a16fb
#endif /* __ALSA_CONTROL_EXTERNAL_H */