On 1/3/25 7:51 AM, Takashi Iwai wrote:
> On Tue, 24 Dec 2024 07:56:36 +0100,
> Wade Wang wrote:
>>
>> From: Terry Junge <linuxhid@xxxxxxxxxxxxxxxxxxxxxx>
>>
>
> Thanks to your updated comments, it's a bit better understandable
> now. However, IMO, it's still too complex than needed.
>
> Basically what we want is to make those kctl names just like "Headset
> Playback Switch" from the original "Earphone Headset Playback Switch".
> If so, a simpler code would be something like:
>
> static void fix_plantronics_control_name(struct usb_mixer_interface *mixer,
> struct snd_kcontrol *kctl)
> {
> static const char * const prefix_to_match[] = {
> "Headset", "Earphone", "Microphone", "Receive", "Transmit"
> };
> static const char * const suffix[] = {
> "Playback Volume", "Playback Switch",
> "Capture Volume", "Capture Switch"
> };
> int i;
>
> for (i = 0; i < ARRAY_SIZE(prefix_to_match); i++) {
> if (strstr(kctl->id.name, prefix_to_match[i]))
> break;
> }
> if (i >= ARRAY_SIZE(prefix_to_match))
> return;
>
> for (i = 0; i < ARRAY_SIZE(suffix); i++) {
> if (strstr(kctl->id.name, suffix[i])) {
> usb_audio_dbg(mixer->chip, "fix kctl name %s\n",
> kctl->id.name);
> sprintf(kctl->id.name, "Headset %s", suffix[i]);
> return;
> }
> }
> }
>
>
> One may put a space around the word if we want to make sure that it's
> a separated word, but I hope you get the idea by the example above.
> This is no hot code path and it runs only once at probe, so the code
> readability and understandability are much more important than
> efficiency, after all.
>
No problem, I'll submit v3 with your suggestions.
Thanks,
Terry
>
> thanks,
>
> Takashi
[Index of Archives]
[Pulseaudio]
[Linux Audio Users]
[ALSA Devel]
[Fedora Desktop]
[Fedora SELinux]
[Big List of Linux Books]
[Yosemite News]
[KDE Users]