control: add LED group support

- sync asound.h with kernel 5.13

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-02-22 12:06:55 +01:00
parent 6c6ba467ec
commit 8e3ee8473b
3 changed files with 28 additions and 1 deletions

View file

@ -227,6 +227,17 @@ typedef enum _snd_ctl_event_type {
SND_CTL_EVENT_LAST = SND_CTL_EVENT_ELEM SND_CTL_EVENT_LAST = SND_CTL_EVENT_ELEM
}snd_ctl_event_type_t; }snd_ctl_event_type_t;
/** CTL LED group */
typedef enum _snd_ctl_led_group {
/** Invalid type */
SND_CTL_ELEM_LED_NONE = 0,
/** Boolean contents */
SND_CTL_ELEM_LED_SPEAKER,
/** Integer contents */
SND_CTL_ELEM_LED_MICROPHONE,
SND_CTL_ELEM_LED_LAST = SND_CTL_ELEM_LED_MICROPHONE
} snd_ctl_led_group_t;
/** Element has been removed (Warning: test this first and if set don't /** Element has been removed (Warning: test this first and if set don't
* test the other masks) \hideinitializer */ * test the other masks) \hideinitializer */
#define SND_CTL_EVENT_MASK_REMOVE (~0U) #define SND_CTL_EVENT_MASK_REMOVE (~0U)
@ -517,6 +528,7 @@ int snd_ctl_elem_info_is_tlv_commandable(const snd_ctl_elem_info_t *obj);
int snd_ctl_elem_info_is_owner(const snd_ctl_elem_info_t *obj); int snd_ctl_elem_info_is_owner(const snd_ctl_elem_info_t *obj);
int snd_ctl_elem_info_is_user(const snd_ctl_elem_info_t *obj); int snd_ctl_elem_info_is_user(const snd_ctl_elem_info_t *obj);
pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj); pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj);
snd_ctl_led_group_t snd_ctl_elem_info_get_led_group(const snd_ctl_elem_info_t *obj);
unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj); unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj);
long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj); long snd_ctl_elem_info_get_min(const snd_ctl_elem_info_t *obj);
long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj); long snd_ctl_elem_info_get_max(const snd_ctl_elem_info_t *obj);

View file

@ -922,7 +922,7 @@ struct snd_timer_tread {
* * * *
****************************************************************************/ ****************************************************************************/
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 9)
struct snd_ctl_card_info { struct snd_ctl_card_info {
int card; /* card number */ int card; /* card number */
@ -968,6 +968,10 @@ typedef int __bitwise snd_ctl_elem_iface_t;
#define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */ #define SNDRV_CTL_ELEM_ACCESS_INACTIVE (1<<8) /* control does actually nothing, but may be updated */
#define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */ #define SNDRV_CTL_ELEM_ACCESS_LOCK (1<<9) /* write lock */
#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */ #define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
#define SNDRV_CTL_ELEM_ACCESS_LED_SHIFT 11
#define SNDRV_CTL_ELEM_ACCESS_LED_MASK (7<<11) /* three bits - LED group */
#define SNDRV_CTL_ELEM_ACCESS_SPK_LED (1<<11) /* speaker (output) LED flag */
#define SNDRV_CTL_ELEM_ACCESS_MIC_LED (2<<11) /* microphone (input) LED flag */
#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */ #define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */
#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */ #define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
/* bits 30 and 31 are obsoleted (for indirect access) */ /* bits 30 and 31 are obsoleted (for indirect access) */

View file

@ -2524,6 +2524,17 @@ pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj)
return obj->owner; return obj->owner;
} }
/**
* \brief Get associated LED group to an element
* \param obj CTL element id/info
* \return LED group enum
*/
snd_ctl_led_group_t snd_ctl_elem_info_get_led_group(const snd_ctl_elem_info_t *obj)
{
assert(obj);
return (obj->access & SNDRV_CTL_ELEM_ACCESS_LED_MASK) >> SNDRV_CTL_ELEM_ACCESS_LED_SHIFT;
}
/** /**
* \brief Get number of value entries from a CTL element id/info * \brief Get number of value entries from a CTL element id/info
* \param obj CTL element id/info * \param obj CTL element id/info