[PATCH alsa-lib v2 3/3] mixer: Add exception for some capture-vol-ctls which have a " Volume" suffix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following ASoC codec drivers:

sound/soc/codecs/rt5659.c
sound/soc/codecs/rt5660.c
sound/soc/codecs/rt5665.c
sound/soc/codecs/rt5668.c
sound/soc/codecs/rt5670.c
sound/soc/codecs/rt5682.c

Use the following troublesome capture-volume-control names:
"IN1 Boost Volume"
"IN2 Boost Volume"
"IN3 Boost Volume"
"STO1 ADC Boost Gain Volume"
"STO2 ADC Boost Gain Volume"
"Mono ADC Boost Gain Volume"

And sound/soc/codecs/es8316.c uses "ADC PGA Gain Volume".

Note how these are suffixed with just " Volume" instead of
"Capture Volume" add some special handling for this to the base_len()
function, which is responsbile for getting the control-type,
so that the type correctly gets set to CTL_CAPTURE_VOLUME instead of
CTL_GLOBAL_VOLUME.

This correctly makes snd_mixer_selem_has_capture_volume() return true for
these (and makes snd_mixer_selem_has_common_volume() return false).

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 src/mixer/simple_none.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c
index 262e3516..22154647 100644
--- a/src/mixer/simple_none.c
+++ b/src/mixer/simple_none.c
@@ -914,9 +914,13 @@ static const struct suf {
  */
 const char * const capture_volume_names[] = {
 	"ADC Boost Gain",
+	"ADC PGA Gain",
 	"IN1 Boost",
 	"IN2 Boost",
 	"IN3 Boost",
+	"Mono ADC Boost Gain",
+	"STO1 ADC Boost Gain",
+	"STO2 ADC Boost Gain",
 	NULL
 };
 #endif
@@ -944,6 +948,17 @@ static int base_len(const char *name, selem_ctl_type_t *type)
 			*type = CTL_CAPTURE_VOLUME;
 			return nlen;
 		}
+
+		/*
+		 * Sometimes these have a " Volume" suffix instead of a
+		 * " Capture Volume" suffix. Check for this so that we set
+		 * type to CTL_CAPTURE_VOLUME instead of CTL_GLOBAL_VOLUME.
+		 */
+		snprintf(buf, sizeof(buf), "%s Volume", capture_volume_names[i]);
+		if (!strcmp(name, buf)) {
+			*type = CTL_CAPTURE_VOLUME;
+			return nlen - strlen(" Volume");
+		}
 	}
 
 	p = suffixes;
-- 
2.30.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux