Skip to contentSkip to conversation

ALSA: mixer_evo: minor fixes and tlv addition

PATCH In review Christian Ruppert 1 participant 6 messages Oct 26 – Nov 15 Sound

lore
Share & tools
lore
#0 lore raw

cover ALSA: mixer_evo: minor fixes and tlv addition

This patch set contains fixes for minor issues discovered while reviewing the proposed audient_id driver as well as the tlv definition for the recording mixer channels. Thanks to Will Porter for triggering this with his submission.

Christian Ruppert (4):
ALSA: mixer_evo: Remove double end marker device list
ALSA: mixer_evo: Add missing snd_usb_lock calls
ALSA: mixer_evo: Fix endianness of boolean inversion
ALSA: mixer_evo: Add tlv for mixer channels

 sound/usb/mixer_evo.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.56.0
#1 lore raw

PATCH 1/4 ALSA: mixer_evo: Remove double end marker device list

The evo_devinfo array accidentally contained two end-of-array markers. This isn't harmful but not very clean. Remove one of them.

---
 sound/usb/mixer_evo.c | 4 ----
 1 file changed, 4 deletions(-)
sound/usb/mixer_evo.c +0 -4
index c327b82c8d2d..26846108a3e1 100644
@@ -196,10 +196,6 @@ static const struct evo_devinfo {
 		.usb_id = USB_ID(USB_AUDIENT_VID, USB_EVO4_PID),
 		.controls = evo4_controls,
 	},
-	{
-		.usb_id = USB_ID(USB_AUDIENT_VID, USB_EVO4_PID),
-		.controls = NULL,
-	},
 	{ 0 } /* sentinel */
 };
 
Signature · 1 line
2.56.0
#2 lore raw

PATCH 2/4 ALSA: mixer_evo: Add missing snd_usb_lock calls

In reply to Christian Ruppert

Bugfix: Add missing snd_usb_lock_shutdown calls to mixer_evo.c.

---
 sound/usb/mixer_evo.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/usb/mixer_evo.c +16 -0
