From patchwork Wed Oct 20 08:59:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Tanure X-Patchwork-Id: 12571849 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93BE3C433FE for ; Wed, 20 Oct 2021 09:01:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 701CA6137F for ; Wed, 20 Oct 2021 09:01:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 701CA6137F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 98B1E169F; Wed, 20 Oct 2021 11:00:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 98B1E169F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634720496; bh=fNH5Yw36OvImjVLK+BcTfgrB2xafjvJlk+JVWPYDy30=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=X36TQE7+qDN1Fehwmzk1o3H5JSeM45ScI7Igc4LYM+Qg+32IN7ADrWkaTRjAvrJbH ojjBLPbx3bWAazKjy/JY/kMAOsIp0kCdC2n7d59JzQ0u/Mf7RVzpD75LyBWG90CHRW yRmvORB7ohqOMPafXOTvF/1Ola6M3OXi/sr9xnwM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 66A37F80253; Wed, 20 Oct 2021 11:00:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28A4BF80229; Wed, 20 Oct 2021 11:00:01 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 01102F80082 for ; Wed, 20 Oct 2021 10:59:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 01102F80082 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="OzA7dOgF" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19K5H3Xv026523; Wed, 20 Oct 2021 03:59:49 -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=SayzzPMsAGjmsIpv5PlkVzoq+CA82VpCeYd/MpP513E=; b=OzA7dOgF+GQ2h7BGIlCl+trOXhLPQJ1qM99ztMa4atD5vBrtHc5m2iNN9Xu/6CtWaq27 4+Lkc/5l/3MUL2FtzisYBOSlFCnkozerZ5ogx9Y0cuyuCnplryzB/bPaI8boJkzFR8G8 yfkdOfd/1w8mYtAO5QL3TWCGjp9gdv/gGUBjyV94Y6mceRpqLYi96Mk5uBXI48hGxM7m poN1Vm6jIJYJUt/ALR6xDQruN2GHm7oTYycEsj89AmkssPMhtP2azki4CgKxfNPLnlOm T+vV65dcsKNvmZoQyoj6Wfc0yoTVCNe0IleFHpt+0gCUy42XYea3qZzTKdoiJeL+qM3M xw== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3bst7q1jty-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 20 Oct 2021 03:59:49 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 20 Oct 2021 09:59:46 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.7 via Frontend Transport; Wed, 20 Oct 2021 09:59:46 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.65.166]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 8EF8111DA; Wed, 20 Oct 2021 08:59:46 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Takashi Iwai , "Jaroslav Kysela" , Len Brown , David Rhodes , Liam Girdwood , "Rafael J . Wysocki" Subject: [RFC PATCH v2 1/3] sound: cs35l41: Allow HDA systems to use CS35l41 ASoC driver Date: Wed, 20 Oct 2021 09:59:42 +0100 Message-ID: <20211020085944.17577-2-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211020085944.17577-1-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dPSgHvP0MXPYjwT38S90ggCfo1io1Fz3 X-Proofpoint-GUID: dPSgHvP0MXPYjwT38S90ggCfo1io1Fz3 X-Proofpoint-Spam-Reason: safe Cc: linux-acpi@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lucas Tanure , patches@opensource.cirrus.com 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Re-use ASoC driver for supporting for Legion 7 16ACHg6 laptop. HDA machine driver will find the registered dais for the Amp and use snd_soc_dai_ops to configure it. Signed-off-by: Lucas Tanure --- include/sound/cs35l41.h | 1 + sound/soc/codecs/cs35l41.c | 139 ++++++++++++++++++++++++++++++++++--- sound/soc/codecs/cs35l41.h | 1 + 3 files changed, 133 insertions(+), 8 deletions(-) diff --git a/include/sound/cs35l41.h b/include/sound/cs35l41.h index 1f1e3c6c9be1..e250d31d4b04 100644 --- a/include/sound/cs35l41.h +++ b/include/sound/cs35l41.h @@ -23,6 +23,7 @@ struct cs35l41_irq_cfg { }; struct cs35l41_platform_data { + bool vspk_always_on; int bst_ind; int bst_ipk; int bst_cap; diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c index b16eb6610c0e..e6bb5c047d89 100644 --- a/sound/soc/codecs/cs35l41.c +++ b/sound/soc/codecs/cs35l41.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "cs35l41.h" @@ -1039,9 +1040,7 @@ static int cs35l41_set_pdata(struct cs35l41_private *cs35l41) { int ret; - /* Set Platform Data */ - /* Required */ - if (cs35l41->pdata.bst_ipk && + if (!cs35l41->pdata.vspk_always_on && cs35l41->pdata.bst_ipk && cs35l41->pdata.bst_ind && cs35l41->pdata.bst_cap) { ret = cs35l41_boost_config(cs35l41, cs35l41->pdata.bst_ind, cs35l41->pdata.bst_cap, @@ -1051,8 +1050,7 @@ static int cs35l41_set_pdata(struct cs35l41_private *cs35l41) return ret; } } else { - dev_err(cs35l41->dev, "Incomplete Boost component DT config\n"); - return -EINVAL; + dev_info(cs35l41->dev, "Boost disabled\n"); } /* Optional */ @@ -1098,12 +1096,92 @@ static int cs35l41_irq_gpio_config(struct cs35l41_private *cs35l41) return irq_pol; } +static const struct reg_sequence cs35l41_safe_to_global_enable[] = { + { 0x00000040, 0x00000055 }, + { 0x00000040, 0x000000AA }, + { 0x0000742C, 0x0000000F }, + { 0x0000742C, 0x00000079 }, + { 0x00007438, 0x00585941 }, + { CS35L41_PLL_CLK_CTRL, 0x00000420 }, //3200000Hz ,BCLK Input ,PLL_REFCLK_EN = 0 + { CS35L41_PLL_CLK_CTRL, 0x00000430 }, //3200000Hz ,BCLK Input ,PLL_REFCLK_EN = 1 + { CS35L41_GLOBAL_CLK_CTRL, 0x00000003 }, //GLOBAL_FS = 48 kHz + { CS35L41_SP_ENABLES, 0x00010000 }, //ASP_RX1_EN = 1 + { CS35L41_SP_RATE_CTRL, 0x00000021 }, //ASP_BCLK_FREQ = 3.072 MHz + { CS35L41_SP_FORMAT, 0x18180200 }, //ASP_RX_WIDTH = 24 bits, ASP_TX_WIDTH = 24 bits, ASP_FMT=I2S, BCLK Slave, FSYNC Slave + { CS35L41_DAC_PCM1_SRC, 0x00000008 }, //DACPCM1_SRC = ASPRX1 + { CS35L41_AMP_DIG_VOL_CTRL, 0x00000000 }, //AMP_VOL_PCM 0.0 dB + { CS35L41_AMP_GAIN_CTRL, 0x00000260 }, //AMP_GAIN_PCM 19.5 dB + { CS35L41_PWR_CTRL2, 0x00000001 }, //AMP_EN = 1 + { CS35L41_PWR_CTRL1, 0x00000001 }, //GLOBAL_EN = 1 + { 0x00000040, 0x000000CC }, + { 0x00000040, 0x00000033 }, +}; + +static const struct reg_sequence cs35l41_global_enable_to_active[] = { + { 0x00000040, 0x00000055 }, + { 0x00000040, 0x000000AA }, + { 0x0000742C, 0x000000F9 }, + { 0x00007438, 0x00580941 }, + { 0x00000040, 0x000000CC }, + { 0x00000040, 0x00000033 }, +}; + +static const struct reg_sequence cs35l41_active_to_safe_first[] = { + { 0x00000040, 0x00000055 }, + { 0x00000040, 0x000000AA }, + { 0x00007438, 0x00585941 }, + { CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, //AMP_VOL_PCM Mute + { CS35L41_PWR_CTRL2, 0x00000000 }, //AMP_EN = 0 + { CS35L41_PWR_CTRL1, 0x00000000 }, + { 0x0000742C, 0x00000009 }, + { 0x00000040, 0x000000CC }, + { 0x00000040, 0x00000033 }, +}; + +static const struct reg_sequence cs35l41_active_to_safe_second[] = { + { 0x00000040, 0x00000055 }, + { 0x00000040, 0x000000AA }, + { 0x00007438, 0x00580941 }, + { 0x00000040, 0x000000CC }, + { 0x00000040, 0x00000033 }, +}; + +static void cs35l41_dai_shutdown(struct snd_pcm_substream *sub, struct snd_soc_dai *dai) +{ + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); + + if (cs35l41->hda) { + regmap_multi_reg_write(cs35l41->regmap, cs35l41_active_to_safe_first, + ARRAY_SIZE(cs35l41_active_to_safe_first)); + usleep_range(1500, 2000); + regmap_multi_reg_write(cs35l41->regmap, cs35l41_active_to_safe_second, + ARRAY_SIZE(cs35l41_active_to_safe_second)); + } +} + +static int cs35l41_dai_prepare(struct snd_pcm_substream *sub, struct snd_soc_dai *dai) +{ + struct cs35l41_private *cs35l41 = snd_soc_component_get_drvdata(dai->component); + + if (cs35l41->hda) { + regmap_multi_reg_write(cs35l41->regmap, cs35l41_safe_to_global_enable, + ARRAY_SIZE(cs35l41_safe_to_global_enable)); + usleep_range(1500, 2000); + regmap_multi_reg_write(cs35l41->regmap, cs35l41_global_enable_to_active, + ARRAY_SIZE(cs35l41_global_enable_to_active)); + } + + return 0; +} + static const struct snd_soc_dai_ops cs35l41_ops = { .startup = cs35l41_pcm_startup, .set_fmt = cs35l41_set_dai_fmt, .hw_params = cs35l41_pcm_hw_params, .set_sysclk = cs35l41_dai_set_sysclk, .set_channel_map = cs35l41_set_channel_map, + .shutdown = cs35l41_dai_shutdown, + .prepare = cs35l41_dai_prepare, }; static struct snd_soc_dai_driver cs35l41_dai[] = { @@ -1126,6 +1204,7 @@ static struct snd_soc_dai_driver cs35l41_dai[] = { }, .ops = &cs35l41_ops, .symmetric_rate = 1, + .symmetric_sample_bits = 1, }, }; @@ -1148,9 +1227,31 @@ static int cs35l41_handle_pdata(struct device *dev, { struct cs35l41_irq_cfg *irq_gpio1_config = &pdata->irq_config1; struct cs35l41_irq_cfg *irq_gpio2_config = &pdata->irq_config2; + struct acpi_device *adev; + struct device *phys_dev; unsigned int val; int ret; + if (memcmp(dev_name(cs35l41->dev), "i2c-CLSA0100", 12) == 0) { + pdata->vspk_always_on = true; + cs35l41->hda = true; + adev = acpi_dev_get_first_match_dev("CLSA0100", "1", -1); + if (!adev) { + dev_err(dev, "Failed to find an ACPI device\n"); + return -ENODEV; + } + + phys_dev = get_device(acpi_get_first_physical_node(adev)); + acpi_dev_put(adev); + + if (!phys_dev) { + dev_err(dev, "Failed to find a physical device\n"); + return -ENODEV; + } + cs35l41->reset_gpio = gpiod_get_index(phys_dev, NULL, 0, GPIOD_ASIS); + return 0; + } + ret = device_property_read_u32(dev, "cirrus,boost-peak-milliamp", &val); if (ret >= 0) pdata->bst_ipk = val; @@ -1237,6 +1338,16 @@ static const struct reg_sequence cs35l41_revb2_errata_patch[] = { { 0x00000040, 0x00003333 }, }; +static const struct reg_sequence cs35l41_reset_to_enabled[] = { + { 0x00000040, 0x00000055 }, + { 0x00000040, 0x000000AA }, + { 0x00007438, 0x00585941 }, + { 0x00007414, 0x08C82222 }, + { 0x0000742C, 0x00000009 }, + { 0x00000040, 0x000000CC }, + { 0x00000040, 0x00000033 }, +}; + int cs35l41_probe(struct cs35l41_private *cs35l41, struct cs35l41_platform_data *pdata) { @@ -1269,8 +1380,8 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, } /* returning NULL can be an option if in stereo mode */ - cs35l41->reset_gpio = devm_gpiod_get_optional(cs35l41->dev, "reset", - GPIOD_OUT_LOW); + if (!cs35l41->reset_gpio) + cs35l41->reset_gpio = devm_gpiod_get_optional(cs35l41->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(cs35l41->reset_gpio)) { ret = PTR_ERR(cs35l41->reset_gpio); cs35l41->reset_gpio = NULL; @@ -1365,6 +1476,16 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, break; } + if (cs35l41->pdata.vspk_always_on) { + ret = regmap_multi_reg_write(cs35l41->regmap, cs35l41_reset_to_enabled, + ARRAY_SIZE(cs35l41_reset_to_enabled)); + if (ret < 0) { + dev_err(cs35l41->dev, "Failed to apply reset to enabled patch: %d\n", ret); + goto err; + } + dev_info(cs35l41->dev, "Safe mode enabled\n"); + } + irq_pol = cs35l41_irq_gpio_config(cs35l41); /* Set interrupt masks for critical errors */ @@ -1437,7 +1558,9 @@ int cs35l41_remove(struct cs35l41_private *cs35l41) { regmap_write(cs35l41->regmap, CS35L41_IRQ1_MASK1, 0xFFFFFFFF); regulator_bulk_disable(CS35L41_NUM_SUPPLIES, cs35l41->supplies); - gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); + + if (cs35l41->reset_gpio && !cs35l41->pdata.vspk_always_on) + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0); return 0; } diff --git a/sound/soc/codecs/cs35l41.h b/sound/soc/codecs/cs35l41.h index 0e2639d6ef19..bb1f08e36c04 100644 --- a/sound/soc/codecs/cs35l41.h +++ b/sound/soc/codecs/cs35l41.h @@ -762,6 +762,7 @@ struct cs35l41_private { struct regmap *regmap; struct regulator_bulk_data supplies[CS35L41_NUM_SUPPLIES]; int irq; + bool hda; /* GPIO for /RST */ struct gpio_desc *reset_gpio; void (*otp_setup)(struct cs35l41_private *cs35l41, bool is_pre_setup, From patchwork Wed Oct 20 08:59:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Tanure X-Patchwork-Id: 12571851 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D2F1C433EF for ; Wed, 20 Oct 2021 09:01:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 01EB561004 for ; Wed, 20 Oct 2021 09:01:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 01EB561004 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 0773E16AD; Wed, 20 Oct 2021 11:00:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0773E16AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634720505; bh=EAhhmcVnkW2X+YJBxLB/GJySTH1vUN6NqykRSe3qtSU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=USrwXwvIlHgg67SElzq+qlr+/IzOjGUv+9BzwQYM9uka+HkCeOPLZR394S+Mg8amn 6aufynPGbtVTY6IfYT75n2p935q85v1QZyN4FPeBiiKZslVU5xbPpHHjL9wFYNVkjI LbExuB9fIyrLyhnCEmnh5GXBV8KQxf3XuxjmcfVc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2FF73F804C3; Wed, 20 Oct 2021 11:00:12 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D80E9F804CA; Wed, 20 Oct 2021 11:00:10 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CF440F80300 for ; Wed, 20 Oct 2021 11:00:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CF440F80300 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="cQMveaC/" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19K5NeVX008304; Wed, 20 Oct 2021 04:00:02 -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=LvOjljNd4EoCQbyz8d+C/xA3gJjHOztj6tZLEGZnz+g=; b=cQMveaC/Eehrljas/h/CQrZydoJYunRY9/Bz883i/tqsITuqrHCmaa9jfnxt/Xt3K3W7 q442CXmj4ul6s8cjLFFeHrizE/ZmI6Sotuxr1u+y2ZQ5JMdb19aIRCwUn7sE4iifDBSG E58bC0Wno3cw75AjRkZw5U+dUSBdkJPi9GaJsycCA7GOe0NuPo/zN+cglwPaLY6QzrvI W0xXp5tBDn7V/1oB/v1S9owmEXwxlCQKXNuW/4GwWjaviwGDTpjR+C5sFB37LrQnFjfo /cIWUjW8sV5498NiDoTVcHRtNdkoKVVn+DBbJpyaH1ffJ2RvhxdwXm8P++9S82ra7TPs Tw== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3bt9k0gcqs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 20 Oct 2021 04:00:01 -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_128_GCM_SHA256) id 15.1.2375.7; Wed, 20 Oct 2021 09:59:47 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.7 via Frontend Transport; Wed, 20 Oct 2021 09:59:47 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.65.166]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id E309E11AF; Wed, 20 Oct 2021 08:59:46 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Takashi Iwai , "Jaroslav Kysela" , Len Brown , David Rhodes , Liam Girdwood , "Rafael J . Wysocki" Subject: [RFC PATCH v2 2/3] ALSA: hda/realtek: Add support for Legion 7 16ACHg6 laptop Speakers Date: Wed, 20 Oct 2021 09:59:43 +0100 Message-ID: <20211020085944.17577-3-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211020085944.17577-1-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: A9LQYSZE32GhD-lsnMc66up9xPYGMGr3 X-Proofpoint-ORIG-GUID: A9LQYSZE32GhD-lsnMc66up9xPYGMGr3 X-Proofpoint-Spam-Reason: safe Cc: linux-acpi@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lucas Tanure , patches@opensource.cirrus.com 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Find the associated Amps by dai name, and use dai ops to configure it. Disable support for Amps if ASoC not built. Signed-off-by: Lucas Tanure --- sound/pci/hda/patch_realtek.c | 109 +++++++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 4407f7da57c4..9a6fe6048b60 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "hda_local.h" #include "hda_auto_parser.h" #include "hda_jack.h" @@ -74,6 +75,11 @@ struct alc_coef_led { unsigned int off; }; +struct alc_soc_dai_node { + struct list_head node; + struct snd_soc_dai *dai; +}; + struct alc_spec { struct hda_gen_spec gen; /* must be at head */ @@ -126,6 +132,9 @@ struct alc_spec { unsigned int coef0; struct input_dev *kb_dev; u8 alc_mute_keycode_map[1]; + + /* ASoC DAIs used to init ASoC components in this sound card */ + struct list_head soc_dais; }; /* @@ -6443,6 +6452,96 @@ static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec, } } +static void alc_soc_dai_clear_list(struct alc_spec *spec) +{ + struct alc_soc_dai_node *n, *tmp; + + if (list_empty(&spec->soc_dais)) + return; + + list_for_each_entry_safe(n, tmp, &spec->soc_dais, node) { + list_del(&n->node); + kfree(n); + } +} + +static int alc_add_soc_dai_list(struct alc_spec *spec, const char *dai_name) +{ +#if IS_ENABLED(CONFIG_SND_SOC) + struct snd_soc_dai_link_component dlc; + struct alc_soc_dai_node *dai_node; + //struct snd_soc_component *comp; + struct snd_soc_dai *dai; + + dlc.dai_name = dai_name; + dlc.of_node = NULL; + dlc.name = NULL; + + dai = snd_soc_find_dai(&dlc); + if (!dai) + return -EPROBE_DEFER; + + dai_node = kmalloc(sizeof(*dai_node), GFP_KERNEL); + if (!dai_node) + return -ENOMEM; + dai_node->dai = dai; + + list_add(&dai_node->node, &spec->soc_dais); + + return 0; +#else + return -EPERM; +#endif +} + +void lenovo_y760_pcm_playback_hook(struct hda_pcm_stream *hinfo, struct hda_codec *cdc, + struct snd_pcm_substream *sub, int act) +{ + struct alc_spec *spec = cdc->spec; + struct alc_soc_dai_node *dai_node; + struct snd_soc_dai *dai; + unsigned int rx_slots[2] = {1, 0}; + int i = 0; + + list_for_each_entry(dai_node, &spec->soc_dais, node) { + dai = dai_node->dai; + if (!dai->driver->ops) + continue; + switch (act) { + case HDA_GEN_PCM_ACT_PREPARE: + if (dai->driver->ops->set_channel_map) + dai->driver->ops->set_channel_map(dai, 0, NULL, 1, &rx_slots[i++]); + if (dai->driver->ops->prepare) + dai->driver->ops->prepare(sub, dai); + break; + case HDA_GEN_PCM_ACT_CLOSE: + if (dai->driver->ops->shutdown) + dai->driver->ops->shutdown(sub, dai); + break; + } + } + +} + +static void alc287_fixup_lenovo_y760(struct hda_codec *codec, const struct hda_fixup *fix, int act) +{ + struct alc_spec *spec = codec->spec; + int ret; + + INIT_LIST_HEAD(&spec->soc_dais); + + ret = alc_add_soc_dai_list(spec, "i2c-CLSA0100:00-cs35l41.0"); + if (ret) + return; + + ret = alc_add_soc_dai_list(spec, "i2c-CLSA0100:00-cs35l41.1"); + if (ret) { + alc_soc_dai_clear_list(spec); + return; + } + spec->gen.pcm_playback_hook = lenovo_y760_pcm_playback_hook; +} + /* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c" @@ -6663,7 +6762,8 @@ enum { ALC287_FIXUP_LEGION_15IMHG05_SPEAKERS, ALC287_FIXUP_LEGION_15IMHG05_AUTOMUTE, ALC287_FIXUP_YOGA7_14ITL_SPEAKERS, - ALC287_FIXUP_13S_GEN2_SPEAKERS + ALC287_FIXUP_13S_GEN2_SPEAKERS, + ALC287_FIXUP_LENOVO_Y760 }; static const struct hda_fixup alc269_fixups[] = { @@ -8361,6 +8461,10 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_HEADSET_MODE, }, + [ALC287_FIXUP_LENOVO_Y760] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc287_fixup_lenovo_y760, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = { @@ -8755,6 +8859,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), SND_PCI_QUIRK(0x17aa, 0x3843, "Yoga 9i", ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP), + SND_PCI_QUIRK(0x17aa, 0x3847, "Legion Y760", ALC287_FIXUP_LENOVO_Y760), SND_PCI_QUIRK(0x17aa, 0x3813, "Legion 7i 15IMHG05", ALC287_FIXUP_LEGION_15IMHG05_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), @@ -9499,6 +9604,8 @@ static int patch_alc269(struct hda_codec *codec) spec->shutup = alc_default_shutup; spec->init_hook = alc_default_init; + INIT_LIST_HEAD(&spec->soc_dais); + switch (codec->core.vendor_id) { case 0x10ec0269: spec->codec_variant = ALC269_TYPE_ALC269VA; From patchwork Wed Oct 20 08:59:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Tanure X-Patchwork-Id: 12571853 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5667CC433EF for ; Wed, 20 Oct 2021 09:02:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF42561004 for ; Wed, 20 Oct 2021 09:02:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CF42561004 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 3894416C1; Wed, 20 Oct 2021 11:01:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3894416C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634720530; bh=BoRayrrsaVGleg1HdSrMpI2Y+1wdA5vQKjwkJoKSaYY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SkhuceQ2oW3ac6LI5W4UZi4/IaLlkNn4QwJwdLirVP9MU68LL6lUvugCwduqKo3Hg DVpiJ35tGnMnFwDa8D5sp/DRhjAMmDCYjM6D5464NmzUTR9nARaUeLzaNLXXn7cVC+ JDckFH/QYoBwoISL/ax0MNDV+yyFsd9NwwFW9lIE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D2831F804B2; Wed, 20 Oct 2021 11:00:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B90CFF804E5; Wed, 20 Oct 2021 11:00:12 +0200 (CEST) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7C061F804B2 for ; Wed, 20 Oct 2021 11:00:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7C061F804B2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="DeTaS6OZ" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19K5NeVY008304; Wed, 20 Oct 2021 04:00:03 -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=BRB15INUzbwgExlLEwJMjzHHvgiQARdV2CIXbCq4f98=; b=DeTaS6OZqt5p4ZZuOYrge9xq2+RqPkcItJyQOtJy2K6RaDL3GiK8to09z7qgI/irwybS 6nokCwLDzkZH/lmMBWUVZVXDQr3NV0clsaFDcEsFHpAGySmJ6AdrufT2HSmCc15zpIqi N2IG8mJ7bgKhi9mmeYXyFfT+PB/wFp8RFpDbX6o2yvGrzcsP0R6zuY9Zq9X6g+G/Ya8P DoBgG8vs3pMZnPDqOduDOAAVBoQiinoJTJAS/95l8SaQGdtYrsu8DycSLCdBUb8zLmhB wiYmQqMzdiLMcNOxGAUdLvcm2YHt6l997689T+z1WZa0K43dQh/gJrohQHi4EyFXvODl Rg== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3bt9k0gcqs-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 20 Oct 2021 04:00:02 -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_128_GCM_SHA256) id 15.1.2375.7; Wed, 20 Oct 2021 09:59:47 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.7 via Frontend Transport; Wed, 20 Oct 2021 09:59:47 +0100 Received: from aryzen.ad.cirrus.com (unknown [198.61.65.166]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3F41411DA; Wed, 20 Oct 2021 08:59:47 +0000 (UTC) From: Lucas Tanure To: Mark Brown , Takashi Iwai , "Jaroslav Kysela" , Len Brown , David Rhodes , Liam Girdwood , "Rafael J . Wysocki" Subject: [RFC PATCH v2 3/3] ACPI / scan: Create platform device for INT3515 ACPI nodes Date: Wed, 20 Oct 2021 09:59:44 +0100 Message-ID: <20211020085944.17577-4-tanureal@opensource.cirrus.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211020085944.17577-1-tanureal@opensource.cirrus.com> References: <20211020085944.17577-1-tanureal@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: 5MX4qB7iondzzwsyrMViwtIQPcIq5Kpy X-Proofpoint-ORIG-GUID: 5MX4qB7iondzzwsyrMViwtIQPcIq5Kpy X-Proofpoint-Spam-Reason: safe Cc: linux-acpi@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lucas Tanure , patches@opensource.cirrus.com 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The ACPI device with CLSA0100 is a sound card with multiple instances of CS35L41. We add an ID to the I2C multi instantiate list to enumerate all I2C slaves correctly. Signed-off-by: Lucas Tanure --- drivers/acpi/scan.c | 1 + drivers/platform/x86/i2c-multi-instantiate.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5b54c80b9d32..c1c27a408420 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1703,6 +1703,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) {"BSG2150", }, {"INT33FE", }, {"INT3515", }, + {"CLSA0100", }, {} }; diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c index a50153ecd560..b61f7e30d42a 100644 --- a/drivers/platform/x86/i2c-multi-instantiate.c +++ b/drivers/platform/x86/i2c-multi-instantiate.c @@ -139,6 +139,12 @@ static const struct i2c_inst_data bsg2150_data[] = { {} }; +static const struct i2c_inst_data clsa0100_data[] = { + { "cs35l41", IRQ_RESOURCE_GPIO, 0 }, + { "cs35l41", IRQ_RESOURCE_GPIO, 0 }, + {} +}; + /* * Device with _HID INT3515 (TI PD controllers) has some unresolved interrupt * issues. The most common problem seen is interrupt flood. @@ -170,6 +176,7 @@ static const struct i2c_inst_data bsg2150_data[] = { static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = { { "BSG1160", (unsigned long)bsg1160_data }, { "BSG2150", (unsigned long)bsg2150_data }, + { "CLSA0100", (unsigned long)clsa0100_data }, { } }; MODULE_DEVICE_TABLE(acpi, i2c_multi_inst_acpi_ids);