* [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
@ 2024-11-14 6:15 Wade Wang
2024-11-14 6:32 ` kernel test robot
2024-11-14 7:10 ` Takashi Iwai
0 siblings, 2 replies; 6+ messages in thread
From: Wade Wang @ 2024-11-14 6:15 UTC (permalink / raw)
To: perex, tiwai, kl, linuxhid, wangdicheng, k.kosik, linux-sound,
linux-kernel, stable, wade.wang
Add a control name fixer for all headsets with VID 0x047F.
Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com>
Signed-off-by: Wade Wang <wade.wang@hp.com>
---
sound/usb/mixer.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index bd67027c7677..110d43ace4d8 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1664,6 +1664,33 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
snd_ctl_rename(card, kctl, "Headphone");
}
+static void fix_plt_control_name(struct snd_kcontrol *kctl)
+{
+ static const char * const names_to_remove[] = {
+ "Earphone",
+ "Microphone",
+ "Receive",
+ "Transmit",
+ NULL
+ };
+ const char * const *n2r;
+ char *dst, *src;
+ size_t len;
+
+ for (n2r = names_to_remove; *n2r; ++n2r) {
+ dst = strstr(kctl->id.name, *n2r);
+ if (dst != NULL) {
+ src = dst + strlen(*n2r);
+ len = strlen(src) + 1;
+ if ((char *)kctl->id.name != dst && *(dst - 1) == ' ')
+ --dst;
+ memmove(dst, src, len);
+ }
+ }
+ if (kctl->id.name[0] == '\0')
+ strscpy(kctl->id.name, "Headset", SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
+}
+
static const struct usb_feature_control_info *get_feature_control_info(int control)
{
int i;
@@ -1780,6 +1807,9 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
if (!mapped_name)
check_no_speaker_on_headset(kctl, mixer->chip->card);
+ if (USB_ID_VENDOR(mixer->chip->usb_id) == 0x047f)
+ fix_plt_control_name(kctl);
+
/*
* determine the stream direction:
* if the connected output is USB stream, then it's likely a
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
2024-11-14 6:15 [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets Wade Wang
@ 2024-11-14 6:32 ` kernel test robot
2024-11-14 7:10 ` Takashi Iwai
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2024-11-14 6:32 UTC (permalink / raw)
To: Wade Wang; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
Link: https://lore.kernel.org/stable/20241114061553.1699264-1-wade.wang%40hp.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
2024-11-14 6:15 [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets Wade Wang
2024-11-14 6:32 ` kernel test robot
@ 2024-11-14 7:10 ` Takashi Iwai
2024-11-14 18:44 ` Terry Junge
1 sibling, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2024-11-14 7:10 UTC (permalink / raw)
To: Wade Wang
Cc: perex, tiwai, kl, linuxhid, wangdicheng, k.kosik, linux-sound,
linux-kernel, stable
On Thu, 14 Nov 2024 07:15:53 +0100,
Wade Wang wrote:
>
> Add a control name fixer for all headsets with VID 0x047F.
>
> Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com>
> Signed-off-by: Wade Wang <wade.wang@hp.com>
Thanks for the patch, but from the description, it's not clear what
this patch actually does. What's the control name fixer and how it
behaves?
Also, are you sure that this can be applied to all devices of
Plantonics & co? Including the devices in future. I thought they had
so many different models.
Last but not least, __build_feature_ctl() is no right place to add the
vendor-specific stuff. There is already a common place in
mixer_quirks.c, e.g. snd_usb_mixer_fu_apply_quirk(). Please move the
fix-up to the appropriate place.
thanks,
Takashi
> ---
> sound/usb/mixer.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index bd67027c7677..110d43ace4d8 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c
> @@ -1664,6 +1664,33 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
> snd_ctl_rename(card, kctl, "Headphone");
> }
>
> +static void fix_plt_control_name(struct snd_kcontrol *kctl)
> +{
> + static const char * const names_to_remove[] = {
> + "Earphone",
> + "Microphone",
> + "Receive",
> + "Transmit",
> + NULL
> + };
> + const char * const *n2r;
> + char *dst, *src;
> + size_t len;
> +
> + for (n2r = names_to_remove; *n2r; ++n2r) {
> + dst = strstr(kctl->id.name, *n2r);
> + if (dst != NULL) {
> + src = dst + strlen(*n2r);
> + len = strlen(src) + 1;
> + if ((char *)kctl->id.name != dst && *(dst - 1) == ' ')
> + --dst;
> + memmove(dst, src, len);
> + }
> + }
> + if (kctl->id.name[0] == '\0')
> + strscpy(kctl->id.name, "Headset", SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
> +}
> +
> static const struct usb_feature_control_info *get_feature_control_info(int control)
> {
> int i;
> @@ -1780,6 +1807,9 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
> if (!mapped_name)
> check_no_speaker_on_headset(kctl, mixer->chip->card);
>
> + if (USB_ID_VENDOR(mixer->chip->usb_id) == 0x047f)
> + fix_plt_control_name(kctl);
> +
> /*
> * determine the stream direction:
> * if the connected output is USB stream, then it's likely a
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
2024-11-14 7:10 ` Takashi Iwai
@ 2024-11-14 18:44 ` Terry Junge
2024-11-15 8:19 ` Takashi Iwai
0 siblings, 1 reply; 6+ messages in thread
From: Terry Junge @ 2024-11-14 18:44 UTC (permalink / raw)
To: Takashi Iwai, Wade Wang
Cc: perex, tiwai, kl, wangdicheng, k.kosik, linux-sound, linux-kernel,
stable
Thanks Takashi,
On 11/13/24 11:10 PM, Takashi Iwai wrote:
> On Thu, 14 Nov 2024 07:15:53 +0100,
> Wade Wang wrote:
>>
>> Add a control name fixer for all headsets with VID 0x047F.
>>
>> Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com>
>> Signed-off-by: Wade Wang <wade.wang@hp.com>
>
> Thanks for the patch, but from the description, it's not clear what
> this patch actually does. What's the control name fixer and how it
> behaves?
It will be better described in the v2 patch.
It modifies names like
Headset Earphone Playback Volume
Headset Microphone Capture Switch
Receive Playback Volume
Transmit Capture Switch
to
Headset Playback Volume
Headset Capture Switch
so user space will bind to the headset's audio controls.
>
> Also, are you sure that this can be applied to all devices of
> Plantonics & co? Including the devices in future. I thought they had
> so many different models.
Yes, the quirk only modifies the control names that contain certain keywords.
Additional keywords may have to be added to the list in the future.
>
> Last but not least, __build_feature_ctl() is no right place to add the
> vendor-specific stuff. There is already a common place in
> mixer_quirks.c, e.g. snd_usb_mixer_fu_apply_quirk(). Please move the
> fix-up to the appropriate place.
I figured as much and I am currently testing with the function updated
and moved to mixer_quirks.c and will be triggered by snd_usb_mixer_fu_apply_quirk().
>
>
> thanks,
>
> Takashi
>
>> ---
>> sound/usb/mixer.c | 30 ++++++++++++++++++++++++++++++
>> 1 file changed, 30 insertions(+)
>>
>> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
>> index bd67027c7677..110d43ace4d8 100644
>> --- a/sound/usb/mixer.c
>> +++ b/sound/usb/mixer.c
>> @@ -1664,6 +1664,33 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl,
>> snd_ctl_rename(card, kctl, "Headphone");
>> }
>>
>> +static void fix_plt_control_name(struct snd_kcontrol *kctl)
>> +{
>> + static const char * const names_to_remove[] = {
>> + "Earphone",
>> + "Microphone",
>> + "Receive",
>> + "Transmit",
>> + NULL
>> + };
>> + const char * const *n2r;
>> + char *dst, *src;
>> + size_t len;
>> +
>> + for (n2r = names_to_remove; *n2r; ++n2r) {
>> + dst = strstr(kctl->id.name, *n2r);
>> + if (dst != NULL) {
>> + src = dst + strlen(*n2r);
>> + len = strlen(src) + 1;
>> + if ((char *)kctl->id.name != dst && *(dst - 1) == ' ')
>> + --dst;
>> + memmove(dst, src, len);
>> + }
>> + }
>> + if (kctl->id.name[0] == '\0')
>> + strscpy(kctl->id.name, "Headset", SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
>> +}
>> +
>> static const struct usb_feature_control_info *get_feature_control_info(int control)
>> {
>> int i;
>> @@ -1780,6 +1807,9 @@ static void __build_feature_ctl(struct usb_mixer_interface *mixer,
>> if (!mapped_name)
>> check_no_speaker_on_headset(kctl, mixer->chip->card);
>>
>> + if (USB_ID_VENDOR(mixer->chip->usb_id) == 0x047f)
>> + fix_plt_control_name(kctl);
>> +
>> /*
>> * determine the stream direction:
>> * if the connected output is USB stream, then it's likely a
>> --
>> 2.43.0
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
2024-11-14 18:44 ` Terry Junge
@ 2024-11-15 8:19 ` Takashi Iwai
2024-11-16 2:10 ` Terry Junge
0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2024-11-15 8:19 UTC (permalink / raw)
To: Terry Junge
Cc: Takashi Iwai, Wade Wang, perex, tiwai, kl, wangdicheng, k.kosik,
linux-sound, linux-kernel, stable
On Thu, 14 Nov 2024 19:44:52 +0100,
Terry Junge wrote:
>
> Thanks Takashi,
>
> On 11/13/24 11:10 PM, Takashi Iwai wrote:
> > On Thu, 14 Nov 2024 07:15:53 +0100,
> > Wade Wang wrote:
> >>
> >> Add a control name fixer for all headsets with VID 0x047F.
> >>
> >> Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com>
> >> Signed-off-by: Wade Wang <wade.wang@hp.com>
> >
> > Thanks for the patch, but from the description, it's not clear what
> > this patch actually does. What's the control name fixer and how it
> > behaves?
>
> It will be better described in the v2 patch.
>
> It modifies names like
>
> Headset Earphone Playback Volume
> Headset Microphone Capture Switch
> Receive Playback Volume
> Transmit Capture Switch
>
> to
>
> Headset Playback Volume
> Headset Capture Switch
>
> so user space will bind to the headset's audio controls.
OK, that makes sense. I suppose that both "Headset Earphone Playback
Volume" and "Receive Playback Volume" don't exist at the same time,
right?
Takashi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets
2024-11-15 8:19 ` Takashi Iwai
@ 2024-11-16 2:10 ` Terry Junge
0 siblings, 0 replies; 6+ messages in thread
From: Terry Junge @ 2024-11-16 2:10 UTC (permalink / raw)
To: Takashi Iwai, Terry Junge
Cc: Wade Wang, perex, tiwai, kl, wangdicheng, k.kosik, linux-sound,
linux-kernel, stable
On 11/15/24 12:19 AM, Takashi Iwai wrote:
> On Thu, 14 Nov 2024 19:44:52 +0100,
> Terry Junge wrote:
>>
>> Thanks Takashi,
>>
>> On 11/13/24 11:10 PM, Takashi Iwai wrote:
>>> On Thu, 14 Nov 2024 07:15:53 +0100,
>>> Wade Wang wrote:
>>>>
>>>> Add a control name fixer for all headsets with VID 0x047F.
>>>>
>>>> Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com>
>>>> Signed-off-by: Wade Wang <wade.wang@hp.com>
>>>
>>> Thanks for the patch, but from the description, it's not clear what
>>> this patch actually does. What's the control name fixer and how it
>>> behaves?
>>
>> It will be better described in the v2 patch.
>>
>> It modifies names like
>>
>> Headset Earphone Playback Volume
>> Headset Microphone Capture Switch
>> Receive Playback Volume
>> Transmit Capture Switch
>>
>> to
>>
>> Headset Playback Volume
>> Headset Capture Switch
>>
>> so user space will bind to the headset's audio controls.
>
> OK, that makes sense. I suppose that both "Headset Earphone Playback
> Volume" and "Receive Playback Volume" don't exist at the same time,
> right?
Yes, that is correct. No device will have both.
Terry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-16 2:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 6:15 [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets Wade Wang
2024-11-14 6:32 ` kernel test robot
2024-11-14 7:10 ` Takashi Iwai
2024-11-14 18:44 ` Terry Junge
2024-11-15 8:19 ` Takashi Iwai
2024-11-16 2:10 ` Terry Junge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox