Skip to content

Commit a532e76

Browse files
Terry Jungegregkh
authored andcommitted
ALSA: usb-audio: Add quirk for Plantronics headsets to fix control names
commit 486f620 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3423cae commit a532e76

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
@@ -4156,6 +4156,52 @@ static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer,
41564156
}
41574157
}
41584158

4159+
/*
4160+
* Some Plantronics headsets have control names that don't meet ALSA naming
4161+
* standards. This function fixes nonstandard source names. By the time
4162+
* this function is called the control name should look like one of these:
4163+
* "source names Playback Volume"
4164+
* "source names Playback Switch"
4165+
* "source names Capture Volume"
4166+
* "source names Capture Switch"
4167+
* If any of the trigger words are found in the name then the name will
4168+
* be changed to:
4169+
* "Headset Playback Volume"
4170+
* "Headset Playback Switch"
4171+
* "Headset Capture Volume"
4172+
* "Headset Capture Switch"
4173+
* depending on the current suffix.
4174+
*/
4175+
static void snd_fix_plt_name(struct snd_usb_audio *chip,
4176+
struct snd_ctl_elem_id *id)
4177+
{
4178+
/* no variant of "Sidetone" should be added to this list */
4179+
static const char * const trigger[] = {
4180+
"Earphone", "Microphone", "Receive", "Transmit"
4181+
};
4182+
static const char * const suffix[] = {
4183+
" Playback Volume", " Playback Switch",
4184+
" Capture Volume", " Capture Switch"
4185+
};
4186+
int i;
4187+
4188+
for (i = 0; i < ARRAY_SIZE(trigger); i++)
4189+
if (strstr(id->name, trigger[i]))
4190+
goto triggered;
4191+
usb_audio_dbg(chip, "no change in %s\n", id->name);
4192+
return;
4193+
4194+
triggered:
4195+
for (i = 0; i < ARRAY_SIZE(suffix); i++)
4196+
if (strstr(id->name, suffix[i])) {
4197+
usb_audio_dbg(chip, "fixing kctl name %s\n", id->name);
4198+
snprintf(id->name, sizeof(id->name), "Headset%s",
4199+
suffix[i]);
4200+
return;
4201+
}
4202+
usb_audio_dbg(chip, "something wrong in kctl name %s\n", id->name);
4203+
}
4204+
41594205
void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
41604206
struct usb_mixer_elem_info *cval, int unitid,
41614207
struct snd_kcontrol *kctl)
@@ -4173,5 +4219,10 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
41734219
cval->min_mute = 1;
41744220
break;
41754221
}
4222+
4223+
/* ALSA-ify some Plantronics headset control names */
4224+
if (USB_ID_VENDOR(mixer->chip->usb_id) == 0x047f &&
4225+
(cval->control == UAC_FU_MUTE || cval->control == UAC_FU_VOLUME))
4226+
snd_fix_plt_name(mixer->chip, &kctl->id);
41764227
}
41774228

0 commit comments

Comments
 (0)