| From fca9c850042a7ab4828ce3a9caa8bc40ea09856a Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?C=C3=A1ssio=20Gabriel?= <cassiogabrielcontato@gmail.com> |
| Date: Tue, 21 Apr 2026 21:53:52 -0300 |
| Subject: ALSA: usb-audio: Avoid false E-MU sample-rate notifications |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| From: Cássio Gabriel <cassiogabrielcontato@gmail.com> |
| |
| commit fca9c850042a7ab4828ce3a9caa8bc40ea09856a upstream. |
| |
| snd_emuusb_set_samplerate() unconditionally notifies the E-MU |
| SampleRate Extension Unit control after issuing SET_CUR. |
| |
| If snd_usb_mixer_set_ctl_value() fails, the control value has not |
| changed, yet snd_usb_mixer_notify_id() still invalidates the cache and |
| emits a value-change event to userspace. |
| |
| Notify the control only after a successful write. |
| |
| Fixes: 7d2b451e65d2 ("ALSA: usb-audio - Added functionality for E-mu 0404USB/0202USB/TrackerPre") |
| Cc: stable@vger.kernel.org |
| Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> |
| Link: https://patch.msgid.link/20260421-alsa-emuusb-samplerate-notify-v1-1-8b63bbc1d7f1@gmail.com |
| Signed-off-by: Takashi Iwai <tiwai@suse.de> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| sound/usb/mixer_quirks.c | 10 ++++++---- |
| 1 file changed, 6 insertions(+), 4 deletions(-) |
| |
| --- a/sound/usb/mixer_quirks.c |
| +++ b/sound/usb/mixer_quirks.c |
| @@ -1538,15 +1538,17 @@ void snd_emuusb_set_samplerate(struct sn |
| { |
| struct usb_mixer_interface *mixer; |
| struct usb_mixer_elem_info *cval; |
| + int err; |
| int unitid = 12; /* SampleRate ExtensionUnit ID */ |
| |
| list_for_each_entry(mixer, &chip->mixer_list, list) { |
| if (mixer->id_elems[unitid]) { |
| cval = mixer_elem_list_to_info(mixer->id_elems[unitid]); |
| - snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, |
| - cval->control << 8, |
| - samplerate_id); |
| - snd_usb_mixer_notify_id(mixer, unitid); |
| + err = snd_usb_mixer_set_ctl_value(cval, UAC_SET_CUR, |
| + cval->control << 8, |
| + samplerate_id); |
| + if (!err) |
| + snd_usb_mixer_notify_id(mixer, unitid); |
| break; |
| } |
| } |