Skip to content

Commit 8dde723

Browse files
committed
ALSA: usb-audio: Avoid unnecessary or invalid connector selection at resume
The recent fix for the resume on Lenovo machines seems causing a regression on others. It's because the change always triggers the connector selection no matter which widget node type is. This patch addresses the regression by setting the resume callback selectively only for the connector widget. Fixes: 44609fc ("ALSA: usb-audio: Check connector value on resume") Cc: <[email protected]> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213897 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 0d4867a commit 8dde723

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

sound/usb/mixer.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,15 @@ static void get_connector_control_name(struct usb_mixer_interface *mixer,
18161816
strlcat(name, " - Output Jack", name_size);
18171817
}
18181818

1819+
/* get connector value to "wake up" the USB audio */
1820+
static int connector_mixer_resume(struct usb_mixer_elem_list *list)
1821+
{
1822+
struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
1823+
1824+
get_connector_value(cval, NULL, NULL);
1825+
return 0;
1826+
}
1827+
18191828
/* Build a mixer control for a UAC connector control (jack-detect) */
18201829
static void build_connector_control(struct usb_mixer_interface *mixer,
18211830
const struct usbmix_name_map *imap,
@@ -1833,6 +1842,10 @@ static void build_connector_control(struct usb_mixer_interface *mixer,
18331842
if (!cval)
18341843
return;
18351844
snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id);
1845+
1846+
/* set up a specific resume callback */
1847+
cval->head.resume = connector_mixer_resume;
1848+
18361849
/*
18371850
* UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the
18381851
* number of channels connected.
@@ -3642,23 +3655,15 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list)
36423655
return 0;
36433656
}
36443657

3645-
static int default_mixer_resume(struct usb_mixer_elem_list *list)
3646-
{
3647-
struct usb_mixer_elem_info *cval = mixer_elem_list_to_info(list);
3648-
3649-
/* get connector value to "wake up" the USB audio */
3650-
if (cval->val_type == USB_MIXER_BOOLEAN && cval->channels == 1)
3651-
get_connector_value(cval, NULL, NULL);
3652-
3653-
return 0;
3654-
}
3655-
36563658
static int default_mixer_reset_resume(struct usb_mixer_elem_list *list)
36573659
{
3658-
int err = default_mixer_resume(list);
3660+
int err;
36593661

3660-
if (err < 0)
3661-
return err;
3662+
if (list->resume) {
3663+
err = list->resume(list);
3664+
if (err < 0)
3665+
return err;
3666+
}
36623667
return restore_mixer_value(list);
36633668
}
36643669

@@ -3697,7 +3702,7 @@ void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list,
36973702
list->id = unitid;
36983703
list->dump = snd_usb_mixer_dump_cval;
36993704
#ifdef CONFIG_PM
3700-
list->resume = default_mixer_resume;
3705+
list->resume = NULL;
37013706
list->reset_resume = default_mixer_reset_resume;
37023707
#endif
37033708
}

0 commit comments

Comments
 (0)