Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4584467pxj; Wed, 12 May 2021 08:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYJYWP5C6dlO6//kdSFG8oi61boyTCD2CCuDpBVju6BFa4DHoLnSRH7LWkfOIbqShTTerr X-Received: by 2002:a9d:d0e:: with SMTP id 14mr31890092oti.12.1620834088051; Wed, 12 May 2021 08:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834088; cv=none; d=google.com; s=arc-20160816; b=jAwBN5lVpmmxEI2s6mQI0dBR7CW52iYgWfPhQ/ejm7ZbTwlsu24u4KjR2di8ortHJg pXCa1kTDGGVLm25LliRmQolMwlrQjz4nvUpAcgv6kI5EFGm/gFnk0jnX6L5tf9R9vk9s jo6bIEW53FArTKck1PhYaK/CfDQdbgLNfIQdYBXJ/UTb0UEhG9W4bncyBRnALoLeGFtr 9U2Wt9T/iQMrdDBNk1T5pJVpFuCp3ZFp6kmIojqGVkpADfUzDb2lDdX179CqaXhn2oo3 aLoDYArhJOJsRa4pKwMa/DkA/WPltWHsL1jYzfCYRpMrvJQzfZEUFxZab2gk9R+IKVxV NM5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aUnWIxbFyNeoStN+FkuLxFhfyXPJ+PYN41NX++ecMBE=; b=Lwo+lCdybygvj8DdDGhnRNnehkXmOVAo52HrqJBmoQ062EwB7Y94j21HO7Z01U8zw+ YutlSxYAgkPHTffSzh5EgfJx3yoseRBvXHhSZhsIcDZzZTgkQwJHbbjEfeVwpoP8pRg5 15OYpKZR6rI9pcUr25UNqA0YC/vUxLEiO4ht6wyCxlC7XC5sSWEmENbVvTdJheyElRvO Lum5a3PE9n277vHYm6zJThLi17UhIHs/poLZRaXSXTqEQMZAkJHUxCCgjJ8Hrs2zas1q lCqIpS3D9Sohx+qn2L/2fnebgeFOh3Jc1HHPJUU/QOesuzSh/mVxoTXX19qwkijtfNsT TnNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yGvYd2Es; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u80si317260oia.265.2021.05.12.08.41.14; Wed, 12 May 2021 08:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yGvYd2Es; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235893AbhELPgH (ORCPT + 99 others); Wed, 12 May 2021 11:36:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:46998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234249AbhELPQS (ORCPT ); Wed, 12 May 2021 11:16:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 469EA61971; Wed, 12 May 2021 15:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831954; bh=Nr3bsYbK1iTpA2f80c0E2GF84LXeMnRzNTqh14JG+ZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yGvYd2Es2AjieXW8YAVa7eRMnTDYDHVXejtLHIMb/fPxGi6YgKnRO95uyNLADew19 TqLPCVTY0NAvrEKzbhbOO24DRPXO1VdRSRdRXs++t3lONV6vAbHPxD7OMekBeyG0M5 xVWZEX8+ZpC+k/+KtW9agkwljpYB58XfueAUVMT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 5.10 083/530] ALSA: hda/realtek: Fix speaker amp on HP Envy AiO 32 Date: Wed, 12 May 2021 16:43:13 +0200 Message-Id: <20210512144822.506109366@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit 622464c893142f7beac89f5ba8c9773bca5e5004 upstream. HP Envy AiO 32-a12xxx has an external amp that is controlled via GPIO bit 0x04. However, unlike other devices, this amp seems to shut down itself after the certain period, hence the OS needs to up/down the bit dynamically only during the actual playback. This patch adds the control of the GPIO bit via the existing pcm_hook mechanism. Ideally it should be triggered at the actual stream start, but we have only the state change at prepare/cleanup, so use those for switching the GPIO bit on/off. This should be good enough for the purpose, and was actually confirmed to work fine. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212873 Cc: Link: https://lore.kernel.org/r/20210504091802.13200-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/patch_realtek.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4331,6 +4331,35 @@ static void alc245_fixup_hp_x360_amp(str } } +/* toggle GPIO2 at each time stream is started; we use PREPARE state instead */ +static void alc274_hp_envy_pcm_hook(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream, + int action) +{ + switch (action) { + case HDA_GEN_PCM_ACT_PREPARE: + alc_update_gpio_data(codec, 0x04, true); + break; + case HDA_GEN_PCM_ACT_CLEANUP: + alc_update_gpio_data(codec, 0x04, false); + break; + } +} + +static void alc274_fixup_hp_envy_gpio(struct hda_codec *codec, + const struct hda_fixup *fix, + int action) +{ + struct alc_spec *spec = codec->spec; + + if (action == HDA_FIXUP_ACT_PROBE) { + spec->gpio_mask |= 0x04; + spec->gpio_dir |= 0x04; + spec->gen.pcm_playback_hook = alc274_hp_envy_pcm_hook; + } +} + static void alc_update_coef_led(struct hda_codec *codec, struct alc_coef_led *led, bool polarity, bool on) @@ -6443,6 +6472,7 @@ enum { ALC255_FIXUP_XIAOMI_HEADSET_MIC, ALC274_FIXUP_HP_MIC, ALC274_FIXUP_HP_HEADSET_MIC, + ALC274_FIXUP_HP_ENVY_GPIO, ALC256_FIXUP_ASUS_HPE, ALC285_FIXUP_THINKPAD_NO_BASS_SPK_HEADSET_JACK, ALC287_FIXUP_HP_GPIO_LED, @@ -7882,6 +7912,10 @@ static const struct hda_fixup alc269_fix .chained = true, .chain_id = ALC274_FIXUP_HP_MIC }, + [ALC274_FIXUP_HP_ENVY_GPIO] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc274_fixup_hp_envy_gpio, + }, [ALC256_FIXUP_ASUS_HPE] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb[]) { @@ -8099,6 +8133,7 @@ static const struct snd_pci_quirk alc269 SND_PCI_QUIRK(0x103c, 0x8497, "HP Envy x360", ALC269_FIXUP_HP_MUTE_LED_MIC3), SND_PCI_QUIRK(0x103c, 0x84e7, "HP Pavilion 15", ALC269_FIXUP_HP_MUTE_LED_MIC3), SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED), + SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO), SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED), SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF),