From nobody Wed Apr 15 04:32:57 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48F2CC433EF for ; Tue, 26 Jul 2022 10:12:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238522AbiGZKM1 (ORCPT ); Tue, 26 Jul 2022 06:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbiGZKMX (ORCPT ); Tue, 26 Jul 2022 06:12:23 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B4B1AD9F for ; Tue, 26 Jul 2022 03:12:23 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q7EUxh002774; Tue, 26 Jul 2022 05:11:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=4GMh/xGa5TNYNqY554M0oZkoPr+GvTe1jc7k9ZTapsY=; b=UGLMfeTT8FEulZN6LnOr1/UDUVyP1E6xT3wqa5efOyUdmqGWFEgUoC8XifnFuM7VRU3K dP1ch53S+dxaV8Jx0747wHV1Viv7ZjGscM4d5qHQ0dj5+0kp7HBMQDPhQO3JoGer+H0h fs8SzYh5jkhjGi2PPllpOsdiUUAyyBqWpErMs0Du0/iRp4XaaZZ7CY6xBVo1xFaS60AK CDDQPJqY9XeTQ45VCnqojFXdFwK4azp2WkxBjacnVH8IeT8h5doLbF7okQhJ0/uuUvGH C0SaKM2VAMl2qA/K20RHbecYbeOybHQWl1r+Qrzi4UJmGbThblB+s+WQYHrJXkhEODw1 fg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3hged1ub6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 05:11:37 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Tue, 26 Jul 2022 05:11:35 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.9 via Frontend Transport; Tue, 26 Jul 2022 05:11:35 -0500 Received: from aryzen.ad.cirrus.com (unknown [198.61.65.94]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 7CF572D4; Tue, 26 Jul 2022 10:11:35 +0000 (UTC) From: Lucas Tanure To: Jaroslav Kysela , Takashi Iwai , Cameron Berkenpas CC: , , , Lucas Tanure Subject: [PATCH 1/2] ALSA: hda: cs35l41: Use the CS35L41 HDA internal define Date: Tue, 26 Jul 2022 11:11:30 +0100 Message-ID: <20220726101131.68058-2-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220726101131.68058-1-tanureal@opensource.cirrus.com> References: <20220726101131.68058-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: BEjZCeMFIzD0y-NIhfrXa8Yr4dFiKTo5 X-Proofpoint-ORIG-GUID: BEjZCeMFIzD0y-NIhfrXa8Yr4dFiKTo5 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Follow GPIO1 pattern, use cs35l41 HDA internal define for IRQ and then translate to ASoC cs35l41 define. Signed-off-by: Lucas Tanure --- sound/pci/hda/cs35l41_hda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 28798d5c1cf1..48d94c683b75 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1014,6 +1014,7 @@ static int cs35l41_hda_apply_properties(struct cs35l4= 1_hda *cs35l41) break; case CS35L41_INTERRUPT: using_irq =3D true; + hw_cfg->gpio2.func =3D CS35L41_GPIO2_INT_OPEN_DRAIN; break; default: dev_err(cs35l41->dev, "Invalid GPIO2 function %d\n", hw_cfg->gpio2.func= ); @@ -1273,7 +1274,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *= cs35l41, const char *hid, i cs35l41->reset_gpio =3D gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH); cs35l41->hw_cfg.bst_type =3D CS35L41_EXT_BOOST_NO_VSPK_SWITCH; cs35l41->speaker_id =3D cs35l41_get_speaker_id(physdev, 0, 0, 2); - hw_cfg->gpio2.func =3D CS35L41_GPIO2_INT_OPEN_DRAIN; + hw_cfg->gpio2.func =3D CS35L41_INTERRUPT; hw_cfg->gpio2.valid =3D true; cs35l41->hw_cfg.valid =3D true; put_device(physdev); --=20 2.37.1 From nobody Wed Apr 15 04:32:57 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 664A2C433EF for ; Tue, 26 Jul 2022 10:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238200AbiGZKMZ (ORCPT ); Tue, 26 Jul 2022 06:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232030AbiGZKMX (ORCPT ); Tue, 26 Jul 2022 06:12:23 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68FBD13F71 for ; Tue, 26 Jul 2022 03:12:22 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q7EUxi002774; Tue, 26 Jul 2022 05:11:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=J6a4T8pQxftHI75LH/Irjoxs38fV4yY7RSYMSSab9K4=; b=MmAJsIDayach9umbmhJxpygRVzvMiS9BP51/7B3oqLpASHXkV4Xu51AowBqnKQfccPuY PDt3NndaCfaqeDVQ8LiQXGB6yRzNurOH/l7SHp6gjfViUS/zcTiMkevRHHmeNfUCaIAq XlXiG1fgNF69cDQGZkvgfTyXxHgfXZD9W85yU1jrRZoJHOJkyTi8kEVEWWFEmYGD7ITB 1yyQ6M5p91h5mwEKOMky8eZ4YDKdhyFw9A5I/R0gD+hdg2VuMNU28p9HeZYO7HV3ioeS /YtrIPZiuiy8fBWK+eXRGCD5SZs5d0MmHbc03CJheox7QUbwjmapc/SfY/Rx3aCr68qs YA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3hged1ub6f-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 05:11:38 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Tue, 26 Jul 2022 05:11:35 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.9 via Frontend Transport; Tue, 26 Jul 2022 05:11:35 -0500 Received: from aryzen.ad.cirrus.com (unknown [198.61.65.94]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id BFD722C5; Tue, 26 Jul 2022 10:11:35 +0000 (UTC) From: Lucas Tanure To: Jaroslav Kysela , Takashi Iwai , Cameron Berkenpas CC: , , , Lucas Tanure Subject: [PATCH 2/2] ALSA: hda: cs35l41: Support CLSA0101 Date: Tue, 26 Jul 2022 11:11:31 +0100 Message-ID: <20220726101131.68058-3-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220726101131.68058-1-tanureal@opensource.cirrus.com> References: <20220726101131.68058-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: qMB8JG4mIG_t3gyNHuQ7TjYZvBgoSvf9 X-Proofpoint-ORIG-GUID: qMB8JG4mIG_t3gyNHuQ7TjYZvBgoSvf9 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for Intel version of Legion 7 laptop. Signed-off-by: Lucas Tanure --- sound/pci/hda/cs35l41_hda.c | 66 +++++++++++++++++++++-------------- sound/pci/hda/patch_realtek.c | 12 +++++++ 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 48d94c683b75..6edf95553745 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1133,6 +1133,45 @@ static int cs35l41_get_speaker_id(struct device *dev= , int amp_index, return speaker_id; } =20 +/* + * Device CLSA010(0/1) doesn't have _DSD so a gpiod_get by the label reset= won't work. + * And devices created by serial-multi-instantiate don't have their device= struct + * pointing to the correct fwnode, so acpi_dev must be used here. + * And devm functions expect that the device requesting the resource has t= he correct + * fwnode. + */ +static int cs35l41_no_acpi_dsd(struct cs35l41_hda *cs35l41, struct device = *physdev, int id, + const char *hid) +{ + struct cs35l41_hw_cfg *hw_cfg =3D &cs35l41->hw_cfg; + + /* check I2C address to assign the index */ + cs35l41->index =3D id =3D=3D 0x40 ? 0 : 1; + cs35l41->channel_index =3D 0; + cs35l41->reset_gpio =3D gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH); + cs35l41->speaker_id =3D cs35l41_get_speaker_id(physdev, 0, 0, 2); + hw_cfg->spk_pos =3D cs35l41->index; + hw_cfg->gpio2.func =3D CS35L41_INTERRUPT; + hw_cfg->gpio2.valid =3D true; + hw_cfg->valid =3D true; + put_device(physdev); + + if (strncmp(hid, "CLSA0100", 8) =3D=3D 0) { + hw_cfg->bst_type =3D CS35L41_EXT_BOOST_NO_VSPK_SWITCH; + } else if (strncmp(hid, "CLSA0101", 8) =3D=3D 0) { + hw_cfg->bst_type =3D CS35L41_EXT_BOOST; + hw_cfg->gpio1.func =3D CS35l41_VSPK_SWITCH; + hw_cfg->gpio1.valid =3D true; + } else { + hw_cfg->valid =3D false; + hw_cfg->gpio1.valid =3D false; + hw_cfg->gpio2.valid =3D false; + return -EINVAL; + } + + return 0; +} + static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *= hid, int id) { struct cs35l41_hw_cfg *hw_cfg =3D &cs35l41->hw_cfg; @@ -1161,7 +1200,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *= cs35l41, const char *hid, i property =3D "cirrus,dev-index"; ret =3D device_property_count_u32(physdev, property); if (ret <=3D 0) - goto no_acpi_dsd; + return cs35l41_no_acpi_dsd(cs35l41, physdev, id, hid); =20 if (ret > ARRAY_SIZE(values)) { ret =3D -EINVAL; @@ -1255,31 +1294,6 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda = *cs35l41, const char *hid, i dev_err(cs35l41->dev, "Failed property %s: %d\n", property, ret); =20 return ret; - -no_acpi_dsd: - /* - * Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset wo= n't work. - * And devices created by serial-multi-instantiate don't have their devic= e struct - * pointing to the correct fwnode, so acpi_dev must be used here. - * And devm functions expect that the device requesting the resource has = the correct - * fwnode. - */ - if (strncmp(hid, "CLSA0100", 8) !=3D 0) - return -EINVAL; - - /* check I2C address to assign the index */ - cs35l41->index =3D id =3D=3D 0x40 ? 0 : 1; - cs35l41->hw_cfg.spk_pos =3D cs35l41->index; - cs35l41->channel_index =3D 0; - cs35l41->reset_gpio =3D gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH); - cs35l41->hw_cfg.bst_type =3D CS35L41_EXT_BOOST_NO_VSPK_SWITCH; - cs35l41->speaker_id =3D cs35l41_get_speaker_id(physdev, 0, 0, 2); - hw_cfg->gpio2.func =3D CS35L41_INTERRUPT; - hw_cfg->gpio2.valid =3D true; - cs35l41->hw_cfg.valid =3D true; - put_device(physdev); - - return 0; } =20 int cs35l41_hda_probe(struct device *dev, const char *device_name, int id,= int irq, diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 0e340c0934db..65fd3e599a83 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6710,6 +6710,12 @@ static void alc287_fixup_legion_16achg6_speakers(str= uct hda_codec *cdc, const st cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0100", 2); } =20 +static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, co= nst struct hda_fixup *fix, + int action) +{ + cs35l41_generic_fixup(cdc, action, "i2c", "CLSA0101", 2); +} + /* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c" =20 @@ -7047,6 +7053,7 @@ enum { ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED, ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED, ALC295_FIXUP_FRAMEWORK_LAPTOP_MIC_NO_PRESENCE, + ALC287_FIXUP_LEGION_16ITHG6, }; =20 /* A special fixup for Lenovo C940 and Yoga Duet 7; @@ -8889,6 +8896,10 @@ static const struct hda_fixup alc269_fixups[] =3D { .chained =3D true, .chain_id =3D ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC }, + [ALC287_FIXUP_LEGION_16ITHG6] =3D { + .type =3D HDA_FIXUP_FUNC, + .v.func =3D alc287_fixup_legion_16ithg6_speakers, + }, }; =20 static const struct snd_pci_quirk alc269_fixup_tbl[] =3D { @@ -9353,6 +9364,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = =3D { SND_PCI_QUIRK(0x17aa, 0x384a, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_= 14ITL_SPEAKERS), SND_PCI_QUIRK(0x17aa, 0x3852, "Lenovo Yoga 7 14ITL5", ALC287_FIXUP_YOGA7_= 14ITL_SPEAKERS), SND_PCI_QUIRK(0x17aa, 0x3853, "Lenovo Yoga 7 15ITL5", ALC287_FIXUP_YOGA7_= 14ITL_SPEAKERS), + SND_PCI_QUIRK(0x17aa, 0x3855, "Legion 7 16ITHG6", ALC287_FIXUP_LEGION_16I= THG6), SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD= _ACPI), SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD= _ACPI), --=20 2.37.1