[PATCH alsa-lib v2 2/3] mixer: Add exception for non " Volume" suffixed capture vol-ctls used in ASoC realtek codec drivers
Hans de Goede
hdegoede at redhat.com
Sun Feb 28 17:13:03 CET 2021
The following ASoC codec drivers:
sound/soc/codecs/rt5640.c
sound/soc/codecs/rt5645.c
sound/soc/codecs/rt5651.c
sound/soc/codecs/rt5677.c
Use capture-volume-control names like: "IN1 Boost", note the missing
" Volume" suffix. This causes the mixer code to not identify these as
volume-controls, which causes some of the dB related sm_elem_ops to
return -EINVAL.
This in turn causes alsamixer to not show dB info and causes UCM profile
HW volume control support in pulseaudio to not work properly due to the
lacking dB scale info.
This cannot be fixed on the kernel side because the non " Volume" suffixed
names are used in UCM profiles currently shipping in alsa-ucm-conf.
Add some code to the base_len() function, which is responsbile for
getting the control-type to deal with these special cases.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
src/mixer/simple_none.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c
index 7da7de1e..262e3516 100644
--- a/src/mixer/simple_none.c
+++ b/src/mixer/simple_none.c
@@ -905,13 +905,29 @@ static const struct suf {
{" Volume", CTL_GLOBAL_VOLUME},
{NULL, 0}
};
+
+/*
+ * Some kernel drivers use mixer-element names for capture-volumes which
+ * are not suffixed with " Capture Volume". This cannot be fixed on the
+ * kernel side because the non-suffixed names are used in UCM profiles,
+ * so we map these to CTL_CAPTURE_VOLUME based on their full name.
+ */
+const char * const capture_volume_names[] = {
+ "ADC Boost Gain",
+ "IN1 Boost",
+ "IN2 Boost",
+ "IN3 Boost",
+ NULL
+};
#endif
/* Return base length */
static int base_len(const char *name, selem_ctl_type_t *type)
{
- const struct suf *p;
size_t nlen = strlen(name);
+ const struct suf *p;
+ char buf[32];
+ int i;
/* exception: "Capture Volume" and "Capture Switch" */
if (!strcmp(name, "Capture Volume")) {
@@ -923,6 +939,13 @@ static int base_len(const char *name, selem_ctl_type_t *type)
return strlen("Capture");
}
+ for (i = 0; capture_volume_names[i]; i++) {
+ if (!strcmp(name, capture_volume_names[i])) {
+ *type = CTL_CAPTURE_VOLUME;
+ return nlen;
+ }
+ }
+
p = suffixes;
while (p->suffix) {
size_t slen = strlen(p->suffix);
--
2.30.1
More information about the Alsa-devel
mailing list