Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Tasos Sahanidis and committed by
Takashi Iwai
fba27476 500372ae

+13 -7
+13 -7
sound/usb/mixer_quirks.c
··· 2277 2277 } 2278 2278 2279 2279 static int realtek_add_jack(struct usb_mixer_interface *mixer, 2280 - char *name, u32 val) 2280 + char *name, u32 val, int unitid, 2281 + const struct snd_kcontrol_new *kctl_new) 2281 2282 { 2282 2283 struct usb_mixer_elem_info *cval; 2283 2284 struct snd_kcontrol *kctl; ··· 2286 2285 cval = kzalloc(sizeof(*cval), GFP_KERNEL); 2287 2286 if (!cval) 2288 2287 return -ENOMEM; 2289 - snd_usb_mixer_elem_init_std(&cval->head, mixer, 2290 - REALTEK_JACK_INTERRUPT_NODE); 2288 + snd_usb_mixer_elem_init_std(&cval->head, mixer, unitid); 2291 2289 cval->head.resume = realtek_resume_jack; 2292 2290 cval->val_type = USB_MIXER_BOOLEAN; 2293 2291 cval->channels = 1; 2294 2292 cval->min = 0; 2295 2293 cval->max = 1; 2296 - kctl = snd_ctl_new1(&realtek_connector_ctl_ro, cval); 2294 + kctl = snd_ctl_new1(kctl_new, cval); 2297 2295 if (!kctl) { 2298 2296 kfree(cval); 2299 2297 return -ENOMEM; ··· 2322 2322 USB_RECIP_DEVICE | USB_TYPE_VENDOR | USB_DIR_OUT, 2323 2323 0, 0, NULL, 0); 2324 2324 2325 - err = realtek_add_jack(mixer, "Line Out Jack", REALTEK_LINE1); 2325 + err = realtek_add_jack(mixer, "Line Out Jack", REALTEK_LINE1, 2326 + REALTEK_JACK_INTERRUPT_NODE, 2327 + &realtek_connector_ctl_ro); 2326 2328 if (err < 0) 2327 2329 return err; 2328 - err = realtek_add_jack(mixer, "Headphone Jack", REALTEK_HP_OUT); 2330 + err = realtek_add_jack(mixer, "Headphone Jack", REALTEK_HP_OUT, 2331 + REALTEK_JACK_INTERRUPT_NODE, 2332 + &realtek_connector_ctl_ro); 2329 2333 if (err < 0) 2330 2334 return err; 2331 2335 err = realtek_add_jack(mixer, "Headset Mic Jack", 2332 - REALTEK_HP_OUT | REALTEK_MIC_FLAG); 2336 + REALTEK_HP_OUT | REALTEK_MIC_FLAG, 2337 + REALTEK_JACK_INTERRUPT_NODE, 2338 + &realtek_connector_ctl_ro); 2333 2339 if (err < 0) 2334 2340 return err; 2335 2341 return 0;