Skip to content

Commit 486f620

Browse files
Terry JungeJiri Kosina
authored andcommitted
ALSA: usb-audio: Add quirk for Plantronics headsets to fix control names
Many Poly/Plantronics headset families name the feature, input, and/or output units in a such a way to produce control names that are not recognized by user space. As such, the volume and mute events do not get routed to the headset's audio controls. As an example from a product family: The microphone mute control is named Headset Microphone Capture Switch and the headset volume control is named Headset Earphone Playback Volume The quirk fixes these to become Headset Capture Switch Headset Playback Volume Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com> Reviewed-by: Takashi Iwai <tiwai@suse.de> Cc: stable@vger.kernel.org Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 9821709 commit 486f620

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

sound/usb/mixer_quirks.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,6 +4216,52 @@ static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer,
42164216
}
42174217
}
42184218

4219+
/*
4220+
* Some Plantronics headsets have control names that don't meet ALSA naming
4221+
* standards. This function fixes nonstandard source names. By the time
4222+
* this function is called the control name should look like one of these:
4223+
* "source names Playback Volume"
4224+
* "source names Playback Switch"
4225+
* "source names Capture Volume"
4226+
* "source names Capture Switch"
4227+
* If any of the trigger words are found in the name then the name will
4228+
* be changed to:
4229+
* "Headset Playback Volume"
4230+
* "Headset Playback Switch"
4231+
* "Headset Capture Volume"
4232+
* "Headset Capture Switch"
4233+
* depending on the current suffix.
4234+
*/
4235+
static void snd_fix_plt_name(struct snd_usb_audio *chip,
4236+
struct snd_ctl_elem_id *id)
4237+
{
4238+
/* no variant of "Sidetone" should be added to this list */
4239+
static const char * const trigger[] = {
4240+
"Earphone", "Microphone", "Receive", "Transmit"
4241+
};
4242+
static const char * const suffix[] = {
4243+
" Playback Volume", " Playback Switch",
4244+
" Capture Volume", " Capture Switch"
4245+
};
4246+
int i;
4247+
4248+
for (i = 0; i < ARRAY_SIZE(trigger); i++)
4249+
if (strstr(id->name, trigger[i]))
4250+
goto triggered;
4251+
usb_audio_dbg(chip, "no change in %s\n", id->name);
4252+
return;
4253+
4254+
triggered:
4255+
for (i = 0; i < ARRAY_SIZE(suffix); i++)
4256+
if (strstr(id->name, suffix[i])) {
4257+
usb_audio_dbg(chip, "fixing kctl name %s\n", id->name);
4258+
snprintf(id->name, sizeof(id->name), "Headset%s",
4259+
suffix[i]);
4260+
return;
4261+
}
4262+
usb_audio_dbg(chip, "something wrong in kctl name %s\n", id->name);
4263+
}
4264+
42194265
void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
42204266
struct usb_mixer_elem_info *cval, int unitid,
42214267
struct snd_kcontrol *kctl)
@@ -4233,5 +4279,10 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
42334279
cval->min_mute = 1;
42344280
break;
42354281
}
4282+
4283+
/* ALSA-ify some Plantronics headset control names */
4284+
if (USB_ID_VENDOR(mixer->chip->usb_id) == 0x047f &&
4285+
(cval->control == UAC_FU_MUTE || cval->control == UAC_FU_VOLUME))
4286+
snd_fix_plt_name(mixer->chip, &kctl->id);
42364287
}
42374288

0 commit comments

Comments
 (0)