From 8e3ee8473bd61dd16385089ce3338ef7eef384f0 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 22 Feb 2021 12:06:55 +0100 Subject: [PATCH] control: add LED group support - sync asound.h with kernel 5.13 Signed-off-by: Jaroslav Kysela --- include/control.h | 12 ++++++++++++ include/sound/uapi/asound.h | 6 +++++- src/control/control.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/control.h b/include/control.h index 8766f440..be0643d2 100644 --- a/include/control.h +++ b/include/control.h @@ -227,6 +227,17 @@ typedef enum _snd_ctl_event_type { SND_CTL_EVENT_LAST = SND_CTL_EVENT_ELEM }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 * test the other masks) \hideinitializer */ #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_user(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); 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); diff --git a/include/sound/uapi/asound.h b/include/sound/uapi/asound.h index ec610c27..b57fd9c0 100644 --- a/include/sound/uapi/asound.h +++ b/include/sound/uapi/asound.h @@ -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 { 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_LOCK (1<<9) /* write lock */ #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_USER (1<<29) /* user space element */ /* bits 30 and 31 are obsoleted (for indirect access) */ diff --git a/src/control/control.c b/src/control/control.c index 78becd73..4cc3fdb3 100644 --- a/src/control/control.c +++ b/src/control/control.c @@ -2524,6 +2524,17 @@ pid_t snd_ctl_elem_info_get_owner(const snd_ctl_elem_info_t *obj) 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 * \param obj CTL element id/info