mirror of https://github.com/torvalds/linux.git
ALSA: usb-audio: Modularize realtek_add_jack in mixer_quirks
Modify the realtek_add_jack function used for the jack detection quirk to allow passing the mixer unit id and an snd_kcontrol_new. This allows adding additional devices that require the same quirk, but implement jack detection with different commands. Signed-off-by: Tasos Sahanidis <tasos@tasossah.com> Link: https://patch.msgid.link/20251126003805.2705503-2-tasos@tasossah.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
500372aeb5
commit
fba274760d
|
|
@ -2277,7 +2277,8 @@ static int realtek_resume_jack(struct usb_mixer_elem_list *list)
|
|||
}
|
||||
|
||||
static int realtek_add_jack(struct usb_mixer_interface *mixer,
|
||||
char *name, u32 val)
|
||||
char *name, u32 val, int unitid,
|
||||
const struct snd_kcontrol_new *kctl_new)
|
||||
{
|
||||
struct usb_mixer_elem_info *cval;
|
||||
struct snd_kcontrol *kctl;
|
||||
|
|
@ -2285,14 +2286,13 @@ static int realtek_add_jack(struct usb_mixer_interface *mixer,
|
|||
cval = kzalloc(sizeof(*cval), GFP_KERNEL);
|
||||
if (!cval)
|
||||
return -ENOMEM;
|
||||
snd_usb_mixer_elem_init_std(&cval->head, mixer,
|
||||
REALTEK_JACK_INTERRUPT_NODE);
|
||||
snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid);
|
||||
cval->head.resume = realtek_resume_jack;
|
||||
cval->val_type = USB_MIXER_BOOLEAN;
|
||||
cval->channels = 1;
|
||||
cval->min = 0;
|
||||
cval->max = 1;
|
||||
kctl = snd_ctl_new1(&realtek_connector_ctl_ro, cval);
|
||||
kctl = snd_ctl_new1(kctl_new, cval);
|
||||
if (!kctl) {
|
||||
kfree(cval);
|
||||
return -ENOMEM;
|
||||
|
|
@ -2322,14 +2322,20 @@ static int dell_dock_mixer_create(struct usb_mixer_interface *mixer)
|
|||
USB_RECIP_DEVICE | USB_TYPE_VENDOR | USB_DIR_OUT,
|
||||
0, 0, NULL, 0);
|
||||
|
||||
err = realtek_add_jack(mixer, "Line Out Jack", REALTEK_LINE1);
|
||||
err = realtek_add_jack(mixer, "Line Out Jack", REALTEK_LINE1,
|
||||
REALTEK_JACK_INTERRUPT_NODE,
|
||||
&realtek_connector_ctl_ro);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = realtek_add_jack(mixer, "Headphone Jack", REALTEK_HP_OUT);
|
||||
err = realtek_add_jack(mixer, "Headphone Jack", REALTEK_HP_OUT,
|
||||
REALTEK_JACK_INTERRUPT_NODE,
|
||||
&realtek_connector_ctl_ro);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = realtek_add_jack(mixer, "Headset Mic Jack",
|
||||
REALTEK_HP_OUT | REALTEK_MIC_FLAG);
|
||||
REALTEK_HP_OUT | REALTEK_MIC_FLAG,
|
||||
REALTEK_JACK_INTERRUPT_NODE,
|
||||
&realtek_connector_ctl_ro);
|
||||
if (err < 0)
|
||||
return err;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue