Commit dc88eef8 authored by Cássio Gabriel's avatar Cássio Gabriel Committed by Takashi Iwai
Browse files

ALSA: 6fire: Fix input volume change detection



usb6fire_control_input_vol_put() stores the analog capture volume
as a signed offset in rt->input_vol[] (-15..+15), but it compares
the cached value against the user-visible mixer value (0..30)
before subtracting 15.

This mixes two domains in the change detection path. Since the
runtime is zero-initialized, the visible default is 15; writing 0
right after probe is ignored, while writing 15 is reported as a
change even though the cached value remains 0.

Normalize the user value before comparing it with the cached offset.

Fixes: 06bb4e74 ("ALSA: snd-usb-6fire: add analog input volume control")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarCássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260416-alsa-6fire-input-volume-change-detection-v1-1-ec78299168df@gmail.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 17bc5dd4
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -290,15 +290,17 @@ static int usb6fire_control_input_vol_put(struct snd_kcontrol *kcontrol,
		struct snd_ctl_elem_value *ucontrol)
{
	struct control_runtime *rt = snd_kcontrol_chip(kcontrol);
	int vol0 = ucontrol->value.integer.value[0] - 15;
	int vol1 = ucontrol->value.integer.value[1] - 15;
	int changed = 0;

	if (rt->input_vol[0] != ucontrol->value.integer.value[0]) {
		rt->input_vol[0] = ucontrol->value.integer.value[0] - 15;
	if (rt->input_vol[0] != vol0) {
		rt->input_vol[0] = vol0;
		rt->ivol_updated &= ~(1 << 0);
		changed = 1;
	}
	if (rt->input_vol[1] != ucontrol->value.integer.value[1]) {
		rt->input_vol[1] = ucontrol->value.integer.value[1] - 15;
	if (rt->input_vol[1] != vol1) {
		rt->input_vol[1] = vol1;
		rt->ivol_updated &= ~(1 << 1);
		changed = 1;
	}