index 26846108a3e1..1fbcbe61b708 100644
@@ -275,6 +275,10 @@ static int snd_ctl_evo_boolean_get(struct snd_kcontrol *kctl,
 
 	int i;
 
+	CLASS(snd_usb_lock, pm)(mixer->chip);
+	if (pm.err < 0)
+		return pm.err;
+
 	for (i = 0; i < hwchan; i++) {
 		u32 buf;
 		int ret;
@@ -312,6 +316,10 @@ static int snd_ctl_evo_boolean_set(struct snd_kcontrol *kctl,
 	int changed = 0;
 	int i;
 
+	CLASS(snd_usb_lock, pm)(mixer->chip);
+	if (pm.err < 0)
+		return pm.err;
+
 	for (i = 0; i < hwchan; i++) {
 		u32 rbuf;
 		u32 buf = cpu_to_le32(ctl_val->value.integer.value[i] ? 1 : 0);
@@ -352,6 +360,10 @@ static int snd_ctl_evo_integer_get(struct snd_kcontrol *kctl,
 
 	int i;
 
+	CLASS(snd_usb_lock, pm)(mixer->chip);
+	if (pm.err < 0)
+		return pm.err;
+
 	for (i = 0; i < hwchan; i++) {
 		u16 buf;
 		s16 val;
@@ -386,6 +398,10 @@ static int snd_ctl_evo_integer_set(struct snd_kcontrol *kctl,
 	int changed = 0;
 	int i;
 
+	CLASS(snd_usb_lock, pm)(mixer->chip);
+	if (pm.err < 0)
+		return pm.err;
+
 	for (i = 0; i < hwchan; i++) {
 		s16 rbuf;
 		s16 buf = cpu_to_le16(ctl_val->value.integer.value[i]);
Signature · 1 line
2.56.0
#3 lore raw

PATCH 3/4 ALSA: mixer_evo: Fix endianness of boolean inversion

In reply to Christian Ruppert

Bugfix: The optional inversion in snd_ctl_evo_boolean_get was in the wrong endianness domain (CPU).
Move it to LE domain to make it work on all machines.

---
 sound/usb/mixer_evo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/mixer_evo.c +1 -1
index 1fbcbe61b708..867d083953ba 100644
@@ -326,7 +326,7 @@ static int snd_ctl_evo_boolean_set(struct snd_kcontrol *kctl,
 		int ret;
 
 		if (ctype->invert)
-			buf ^= 0x1;
+			buf ^= cpu_to_le32(0x1);
 
 		ret = snd_evo_get_cur(mixer, value + i, index,
 				      &rbuf, sizeof(rbuf));
Signature · 1 line
2.56.0
#4 lore raw

PATCH 4/4 ALSA: mixer_evo: Add tlv for mixer channels

In reply to Christian Ruppert

mixer_evo didn't declare tlv for the recording mixer matrix which seems to confuse some userland programs. Add tlv definitions to fix this.

We still do not add tlv for the crossfader (generally labelled "mixer") because there doesn't seem to be a way to declare this so that userland programs just keep it as linear as it is and should be.

---
 sound/usb/mixer_evo.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
sound/usb/mixer_evo.c +11 -2
index 867d083953ba..c1e0332232f2 100644
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/control.h>
+#include <sound/tlv.h>
 
 #include "usbaudio.h"
 #include "mixer.h"
@@ -31,6 +32,9 @@ enum snd_evo_type {
 	SND_EVO_TYPE_NCTYPES
 };
 
+/* Mixer matrix: -128dB (mute) to +6dB */
+static const DECLARE_TLV_DB_MINMAX_MUTE(snd_evo_tlv_mixer, -12800, 600);
+
 static const struct snd_evo_ctrl_type {
 	snd_ctl_elem_type_t type;
 	bool invert;
@@ -40,6 +44,7 @@ static const struct snd_evo_ctrl_type {
 	union {
 		int integer;
 	} max;
+	const unsigned int *tlv;
 	u16 wValue;
 	u16 wIndex;
 } snd_evo_ctypes[SND_EVO_TYPE_NCTYPES] = {
@@ -49,6 +54,7 @@ static const struct snd_evo_ctrl_type {
 		.max.integer = 127,
 		.wValue = 0x0000,
 		.wIndex = 0x3800,
+		/* no TLV here because we can't describe the cross-fader */
 	},
 	[SND_EVO_TYPE_PHANTOM] = {
 		.type = SNDRV_CTL_ELEM_TYPE_BOOLEAN,
@@ -80,6 +86,7 @@ static const struct snd_evo_ctrl_type {
 		.max.integer = 6 * 256,
 		.wValue = 0x0100,
 		.wIndex = 0x3C00,
+		.tlv = snd_evo_tlv_mixer,
 	},
 };
 
@@ -431,8 +438,6 @@ static int snd_ctl_evo_info(struct snd_kcontrol *kctl,
 	const struct snd_evo_ctrl_type *const ctype = snd_evo_kctl_type(kctl);
 
 	uinfo->type = ctype->type;
-	uinfo->access = SNDRV_CTL_ELEM_ACCESS_READWRITE
-			| SNDRV_CTL_ELEM_ACCESS_VOLATILE;
 	uinfo->count = snd_evo_kctl_channels(kctl);
 	uinfo->value.integer.min = ctype->min.integer;
 	uinfo->value.integer.max = ctype->max.integer;
@@ -454,6 +459,10 @@ static int snd_evo_add_ctrl(struct usb_mixer_interface *mixer,
 	knew.info = snd_ctl_evo_info;
 	knew.private_value = snd_evo_kctl_priv(ctrl->type, ctrl->val_offs,
 					       ctrl->hwchannels);
+	knew.tlv.p = ctype->tlv;
+	knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE
+			| SNDRV_CTL_ELEM_ACCESS_VOLATILE
+			| (ctype->tlv ? SNDRV_CTL_ELEM_ACCESS_TLV_READ : 0);
 
 	switch (ctype->type) {
 	case SNDRV_CTL_ELEM_TYPE_INTEGER:
Signature · 1 line
2.56.0
#5 lore raw
In reply to Christian Ruppert

Hi Takashi,

I wonder what has become of this patch set. It was intended to be applied before the initial driver goes into a stable kernel (7.4 that would be) and the iD14 support currently under discussion with Will also requires this.

I kept it intentionally short and limited to bugfixes so it can still be applied after the merge window is closed. Let me know if this possible or if I should refactor it into the bigger patch set for the next merge window.

Thanks,
Christian

Quoted 17 lines · Christian Ruppert

This patch set contains fixes for minor issues discovered while reviewing the proposed audient_id driver as well as the tlv definition for the recording mixer channels. Thanks to Will Porter for triggering this with his submission.

Christian Ruppert (4):
ALSA: mixer_evo: Remove double end marker device list
ALSA: mixer_evo: Add missing snd_usb_lock calls
ALSA: mixer_evo: Fix endianness of boolean inversion
ALSA: mixer_evo: Add tlv for mixer channels

 sound/usb/mixer_evo.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.56.0