From nobody Sat Nov 23 04:53:25 2024 Received: from us-smtp-delivery-162.mimecast.com (us-smtp-delivery-162.mimecast.com [170.10.129.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB52416FF44 for ; Thu, 14 Nov 2024 06:30:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.162 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731565814; cv=none; b=iosiQ9N+p1KHxITTO9OX1Ey3vsLbKzNpGfsTx6hFgbg3qrudriE/jBETMbfl0iq9u9MTnWzqq8Ih/Dsj/0OS8D4ns5hrd8Bqbt87SFX2NEDnHlVgX3tzX3zeE4xQM9/REwPpy9wATYywYqeOA0VArw6CEU4tShUF11AuXKzqHLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731565814; c=relaxed/simple; bh=CsRf5xskqnnwINpwcylW+VBcW/qhSStwtZpmpiu+k+c=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=Et93CdvF/5TJT5LorDTWZytVy89VOk21CS8vszZ3mNiXe2rB9rbLq655ZNLadcFqxB8yylEFNenNiuBPVYIqezp/QY9rwjAJofZgEKW0r0eRfmv6GOdnFKsSRs7r0DAse62GPEjlZeXr9VtoED7GKBnsPcu0SuTN9vSEgx9eHQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hp.com; spf=pass smtp.mailfrom=hp.com; dkim=pass (1024-bit key) header.d=hp.com header.i=@hp.com header.b=Lf9RBAaB; arc=none smtp.client-ip=170.10.129.162 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hp.com header.i=@hp.com header.b="Lf9RBAaB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hp.com; s=mimecast20180716; t=1731565808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CsRf5xskqnnwINpwcylW+VBcW/qhSStwtZpmpiu+k+c=; b=Lf9RBAaBjFnfNc9GlNQ20/QjNb1la/0rRQhsa+DOcIYeOZIu1q5TGI0UNVAgOZdDP+1W5G Gm8esNsxVgVkNrzaAPmJ1Ddw+NEEl+SwcAXZhqosZW13QoF3bZAftTM3mc+Z8okzbGKfzo bErh8LKNpjQ3rSc4OFF4DzlPgYa+qwg= Received: from g8t13016g.inc.hp.com (hpifallback.mail.core.hp.com [15.72.64.134]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-6rns3xBqMvuRn99G25z-8A-1; Thu, 14 Nov 2024 01:30:05 -0500 X-MC-Unique: 6rns3xBqMvuRn99G25z-8A-1 X-Mimecast-MFC-AGG-ID: 6rns3xBqMvuRn99G25z-8A Received: from g8t13021g.inc.hpicorp.net (g8t13021g.inc.hpicorp.net [15.60.27.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by g8t13016g.inc.hp.com (Postfix) with ESMTPS id 905DC6000FD4; Thu, 14 Nov 2024 06:30:02 +0000 (UTC) Received: from mail.hp.com (unknown [15.32.134.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by g8t13021g.inc.hpicorp.net (Postfix) with ESMTPS id 334F5600075A; Thu, 14 Nov 2024 06:26:14 +0000 (UTC) Received: from cdc-linux-buildsrv17.. (localhost [127.0.0.1]) by mail.hp.com (Postfix) with ESMTP id 6FE7CA4159F; Thu, 14 Nov 2024 14:15:59 +0800 (CST) From: Wade Wang To: perex@perex.cz, tiwai@suse.com, kl@kl.wtf, linuxhid@cosmicgizmosystems.com, wangdicheng@kylinos.cn, k.kosik@outlook.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, wade.wang@hp.com Subject: [PATCH] ALSA: usb-audio: Fix control names for Plantronics/Poly Headsets Date: Thu, 14 Nov 2024 14:15:53 +0800 Message-Id: <20241114061553.1699264-1-wade.wang@hp.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nPxVys-caMKKgX8Z2ndaQOa3P3wLVO9aoQLaxsR9GC4_1731565804 X-Mimecast-Originator: hp.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Add a control name fixer for all headsets with VID 0x047F. Signed-off-by: Terry Junge Signed-off-by: Wade Wang --- 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_k= control *kctl, snd_ctl_rename(card, kctl, "Headphone"); } =20 +static void fix_plt_control_name(struct snd_kcontrol *kctl) +{ + static const char * const names_to_remove[] =3D { + "Earphone", + "Microphone", + "Receive", + "Transmit", + NULL + }; + const char * const *n2r; + char *dst, *src; + size_t len; + + for (n2r =3D names_to_remove; *n2r; ++n2r) { + dst =3D strstr(kctl->id.name, *n2r); + if (dst !=3D NULL) { + src =3D dst + strlen(*n2r); + len =3D strlen(src) + 1; + if ((char *)kctl->id.name !=3D dst && *(dst - 1) =3D=3D ' ') + --dst; + memmove(dst, src, len); + } + } + if (kctl->id.name[0] =3D=3D '\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_inte= rface *mixer, if (!mapped_name) check_no_speaker_on_headset(kctl, mixer->chip->card); =20 + if (USB_ID_VENDOR(mixer->chip->usb_id) =3D=3D 0x047f) + fix_plt_control_name(kctl); + /* * determine the stream direction: * if the connected output is USB stream, then it's likely a --=20 2.43.0