From patchwork Tue Mar 5 14:09:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 10839509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0BE717E4 for ; Tue, 5 Mar 2019 14:10:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABA002C26E for ; Tue, 5 Mar 2019 14:10:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A01772C260; Tue, 5 Mar 2019 14:10:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79D692BD25 for ; Tue, 5 Mar 2019 14:10:32 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C8715850; Tue, 5 Mar 2019 15:09:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C8715850 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551795029; bh=1X63HwDfHRgpkJLHGYkc8Ku1lVnBoMNkLCbW3rslZ8I=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=qvlbwjlst6VKctyzW0r/BDBm9j+ZgGbUDNFMXusiyxJpFwhbJMVJcYvpkdzgkR1f5 R+ZzIK4Tnss1BP4AavFz+Cp7ECkMTZWMegYoxTst6uNvs0B9mr4736s9DBpbikY4iA kdT+ekRbK911wL8jp839vDokt1beF3glmcfnSYSQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2BBE4F896F0; Tue, 5 Mar 2019 15:09:39 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B804F896EB; Tue, 5 Mar 2019 15:09:36 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C2692F896EB for ; Tue, 5 Mar 2019 15:09:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C2692F896EB Received: from [123.112.101.77] (helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1h1Al9-0000zC-DR; Tue, 05 Mar 2019 14:09:32 +0000 From: Hui Wang To: alsa-devel@alsa-project.org, tiwai@suse.de Date: Tue, 5 Mar 2019 22:09:10 +0800 Message-Id: <20190305140910.25615-1-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 Cc: stable@vger.kernel.org Subject: [alsa-devel] [PATCH] ALSA: hda: set the 2nd headphone's name to be Headphone2 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Recently I saw two Headphones on some HP machines, the 1st Headphone comes from the Front Headphone Jack, the 2nd one comes from the Front Headset Jack, and the current HDA driver will set the same name to them and with different index, just like below: 'Headphone Playback Volume' 'Headphone Playback Switch' 'Headphone Playback Volume' index 1 'Headphone Playback Switch' index 1 'Front Headphone Jack' 'Front Headphone Jack' index 1 This can't be handled by pulseaudio, and pulseaduio already has a path analog-output-headphones-2.conf to handle the 2nd headphone, now we set the 2nd headphone's name to "Headphone2", leave the other headphones unchanged. The change of hda_auto_parser.c will change the name of Jack. The change of hda_generic.c will change the name of Volume and Switch. Cc: Signed-off-by: Hui Wang --- The alsa-info.txt before applying this patch: https://pastebin.ubuntu.com/p/CrPrHRykgT/ The alsa-info.txt after applying this patch: https://pastebin.ubuntu.com/p/9VbkyvMBkW/ sound/pci/hda/hda_auto_parser.c | 11 +++++++++-- sound/pci/hda/hda_generic.c | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c index df0d636145f8..748c62a9c5eb 100644 --- a/sound/pci/hda/hda_auto_parser.c +++ b/sound/pci/hda/hda_auto_parser.c @@ -714,6 +714,8 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid); const char *name = NULL; int i; + int ret; + int index; bool hdmi; if (indexp) @@ -729,8 +731,13 @@ int snd_hda_get_pin_label(struct hda_codec *codec, hda_nid_t nid, return fill_audio_out_name(codec, nid, cfg, "Speaker", label, maxlen, indexp); case AC_JACK_HP_OUT: - return fill_audio_out_name(codec, nid, cfg, "Headphone", - label, maxlen, indexp); + ret = fill_audio_out_name(codec, nid, cfg, "Headphone", + label, maxlen, &index); + if (index == 1) + snprintf(label, maxlen, "%s", "Headphone2"); + if (indexp) + *indexp = index; + return ret; case AC_JACK_SPDIF_OUT: case AC_JACK_DIG_OTHER_OUT: hdmi = is_hdmi_cfg(def_conf); diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 4095cd7c56c6..2a34e8a6e2e1 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -2175,6 +2175,8 @@ static int create_extra_outs(struct hda_codec *codec, int num_pins, if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) name = "Bass Speaker"; + else if (num_pins == 2 && i == 1 && !strcmp(pfx, "Headphone")) + name = "Headphone2"; else if (num_pins >= 3) { snprintf(tmp, sizeof(tmp), "%s %s", pfx, channel_name[i]);