From patchwork Thu Nov 14 06:15:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wade Wang X-Patchwork-Id: 13874589 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 101FF1EF95B for ; Thu, 14 Nov 2024 06:30:08 +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=1731565812; cv=none; b=Pop06CcW0X4bJIrkgd4D8o22GHiQrvFxIEQ+tjT9xFjs33AK4V5WscqJFlS0bGp53ON32Nd9VzCZpnrIrgLB0pvqR728MLkjpe0orkB22xM97rbqwpPy4Zr3h0XGP424chEHV6kkHYeSPP1Ga5Hg2CiCa/xWu56WYWlhSR2Zqng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731565812; c=relaxed/simple; bh=CsRf5xskqnnwINpwcylW+VBcW/qhSStwtZpmpiu+k+c=; h=From:To:Subject:Date:Message-Id:MIME-Version:Content-Type; b=GhIFa/t/a/V95bjk17kLIVo2iarSfN4kK23N06mwUEnMGzw7bDWNB/VdYuB6Fvt7H2LFpjQRUCxfOrkHCMjbxMc5Um3W/FOn/iok3DBvsEiGrQLpinOy4IANiqInY1QcLNig1jjfmK4TaQWdDlUjUwtTM8lRY6A9s/2PDMlxOuU= 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-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: PZKyQDZee9--E5xgYOr1rESld5fa-gVckDUK1c53nEg_1731565804 X-Mimecast-Originator: hp.com 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_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