From patchwork Fri Sep 15 12:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723171 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BDA6CEE645A for ; Fri, 15 Sep 2023 12:42:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E4F28820; Fri, 15 Sep 2023 14:41:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E4F28820 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781743; bh=UAXLDE6WMKwXnDGkOr95bOXY75KS5faYVhSOFTxfxzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MjXKmVwDQnQt+V1ZRdaaCDTslsOPsRZLJI/feAKg015Ygxbo3jMDZiXtI3oWtIF3b vW+2SnR86zHnt9CsBEd4LZg89mqqAt0WAbC3E1UzfjOPzTDNR59NjAmzbCX8Ml9PYr pgI+xvuau/R+7bbfLsNw0us4Rn6HWBYb3nYHCk3M= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0861DF80589; Fri, 15 Sep 2023 14:40:35 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 47A8BF80580; Fri, 15 Sep 2023 14:40:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F0F6F8056F; Fri, 15 Sep 2023 14:40:30 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 437DBF8007C for ; Fri, 15 Sep 2023 14:40:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 437DBF8007C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LKiX+k/r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781617; x=1726317617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UAXLDE6WMKwXnDGkOr95bOXY75KS5faYVhSOFTxfxzI=; b=LKiX+k/rK1UAcqZUVauYWkseimpEM3JftAE4VNq1mne2nJ/CDQ1mCg7S 7nL02BgEKRjckSCreqt4N9dUDFLHZ69KHVKxJcvRrjCh1PVDlvzjUyPi/ dWDPmZ2FxlYXAzwrgk8gO7gfyflBsTix6RrfQN6/Y1/0rJ/PPrBuzEuYa EYgBMF/lsQ95gm6y4lmZqcpbWsheZfK2/Tk+kiEuvIB8ckzUhP7zUBGUg fdAHIBRaOODrM3QxCFgOYawlExOwZKmVMKSTTx/Ly+j1jhMB0wTjNlr2n AzHXobVkHfUDN4npe/I7mBj5tZPH2har+wBKb8x0LaQ2Uq+K+sNE7Bo8v g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653104" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653104" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304520" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304520" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:07 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 01/19] ASoC: Intel: sof_rt5682: cleanup unnecessary quirk flag Date: Fri, 15 Sep 2023 20:48:34 +0800 Message-Id: <20230915124852.1696857-2-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: IAF4SE72XWHFS2HFW2KJH3C3JHA7P2MS X-Message-ID-Hash: IAF4SE72XWHFS2HFW2KJH3C3JHA7P2MS X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Remove SOF_RT5682_MCLK_24MHZ flag from JSL and CML/WHL board configs since the information could be retrieved from SOF API. The macro itself is removed as well. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_rt5682.c | 122 ++++++++++++++-------------- 1 file changed, 59 insertions(+), 63 deletions(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index fae091b9b55c..b3e90794f4e6 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -34,7 +34,6 @@ #define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define SOF_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) #define SOF_RT5682_MCLK_EN BIT(3) -#define SOF_RT5682_MCLK_24MHZ BIT(4) #define SOF_SPEAKER_AMP_PRESENT BIT(5) #define SOF_RT5682_SSP_AMP_SHIFT 6 #define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6)) @@ -119,7 +118,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"), }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(1)), }, { @@ -133,7 +131,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Dooly"), }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT1015_SPEAKER_AMP_PRESENT | @@ -145,7 +142,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"), }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), @@ -295,51 +291,60 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; struct snd_soc_jack *jack; int extra_jack_data; - int ret; + int ret, mclk_freq; - /* need to enable ASRC function for 24MHz mclk rate */ - if ((sof_rt5682_quirk & SOF_RT5682_MCLK_EN) && - (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ)) { - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) - rt5682s_sel_asrc_clk_src(component, - RT5682S_DA_STEREO1_FILTER | - RT5682S_AD_STEREO1_FILTER, - RT5682S_CLK_SEL_I2S1_ASRC); - else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { - rt5645_sel_asrc_clk_src(component, - RT5645_DA_STEREO_FILTER | - RT5645_AD_STEREO_FILTER, - RT5645_CLK_SEL_I2S1_ASRC); - rt5645_sel_asrc_clk_src(component, - RT5645_DA_MONO_L_FILTER | - RT5645_DA_MONO_R_FILTER, - RT5645_CLK_SEL_I2S2_ASRC); - } else - rt5682_sel_asrc_clk_src(component, - RT5682_DA_STEREO1_FILTER | - RT5682_AD_STEREO1_FILTER, - RT5682_CLK_SEL_I2S1_ASRC); - } + if (sof_rt5682_quirk & SOF_RT5682_MCLK_EN) { + mclk_freq = sof_dai_get_mclk(rtd); + if (mclk_freq <= 0) { + dev_err(rtd->dev, "invalid mclk freq %d\n", mclk_freq); + return -EINVAL; + } - if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { - /* - * The firmware might enable the clock at - * boot (this information may or may not - * be reflected in the enable clock register). - * To change the rate we must disable the clock - * first to cover these cases. Due to common - * clock framework restrictions that do not allow - * to disable a clock that has not been enabled, - * we need to enable the clock first. - */ - ret = clk_prepare_enable(ctx->mclk); - if (!ret) - clk_disable_unprepare(ctx->mclk); + /* need to enable ASRC function for 24MHz mclk rate */ + if (mclk_freq == 24000000) { + dev_info(rtd->dev, "enable ASRC\n"); - ret = clk_set_rate(ctx->mclk, 19200000); + if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) + rt5682s_sel_asrc_clk_src(component, + RT5682S_DA_STEREO1_FILTER | + RT5682S_AD_STEREO1_FILTER, + RT5682S_CLK_SEL_I2S1_ASRC); + else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + rt5645_sel_asrc_clk_src(component, + RT5645_DA_STEREO_FILTER | + RT5645_AD_STEREO_FILTER, + RT5645_CLK_SEL_I2S1_ASRC); + rt5645_sel_asrc_clk_src(component, + RT5645_DA_MONO_L_FILTER | + RT5645_DA_MONO_R_FILTER, + RT5645_CLK_SEL_I2S2_ASRC); + } else + rt5682_sel_asrc_clk_src(component, + RT5682_DA_STEREO1_FILTER | + RT5682_AD_STEREO1_FILTER, + RT5682_CLK_SEL_I2S1_ASRC); + } - if (ret) - dev_err(rtd->dev, "unable to set MCLK rate\n"); + if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { + /* + * The firmware might enable the clock at + * boot (this information may or may not + * be reflected in the enable clock register). + * To change the rate we must disable the clock + * first to cover these cases. Due to common + * clock framework restrictions that do not allow + * to disable a clock that has not been enabled, + * we need to enable the clock first. + */ + ret = clk_prepare_enable(ctx->mclk); + if (!ret) + clk_disable_unprepare(ctx->mclk); + + ret = clk_set_rate(ctx->mclk, 19200000); + + if (ret) + dev_err(rtd->dev, "unable to set MCLK rate\n"); + } } /* @@ -413,17 +418,9 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, /* get the tplg configured mclk. */ pll_in = sof_dai_get_mclk(rtd); - - /* mclk from the quirk is the first choice */ - if (sof_rt5682_quirk & SOF_RT5682_MCLK_24MHZ) { - if (pll_in != 24000000) - dev_warn(rtd->dev, "configure wrong mclk in tplg, please use 24MHz.\n"); - pll_in = 24000000; - } else if (pll_in == 0) { - /* use default mclk if not specified correct in topology */ - pll_in = 19200000; - } else if (pll_in < 0) { - return pll_in; + if (pll_in <= 0) { + dev_err(rtd->dev, "invalid mclk freq %d\n", pll_in); + return -EINVAL; } } else { if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) @@ -451,7 +448,12 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, /* when MCLK is 512FS, no need to set PLL configuration additionally. */ if (pll_in == pll_out) - clk_id = RT5682S_SCLK_S_MCLK; + if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) + clk_id = RT5682S_SCLK_S_MCLK; + else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) + clk_id = RT5645_SCLK_S_MCLK; + else + clk_id = RT5682_SCLK_S_MCLK; else { /* Configure pll for codec */ ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in, @@ -1071,7 +1073,6 @@ static const struct platform_device_id board_ids[] = { { .name = "cml_rt1015_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT1015_SPEAKER_AMP_PRESENT | @@ -1080,7 +1081,6 @@ static const struct platform_device_id board_ids[] = { { .name = "jsl_rt5682_rt1015", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT1015_SPEAKER_AMP_PRESENT | @@ -1089,7 +1089,6 @@ static const struct platform_device_id board_ids[] = { { .name = "jsl_rt5682_mx98360", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_MAX98360A_SPEAKER_AMP_PRESENT | @@ -1098,7 +1097,6 @@ static const struct platform_device_id board_ids[] = { { .name = "jsl_rt5682_rt1015p", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT1015P_SPEAKER_AMP_PRESENT | @@ -1107,7 +1105,6 @@ static const struct platform_device_id board_ids[] = { { .name = "jsl_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0)), }, { @@ -1271,7 +1268,6 @@ static const struct platform_device_id board_ids[] = { { .name = "jsl_rt5650", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_MCLK_24MHZ | SOF_RT5682_SSP_CODEC(0) | SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), From patchwork Fri Sep 15 12:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723968 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EF768EE6457 for ; Fri, 15 Sep 2023 12:42:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C093893A; Fri, 15 Sep 2023 14:41:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C093893A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781726; bh=9SpmP9nyA0bIyq9diuUGx7TkBuhSmaRmDr/P1UcmsIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pXzLRaQIzPV0xb1JddQ+GkstIQVQPSSMkgAWgqeEkdJ6bF8yhr/5VmGTeAl1WqGwM yLu9sRS3XmnlY3aDmiMA3lIyt6vENSabuua87qMMddW9enZ+pOoK/lCjP0cJIPyzSl aaU4eZyKwyaE2NS+uuikpXMqqcryzXU54IvbgMFY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35371F80431; Fri, 15 Sep 2023 14:40:31 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3E972F8057A; Fri, 15 Sep 2023 14:40:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 495AFF8056F; Fri, 15 Sep 2023 14:40:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 E19C9F80425 for ; Fri, 15 Sep 2023 14:40:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E19C9F80425 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UF53dgRq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781618; x=1726317618; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9SpmP9nyA0bIyq9diuUGx7TkBuhSmaRmDr/P1UcmsIQ=; b=UF53dgRqbuYeCULEneyI98nO5QtxbVyv+4oFjeLRJDl4PMOnNu4ZE9jz AiXMgqMwNB0cVwrwuCenZ2Am5nho5PRemfMoFv4b1CVyqZQDR3Bk9wpSU LoLDNr15eqGDi2mocMILQIPaRQasK6mBebXC9hjo3Re+knvp0PuNwMV4t jQSLCPksIEkjV94rWHuM6T6934kFk+rfg5aXBBkmAnY45AQfqWz/fQDEY yepRM+5edL2lDstAcy1R+NIr9jLznUdaAMMgmUGPdWVo+YP86ttsDBVaI vDv8A3Mj/mXpn+Ww0f5eOKbdlmbo/3NakTFhH6pijYrURleH/fW8r/AeJ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653113" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653113" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304534" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304534" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:10 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 02/19] ASoC: Intel: ssp-common: support codec detection Date: Fri, 15 Sep 2023 20:48:35 +0800 Message-Id: <20230915124852.1696857-3-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: TV6XQCXYRESF7M6LFGCCTLJPAQJ4HB4K X-Message-ID-Hash: TV6XQCXYRESF7M6LFGCCTLJPAQJ4HB4K X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Create a new common module to host functions which could be shared among SSP machine drivers. Add functions to detect headphone codec and speaker amplifier via ACPI system at runtime in order to remove codec type quirks in machine drivers. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 3 + sound/soc/intel/boards/Makefile | 3 + sound/soc/intel/boards/sof_ssp_common.c | 101 ++++++++++++++++++++++++ sound/soc/intel/boards/sof_ssp_common.h | 71 +++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 sound/soc/intel/boards/sof_ssp_common.c create mode 100644 sound/soc/intel/boards/sof_ssp_common.h diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index f5974619889f..2b735a1ac181 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -38,6 +38,9 @@ config SND_SOC_INTEL_SOF_REALTEK_COMMON config SND_SOC_INTEL_SOF_CIRRUS_COMMON tristate +config SND_SOC_INTEL_SOF_SSP_COMMON + tristate + if SND_SOC_INTEL_CATPT config SND_SOC_INTEL_HASWELL_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 936888112952..ce03a0be1a92 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -96,3 +96,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_REALTEK_COMMON) += snd-soc-intel-sof-realtek-comm snd-soc-intel-sof-cirrus-common-objs += sof_cirrus_common.o obj-$(CONFIG_SND_SOC_INTEL_SOF_CIRRUS_COMMON) += snd-soc-intel-sof-cirrus-common.o + +snd-soc-intel-sof-ssp-common-objs += sof_ssp_common.o +obj-$(CONFIG_SND_SOC_INTEL_SOF_SSP_COMMON) += snd-soc-intel-sof-ssp-common.o diff --git a/sound/soc/intel/boards/sof_ssp_common.c b/sound/soc/intel/boards/sof_ssp_common.c new file mode 100644 index 000000000000..41a258e45a61 --- /dev/null +++ b/sound/soc/intel/boards/sof_ssp_common.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright(c) 2023 Intel Corporation. All rights reserved. + +#include +#include +#include "sof_ssp_common.h" + +/* + * Codec probe function + */ +#define CODEC_MAP_ENTRY(n, h, t) \ + { \ + .name = n, \ + .acpi_hid = h, \ + .codec_type = t, \ + } + +struct codec_map { + const char *name; + const char *acpi_hid; + enum sof_ssp_codec codec_type; +}; + +static const struct codec_map codecs[] = { + /* Cirrus Logic */ + CODEC_MAP_ENTRY("CS42L42", CS42L42_ACPI_HID, CODEC_CS42L42), + + /* Dialog */ + CODEC_MAP_ENTRY("DA7219", DA7219_ACPI_HID, CODEC_DA7219), + + /* Everest */ + CODEC_MAP_ENTRY("ES8316", ES8316_ACPI_HID, CODEC_ES8316), + CODEC_MAP_ENTRY("ES8326", ES8326_ACPI_HID, CODEC_ES8326), + CODEC_MAP_ENTRY("ES8336", ES8336_ACPI_HID, CODEC_ES8336), + + /* Nuvoton */ + CODEC_MAP_ENTRY("NAU8825", NAU8825_ACPI_HID, CODEC_NAU8825), + + /* Realtek */ + CODEC_MAP_ENTRY("RT5650", RT5650_ACPI_HID, CODEC_RT5650), + CODEC_MAP_ENTRY("RT5682", RT5682_ACPI_HID, CODEC_RT5682), + CODEC_MAP_ENTRY("RT5682S", RT5682S_ACPI_HID, CODEC_RT5682S), +}; + +static const struct codec_map amps[] = { + /* Cirrus Logic */ + CODEC_MAP_ENTRY("CS35L41", CS35L41_ACPI_HID, CODEC_CS35L41), + + /* Maxim */ + CODEC_MAP_ENTRY("MAX98357A", MAX_98357A_ACPI_HID, CODEC_MAX98357A), + CODEC_MAP_ENTRY("MAX98360A", MAX_98360A_ACPI_HID, CODEC_MAX98360A), + CODEC_MAP_ENTRY("MAX98373", MAX_98373_ACPI_HID, CODEC_MAX98373), + CODEC_MAP_ENTRY("MAX98390", MAX_98390_ACPI_HID, CODEC_MAX98390), + + /* Nuvoton */ + CODEC_MAP_ENTRY("NAU8318", NAU8318_ACPI_HID, CODEC_NAU8318), + + /* Realtek */ + CODEC_MAP_ENTRY("RT1011", RT1011_ACPI_HID, CODEC_RT1011), + CODEC_MAP_ENTRY("RT1015", RT1015_ACPI_HID, CODEC_RT1015), + CODEC_MAP_ENTRY("RT1015P", RT1015P_ACPI_HID, CODEC_RT1015P), + CODEC_MAP_ENTRY("RT1019P", RT1019P_ACPI_HID, CODEC_RT1019P), + CODEC_MAP_ENTRY("RT1308", RT1308_ACPI_HID, CODEC_RT1308), +}; + +enum sof_ssp_codec sof_ssp_detect_codec_type(struct device *dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(codecs); i++) { + if (!acpi_dev_present(codecs[i].acpi_hid, NULL, -1)) + continue; + + dev_dbg(dev, "codec %s found\n", codecs[i].name); + return codecs[i].codec_type; + } + + return CODEC_NONE; +} +EXPORT_SYMBOL_NS(sof_ssp_detect_codec_type, SND_SOC_INTEL_SOF_SSP_COMMON); + +enum sof_ssp_codec sof_ssp_detect_amp_type(struct device *dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(amps); i++) { + if (!acpi_dev_present(amps[i].acpi_hid, NULL, -1)) + continue; + + dev_dbg(dev, "amp %s found\n", amps[i].name); + return amps[i].codec_type; + } + + return CODEC_NONE; +} +EXPORT_SYMBOL_NS(sof_ssp_detect_amp_type, SND_SOC_INTEL_SOF_SSP_COMMON); + +MODULE_DESCRIPTION("ASoC Intel SOF Common Machine Driver Helpers"); +MODULE_AUTHOR("Brent Lu "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/intel/boards/sof_ssp_common.h b/sound/soc/intel/boards/sof_ssp_common.h new file mode 100644 index 000000000000..e3fd6fb1db1c --- /dev/null +++ b/sound/soc/intel/boards/sof_ssp_common.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright(c) 2023 Intel Corporation. + */ + +#ifndef __SOF_SSP_COMMON_H +#define __SOF_SSP_COMMON_H + +/* Cirrus Logic */ +#define CS35L41_ACPI_HID "CSC3541" +#define CS42L42_ACPI_HID "10134242" + +/* Dialog */ +#define DA7219_ACPI_HID "DLGS7219" + +/* Everest */ +#define ES8316_ACPI_HID "ESSX8316" +#define ES8326_ACPI_HID "ESSX8326" +#define ES8336_ACPI_HID "ESSX8336" + +#define MAX_98357A_ACPI_HID "MX98357A" +#define MAX_98360A_ACPI_HID "MX98360A" +#define MAX_98373_ACPI_HID "MX98373" +#define MAX_98390_ACPI_HID "MX98390" + +/* Nuvoton */ +#define NAU8318_ACPI_HID "NVTN2012" +#define NAU8825_ACPI_HID "10508825" + +/* Realtek */ +#define RT1011_ACPI_HID "10EC1011" +#define RT1015_ACPI_HID "10EC1015" +#define RT1015P_ACPI_HID "RTL1015" +#define RT1019P_ACPI_HID "RTL1019" +#define RT1308_ACPI_HID "10EC1308" +#define RT5650_ACPI_HID "10EC5650" +#define RT5682_ACPI_HID "10EC5682" +#define RT5682S_ACPI_HID "RTL5682" + +enum sof_ssp_codec { + CODEC_NONE, + + /* headphone codec */ + CODEC_CS42L42, + CODEC_DA7219, + CODEC_ES8316, + CODEC_ES8326, + CODEC_ES8336, + CODEC_NAU8825, + CODEC_RT5650, + CODEC_RT5682, + CODEC_RT5682S, + + /* speaker amplifier */ + CODEC_CS35L41, + CODEC_MAX98357A, + CODEC_MAX98360A, + CODEC_MAX98373, + CODEC_MAX98390, + CODEC_NAU8318, + CODEC_RT1011, + CODEC_RT1015, + CODEC_RT1015P, + CODEC_RT1019P, + CODEC_RT1308, +}; + +enum sof_ssp_codec sof_ssp_detect_codec_type(struct device *dev); +enum sof_ssp_codec sof_ssp_detect_amp_type(struct device *dev); + +#endif /* __SOF_SSP_COMMON_H */ From patchwork Fri Sep 15 12:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723967 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 31C49EE6457 for ; Fri, 15 Sep 2023 12:42:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4769EDF0; Fri, 15 Sep 2023 14:41:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4769EDF0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781755; bh=2o8R/9dX2r/z+0qtyE/+W/qmG3tC2MPK2fZ2ZzYf59A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MLMbt6Zj94LOfmhS7LqTumFG+ytiYtyvF9BHAcWmEAPAc0SGs2TPxld7S+z5nyfSf 71Dl6gSbZkET3AEuoUXcc5pHY4P0vtbrNrYQZrZhn53NsW2VP0zzP1iQGwPTSdzfoN gyAyIa6tltFolH2BcjoN9kW1Xu/enjPXjR/6yYvw= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AABF8F805A8; Fri, 15 Sep 2023 14:40:38 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DE675F80579; Fri, 15 Sep 2023 14:40:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 10A6DF80431; Fri, 15 Sep 2023 14:40:31 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 185E3F8047D for ; Fri, 15 Sep 2023 14:40:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 185E3F8047D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KDMHZjQT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781619; x=1726317619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2o8R/9dX2r/z+0qtyE/+W/qmG3tC2MPK2fZ2ZzYf59A=; b=KDMHZjQTY5VA2Dnjnv2nwOZraSYjMRAFJjw333rwMZika8QRHRcXtfVk VdlRhwkK+OG10VHaGN6ujI5BB75REQbDClXNM5P1LtkAsARJjOgYjwxrS vg8T4OKUAnmL2S2qILwxrlISp2iNtlgjz5UuVvWrS3oMcmoSrBQCFVVKA DyU177nDhtKBN1T6hxL4IeIAUkV8kDHO6XQkw69ctH+4qBGj21/5CGCtn av40d6Q3KIPBf8alfibjsJidL7ip0KCBuAoxBUEpRw1p1SCiAXE/eq/Uz 5iIeKOPLIfAfAWWM6cHfH6yVMntQUFgmLqUg5iCLkkPlQa0toiYvi0pUI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653123" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653123" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304546" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304546" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:13 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 03/19] ASoC: Intel: use ACPI HID definition in ssp-common Date: Fri, 15 Sep 2023 20:48:36 +0800 Message-Id: <20230915124852.1696857-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: ETSKSOWE2SZJPN3P7U2V6WYJHJG5F6FL X-Message-ID-Hash: ETSKSOWE2SZJPN3P7U2V6WYJHJG5F6FL X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ACPI HID definition in ssp-common header for device name macros. No functional change here. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_cirrus_common.h | 9 ++--- sound/soc/intel/boards/sof_maxim_common.h | 13 +++++--- sound/soc/intel/boards/sof_realtek_common.h | 37 +++++++++++++++------ 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/sound/soc/intel/boards/sof_cirrus_common.h b/sound/soc/intel/boards/sof_cirrus_common.h index ca438c12c386..d4ecf8d023d1 100644 --- a/sound/soc/intel/boards/sof_cirrus_common.h +++ b/sound/soc/intel/boards/sof_cirrus_common.h @@ -9,15 +9,16 @@ #define __SOF_CIRRUS_COMMON_H #include +#include "sof_ssp_common.h" /* * Cirrus Logic CS35L41/CS35L53 */ #define CS35L41_CODEC_DAI "cs35l41-pcm" -#define CS35L41_DEV0_NAME "i2c-CSC3541:00" -#define CS35L41_DEV1_NAME "i2c-CSC3541:01" -#define CS35L41_DEV2_NAME "i2c-CSC3541:02" -#define CS35L41_DEV3_NAME "i2c-CSC3541:03" +#define CS35L41_DEV0_NAME "i2c-" CS35L41_ACPI_HID ":00" +#define CS35L41_DEV1_NAME "i2c-" CS35L41_ACPI_HID ":01" +#define CS35L41_DEV2_NAME "i2c-" CS35L41_ACPI_HID ":02" +#define CS35L41_DEV3_NAME "i2c-" CS35L41_ACPI_HID ":03" void cs35l41_set_dai_link(struct snd_soc_dai_link *link); void cs35l41_set_codec_conf(struct snd_soc_card *card); diff --git a/sound/soc/intel/boards/sof_maxim_common.h b/sound/soc/intel/boards/sof_maxim_common.h index a095b47b856b..fe0212fbad8e 100644 --- a/sound/soc/intel/boards/sof_maxim_common.h +++ b/sound/soc/intel/boards/sof_maxim_common.h @@ -11,10 +11,14 @@ #define __SOF_MAXIM_COMMON_H #include +#include "sof_ssp_common.h" +/* + * Maxim MAX98373 + */ #define MAX_98373_CODEC_DAI "max98373-aif1" -#define MAX_98373_DEV0_NAME "i2c-MX98373:00" -#define MAX_98373_DEV1_NAME "i2c-MX98373:01" +#define MAX_98373_DEV0_NAME "i2c-" MAX_98373_ACPI_HID ":00" +#define MAX_98373_DEV1_NAME "i2c-" MAX_98373_ACPI_HID ":01" extern struct snd_soc_dai_link_component max_98373_components[2]; extern struct snd_soc_ops max_98373_ops; @@ -27,7 +31,6 @@ int max_98373_trigger(struct snd_pcm_substream *substream, int cmd); /* * Maxim MAX98390 */ -#define MAX_98390_ACPI_HID "MX98390" #define MAX_98390_CODEC_DAI "max98390-aif1" #define MAX_98390_DEV0_NAME "i2c-" MAX_98390_ACPI_HID ":00" #define MAX_98390_DEV1_NAME "i2c-" MAX_98390_ACPI_HID ":01" @@ -41,8 +44,8 @@ void max_98390_set_codec_conf(struct device *dev, struct snd_soc_card *card); * Maxim MAX98357A/MAX98360A */ #define MAX_98357A_CODEC_DAI "HiFi" -#define MAX_98357A_DEV0_NAME "MX98357A:00" -#define MAX_98360A_DEV0_NAME "MX98360A:00" +#define MAX_98357A_DEV0_NAME MAX_98357A_ACPI_HID ":00" +#define MAX_98360A_DEV0_NAME MAX_98360A_ACPI_HID ":00" void max_98357a_dai_link(struct snd_soc_dai_link *link); void max_98360a_dai_link(struct snd_soc_dai_link *link); diff --git a/sound/soc/intel/boards/sof_realtek_common.h b/sound/soc/intel/boards/sof_realtek_common.h index 3ae99d8239e0..e3fa2924c1c1 100644 --- a/sound/soc/intel/boards/sof_realtek_common.h +++ b/sound/soc/intel/boards/sof_realtek_common.h @@ -11,36 +11,53 @@ #define __SOF_REALTEK_COMMON_H #include +#include "sof_ssp_common.h" + +/* + * Realtek ALC1011 + */ #define RT1011_CODEC_DAI "rt1011-aif" -#define RT1011_DEV0_NAME "i2c-10EC1011:00" -#define RT1011_DEV1_NAME "i2c-10EC1011:01" -#define RT1011_DEV2_NAME "i2c-10EC1011:02" -#define RT1011_DEV3_NAME "i2c-10EC1011:03" +#define RT1011_DEV0_NAME "i2c-" RT1011_ACPI_HID ":00" +#define RT1011_DEV1_NAME "i2c-" RT1011_ACPI_HID ":01" +#define RT1011_DEV2_NAME "i2c-" RT1011_ACPI_HID ":02" +#define RT1011_DEV3_NAME "i2c-" RT1011_ACPI_HID ":03" void sof_rt1011_dai_link(struct snd_soc_dai_link *link); void sof_rt1011_codec_conf(struct snd_soc_card *card); +/* + * Realtek ALC1015 (AUTO) + */ #define RT1015P_CODEC_DAI "HiFi" -#define RT1015P_DEV0_NAME "RTL1015:00" -#define RT1015P_DEV1_NAME "RTL1015:01" +#define RT1015P_DEV0_NAME RT1015P_ACPI_HID ":00" +#define RT1015P_DEV1_NAME RT1015P_ACPI_HID ":01" void sof_rt1015p_dai_link(struct snd_soc_dai_link *link); void sof_rt1015p_codec_conf(struct snd_soc_card *card); +/* + * Realtek ALC1015 (I2C) + */ #define RT1015_CODEC_DAI "rt1015-aif" -#define RT1015_DEV0_NAME "i2c-10EC1015:00" -#define RT1015_DEV1_NAME "i2c-10EC1015:01" +#define RT1015_DEV0_NAME "i2c-" RT1015_ACPI_HID ":00" +#define RT1015_DEV1_NAME "i2c-" RT1015_ACPI_HID ":01" void sof_rt1015_dai_link(struct snd_soc_dai_link *link); void sof_rt1015_codec_conf(struct snd_soc_card *card); +/* + * Realtek ALC1308 + */ #define RT1308_CODEC_DAI "rt1308-aif" -#define RT1308_DEV0_NAME "i2c-10EC1308:00" +#define RT1308_DEV0_NAME "i2c-" RT1308_ACPI_HID ":00" void sof_rt1308_dai_link(struct snd_soc_dai_link *link); +/* + * Realtek ALC1019 + */ #define RT1019P_CODEC_DAI "HiFi" -#define RT1019P_DEV0_NAME "RTL1019:00" +#define RT1019P_DEV0_NAME RT1019P_ACPI_HID ":00" void sof_rt1019p_dai_link(struct snd_soc_dai_link *link); From patchwork Fri Sep 15 12:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723966 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4700CEE645A for ; Fri, 15 Sep 2023 12:43:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 55ABEA4A; Fri, 15 Sep 2023 14:42:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55ABEA4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781792; bh=5PWUaIZum/XjgZdwhpth+TxhJ7Zt9lVhdLywvI0D+hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hrKYOZlHmhhwI8swXL59OHyN+LrWSvHYJhoVKDl4NyWYZRtFALBrKQywp+X1ijo5b Mh8Sh85GoILn9eV8C4g6FLLy1Yr/FxUj4QVlXzKb57X3VldqlxphreVEd3FY31/6y6 GyiMjsZJEVJMBjSmQeYS/afYq9DOJFoPehBbYAWc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3CAE9F805BD; Fri, 15 Sep 2023 14:40:43 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 14C3AF805B6; Fri, 15 Sep 2023 14:40:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 349B3F8057D; Fri, 15 Sep 2023 14:40:33 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 7E0D2F80246 for ; Fri, 15 Sep 2023 14:40:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7E0D2F80246 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BHcQLmOy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781621; x=1726317621; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5PWUaIZum/XjgZdwhpth+TxhJ7Zt9lVhdLywvI0D+hk=; b=BHcQLmOyIwOE7wyfZfveS/Vme/+n7uNV9FckFd6f9DlBg8PmvgqM/W7t z9psafsp2e7marGmc25FwW40BGhrqr5j7J6mCltX0Hwgf7FzmBsmvljIJ Bi8Q/FD7yjkVNF3bc0M8yBGA5lqDCC3l8wUc+MqALVR2d3neBnd/yYZA/ YBiCYQAstUvF7LTENl/xB9Z9EQBzbE8cw1MHDJiacz4WwYXEBk/6BbLpm /ZqA4RHDHeRhBgrQuI/FocEJavRNlQ2j7FqXxNtWD9RgGdkD+1k3hP4Ue NDOuHmuJqGKO/2s6i4/jp8S2Jom2zZgwarLMPeeSEZfMdGE1fWuU2vnHT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653138" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653138" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304552" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304552" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:15 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 04/19] ASoC: Intel: sof_rt5682: use ssp-common module to detect codec Date: Fri, 15 Sep 2023 20:48:37 +0800 Message-Id: <20230915124852.1696857-5-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 4OSIPXS3VCLVNYLSJRWAOQPOX62ZQUWK X-Message-ID-Hash: 4OSIPXS3VCLVNYLSJRWAOQPOX62ZQUWK X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ssp-common module to detect codec and amplifier type in driver probe function and remove all quirks about codec and amplifier type. Due to codec detection feature, we could remove HP Dooly's DMI quirk safely. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_rt5682.c | 322 ++++++++++++++-------------- 2 files changed, 166 insertions(+), 157 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 2b735a1ac181..f41343bb5c4f 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -496,6 +496,7 @@ config SND_SOC_INTEL_SOF_RT5682_MACH select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON select SND_SOC_INTEL_SOF_REALTEK_COMMON + select SND_SOC_INTEL_SOF_SSP_COMMON help This adds support for ASoC machine driver for SOF platforms with rt5650 or rt5682 codec. diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index b3e90794f4e6..e817be1edaba 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -28,13 +28,13 @@ #include "hda_dsp_common.h" #include "sof_maxim_common.h" #include "sof_realtek_common.h" +#include "sof_ssp_common.h" #define NAME_SIZE 32 #define SOF_RT5682_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define SOF_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) #define SOF_RT5682_MCLK_EN BIT(3) -#define SOF_SPEAKER_AMP_PRESENT BIT(5) #define SOF_RT5682_SSP_AMP_SHIFT 6 #define SOF_RT5682_SSP_AMP_MASK (GENMASK(8, 6)) #define SOF_RT5682_SSP_AMP(quirk) \ @@ -44,11 +44,6 @@ #define SOF_RT5682_NUM_HDMIDEV_MASK (GENMASK(12, 10)) #define SOF_RT5682_NUM_HDMIDEV(quirk) \ ((quirk << SOF_RT5682_NUM_HDMIDEV_SHIFT) & SOF_RT5682_NUM_HDMIDEV_MASK) -#define SOF_RT1011_SPEAKER_AMP_PRESENT BIT(13) -#define SOF_RT1015_SPEAKER_AMP_PRESENT BIT(14) -#define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(16) -#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(17) -#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(18) /* BT audio offload: reserve 3 bits for future */ #define SOF_BT_OFFLOAD_SSP_SHIFT 19 @@ -56,10 +51,6 @@ #define SOF_BT_OFFLOAD_SSP(quirk) \ (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(22) -#define SOF_RT5682S_HEADPHONE_CODEC_PRESENT BIT(23) -#define SOF_MAX98390_SPEAKER_AMP_PRESENT BIT(24) -#define SOF_RT1019_SPEAKER_AMP_PRESENT BIT(26) -#define SOF_RT5650_HEADPHONE_CODEC_PRESENT BIT(27) /* HDMI capture*/ #define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 27 @@ -86,6 +77,8 @@ struct sof_card_private { struct list_head hdmi_pcm_list; bool common_hdmi_codec_drv; bool idisp_codec; + enum sof_ssp_codec codec_type; + enum sof_ssp_codec amp_type; }; static int sof_rt5682_quirk_cb(const struct dmi_system_id *id) @@ -120,22 +113,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(1)), }, - { - /* - * Dooly is hatch family but using rt1015 amp so it - * requires a quirk before "Google_Hatch". - */ - .callback = sof_rt5682_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "HP"), - DMI_MATCH(DMI_PRODUCT_NAME, "Dooly"), - }, - .driver_data = (void *)(SOF_RT5682_MCLK_EN | - SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1015_SPEAKER_AMP_PRESENT | - SOF_RT5682_SSP_AMP(1)), - }, { .callback = sof_rt5682_quirk_cb, .matches = { @@ -143,7 +120,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { @@ -163,8 +139,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -177,8 +151,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -190,8 +162,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98390_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -203,8 +173,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -216,8 +184,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(0) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(1) | @@ -232,8 +198,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1019_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(0) | SOF_RT5682_NUM_HDMIDEV(3) ), @@ -245,7 +209,6 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { }, .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(0) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(1) | @@ -304,12 +267,8 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) if (mclk_freq == 24000000) { dev_info(rtd->dev, "enable ASRC\n"); - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) - rt5682s_sel_asrc_clk_src(component, - RT5682S_DA_STEREO1_FILTER | - RT5682S_AD_STEREO1_FILTER, - RT5682S_CLK_SEL_I2S1_ASRC); - else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + switch (ctx->codec_type) { + case CODEC_RT5650: rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_AD_STEREO_FILTER, @@ -318,11 +277,24 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) RT5645_DA_MONO_L_FILTER | RT5645_DA_MONO_R_FILTER, RT5645_CLK_SEL_I2S2_ASRC); - } else + break; + case CODEC_RT5682: rt5682_sel_asrc_clk_src(component, RT5682_DA_STEREO1_FILTER | RT5682_AD_STEREO1_FILTER, RT5682_CLK_SEL_I2S1_ASRC); + break; + case CODEC_RT5682S: + rt5682s_sel_asrc_clk_src(component, + RT5682S_DA_STEREO1_FILTER | + RT5682S_AD_STEREO1_FILTER, + RT5682S_CLK_SEL_I2S1_ASRC); + break; + default: + dev_err(rtd->dev, "invalid codec type %d\n", + ctx->codec_type); + return -EINVAL; + } } if (sof_rt5682_quirk & SOF_RT5682_MCLK_BYTCHT_EN) { @@ -370,7 +342,7 @@ static int sof_rt5682_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + if (ctx->codec_type == CODEC_RT5650) { extra_jack_data = SND_JACK_MICROPHONE | SND_JACK_BTN_0; ret = snd_soc_component_set_jack(component, jack, &extra_jack_data); } else @@ -409,12 +381,21 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, } } - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) - pll_source = RT5682S_PLL_S_MCLK; - else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) + switch (ctx->codec_type) { + case CODEC_RT5650: pll_source = RT5645_PLL1_S_MCLK; - else + break; + case CODEC_RT5682: pll_source = RT5682_PLL1_S_MCLK; + break; + case CODEC_RT5682S: + pll_source = RT5682S_PLL_S_MCLK; + break; + default: + dev_err(rtd->dev, "invalid codec type %d\n", + ctx->codec_type); + return -EINVAL; + } /* get the tplg configured mclk. */ pll_in = sof_dai_get_mclk(rtd); @@ -423,38 +404,63 @@ static int sof_rt5682_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } } else { - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) - pll_source = RT5682S_PLL_S_BCLK1; - else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) + switch (ctx->codec_type) { + case CODEC_RT5650: pll_source = RT5645_PLL1_S_BCLK1; - else + break; + case CODEC_RT5682: pll_source = RT5682_PLL1_S_BCLK1; + break; + case CODEC_RT5682S: + pll_source = RT5682S_PLL_S_BCLK1; + break; + default: + dev_err(rtd->dev, "invalid codec type %d\n", + ctx->codec_type); + return -EINVAL; + } pll_in = params_rate(params) * 50; } - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) { - pll_id = RT5682S_PLL2; - clk_id = RT5682S_SCLK_S_PLL2; - } else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + switch (ctx->codec_type) { + case CODEC_RT5650: pll_id = 0; /* not used in codec driver */ clk_id = RT5645_SCLK_S_PLL1; - } else { + break; + case CODEC_RT5682: pll_id = RT5682_PLL1; clk_id = RT5682_SCLK_S_PLL1; + break; + case CODEC_RT5682S: + pll_id = RT5682S_PLL2; + clk_id = RT5682S_SCLK_S_PLL2; + break; + default: + dev_err(rtd->dev, "invalid codec type %d\n", ctx->codec_type); + return -EINVAL; } pll_out = params_rate(params) * 512; /* when MCLK is 512FS, no need to set PLL configuration additionally. */ - if (pll_in == pll_out) - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) - clk_id = RT5682S_SCLK_S_MCLK; - else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) + if (pll_in == pll_out) { + switch (ctx->codec_type) { + case CODEC_RT5650: clk_id = RT5645_SCLK_S_MCLK; - else + break; + case CODEC_RT5682: clk_id = RT5682_SCLK_S_MCLK; - else { + break; + case CODEC_RT5682S: + clk_id = RT5682S_SCLK_S_MCLK; + break; + default: + dev_err(rtd->dev, "invalid codec type %d\n", + ctx->codec_type); + return -EINVAL; + } + } else { /* Configure pll for codec */ ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, pll_in, pll_out); @@ -502,7 +508,7 @@ static int sof_card_late_probe(struct snd_soc_card *card) struct sof_hdmi_pcm *pcm; int err; - if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { + if (ctx->amp_type == CODEC_MAX98373) { /* Disable Left and Right Spk pin after boot */ snd_soc_dapm_disable_pin(dapm, "Left Spk"); snd_soc_dapm_disable_pin(dapm, "Right Spk"); @@ -666,12 +672,11 @@ static struct snd_soc_dai_link_component dmic_component[] = { #define IDISP_CODEC_MASK 0x4 -static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, - int ssp_codec, - int ssp_amp, - int dmic_be_num, - int hdmi_num, - bool idisp_codec) +static struct snd_soc_dai_link * +sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec codec_type, + enum sof_ssp_codec amp_type, int ssp_codec, + int ssp_amp, int dmic_be_num, int hdmi_num, + bool idisp_codec) { struct snd_soc_dai_link_component *idisp_components; struct snd_soc_dai_link_component *cpus; @@ -693,16 +698,25 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, goto devm_err; links[id].id = id; - if (sof_rt5682_quirk & SOF_RT5682S_HEADPHONE_CODEC_PRESENT) { - links[id].codecs = rt5682s_component; - links[id].num_codecs = ARRAY_SIZE(rt5682s_component); - } else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + + switch (codec_type) { + case CODEC_RT5650: links[id].codecs = &rt5650_components[0]; links[id].num_codecs = 1; - } else { + break; + case CODEC_RT5682: links[id].codecs = rt5682_component; links[id].num_codecs = ARRAY_SIZE(rt5682_component); + break; + case CODEC_RT5682S: + links[id].codecs = rt5682s_component; + links[id].num_codecs = ARRAY_SIZE(rt5682s_component); + break; + default: + dev_err(dev, "invalid codec type %d\n", codec_type); + return NULL; } + links[id].platforms = platform_component; links[id].num_platforms = ARRAY_SIZE(platform_component); links[id].init = sof_rt5682_codec_init; @@ -813,42 +827,54 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, } /* speaker amp */ - if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) { + if (amp_type != CODEC_NONE) { links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_amp); if (!links[id].name) goto devm_err; links[id].id = id; - if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) { - sof_rt1015_dai_link(&links[id]); - } else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) { - sof_rt1015p_dai_link(&links[id]); - } else if (sof_rt5682_quirk & SOF_RT1019_SPEAKER_AMP_PRESENT) { - sof_rt1019p_dai_link(&links[id]); - } else if (sof_rt5682_quirk & - SOF_MAX98373_SPEAKER_AMP_PRESENT) { + + switch (amp_type) { + case CODEC_MAX98357A: + max_98357a_dai_link(&links[id]); + break; + case CODEC_MAX98360A: + max_98360a_dai_link(&links[id]); + break; + case CODEC_MAX98373: links[id].codecs = max_98373_components; links[id].num_codecs = ARRAY_SIZE(max_98373_components); links[id].init = max_98373_spk_codec_init; links[id].ops = &max_98373_ops; - } else if (sof_rt5682_quirk & - SOF_MAX98360A_SPEAKER_AMP_PRESENT) { - max_98360a_dai_link(&links[id]); - } else if (sof_rt5682_quirk & - SOF_RT1011_SPEAKER_AMP_PRESENT) { - sof_rt1011_dai_link(&links[id]); - } else if (sof_rt5682_quirk & - SOF_MAX98390_SPEAKER_AMP_PRESENT) { + break; + case CODEC_MAX98390: max_98390_dai_link(dev, &links[id]); - } else if (sof_rt5682_quirk & SOF_RT5650_HEADPHONE_CODEC_PRESENT) { + break; + case CODEC_RT1011: + sof_rt1011_dai_link(&links[id]); + break; + case CODEC_RT1015: + sof_rt1015_dai_link(&links[id]); + break; + case CODEC_RT1015P: + sof_rt1015p_dai_link(&links[id]); + break; + case CODEC_RT1019P: + sof_rt1019p_dai_link(&links[id]); + break; + case CODEC_RT5650: + /* use AIF2 to support speaker pipeline */ links[id].codecs = &rt5650_components[1]; links[id].num_codecs = 1; links[id].init = rt5650_spk_init; links[id].ops = &sof_rt5682_ops; - } else { - max_98357a_dai_link(&links[id]); + break; + default: + dev_err(dev, "invalid amp type %d\n", amp_type); + return NULL; } + links[id].platforms = platform_component; links[id].num_platforms = ARRAY_SIZE(platform_component); links[id].dpcm_playback = 1; @@ -951,20 +977,16 @@ static int sof_audio_probe(struct platform_device *pdev) mach = pdev->dev.platform_data; - /* A speaker amp might not be present when the quirk claims one is. - * Detect this via whether the machine driver match includes quirk_data. - */ - if ((sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) - sof_rt5682_quirk &= ~SOF_SPEAKER_AMP_PRESENT; - - /* Detect the headset codec variant */ - if (acpi_dev_present("RTL5682", NULL, -1)) - sof_rt5682_quirk |= SOF_RT5682S_HEADPHONE_CODEC_PRESENT; - else if (acpi_dev_present("10EC5650", NULL, -1)) { - sof_rt5682_quirk |= SOF_RT5650_HEADPHONE_CODEC_PRESENT; + ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); + ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); + if (ctx->codec_type == CODEC_RT5650) { sof_audio_card_rt5682.name = devm_kstrdup(&pdev->dev, "rt5650", GFP_KERNEL); + + /* create speaker dai link also */ + if (ctx->amp_type == CODEC_NONE) + ctx->amp_type = CODEC_RT5650; } if (soc_intel_is_byt() || soc_intel_is_cht()) { @@ -1017,19 +1039,9 @@ static int sof_audio_probe(struct platform_device *pdev) /* compute number of dai links */ sof_audio_card_rt5682.num_links = 1 + dmic_be_num + hdmi_num; - if (sof_rt5682_quirk & SOF_SPEAKER_AMP_PRESENT) + if (ctx->amp_type != CODEC_NONE) sof_audio_card_rt5682.num_links++; - if (sof_rt5682_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) - max_98373_set_codec_conf(&sof_audio_card_rt5682); - else if (sof_rt5682_quirk & SOF_RT1011_SPEAKER_AMP_PRESENT) - sof_rt1011_codec_conf(&sof_audio_card_rt5682); - else if (sof_rt5682_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) - sof_rt1015p_codec_conf(&sof_audio_card_rt5682); - else if (sof_rt5682_quirk & SOF_MAX98390_SPEAKER_AMP_PRESENT) { - max_98390_set_codec_conf(&pdev->dev, &sof_audio_card_rt5682); - } - if (sof_rt5682_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) sof_audio_card_rt5682.num_links++; @@ -1038,15 +1050,43 @@ static int sof_audio_probe(struct platform_device *pdev) hweight32((sof_rt5682_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT_MASK) >> SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT); - dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, - dmic_be_num, hdmi_num, ctx->idisp_codec); + dai_links = sof_card_dai_links_create(&pdev->dev, ctx->codec_type, + ctx->amp_type, ssp_codec, ssp_amp, + dmic_be_num, hdmi_num, + ctx->idisp_codec); if (!dai_links) return -ENOMEM; sof_audio_card_rt5682.dai_link = dai_links; - if (sof_rt5682_quirk & SOF_RT1015_SPEAKER_AMP_PRESENT) + /* update codec_conf */ + switch (ctx->amp_type) { + case CODEC_MAX98373: + max_98373_set_codec_conf(&sof_audio_card_rt5682); + break; + case CODEC_MAX98390: + max_98390_set_codec_conf(&pdev->dev, &sof_audio_card_rt5682); + break; + case CODEC_RT1011: + sof_rt1011_codec_conf(&sof_audio_card_rt5682); + break; + case CODEC_RT1015: sof_rt1015_codec_conf(&sof_audio_card_rt5682); + break; + case CODEC_RT1015P: + sof_rt1015p_codec_conf(&sof_audio_card_rt5682); + break; + case CODEC_NONE: + case CODEC_MAX98357A: + case CODEC_MAX98360A: + case CODEC_RT1019P: + case CODEC_RT5650: + /* no codec conf required */ + break; + default: + dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); + return -EINVAL; + } INIT_LIST_HEAD(&ctx->hdmi_pcm_list); @@ -1074,32 +1114,24 @@ static const struct platform_device_id board_ids[] = { .name = "cml_rt1015_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1015_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { .name = "jsl_rt5682_rt1015", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1015_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { .name = "jsl_rt5682_mx98360", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { .name = "jsl_rt5682_rt1015p", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1015P_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { @@ -1111,7 +1143,6 @@ static const struct platform_device_id board_ids[] = { .name = "tgl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1121,8 +1152,6 @@ static const struct platform_device_id board_ids[] = { .name = "tgl_rt1011_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1011_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1132,8 +1161,6 @@ static const struct platform_device_id board_ids[] = { .name = "tgl_mx98373_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1143,8 +1170,6 @@ static const struct platform_device_id board_ids[] = { .name = "adl_mx98373_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1154,7 +1179,6 @@ static const struct platform_device_id board_ids[] = { .name = "adl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -1162,8 +1186,6 @@ static const struct platform_device_id board_ids[] = { .name = "adl_max98390_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98390_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1173,8 +1195,6 @@ static const struct platform_device_id board_ids[] = { .name = "adl_mx98360_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1192,8 +1212,6 @@ static const struct platform_device_id board_ids[] = { .name = "adl_rt1019_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1019_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1211,7 +1229,6 @@ static const struct platform_device_id board_ids[] = { .name = "rpl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(2) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -1219,8 +1236,6 @@ static const struct platform_device_id board_ids[] = { .name = "rpl_mx98360_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1230,8 +1245,6 @@ static const struct platform_device_id board_ids[] = { .name = "rpl_rt1019_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1019_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1241,7 +1254,6 @@ static const struct platform_device_id board_ids[] = { .name = "mtl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -1251,8 +1263,6 @@ static const struct platform_device_id board_ids[] = { .name = "mtl_mx98360_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1) | SOF_RT5682_NUM_HDMIDEV(4)), }, @@ -1260,8 +1270,6 @@ static const struct platform_device_id board_ids[] = { .name = "mtl_rt1019_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1019_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(0) | SOF_RT5682_NUM_HDMIDEV(3)), }, @@ -1269,7 +1277,6 @@ static const struct platform_device_id board_ids[] = { .name = "jsl_rt5650", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | SOF_RT5682_SSP_AMP(1)), }, { } @@ -1296,3 +1303,4 @@ MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); From patchwork Fri Sep 15 12:48:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723168 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B26B4EE645A for ; Fri, 15 Sep 2023 12:44:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1BC89A4B; Fri, 15 Sep 2023 14:43:13 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1BC89A4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781843; bh=bVfCil5ufddbmfhQlDsTmctnStrzCN6TLD6moA5QBb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EgOkz2eCZ8HOTWMiRqEZdm07R5Noz1+XuQqi1/qSJo1l4nsDHEOrrEBPE4JWAtzWO CVnV4GgYPTckJOxTDVG0Q6DvvUGiJPjoynQZDzRgczT/QZQNOorsChjSHo66QAREoQ lERh2GnfL0okBDcMdprUTOjvHYE/jFBCOmE6L7No= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 55776F805ED; Fri, 15 Sep 2023 14:40:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 7F6BAF805B2; Fri, 15 Sep 2023 14:40:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 61F72F805AD; Fri, 15 Sep 2023 14:40:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 C61ECF80141 for ; Fri, 15 Sep 2023 14:40:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C61ECF80141 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CLbkp2h+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781623; x=1726317623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bVfCil5ufddbmfhQlDsTmctnStrzCN6TLD6moA5QBb8=; b=CLbkp2h+6FMdUm4JroV8yxzAR39jKNe4lbSiXxlLMIxgKfeb3i1Bz5pr mbYPPodraxT5llTZzuxhA2b/YSlDFddGi2YgGHgyxwOXNP9MIlcl6+xNM X6KYOUAWVzux/e8a43NzARe16ewP5fQjnpTYbhBzVPBQHOKYxLF6KPjML jNXLAKBisgEvEdDv6/XcJMTGRIPjPbmIL92l9RvDyamxGuJF5BB6UVqWy At6GR+CNMyBysj5wHVXfiiswHZdoNu1y2hFB4U384g6BEEGaesBeUSDgT QFZpjlNAq1yLLQXGrqTJ6vcJXczHRTk99BRvrKjFQNSUlBcdihANElEkp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653145" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653145" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304558" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304558" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:18 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 05/19] ASoC: Intel: sof_cs42l42: use ssp-common module to detect codec Date: Fri, 15 Sep 2023 20:48:38 +0800 Message-Id: <20230915124852.1696857-6-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: GBOHG5ZY4SIMNJKKK72OKVWR5VP57YK4 X-Message-ID-Hash: GBOHG5ZY4SIMNJKKK72OKVWR5VP57YK4 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ssp-common module to detect codec and amplifier type in driver probe function and remove all quirks about codec and amplifier type. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_cs42l42.c | 55 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index f41343bb5c4f..1bc47f7c502a 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -514,6 +514,7 @@ config SND_SOC_INTEL_SOF_CS42L42_MACH select SND_SOC_HDAC_HDMI select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON + select SND_SOC_INTEL_SOF_SSP_COMMON help This adds support for ASoC machine driver for SOF platforms with cs42l42 codec. diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c index e6695e77d594..70d3002afb52 100644 --- a/sound/soc/intel/boards/sof_cs42l42.c +++ b/sound/soc/intel/boards/sof_cs42l42.c @@ -23,12 +23,12 @@ #include "../common/soc-intel-quirks.h" #include "hda_dsp_common.h" #include "sof_maxim_common.h" +#include "sof_ssp_common.h" #define NAME_SIZE 32 #define SOF_CS42L42_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define SOF_CS42L42_SSP_CODEC_MASK (GENMASK(2, 0)) -#define SOF_SPEAKER_AMP_PRESENT BIT(3) #define SOF_CS42L42_SSP_AMP_SHIFT 4 #define SOF_CS42L42_SSP_AMP_MASK (GENMASK(6, 4)) #define SOF_CS42L42_SSP_AMP(quirk) \ @@ -46,8 +46,6 @@ #define SOF_CS42L42_SSP_BT_MASK (GENMASK(28, 26)) #define SOF_CS42L42_SSP_BT(quirk) \ (((quirk) << SOF_CS42L42_SSP_BT_SHIFT) & SOF_CS42L42_SSP_BT_MASK) -#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(29) -#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(30) enum { LINK_NONE = 0, @@ -83,6 +81,8 @@ struct sof_card_private { struct snd_soc_jack headset_jack; struct list_head hdmi_pcm_list; bool common_hdmi_codec_drv; + enum sof_ssp_codec codec_type; + enum sof_ssp_codec amp_type; }; static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) @@ -299,12 +299,13 @@ static struct snd_soc_dai_link_component dmic_component[] = { static int create_spk_amp_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus, - int *id, int ssp_amp) + int *id, enum sof_ssp_codec amp_type, + int ssp_amp) { int ret = 0; /* speaker amp */ - if (!(sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT)) + if (amp_type == CODEC_NONE) return 0; links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", @@ -316,14 +317,16 @@ static int create_spk_amp_dai_links(struct device *dev, links[*id].id = *id; - if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) { + switch (amp_type) { + case CODEC_MAX98357A: max_98357a_dai_link(&links[*id]); - } else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { + break; + case CODEC_MAX98360A: max_98360a_dai_link(&links[*id]); - } else { - dev_err(dev, "no amp defined\n"); - ret = -EINVAL; - goto devm_err; + break; + default: + dev_err(dev, "invalid amp type %d\n", amp_type); + return -EINVAL; } links[*id].platforms = platform_component; @@ -528,12 +531,10 @@ static int create_bt_offload_dai_links(struct device *dev, return -ENOMEM; } -static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, - int ssp_codec, - int ssp_amp, - int ssp_bt, - int dmic_be_num, - int hdmi_num) +static struct snd_soc_dai_link * +sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, + int ssp_codec, int ssp_amp, int ssp_bt, + int dmic_be_num, int hdmi_num) { struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link *links; @@ -561,7 +562,8 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, } break; case LINK_SPK: - ret = create_spk_amp_dai_links(dev, links, cpus, &id, ssp_amp); + ret = create_spk_amp_dai_links(dev, links, cpus, &id, + amp_type, ssp_amp); if (ret < 0) { dev_err(dev, "fail to create spk amp dai links, ret %d\n", ret); @@ -624,6 +626,9 @@ static int sof_audio_probe(struct platform_device *pdev) mach = pdev->dev.platform_data; + ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); + ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); + if (soc_intel_is_glk()) { dmic_be_num = 1; hdmi_num = 3; @@ -649,13 +654,14 @@ static int sof_audio_probe(struct platform_device *pdev) /* compute number of dai links */ sof_audio_card_cs42l42.num_links = 1 + dmic_be_num + hdmi_num; - if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT) + if (ctx->amp_type != CODEC_NONE) sof_audio_card_cs42l42.num_links++; if (sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT) sof_audio_card_cs42l42.num_links++; - dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, - ssp_bt, dmic_be_num, hdmi_num); + dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, + ssp_codec, ssp_amp, ssp_bt, + dmic_be_num, hdmi_num); if (!dai_links) return -ENOMEM; @@ -683,24 +689,18 @@ static const struct platform_device_id board_ids[] = { { .name = "glk_cs4242_mx98357a", .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(2) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98357A_SPEAKER_AMP_PRESENT | SOF_CS42L42_SSP_AMP(1)) | SOF_CS42L42_DAILINK(LINK_SPK, LINK_HP, LINK_DMIC, LINK_HDMI, LINK_NONE), }, { .name = "jsl_cs4242_mx98360a", .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_CS42L42_SSP_AMP(1)) | SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NONE), }, { .name = "adl_mx98360a_cs4242", .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_CS42L42_SSP_AMP(1) | SOF_CS42L42_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_PRESENT | @@ -727,3 +727,4 @@ MODULE_AUTHOR("Brent Lu "); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); From patchwork Fri Sep 15 12:48:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723169 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1684BEE6457 for ; Fri, 15 Sep 2023 12:43:29 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 36E81E0E; Fri, 15 Sep 2023 14:42:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 36E81E0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781807; bh=tbN/G1zhPkgIt9wSBrNHxQMPQ72c8sAZ06gLjRWnJiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NjI0zSK1dK4Yq/OvwAgxVQG97n4F1ZdpyMLkyGxItjcvRSDL6voe51Trtbzyn0GoI 5pKkfBzfx5TYIkdVmPn5pVPMMRI31KkRHi6zvtbslB4YyO7Qfz8kRExK4k/gP3UxgT buc+bO8cmymPsypQUW/LQXlfd5uNCuEVmIENIsEU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B922BF805D8; Fri, 15 Sep 2023 14:40:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D067DF805C9; Fri, 15 Sep 2023 14:40:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DCB58F80558; Fri, 15 Sep 2023 14:40:34 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 A4FB5F80558 for ; Fri, 15 Sep 2023 14:40:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A4FB5F80558 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=cFO7gGsc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781626; x=1726317626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tbN/G1zhPkgIt9wSBrNHxQMPQ72c8sAZ06gLjRWnJiA=; b=cFO7gGscw9ULf0mLvFNldXzcQ9PfyqzdoCUSt//FlNax0CyE3LG8Jwsp e93G/mADL75GWhNf80YhUO4MrDj164RFEocJf2BAYUIxAgBhBwJA7uPtE 2g8jgrksocOVPw0nfBfmIJxRrOQKkiMDnIeRffMLmxH6qJP1GmznlJqQu ovFcRd6VJJEAOz/w9ep+Nw+eLFf6yuV/vYaCVW/caGlMw+vg0oDOahz+Q u7dTCcsyIppOgBcYx94SXR4gr9v1nNAEWnt7BN51hZ2AnkOhdx1/hpaTP G77tKIpCod9Ltk2/NbLqj/qZtZ7nbgXb4z5vk5jYvIP6+F45Md7cvognX w==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653151" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653151" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304562" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304562" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:21 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 06/19] ASoC: Intel: sof_ssp_amp: use ssp-common module to detect codec Date: Fri, 15 Sep 2023 20:48:39 +0800 Message-Id: <20230915124852.1696857-7-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: SLXROAPW7ZYAMQ45C4ACHXFPOIFQJHEX X-Message-ID-Hash: SLXROAPW7ZYAMQ45C4ACHXFPOIFQJHEX X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ssp-common module to detect codec and amplifier type in driver probe function and remove all quirks about codec and amplifier type. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_ssp_amp.c | 53 ++++++++++++++++++---------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 1bc47f7c502a..857bb8628a4c 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -637,6 +637,7 @@ config SND_SOC_INTEL_SOF_SSP_AMP_MACH select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_SOF_REALTEK_COMMON select SND_SOC_INTEL_SOF_CIRRUS_COMMON + select SND_SOC_INTEL_SOF_SSP_COMMON help This adds support for ASoC machine driver for SOF platforms with RT1308/CS35L41 I2S audio codec. diff --git a/sound/soc/intel/boards/sof_ssp_amp.c b/sound/soc/intel/boards/sof_ssp_amp.c index 5aa16fd3939b..e2b3553dbc65 100644 --- a/sound/soc/intel/boards/sof_ssp_amp.c +++ b/sound/soc/intel/boards/sof_ssp_amp.c @@ -21,6 +21,7 @@ #include "hda_dsp_common.h" #include "sof_realtek_common.h" #include "sof_cirrus_common.h" +#include "sof_ssp_common.h" #define NAME_SIZE 32 @@ -59,10 +60,6 @@ #define SOF_BT_OFFLOAD_SSP(quirk) \ (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) -/* Speaker amplifiers */ -#define SOF_RT1308_SPEAKER_AMP_PRESENT BIT(21) -#define SOF_CS35L41_SPEAKER_AMP_PRESENT BIT(22) - /* Default: SSP2 */ static unsigned long sof_ssp_amp_quirk = SOF_AMPLIFIER_SSP(2); @@ -77,6 +74,7 @@ struct sof_card_private { struct list_head hdmi_pcm_list; bool common_hdmi_codec_drv; bool idisp_codec; + enum sof_ssp_codec amp_type; }; static const struct dmi_system_id chromebook_platforms[] = { @@ -188,11 +186,10 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) #define IDISP_CODEC_MASK 0x4 -static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, - int ssp_codec, - int dmic_be_num, - int hdmi_num, - bool idisp_codec) +static struct snd_soc_dai_link * +sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, + int ssp_codec, int dmic_be_num, int hdmi_num, + bool idisp_codec) { struct snd_soc_dai_link_component *idisp_components; struct snd_soc_dai_link_component *cpus; @@ -243,11 +240,19 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, return NULL; links[id].id = id; - if (sof_ssp_amp_quirk & SOF_RT1308_SPEAKER_AMP_PRESENT) { - sof_rt1308_dai_link(&links[id]); - } else if (sof_ssp_amp_quirk & SOF_CS35L41_SPEAKER_AMP_PRESENT) { + + switch (amp_type) { + case CODEC_CS35L41: cs35l41_set_dai_link(&links[id]); + break; + case CODEC_RT1308: + sof_rt1308_dai_link(&links[id]); + break; + default: + dev_err(dev, "invalid amp type %d\n", amp_type); + return NULL; } + links[id].platforms = platform_component; links[id].num_platforms = ARRAY_SIZE(platform_component); links[id].dpcm_playback = 1; @@ -385,6 +390,8 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) mach = pdev->dev.platform_data; + ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); + if (dmi_check_system(chromebook_platforms) || mach->mach_params.dmic_num > 0) dmic_be_num = 2; @@ -413,15 +420,26 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) if (sof_ssp_amp_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) sof_ssp_amp_card.num_links++; - dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, dmic_be_num, hdmi_num, ctx->idisp_codec); + dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, + ssp_codec, dmic_be_num, hdmi_num, + ctx->idisp_codec); if (!dai_links) return -ENOMEM; sof_ssp_amp_card.dai_link = dai_links; /* update codec_conf */ - if (sof_ssp_amp_quirk & SOF_CS35L41_SPEAKER_AMP_PRESENT) { + switch (ctx->amp_type) { + case CODEC_CS35L41: cs35l41_set_codec_conf(&sof_ssp_amp_card); + break; + case CODEC_NONE: + case CODEC_RT1308: + /* no codec conf required */ + break; + default: + dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); + return -EINVAL; } INIT_LIST_HEAD(&ctx->hdmi_pcm_list); @@ -451,8 +469,7 @@ static const struct platform_device_id board_ids[] = { SOF_NO_OF_HDMI_CAPTURE_SSP(2) | SOF_HDMI_CAPTURE_1_SSP(1) | SOF_HDMI_CAPTURE_2_SSP(5) | - SOF_SSP_HDMI_CAPTURE_PRESENT | - SOF_RT1308_SPEAKER_AMP_PRESENT), + SOF_SSP_HDMI_CAPTURE_PRESENT), }, { .name = "adl_cs35l41", @@ -460,8 +477,7 @@ static const struct platform_device_id board_ids[] = { SOF_NO_OF_HDMI_PLAYBACK(4) | SOF_HDMI_PLAYBACK_PRESENT | SOF_BT_OFFLOAD_SSP(2) | - SOF_SSP_BT_OFFLOAD_PRESENT | - SOF_CS35L41_SPEAKER_AMP_PRESENT), + SOF_SSP_BT_OFFLOAD_PRESENT), }, { .name = "adl_lt6911_hdmi_ssp", @@ -502,3 +518,4 @@ MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_CIRRUS_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); From patchwork Fri Sep 15 12:48:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723964 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 90E52EE645A for ; Fri, 15 Sep 2023 12:44:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 462DC886; Fri, 15 Sep 2023 14:43:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 462DC886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781853; bh=BaxBV/Oz+EI6y2bppdoICrofYo9op8zjE+oxAlwSzwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=R0EOxHl1poXU8/Ay5LopNfo2l9eA6s7AXncvyYFQMuXpc8P2PUFx4zkQpapkYWExl N1Ky0c0hIXaAXyHoAoFOgYTimIy8FKrOae9bpRqmPd92ws72qYuuu9u9WBFqYZwm0i V2jwNjN/F26JDc12Tb2aKKnYtjDa5j7H5W7rrNiM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 82E74F805F2; Fri, 15 Sep 2023 14:40:55 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 5AC1BF805F0; Fri, 15 Sep 2023 14:40:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CE10EF805BE; Fri, 15 Sep 2023 14:40:40 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 902FDF80425 for ; Fri, 15 Sep 2023 14:40:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 902FDF80425 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YuoBXegp DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781628; x=1726317628; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BaxBV/Oz+EI6y2bppdoICrofYo9op8zjE+oxAlwSzwg=; b=YuoBXegpV13zLW+cX3B7LKYd++giapHqovEQw6TzL0KcZvycCUDlFK4b woDmcSsmQPBfAmFjNOrinDx3orh7s2/BCbWDj38fGk3XMHouTPSv995yU zrJQBN+VME5q/uTOLf7aYe3WzqQQyhNX/MHOv1VeeC1/HGW83juJMUStm MuuL77+OLgHOCfbJcauVhtIeUcojCI4Ow5O2xlNNhCqNVhyJY7sO3KbIl oNoCyTzxF+SxToSQdd8P5nYJ0JM0Em6BDMcan7Ld/8sZBTPVL0r2t6Dyn /ncJ6Szavy7j/qsInyrPGNkk3GFEsf4MtvYmRnfHpGHXNNw8ai4vsZhGb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653160" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653160" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304566" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304566" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:23 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 07/19] ASoC: Intel: sof_nau8825: use ssp-common module to detect codec Date: Fri, 15 Sep 2023 20:48:40 +0800 Message-Id: <20230915124852.1696857-8-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: VMVWJTLG44H6WDISTQU4QXGB7F5CBRPR X-Message-ID-Hash: VMVWJTLG44H6WDISTQU4QXGB7F5CBRPR X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ssp-common module to detect codec and amplifier type in driver probe function and remove all quirks about codec and amplifier type. Signed-off-by: Brent Lu Reviewed-by: Rander Wang Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_nau8825.c | 111 ++++++++++++++------------- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 857bb8628a4c..6da6cad7fd05 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -566,6 +566,7 @@ config SND_SOC_INTEL_SOF_NAU8825_MACH select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON select SND_SOC_INTEL_SOF_REALTEK_COMMON + select SND_SOC_INTEL_SOF_SSP_COMMON help This adds support for ASoC machine driver for SOF platforms with nau8825 codec. diff --git a/sound/soc/intel/boards/sof_nau8825.c b/sound/soc/intel/boards/sof_nau8825.c index 46b7ecf6f9f1..1e4fa5dbe0f6 100644 --- a/sound/soc/intel/boards/sof_nau8825.c +++ b/sound/soc/intel/boards/sof_nau8825.c @@ -23,12 +23,12 @@ #include "hda_dsp_common.h" #include "sof_realtek_common.h" #include "sof_maxim_common.h" +#include "sof_ssp_common.h" #define NAME_SIZE 32 #define SOF_NAU8825_SSP_CODEC(quirk) ((quirk) & GENMASK(2, 0)) #define SOF_NAU8825_SSP_CODEC_MASK (GENMASK(2, 0)) -#define SOF_SPEAKER_AMP_PRESENT BIT(3) #define SOF_NAU8825_SSP_AMP_SHIFT 4 #define SOF_NAU8825_SSP_AMP_MASK (GENMASK(6, 4)) #define SOF_NAU8825_SSP_AMP(quirk) \ @@ -44,11 +44,6 @@ #define SOF_BT_OFFLOAD_SSP(quirk) \ (((quirk) << SOF_BT_OFFLOAD_SSP_SHIFT) & SOF_BT_OFFLOAD_SSP_MASK) #define SOF_SSP_BT_OFFLOAD_PRESENT BIT(13) -#define SOF_RT1019P_SPEAKER_AMP_PRESENT BIT(14) -#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(15) -#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(16) -#define SOF_RT1015P_SPEAKER_AMP_PRESENT BIT(17) -#define SOF_NAU8318_SPEAKER_AMP_PRESENT BIT(18) static unsigned long sof_nau8825_quirk = SOF_NAU8825_SSP_CODEC(0); @@ -62,6 +57,8 @@ struct sof_card_private { struct clk *mclk; struct snd_soc_jack sof_headset; struct list_head hdmi_pcm_list; + enum sof_ssp_codec codec_type; + enum sof_ssp_codec amp_type; }; static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) @@ -192,7 +189,7 @@ static int sof_card_late_probe(struct snd_soc_card *card) struct sof_hdmi_pcm *pcm; int err; - if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { + if (ctx->amp_type == CODEC_MAX98373) { /* Disable Left and Right Spk pin after boot */ snd_soc_dapm_disable_pin(dapm, "Left Spk"); snd_soc_dapm_disable_pin(dapm, "Right Spk"); @@ -346,11 +343,10 @@ static struct snd_soc_dai_link_component nau8318_components[] = { } }; -static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, - int ssp_codec, - int ssp_amp, - int dmic_be_num, - int hdmi_num) +static struct snd_soc_dai_link * +sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, + int ssp_codec, int ssp_amp, int dmic_be_num, + int hdmi_num) { struct snd_soc_dai_link_component *idisp_components; struct snd_soc_dai_link_component *cpus; @@ -463,35 +459,40 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, } /* speaker amp */ - if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) { + if (amp_type != CODEC_NONE) { links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_amp); if (!links[id].name) goto devm_err; links[id].id = id; - if (sof_nau8825_quirk & SOF_RT1019P_SPEAKER_AMP_PRESENT) { - links[id].codecs = rt1019p_component; - links[id].num_codecs = ARRAY_SIZE(rt1019p_component); - links[id].init = speaker_codec_init; - } else if (sof_nau8825_quirk & - SOF_MAX98373_SPEAKER_AMP_PRESENT) { + + switch (amp_type) { + case CODEC_MAX98360A: + max_98360a_dai_link(&links[id]); + break; + case CODEC_MAX98373: links[id].codecs = max_98373_components; links[id].num_codecs = ARRAY_SIZE(max_98373_components); links[id].init = max_98373_spk_codec_init; links[id].ops = &max_98373_ops; - } else if (sof_nau8825_quirk & - SOF_MAX98360A_SPEAKER_AMP_PRESENT) { - max_98360a_dai_link(&links[id]); - } else if (sof_nau8825_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) { - sof_rt1015p_dai_link(&links[id]); - } else if (sof_nau8825_quirk & - SOF_NAU8318_SPEAKER_AMP_PRESENT) { + break; + case CODEC_NAU8318: links[id].codecs = nau8318_components; links[id].num_codecs = ARRAY_SIZE(nau8318_components); links[id].init = speaker_codec_init; - } else { - goto devm_err; + break; + case CODEC_RT1015P: + sof_rt1015p_dai_link(&links[id]); + break; + case CODEC_RT1019P: + links[id].codecs = rt1019p_component; + links[id].num_codecs = ARRAY_SIZE(rt1019p_component); + links[id].init = speaker_codec_init; + break; + default: + dev_err(dev, "invalid amp type %d\n", amp_type); + return NULL; } links[id].platforms = platform_component; @@ -557,11 +558,8 @@ static int sof_audio_probe(struct platform_device *pdev) mach = pdev->dev.platform_data; - /* A speaker amp might not be present when the quirk claims one is. - * Detect this via whether the machine driver match includes quirk_data. - */ - if ((sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) && !mach->quirk_data) - sof_nau8825_quirk &= ~SOF_SPEAKER_AMP_PRESENT; + ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); + ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); dev_dbg(&pdev->dev, "sof_nau8825_quirk = %lx\n", sof_nau8825_quirk); @@ -581,24 +579,39 @@ static int sof_audio_probe(struct platform_device *pdev) /* compute number of dai links */ sof_audio_card_nau8825.num_links = 1 + dmic_be_num + hdmi_num; - if (sof_nau8825_quirk & SOF_SPEAKER_AMP_PRESENT) + if (ctx->amp_type != CODEC_NONE) sof_audio_card_nau8825.num_links++; - if (sof_nau8825_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) - max_98373_set_codec_conf(&sof_audio_card_nau8825); - else if (sof_nau8825_quirk & SOF_RT1015P_SPEAKER_AMP_PRESENT) - sof_rt1015p_codec_conf(&sof_audio_card_nau8825); - if (sof_nau8825_quirk & SOF_SSP_BT_OFFLOAD_PRESENT) sof_audio_card_nau8825.num_links++; - dai_links = sof_card_dai_links_create(&pdev->dev, ssp_codec, ssp_amp, - dmic_be_num, hdmi_num); + dai_links = sof_card_dai_links_create(&pdev->dev, ctx->amp_type, + ssp_codec, ssp_amp, dmic_be_num, + hdmi_num); if (!dai_links) return -ENOMEM; sof_audio_card_nau8825.dai_link = dai_links; + /* update codec_conf */ + switch (ctx->amp_type) { + case CODEC_MAX98373: + max_98373_set_codec_conf(&sof_audio_card_nau8825); + break; + case CODEC_RT1015P: + sof_rt1015p_codec_conf(&sof_audio_card_nau8825); + break; + case CODEC_NONE: + case CODEC_MAX98360A: + case CODEC_NAU8318: + case CODEC_RT1019P: + /* no codec conf required */ + break; + default: + dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); + return -EINVAL; + } + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); sof_audio_card_nau8825.dev = &pdev->dev; @@ -627,16 +640,12 @@ static const struct platform_device_id board_ids[] = { { .name = "adl_rt1019p_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1019P_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(2) | SOF_NAU8825_NUM_HDMIDEV(4)), }, { .name = "adl_max98373_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -646,8 +655,6 @@ static const struct platform_device_id board_ids[] = { /* The limitation of length of char array, shorten the name */ .name = "adl_mx98360a_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98360A_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -657,8 +664,6 @@ static const struct platform_device_id board_ids[] = { { .name = "adl_rt1015p_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_RT1015P_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -667,8 +672,6 @@ static const struct platform_device_id board_ids[] = { { .name = "adl_nau8318_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_NAU8318_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -677,8 +680,6 @@ static const struct platform_device_id board_ids[] = { { .name = "rpl_max98373_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_MAX98373_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -687,8 +688,6 @@ static const struct platform_device_id board_ids[] = { { .name = "rpl_nau8318_8825", .driver_data = (kernel_ulong_t)(SOF_NAU8825_SSP_CODEC(0) | - SOF_SPEAKER_AMP_PRESENT | - SOF_NAU8318_SPEAKER_AMP_PRESENT | SOF_NAU8825_SSP_AMP(1) | SOF_NAU8825_NUM_HDMIDEV(4) | SOF_BT_OFFLOAD_SSP(2) | @@ -712,7 +711,9 @@ module_platform_driver(sof_audio) MODULE_DESCRIPTION("SOF Audio Machine driver for NAU8825"); MODULE_AUTHOR("David Lin "); MODULE_AUTHOR("Mac Chiang "); +MODULE_AUTHOR("Brent Lu "); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); From patchwork Fri Sep 15 12:48:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723167 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 87F93EE6457 for ; Fri, 15 Sep 2023 12:44:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A867DE73; Fri, 15 Sep 2023 14:43:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A867DE73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781865; bh=QWMu3bfivn3cNzh024O95MPdPpmOIPFXllo59K5NqvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Cn38aXzny9YdOPkguwE30JBkl9krf9qGmzVnTNmKHC4IBm5d3tAGH3h82j1221RvN 0iQzFCnhp2FAPLkL76DUzkcB7wQvGjZEqmBlyxAD37/zRWS/U1krceuM7xmV/QUTXx EPGFx3/aR0TCi2ZTKCo4fbUZzxJxFxd8+vN4Lkuk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9865FF80600; Fri, 15 Sep 2023 14:41:00 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 25A0CF805FC; Fri, 15 Sep 2023 14:41:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 399D8F805B6; Fri, 15 Sep 2023 14:40:41 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 44181F80570 for ; Fri, 15 Sep 2023 14:40:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44181F80570 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=egZrBsAB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781632; x=1726317632; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QWMu3bfivn3cNzh024O95MPdPpmOIPFXllo59K5NqvU=; b=egZrBsABJyd2IfVgzalOt5SVXsh8de21/5gWsbkvkiDGYBpbzA1+GU6f /vLH4fJgg5ACmvzMnDBtfelarMydvHfgbbHwoF+0/cxKSCe/SYQM9J1sY pMf9UA7rA7HxJetpSXUAn4WuKNiHhMte2PSSDgqKsf/OdtWzr5bdWIK/V JxXfwGtPjAQe+leBOG1fXkFnz8OVNJgYpy4BCi8zuS+OlZa2iXN90lL8y qzYE7wMBL1KqmUJRnoU7T2hePwF8jHXdaz+9ZH59fx+g13LsyaUZqv8KE 8WcwQk/2J9kpFV848v2MTruLRRaxBjVaqam28rV+kJH6IxpqSy4XLqlAl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653169" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653169" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304583" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304583" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:26 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 08/19] ASoC: Intel: sof_rt5682: Add support for Rex with discrete BT offload. Date: Fri, 15 Sep 2023 20:48:41 +0800 Message-Id: <20230915124852.1696857-9-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: IZ566JWGRYV3IZOJV2Q3QJJNLCBUTCOI X-Message-ID-Hash: IZ566JWGRYV3IZOJV2Q3QJJNLCBUTCOI X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Uday M Bhat System firmware has included additional audio DMI string MAX98360_ALC5682I_DISCRETE_I2S_BT for discrete BT offload supporting devices. Same DMI string match is introduced in sof_rt5682_quirk_table. Signed-off-by: Uday M Bhat Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_rt5682.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index e817be1edaba..c65eede071c2 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -190,6 +190,20 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { SOF_SSP_BT_OFFLOAD_PRESENT ), }, + { + .callback = sof_rt5682_quirk_cb, + .matches = { + DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Rex"), + DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98360_ALC5682I_DISCRETE_I2S_BT"), + }, + .driver_data = (void *)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(2) | + SOF_RT5682_SSP_AMP(0) | + SOF_RT5682_NUM_HDMIDEV(3) | + SOF_BT_OFFLOAD_SSP(1) | + SOF_SSP_BT_OFFLOAD_PRESENT + ), + }, { .callback = sof_rt5682_quirk_cb, .matches = { From patchwork Fri Sep 15 12:48:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723965 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A7CFDEE645A for ; Fri, 15 Sep 2023 12:43:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E4B4BDEE; Fri, 15 Sep 2023 14:42:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E4B4BDEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781827; bh=UZimd24515p6hrvMRb7ig1XNp+esKHxhgQUidKWvpoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KV6dpS0hJOm6sWt59HBxkyAfnl+wZ7EAzMuzoNmesvvXcjHBHc0+/DSO1V+LLcwpB Z3oCoXYphItTKK0jRFQs8E00UgzzC9hQVMIXF3lo2onFRkDe3hX4wLNgecfN6iXugp Qukf9eOzfcQfDfrdsEb0tPjAPfcacHFlOoCamZ7w= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AD5EF805E4; Fri, 15 Sep 2023 14:40:51 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 8BF58F805E0; Fri, 15 Sep 2023 14:40:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C6488F8058C; Fri, 15 Sep 2023 14:40:35 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 31C69F80579 for ; Fri, 15 Sep 2023 14:40:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 31C69F80579 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mRU+gB+D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781633; x=1726317633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UZimd24515p6hrvMRb7ig1XNp+esKHxhgQUidKWvpoI=; b=mRU+gB+DJiJWRzUNN2vS2NrWwyBG7wpnjNYS2wUmtCLUE5jycJXZS/XT 91E/debBBiQ9ad8UE7MtwL6WOSJ/OC96YcCqNoG/9BTk73lIIo/3A1eAm 0rvAE5kcXPhZZq5iK9+qV+yG09Bki6adbi6UyARJBo2U3pNebjvW70tiv S4WwPH+GPvTJr0cr+QWBgfJW71nLu8GHayRavyVXAt6xS9x4+LGno56CW yMk9llLRljkw5ZqDTe67BhbPHX2ztmM4DYwgkrLjK2mP7y0Bv9NqvOcm7 Mmh/9EdUBNh21c22HQYOhscl7Tq6rLBAs6z/MT4zcnzEqXyrvjZMm8Vdd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653185" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653185" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304591" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304591" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:29 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 09/19] ASoC: Intel: sof_rt5682: Modify number of HDMI to 3 for MTL/Rex devices Date: Fri, 15 Sep 2023 20:48:42 +0800 Message-Id: <20230915124852.1696857-10-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: MY3INCBTH7ELLRS5Z4ZCWWC2HG37ZG7E X-Message-ID-Hash: MY3INCBTH7ELLRS5Z4ZCWWC2HG37ZG7E X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Uday M Bhat For all MTL/Rex devices, number of HDMI supported is 3. Signed-off-by: Yong Zhi Signed-off-by: Uday M Bhat Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_rt5682.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index c65eede071c2..bbe15c36b855 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -185,7 +185,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | SOF_RT5682_SSP_AMP(0) | - SOF_RT5682_NUM_HDMIDEV(4) | + SOF_RT5682_NUM_HDMIDEV(3) | SOF_BT_OFFLOAD_SSP(1) | SOF_SSP_BT_OFFLOAD_PRESENT ), @@ -224,7 +224,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = { .driver_data = (void *)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(2) | SOF_RT5682_SSP_AMP(0) | - SOF_RT5682_NUM_HDMIDEV(4) | + SOF_RT5682_NUM_HDMIDEV(3) | SOF_BT_OFFLOAD_SSP(1) | SOF_SSP_BT_OFFLOAD_PRESENT ), @@ -1269,7 +1269,7 @@ static const struct platform_device_id board_ids[] = { .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | SOF_RT5682_SSP_AMP(1) | - SOF_RT5682_NUM_HDMIDEV(4) | + SOF_RT5682_NUM_HDMIDEV(3) | SOF_BT_OFFLOAD_SSP(2) | SOF_SSP_BT_OFFLOAD_PRESENT), }, @@ -1278,7 +1278,7 @@ static const struct platform_device_id board_ids[] = { .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0) | SOF_RT5682_SSP_AMP(1) | - SOF_RT5682_NUM_HDMIDEV(4)), + SOF_RT5682_NUM_HDMIDEV(3)), }, { .name = "mtl_rt1019_rt5682", From patchwork Fri Sep 15 12:48:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723962 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4C19CEE6457 for ; Fri, 15 Sep 2023 12:45:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 60475DEE; Fri, 15 Sep 2023 14:44:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 60475DEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781923; bh=+nKJ/PSxOyzVc92SxY5hlQYodLmGBl0Juiujx8Gpw9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RBL6yWeXpdYxPm95vNv0yAQaFY5ca3BXpeiOkj0W5htSt+fi+u8nPWV1vWL0S1Wqu 90rYyTQnp+CLTvcBzVvcjdxdoq221nd7OzRgHheCr9irA2Heoze73A8MmHDkX3a7OK SDWNSCjqt/e6tRyo3XZWf1IGNsHMFQ6OeTSnzqP8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B86C4F80610; Fri, 15 Sep 2023 14:41:09 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D9D04F80615; Fri, 15 Sep 2023 14:41:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 421C5F805C6; Fri, 15 Sep 2023 14:40:46 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 04F23F805A1 for ; Fri, 15 Sep 2023 14:40:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 04F23F805A1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UXIgqf6L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781637; x=1726317637; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+nKJ/PSxOyzVc92SxY5hlQYodLmGBl0Juiujx8Gpw9Y=; b=UXIgqf6L651gBRaPF+a2vNwxi+KqcXfVRV0J13KAfV4+VKV8VzDi+Al2 9/mLwzfECGA4+Nvp0socP3yb+USAJZwKjrLkTKE9bpatFSLW+mUvA2PlL j0yvuKuIKvac6pFvF5e97gA2dH2nbCz7AO6cYwCSqynAzyNjXvgHvH5Lk c6iCu1VI2uWrsX8I59GA2Tg5wppwxj5zcmv6oUipud6TCRFGRthiDfD+o OrAtFxN/3RIvaoxuIrZXfwjnoxR4wTE59aa6Xtbrw0uVaFQX1bCu5Q451 RI2myX+x3vZFFwq8q1W8lBcT2d8imWf0sfhE4kXWw96xaNqlUq+wd5car A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653194" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653194" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304597" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304597" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:31 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 10/19] ASoC: Intel: sof_rt5682: add adl_rt5650 board config Date: Fri, 15 Sep 2023 20:48:43 +0800 Message-Id: <20230915124852.1696857-11-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 3SYVD2C5QJVK3IWEHVH5TDR7JM464WBE X-Message-ID-Hash: 3SYVD2C5QJVK3IWEHVH5TDR7JM464WBE X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu This configuration supports ADL boards which implement ALC5650 dual I2S interface codec. Two DAI links are added: AIF1 (on codec side) for headphone and AIF2 for speakers. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_rt5682.c | 21 +++++++++++++------ .../intel/common/soc-acpi-intel-adl-match.c | 12 +++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index bbe15c36b855..f5767f9e506d 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -1153,6 +1153,12 @@ static const struct platform_device_id board_ids[] = { .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | SOF_RT5682_SSP_CODEC(0)), }, + { + .name = "jsl_rt5650", + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(0) | + SOF_RT5682_SSP_AMP(1)), + }, { .name = "tgl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | @@ -1239,6 +1245,15 @@ static const struct platform_device_id board_ids[] = { /* SSP 0 and SSP 2 are used for HDMI IN */ SOF_HDMI_CAPTURE_SSP_MASK(0x5)), }, + { + .name = "adl_rt5650", + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(0) | + SOF_RT5682_SSP_AMP(1) | + SOF_RT5682_NUM_HDMIDEV(4) | + SOF_BT_OFFLOAD_SSP(2) | + SOF_SSP_BT_OFFLOAD_PRESENT), + }, { .name = "rpl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | @@ -1287,12 +1302,6 @@ static const struct platform_device_id board_ids[] = { SOF_RT5682_SSP_AMP(0) | SOF_RT5682_NUM_HDMIDEV(3)), }, - { - .name = "jsl_rt5650", - .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | - SOF_RT5682_SSP_CODEC(0) | - SOF_RT5682_SSP_AMP(1)), - }, { } }; MODULE_DEVICE_TABLE(platform, board_ids); diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c index 8e995edf4c10..4e9787870f60 100644 --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c @@ -492,6 +492,11 @@ static const struct snd_soc_acpi_codecs adl_nau8318_amp = { .codecs = {"NVTN2012"} }; +static struct snd_soc_acpi_codecs adl_rt5650_amp = { + .num_codecs = 1, + .codecs = {"10EC5650"} +}; + struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { { .comp_ids = &adl_rt5682_rt5682s_hp, @@ -602,6 +607,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { SND_SOC_ACPI_TPLG_INTEL_SSP_MSB | SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER, }, + { + .id = "10EC5650", + .drv_name = "adl_rt5650", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &adl_rt5650_amp, + .sof_tplg_filename = "sof-adl-rt5650.tplg", + }, /* place amp-only boards in the end of table */ { .id = "CSC3541", From patchwork Fri Sep 15 12:48:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723963 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 98D31EE6457 for ; Fri, 15 Sep 2023 12:44:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C2575E7D; Fri, 15 Sep 2023 14:43:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C2575E7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781884; bh=gIUeaog6rZ9DkgKcRoWsnvL1KNFZmqd7XdbNJXyfyWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=jR5F19AIjJt15tmnDvbfdYRITrhICkAaN1VQwd7emjqQFhkz6edpjN0LUZWFFY1LK QPFNiNOXy20MIrvHobBjzvikN9/C8v4o9aPPi2NBjDDwT3gAACDAFe4NwHecfKIP+i sQhIolUj7FUOLomHEq8HF2FAPtO86lwk0GGqI9eA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4F4F1F8060A; Fri, 15 Sep 2023 14:41:03 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 71A17F80606; Fri, 15 Sep 2023 14:41:02 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 75D0CF805B6; Fri, 15 Sep 2023 14:40:42 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 DE285F805AA for ; Fri, 15 Sep 2023 14:40:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DE285F805AA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Pnal9k7L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781639; x=1726317639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gIUeaog6rZ9DkgKcRoWsnvL1KNFZmqd7XdbNJXyfyWo=; b=Pnal9k7LX9euKGWhje8YfwP3umZ0HQmhzATdADFrI6hPliz63lZV+3kf GrqD05knY8zPLFzOP2x/hEOYk/KCWXIjdftM/kdf3I5dfXZpoz/L6fqjj /IGLUPtGnuSyyf3nBGkDsGxSFYcT4iy64rIZDmQPFXSKuoyExSL6pHOFD n1I0uAn+fNkBqjjqNL+GVDPquyeGnp67NxpPEd+prp7ALLpHPaTfVZ4XN FKNndwtwaVThvLZ1j2NSXUTRr9XJvB+v8xDmP+/y8iKmqQ67EWbAkevCE jNFcQj/IHG8pJxzNKPQYShBXuQhKNl7Ull4AoRLADfAg5NeOhmiRzBMR+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653200" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653200" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304601" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304601" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:34 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 11/19] ASoC: Intel: sof_rt5682: add HDMI_In capture feature support for RPL. Date: Fri, 15 Sep 2023 20:48:44 +0800 Message-Id: <20230915124852.1696857-12-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: P34FVXOW7KTW5M3LYBE4KCCU63OUNWVS X-Message-ID-Hash: P34FVXOW7KTW5M3LYBE4KCCU63OUNWVS X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Balamurugan C Added HDMI-in capture support for RPL boards. previously it used adl machines and now its moved into separate match entry. Signed-off-by: Balamurugan C Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_rt5682.c | 8 ++++++++ sound/soc/intel/common/soc-acpi-intel-rpl-match.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c index f5767f9e506d..9ece71062a3b 100644 --- a/sound/soc/intel/boards/sof_rt5682.c +++ b/sound/soc/intel/boards/sof_rt5682.c @@ -1279,6 +1279,14 @@ static const struct platform_device_id board_ids[] = { SOF_BT_OFFLOAD_SSP(2) | SOF_SSP_BT_OFFLOAD_PRESENT), }, + { + .name = "rpl_rt5682_c1_h02", + .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | + SOF_RT5682_SSP_CODEC(1) | + SOF_RT5682_NUM_HDMIDEV(3) | + /* SSP 0 and SSP 2 are used for HDMI IN */ + SOF_HDMI_CAPTURE_SSP_MASK(0x5)), + }, { .name = "mtl_mx98357_rt5682", .driver_data = (kernel_ulong_t)(SOF_RT5682_MCLK_EN | diff --git a/sound/soc/intel/common/soc-acpi-intel-rpl-match.c b/sound/soc/intel/common/soc-acpi-intel-rpl-match.c index 122673c1dae2..b0ffade5bb08 100644 --- a/sound/soc/intel/common/soc-acpi-intel-rpl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-rpl-match.c @@ -402,6 +402,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_rpl_machines[] = { .quirk_data = &rpl_rt1019p_amp, .sof_tplg_filename = "sof-rpl-rt1019-rt5682.tplg", }, + { + .comp_ids = &rpl_rt5682_hp, + .drv_name = "rpl_rt5682_c1_h02", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &rpl_lt6911_hdmi, + .sof_tplg_filename = "sof-rpl-rt5682-ssp1-hdmi-ssp02.tplg", + }, { .comp_ids = &rpl_essx_83x6, .drv_name = "rpl_es83x6_c1_h02", From patchwork Fri Sep 15 12:48:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723166 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4DACFEE645A for ; Fri, 15 Sep 2023 12:45:03 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E3728E0E; Fri, 15 Sep 2023 14:44:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E3728E0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781900; bh=3PGrPEVFkjyjnStgupe6/kqw87gbIX3yc0ZoAhK/yME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ctnJZogDUZDKVSoo23qPiAd+YvAQ579OmgOc3yVighZL23/Dxi84UuQ7QsQzrPGnv W55ydOUVXdIo21u6bygjPGBbYbecQEoCL4x2BB4zFN7+9R4h6CjNTH3fY059aVtXAP PQ6lqtwQHTb4BIScFITPl0ipsaw9Tl2Lk17RdO+o= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D937BF8060E; Fri, 15 Sep 2023 14:41:06 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 315CFF80601; Fri, 15 Sep 2023 14:41:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0772EF805C7; Fri, 15 Sep 2023 14:40:45 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 C0A09F805B2 for ; Fri, 15 Sep 2023 14:40:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C0A09F805B2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=O5EsIE2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781641; x=1726317641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3PGrPEVFkjyjnStgupe6/kqw87gbIX3yc0ZoAhK/yME=; b=O5EsIE2EBHbjpycsXO3IUy74gWddAd1Dg2p9ALvmlRGQXyfqaOeWEuww f6JL+fAEfj6yHMgPdyJ4Lacx3vmacnxZJSKg1r+UcNvy6NgS6SPMjceUZ lMMzdELbj4VuATYjC8NMsKo7jHozrKCnAHw/ug8rUfuyOHNcwQZ2m0Qew 6c/5sy8Rz7HcQRhACWYPmJLXfAoh8ht9ESpyWKwvQ+MXCupbdfUHVuXMD FyQtdptHeaePeBqPcjAwzRKjxFErC7ABgkDVwzv7vKYsOQ/f8tilX0rT6 yvwqU/+7Tla28uxNaGFnv8xJyUe67W1Qevhk7Pt6pzHiM5EUCiFfKyG5J A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653209" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653209" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304606" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304606" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:36 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 12/19] ASoC: Intel: sof_ssp_amp: do not create amp link for nocodec board Date: Fri, 15 Sep 2023 20:48:45 +0800 Message-Id: <20230915124852.1696857-13-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: BIQGHWII6X5YUJRB6GAJ37HZF2OPWV56 X-Message-ID-Hash: BIQGHWII6X5YUJRB6GAJ37HZF2OPWV56 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu A BE DAI link for speaker amplifier is always created even a board quirk specifies there is no amplifier. Modify the driver to check amplifier type before creating corresponding DAI link. The topology (sof-tgl-rt1308-hdmi-ssp.m4) which supports HDMI-IN is using fixed BE ID for each DAI link. Therefore we also uses fixed ID in machine driver side. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Reviewed-by: Balamurugan C Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_ssp_amp.c | 79 +++++++++++++++++----------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/sound/soc/intel/boards/sof_ssp_amp.c b/sound/soc/intel/boards/sof_ssp_amp.c index e2b3553dbc65..483ddb1c04cd 100644 --- a/sound/soc/intel/boards/sof_ssp_amp.c +++ b/sound/soc/intel/boards/sof_ssp_amp.c @@ -186,6 +186,12 @@ static int sof_hdmi_init(struct snd_soc_pcm_runtime *rtd) #define IDISP_CODEC_MASK 0x4 +/* BE ID defined in sof-tgl-rt1308-hdmi-ssp.m4 */ +#define HDMI_IN_BE_ID 0 +#define SPK_BE_ID 2 +#define DMIC01_BE_ID 3 +#define INTEL_HDMI_BE_ID 5 + static struct snd_soc_dai_link * sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int ssp_codec, int dmic_be_num, int hdmi_num, @@ -195,6 +201,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, struct snd_soc_dai_link_component *cpus; struct snd_soc_dai_link *links; int i, id = 0; + bool fixed_be = false; links = devm_kcalloc(dev, sof_ssp_amp_card.num_links, sizeof(struct snd_soc_dai_link), GFP_KERNEL); @@ -208,6 +215,9 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int num_of_hdmi_ssp = (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT; + /* the topology supports HDMI-IN uses fixed BE ID for DAI links */ + fixed_be = true; + for (i = 1; i <= num_of_hdmi_ssp; i++) { int port = (i == 1 ? (sof_ssp_amp_quirk & SOF_HDMI_CAPTURE_1_SSP_MASK) >> SOF_HDMI_CAPTURE_1_SSP_SHIFT : @@ -222,7 +232,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port); if (!links[id].name) return NULL; - links[id].id = id; + links[id].id = fixed_be ? (HDMI_IN_BE_ID + i - 1) : id; links[id].codecs = &asoc_dummy_dlc; links[id].num_codecs = 1; links[id].platforms = platform_component; @@ -235,38 +245,40 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, } /* codec SSP */ - links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec); - if (!links[id].name) - return NULL; + if (amp_type != CODEC_NONE) { + links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_codec); + if (!links[id].name) + return NULL; - links[id].id = id; + links[id].id = fixed_be ? SPK_BE_ID : id; - switch (amp_type) { - case CODEC_CS35L41: - cs35l41_set_dai_link(&links[id]); - break; - case CODEC_RT1308: - sof_rt1308_dai_link(&links[id]); - break; - default: - dev_err(dev, "invalid amp type %d\n", amp_type); - return NULL; + switch (amp_type) { + case CODEC_CS35L41: + cs35l41_set_dai_link(&links[id]); + break; + case CODEC_RT1308: + sof_rt1308_dai_link(&links[id]); + break; + default: + dev_err(dev, "invalid amp type %d\n", amp_type); + return NULL; + } + + links[id].platforms = platform_component; + links[id].num_platforms = ARRAY_SIZE(platform_component); + links[id].dpcm_playback = 1; + /* feedback from amplifier or firmware-generated echo reference */ + links[id].dpcm_capture = 1; + links[id].no_pcm = 1; + links[id].cpus = &cpus[id]; + links[id].num_cpus = 1; + links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_codec); + if (!links[id].cpus->dai_name) + return NULL; + + id++; } - links[id].platforms = platform_component; - links[id].num_platforms = ARRAY_SIZE(platform_component); - links[id].dpcm_playback = 1; - /* feedback from amplifier or firmware-generated echo reference */ - links[id].dpcm_capture = 1; - links[id].no_pcm = 1; - links[id].cpus = &cpus[id]; - links[id].num_cpus = 1; - links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_codec); - if (!links[id].cpus->dai_name) - return NULL; - - id++; - /* dmic */ if (dmic_be_num > 0) { /* at least we have dmic01 */ @@ -283,7 +295,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, } for (i = 0; i < dmic_be_num; i++) { - links[id].id = id; + links[id].id = fixed_be ? (DMIC01_BE_ID + i) : id; links[id].num_cpus = 1; links[id].codecs = dmic_component; links[id].num_codecs = ARRAY_SIZE(dmic_component); @@ -312,7 +324,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, if (!links[id].name) goto devm_err; - links[id].id = id; + links[id].id = fixed_be ? (INTEL_HDMI_BE_ID + i - 1) : id; links[id].cpus = &cpus[id]; links[id].num_cpus = 1; links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, @@ -398,7 +410,10 @@ static int sof_ssp_amp_probe(struct platform_device *pdev) ssp_codec = sof_ssp_amp_quirk & SOF_AMPLIFIER_SSP_MASK; /* set number of dai links */ - sof_ssp_amp_card.num_links = 1 + dmic_be_num; + sof_ssp_amp_card.num_links = dmic_be_num; + + if (ctx->amp_type != CODEC_NONE) + sof_ssp_amp_card.num_links++; if (sof_ssp_amp_quirk & SOF_SSP_HDMI_CAPTURE_PRESENT) sof_ssp_amp_card.num_links += (sof_ssp_amp_quirk & SOF_NO_OF_HDMI_CAPTURE_SSP_MASK) >> From patchwork Fri Sep 15 12:48:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723165 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B943EEE6457 for ; Fri, 15 Sep 2023 12:45:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3DB44DF0; Fri, 15 Sep 2023 14:44:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3DB44DF0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781937; bh=zPy+3sccQoKNgoc0xK4zF+WWBM6gv5CjZjz0dOBjI6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kbHEki4x0RyjO+hHUZ/4PcRZLxfaC9RS0gueBwzDyycvCW7YWLlk9nI5PL8EodEkg 7s4+1blH5Yi03Y9s52mU89LOSjhJuSQCSuQ0LPOm3SbAUi6P1Wfax+9FfI00UERyf5 EOY0cFhvx1MzPGJj/HdMIuIFGRSBZ1mldUQgzwhY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8AE57F8061E; Fri, 15 Sep 2023 14:41:11 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 75063F8061C; Fri, 15 Sep 2023 14:41:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A0803F805D7; Fri, 15 Sep 2023 14:40:48 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 BB13FF805C4 for ; Fri, 15 Sep 2023 14:40:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BB13FF805C4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LsuaEtCP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781644; x=1726317644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zPy+3sccQoKNgoc0xK4zF+WWBM6gv5CjZjz0dOBjI6c=; b=LsuaEtCP6dehHBHOMow8mbe/VIU6Nq3ox6sDEN6bzZ//zgBkYLXv+dwD 24ORphbTuE9EVL8PDaxlMC0BaY5xBnF0x4/DLj7VUJ2StCF7qMQUp/wgF UpQ1ar1on7Yy2YdaG7N5fcTrVTPExfn/AW/VTJDlZLPccztKkVl1yQgR3 EDVVbIpYsqpxvx0virzfpA/yvSSQm9sCAOZhGEOd89y9StnDZSobBbxOE N5WjVa/5VYyubxaj8lX2+DPDpazLKWomoJljGvd3bs7xv+b9jIKv+clKb 0xTKj5mVMQIO047jnrDpdR38OA/vsbDsMn5LBNoFkdsXEm+8sLPr70HHm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653217" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653217" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304612" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304612" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:39 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 13/19] ASoC: Intel: nuvoton-common: support nau8318 amplifier Date: Fri, 15 Sep 2023 20:48:46 +0800 Message-Id: <20230915124852.1696857-14-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7YGITBTB3DHHAHSMKUMQMMKRHWJHHXXQ X-Message-ID-Hash: 7YGITBTB3DHHAHSMKUMQMMKRHWJHHXXQ X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Implement nau8318 support code in this common module so it could be shared between multiple SOF machine drivers. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 3 + sound/soc/intel/boards/Makefile | 3 + sound/soc/intel/boards/sof_nuvoton_common.c | 73 +++++++++++++++++++++ sound/soc/intel/boards/sof_nuvoton_common.h | 22 +++++++ 4 files changed, 101 insertions(+) create mode 100644 sound/soc/intel/boards/sof_nuvoton_common.c create mode 100644 sound/soc/intel/boards/sof_nuvoton_common.h diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 6da6cad7fd05..d32098e0c576 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -38,6 +38,9 @@ config SND_SOC_INTEL_SOF_REALTEK_COMMON config SND_SOC_INTEL_SOF_CIRRUS_COMMON tristate +config SND_SOC_INTEL_SOF_NUVOTON_COMMON + tristate + config SND_SOC_INTEL_SOF_SSP_COMMON tristate diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index ce03a0be1a92..70eb596f4ec3 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -97,5 +97,8 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_REALTEK_COMMON) += snd-soc-intel-sof-realtek-comm snd-soc-intel-sof-cirrus-common-objs += sof_cirrus_common.o obj-$(CONFIG_SND_SOC_INTEL_SOF_CIRRUS_COMMON) += snd-soc-intel-sof-cirrus-common.o +snd-soc-intel-sof-nuvoton-common-objs += sof_nuvoton_common.o +obj-$(CONFIG_SND_SOC_INTEL_SOF_NUVOTON_COMMON) += snd-soc-intel-sof-nuvoton-common.o + snd-soc-intel-sof-ssp-common-objs += sof_ssp_common.o obj-$(CONFIG_SND_SOC_INTEL_SOF_SSP_COMMON) += snd-soc-intel-sof-ssp-common.o diff --git a/sound/soc/intel/boards/sof_nuvoton_common.c b/sound/soc/intel/boards/sof_nuvoton_common.c new file mode 100644 index 000000000000..549a412f5d53 --- /dev/null +++ b/sound/soc/intel/boards/sof_nuvoton_common.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * This file defines data structures and functions used in Machine + * Driver for Intel platforms with Nuvoton Codecs. + * + * Copyright 2023 Intel Corporation. + */ +#include +#include +#include "sof_nuvoton_common.h" + +/* + * Nuvoton NAU8318 + */ +static const struct snd_kcontrol_new nau8318_kcontrols[] = { + SOC_DAPM_PIN_SWITCH("Spk"), +}; + +static const struct snd_soc_dapm_widget nau8318_widgets[] = { + SND_SOC_DAPM_SPK("Spk", NULL), +}; + +static const struct snd_soc_dapm_route nau8318_routes[] = { + { "Spk", NULL, "Speaker" }, +}; + +static struct snd_soc_dai_link_component nau8318_components[] = { + { + .name = NAU8318_DEV0_NAME, + .dai_name = NAU8318_CODEC_DAI, + } +}; + +static int nau8318_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card = rtd->card; + int ret; + + ret = snd_soc_dapm_new_controls(&card->dapm, nau8318_widgets, + ARRAY_SIZE(nau8318_widgets)); + if (ret) { + dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret); + return ret; + } + + ret = snd_soc_add_card_controls(card, nau8318_kcontrols, + ARRAY_SIZE(nau8318_kcontrols)); + if (ret) { + dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret); + return ret; + } + + ret = snd_soc_dapm_add_routes(&card->dapm, nau8318_routes, + ARRAY_SIZE(nau8318_routes)); + + if (ret) { + dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret); + return ret; + } + + return ret; +} + +void nau8318_set_dai_link(struct snd_soc_dai_link *link) +{ + link->codecs = nau8318_components; + link->num_codecs = ARRAY_SIZE(nau8318_components); + link->init = nau8318_init; +} +EXPORT_SYMBOL_NS(nau8318_set_dai_link, SND_SOC_INTEL_SOF_NUVOTON_COMMON); + +MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/intel/boards/sof_nuvoton_common.h b/sound/soc/intel/boards/sof_nuvoton_common.h new file mode 100644 index 000000000000..53a84f9a67c0 --- /dev/null +++ b/sound/soc/intel/boards/sof_nuvoton_common.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * This file defines data structures used in Machine Driver for Intel + * platforms with Nuvoton Codecs. + * + * Copyright 2023 Intel Corporation. + */ +#ifndef __SOF_NUVOTON_COMMON_H +#define __SOF_NUVOTON_COMMON_H + +#include +#include "sof_ssp_common.h" + +/* + * Nuvoton NAU8318 + */ +#define NAU8318_CODEC_DAI "nau8315-hifi" +#define NAU8318_DEV0_NAME "i2c-" NAU8318_ACPI_HID ":00" + +void nau8318_set_dai_link(struct snd_soc_dai_link *link); + +#endif /* __SOF_NUVOTON_COMMON_H */ From patchwork Fri Sep 15 12:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723961 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5F07AEE6457 for ; Fri, 15 Sep 2023 12:45:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4C40C886; Fri, 15 Sep 2023 14:44:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4C40C886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781948; bh=YXSSgOw5N8MwBgTNoSH8ULGEgSmUm7QP4kIXSJZ0t0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cdELOA+hgozQ/UY/DVem2mSJ+rQ4F2HIDA7zFz8VUmwvynht3E0JxoX9348wveKyY jsc85D411LURoB6S5QkgVc/UZ2yoeU3RximkH0FnEMTWsLuDs9W4u4IvdAGYV/+4ct 1/E6G+sioZoihTm+BM0vlMx/VvBWf5kC/a/rbtZk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D8C0F80639; Fri, 15 Sep 2023 14:41:15 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id EB3B2F8062F; Fri, 15 Sep 2023 14:41:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 79749F805CA; Fri, 15 Sep 2023 14:40:49 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 9D758F805B2 for ; Fri, 15 Sep 2023 14:40:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D758F805B2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nZJptxmA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781646; x=1726317646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YXSSgOw5N8MwBgTNoSH8ULGEgSmUm7QP4kIXSJZ0t0o=; b=nZJptxmA8ORiTlkSTeL3gY6yzjX88PPUqZsM8dD0M0+R2amAp31ilQdI bNNKUAbBJjPd3TPB84P3HRk0t0nl04tIsHVNTNBCDrKi/t/aQeKVczrdh 42k9fQVSRkEIbmsxgfRHtM4x6O5075MzWokVVB8tz8N4Z386Af3lfFbiC ZEgIN6idVCGyrulqJ2z68TkfvLtAtqcEZXhYdFlxhy7h28kh7DuasBRzN iiLsO1+fEzIbF2A2Tt7yXVm2AspzkkrkqocEF9K7xosn/k+bJnSXiH7wX 8s2/gxxn243TP9oEH1Bs90deKS0O4EVXXlMg1PypMvNqmJSnaLS6j/O5S A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653221" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653221" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304639" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304639" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:41 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 14/19] ASoC: Intel: sof_nau8825: use nuvoton-common module Date: Fri, 15 Sep 2023 20:48:47 +0800 Message-Id: <20230915124852.1696857-15-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 5A5TGGMMDGHWVANP3DIPVOBK6ZSSSBQ6 X-Message-ID-Hash: 5A5TGGMMDGHWVANP3DIPVOBK6ZSSSBQ6 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use nuvoton-common module to support nau8318 speaker amplifier. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_nau8825.c | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index d32098e0c576..f3901a6259f7 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -568,6 +568,7 @@ config SND_SOC_INTEL_SOF_NAU8825_MACH select SND_SOC_HDAC_HDMI select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_INTEL_SOF_MAXIM_COMMON + select SND_SOC_INTEL_SOF_NUVOTON_COMMON select SND_SOC_INTEL_SOF_REALTEK_COMMON select SND_SOC_INTEL_SOF_SSP_COMMON help diff --git a/sound/soc/intel/boards/sof_nau8825.c b/sound/soc/intel/boards/sof_nau8825.c index 1e4fa5dbe0f6..1e4e58f22ca6 100644 --- a/sound/soc/intel/boards/sof_nau8825.c +++ b/sound/soc/intel/boards/sof_nau8825.c @@ -23,6 +23,7 @@ #include "hda_dsp_common.h" #include "sof_realtek_common.h" #include "sof_maxim_common.h" +#include "sof_nuvoton_common.h" #include "sof_ssp_common.h" #define NAME_SIZE 32 @@ -336,13 +337,6 @@ static struct snd_soc_dai_link_component rt1019p_component[] = { } }; -static struct snd_soc_dai_link_component nau8318_components[] = { - { - .name = "NVTN2012:00", - .dai_name = "nau8315-hifi", - } -}; - static struct snd_soc_dai_link * sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int ssp_codec, int ssp_amp, int dmic_be_num, @@ -478,9 +472,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, links[id].ops = &max_98373_ops; break; case CODEC_NAU8318: - links[id].codecs = nau8318_components; - links[id].num_codecs = ARRAY_SIZE(nau8318_components); - links[id].init = speaker_codec_init; + nau8318_set_dai_link(&links[id]); break; case CODEC_RT1015P: sof_rt1015p_dai_link(&links[id]); @@ -715,5 +707,6 @@ MODULE_AUTHOR("Brent Lu "); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_NUVOTON_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_REALTEK_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); From patchwork Fri Sep 15 12:48:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723164 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8A97DEE6457 for ; Fri, 15 Sep 2023 12:46:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F2557DF1; Fri, 15 Sep 2023 14:45:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F2557DF1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781966; bh=FBGhKyTn6NtmsCUHTKZxMrlPQv5iDnqvm0TTI65TSmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PRDRHx4c9aYnmSrxLAoQzl4gky66rWK+FbRZ4hl4vH6AuhH/ui7GxaB/AillYD4bb MHjACus7ls2PExZfNR/HLvj2WyAB+3NNvD8yzZyMZom+wt3x5B7SP8oRv1sFcFPV9+ mMDZafLHR6iodh8tds8a+pLgE3OvDYo+fXFiKw2E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0D6EBF8056F; Fri, 15 Sep 2023 14:41:17 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 42678F80564; Fri, 15 Sep 2023 14:41:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E97D7F805E7; Fri, 15 Sep 2023 14:40:52 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 ED525F805E2 for ; Fri, 15 Sep 2023 14:40:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz ED525F805E2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CAJ6u9Sz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781651; x=1726317651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FBGhKyTn6NtmsCUHTKZxMrlPQv5iDnqvm0TTI65TSmU=; b=CAJ6u9SzDmrsTYEmvlE49CXj4g4312bxcFd0F31BSqWVj5YSMal0yEAO yUscQLqTP9gP4ywJpGSSNHps7pyXpNQq/Ebl1gyzueb0fhnS0bgsKBmiw ekv2dkL7eZrUzeUhffYanuoIpnkyF0NIKnVvq9U2QX2yHreH8lFdRSe7u 4RbLGF2wNfxUsuu9oJavf09zl9IYA753ZGvkJAXPdnQ7dOlad8xk/QsYI OlInDhQVBL0mkH00ZJj8hhoW2mccLBzIyE4Mu94iswfRDvzencijujQ3i NLmmCTYZOGjKniHIYnM0OdkLNrZ4QasRzpOGUnQSC/StossB1aE6dyQSq Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653231" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653231" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304667" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304667" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:44 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 15/19] ASoC: Intel: sof_nau8825: use realtek-common module Date: Fri, 15 Sep 2023 20:48:48 +0800 Message-Id: <20230915124852.1696857-16-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 2FX4JS5ROZGZGV57NBWWPNDWBQWG2NJZ X-Message-ID-Hash: 2FX4JS5ROZGZGV57NBWWPNDWBQWG2NJZ X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use realtek-common module to support rt1019p speaker amplifier. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_nau8825.c | 52 +--------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/sound/soc/intel/boards/sof_nau8825.c b/sound/soc/intel/boards/sof_nau8825.c index 1e4e58f22ca6..10fdd70b09c9 100644 --- a/sound/soc/intel/boards/sof_nau8825.c +++ b/sound/soc/intel/boards/sof_nau8825.c @@ -214,10 +214,6 @@ static const struct snd_kcontrol_new sof_controls[] = { SOC_DAPM_PIN_SWITCH("Right Spk"), }; -static const struct snd_kcontrol_new speaker_controls[] = { - SOC_DAPM_PIN_SWITCH("Spk"), -}; - static const struct snd_soc_dapm_widget sof_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -225,10 +221,6 @@ static const struct snd_soc_dapm_widget sof_widgets[] = { SND_SOC_DAPM_SPK("Right Spk", NULL), }; -static const struct snd_soc_dapm_widget speaker_widgets[] = { - SND_SOC_DAPM_SPK("Spk", NULL), -}; - static const struct snd_soc_dapm_widget dmic_widgets[] = { SND_SOC_DAPM_MIC("SoC DMIC", NULL), }; @@ -242,44 +234,11 @@ static const struct snd_soc_dapm_route sof_map[] = { { "MIC", NULL, "Headset Mic" }, }; -static const struct snd_soc_dapm_route speaker_map[] = { - /* speaker */ - { "Spk", NULL, "Speaker" }, -}; - static const struct snd_soc_dapm_route dmic_map[] = { /* digital mics */ {"DMic", NULL, "SoC DMIC"}, }; -static int speaker_codec_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_card *card = rtd->card; - int ret; - - ret = snd_soc_dapm_new_controls(&card->dapm, speaker_widgets, - ARRAY_SIZE(speaker_widgets)); - if (ret) { - dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret); - /* Don't need to add routes if widget addition failed */ - return ret; - } - - ret = snd_soc_add_card_controls(card, speaker_controls, - ARRAY_SIZE(speaker_controls)); - if (ret) { - dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret); - return ret; - } - - ret = snd_soc_dapm_add_routes(&card->dapm, speaker_map, - ARRAY_SIZE(speaker_map)); - - if (ret) - dev_err(rtd->dev, "Speaker map addition failed: %d\n", ret); - return ret; -} - static int dmic_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_card *card = rtd->card; @@ -330,13 +289,6 @@ static struct snd_soc_dai_link_component dmic_component[] = { } }; -static struct snd_soc_dai_link_component rt1019p_component[] = { - { - .name = "RTL1019:00", - .dai_name = "HiFi", - } -}; - static struct snd_soc_dai_link * sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, int ssp_codec, int ssp_amp, int dmic_be_num, @@ -478,9 +430,7 @@ sof_card_dai_links_create(struct device *dev, enum sof_ssp_codec amp_type, sof_rt1015p_dai_link(&links[id]); break; case CODEC_RT1019P: - links[id].codecs = rt1019p_component; - links[id].num_codecs = ARRAY_SIZE(rt1019p_component); - links[id].init = speaker_codec_init; + sof_rt1019p_dai_link(&links[id]); break; default: dev_err(dev, "invalid amp type %d\n", amp_type); From patchwork Fri Sep 15 12:48:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723960 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 645A3EE645A for ; Fri, 15 Sep 2023 12:46:23 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 920B7E0F; Fri, 15 Sep 2023 14:45:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 920B7E0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781981; bh=TJHPKjAa/3Mwa+riqAKz7f7NRQpGWWQChIkC5bJZVwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=VltWy9z8y5UQM9h5xuwrelbEDB/xbGnZ92eyz/MDXNXLRfDyMHTy6RR6BZeMCL69G bOIAwGVes18o58HNBTUvXhwR3hs7BT3AM1G55zAMvK5Y+wLatFIwQqiTysOcTyulfx 331C4+rDiv0xYSBW2d6Et2MbYbyh1XARBg59dZlo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 765F4F80649; Fri, 15 Sep 2023 14:41:20 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id DBBC1F80642; Fri, 15 Sep 2023 14:41:19 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 101BFF805F8; Fri, 15 Sep 2023 14:40:57 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 E9134F805E6 for ; Fri, 15 Sep 2023 14:40:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E9134F805E6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BvtIy/6v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781653; x=1726317653; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TJHPKjAa/3Mwa+riqAKz7f7NRQpGWWQChIkC5bJZVwY=; b=BvtIy/6vvkve1TosHVsojtpyzpmSJ5GCOkqS2sk2WNXH92O/Q/q82cVI 1ZOoD4vlG/Xe2eM9/i8XuHy/EVDhktLR8gqIZ0hjjUrUfCV1d48F2gg15 5/lr0irjzH9yw3EHp/ghik17MrIwOzZOskDENn+27ZASmgoPu1L5CLl+o xwn9NzE8HZ8S74L8UIQXH1emiWHbzfDfuFuSr293XL3ekMPoCsWkVoLBQ INCz2WK8i7iUEwdMgWFCKTi4zCGkF+NiBjkWTueTmuetWJBV09tZj8+Do 5NPLOCyDFWCWFMeIC6rJ50tsIjGu+rpmJM8yOQlEnFHGE+QoyeUkQN8Kz A==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653246" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653246" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304686" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304686" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:47 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 16/19] ASoC: Intel: sof_da7219: rename driver file and kernel option Date: Fri, 15 Sep 2023 20:48:49 +0800 Message-Id: <20230915124852.1696857-17-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: FKV266A3UJF7OGTDAAWLUFW2XRGQJVZ3 X-Message-ID-Hash: FKV266A3UJF7OGTDAAWLUFW2XRGQJVZ3 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Rename the driver file and kernel option to be consistent with other SOF machine drivers. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 11 ++++------- sound/soc/intel/boards/Makefile | 4 ++-- .../boards/{sof_da7219_max98373.c => sof_da7219.c} | 0 3 files changed, 6 insertions(+), 9 deletions(-) rename sound/soc/intel/boards/{sof_da7219_max98373.c => sof_da7219.c} (100%) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index f3901a6259f7..b6aa8db86b67 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -610,25 +610,22 @@ config SND_SOC_INTEL_SOF_CML_RT1011_RT5682_MACH endif ## SND_SOC_SOF_COMETLAKE && SND_SOC_SOF_HDA_LINK -if SND_SOC_SOF_JASPERLAKE - -config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH - tristate "SOF with DA7219 and MAX98373/MAX98360A in I2S Mode" +config SND_SOC_INTEL_SOF_DA7219_MACH + tristate "SOF with DA7219 codec in I2S Mode" depends on I2C && ACPI depends on MFD_INTEL_LPSS || COMPILE_TEST depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC select SND_SOC_INTEL_HDA_DSP_COMMON select SND_SOC_DA7219 + select SND_SOC_MAX98357A select SND_SOC_MAX98373_I2C select SND_SOC_DMIC help This adds support for ASoC machine driver for SOF platforms - with DA7219 + MAX98373/MAX98360A I2S audio codec. + with Dialog DA7219 I2S audio codec. Say Y if you have such a device. If unsure select "N". -endif ## SND_SOC_SOF_JASPERLAKE - if SND_SOC_SOF_HDA_LINK config SND_SOC_INTEL_SOF_SSP_AMP_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 70eb596f4ec3..ae78e4aa69fc 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -23,6 +23,7 @@ snd-soc-sof_rt5682-objs := sof_rt5682.o snd-soc-sof_cs42l42-objs := sof_cs42l42.o snd-soc-sof_es8336-objs := sof_es8336.o snd-soc-sof_nau8825-objs := sof_nau8825.o +snd-soc-sof_da7219-objs := sof_da7219.o snd-soc-cml_rt1011_rt5682-objs := cml_rt1011_rt5682.o snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o snd-soc-kbl_da7219_max98927-objs := kbl_da7219_max98927.o @@ -33,7 +34,6 @@ snd-soc-skl_rt286-objs := skl_rt286.o snd-soc-skl_hda_dsp-objs := skl_hda_dsp_generic.o skl_hda_dsp_common.o snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o -snd-soc-sof_da7219_max98373-objs := sof_da7219_max98373.o snd-soc-ehl-rt5660-objs := ehl_rt5660.o snd-soc-sof-ssp-amp-objs := sof_ssp_amp.o snd-soc-sof-sdw-objs += sof_sdw.o \ @@ -49,6 +49,7 @@ obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o obj-$(CONFIG_SND_SOC_INTEL_SOF_CS42L42_MACH) += snd-soc-sof_cs42l42.o obj-$(CONFIG_SND_SOC_INTEL_SOF_ES8336_MACH) += snd-soc-sof_es8336.o obj-$(CONFIG_SND_SOC_INTEL_SOF_NAU8825_MACH) += snd-soc-sof_nau8825.o +obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MACH) += snd-soc-sof_da7219.o obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-hsw-rt5640.o obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o @@ -79,7 +80,6 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ssm4567.o obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o -obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH) += snd-soc-sof_da7219_max98373.o obj-$(CONFIG_SND_SOC_INTEL_EHL_RT5660_MACH) += snd-soc-ehl-rt5660.o obj-$(CONFIG_SND_SOC_INTEL_SOUNDWIRE_SOF_MACH) += snd-soc-sof-sdw.o obj-$(CONFIG_SND_SOC_INTEL_SOF_SSP_AMP_MACH) += snd-soc-sof-ssp-amp.o diff --git a/sound/soc/intel/boards/sof_da7219_max98373.c b/sound/soc/intel/boards/sof_da7219.c similarity index 100% rename from sound/soc/intel/boards/sof_da7219_max98373.c rename to sound/soc/intel/boards/sof_da7219.c From patchwork Fri Sep 15 12:48:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723163 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8AA43EE645A for ; Fri, 15 Sep 2023 12:46:41 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 47A4BE8D; Fri, 15 Sep 2023 14:45:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 47A4BE8D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694781999; bh=dI+Ms/XPAG3smkdJ6NySi5sgSztrEsipffKFUAvfAFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LyGYZbaSy01ApWQmiv0093AFcKFv9DpgLWOGUQPy27os7b70n618FwXP1pY3vK6hO l54vYv78CjnzjHp7mbl+YFL8zji6Gq47U1qTf/gUlVVdwzjuispQf056pBk8T0fGB6 z7K+ABv3FbeWLxsn4B+ic1apEq37vlAnaAxhGHpk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 72B86F80651; Fri, 15 Sep 2023 14:41:23 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A9D18F80659; Fri, 15 Sep 2023 14:41:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4BC8DF80606; Fri, 15 Sep 2023 14:41:01 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 C4D0FF805EC for ; Fri, 15 Sep 2023 14:40:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4D0FF805EC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=K6Z58H34 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781655; x=1726317655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dI+Ms/XPAG3smkdJ6NySi5sgSztrEsipffKFUAvfAFs=; b=K6Z58H34zJJUArrbqfgKzm0wjOa6gOa8lwte9CwXZ4VbTcN/ZK9VE1EA 5IWADfWHUdvKYLPWfnlIUYA2ANXC5sjlCSRZUjsRZCQUSesY3TfbUqy7q BlKIqzuot+v5iOAyfk3OQNXsL89KieLxCUCvexSwNG3oiC/SGPVoP0o0l 2uDA6weaAdVzub2Eb5LTXT5kovQwzm2KiFsPibloldFO8JKs8HgzZ4H2P G0P6whTQktpTla2SyfBBtwYBp+Z+VsTFiy8OOb5r5Z87Avm4CtcA7hD2F KFUWuseN8HU1NbWv+kahCdZeEZj1F1d4nU1OFFC7eAAD5RbQZhccNxF1z Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653255" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653255" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304701" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304701" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:50 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 17/19] ASoC: Intel: sof_da7219: use maxim-common module Date: Fri, 15 Sep 2023 20:48:50 +0800 Message-Id: <20230915124852.1696857-18-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7VIE2F6XZVL72KQ7ZSAWSAII4GXDD5KV X-Message-ID-Hash: 7VIE2F6XZVL72KQ7ZSAWSAII4GXDD5KV X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use maxim-common module to handle speaker amp DAI link registration. No functional change in this commit. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_da7219.c | 182 ++++++++++------------------ 2 files changed, 63 insertions(+), 120 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index b6aa8db86b67..6c97e22f248c 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -620,6 +620,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH select SND_SOC_MAX98357A select SND_SOC_MAX98373_I2C select SND_SOC_DMIC + select SND_SOC_INTEL_SOF_MAXIM_COMMON help This adds support for ASoC machine driver for SOF platforms with Dialog DA7219 I2S audio codec. diff --git a/sound/soc/intel/boards/sof_da7219.c b/sound/soc/intel/boards/sof_da7219.c index bbd47e7e4343..c204c3dfd133 100644 --- a/sound/soc/intel/boards/sof_da7219.c +++ b/sound/soc/intel/boards/sof_da7219.c @@ -2,7 +2,7 @@ // Copyright(c) 2019 Intel Corporation. /* - * Intel SOF Machine driver for DA7219 + MAX98373/MAX98360A codec + * Intel SOF Machine driver for Dialog headphone codec */ #include @@ -15,11 +15,15 @@ #include #include "../../codecs/da7219.h" #include "hda_dsp_common.h" +#include "sof_maxim_common.h" + +/* Speaker amp type + * TBD: use ssp-common module for type detection + */ +#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(0) +#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(1) #define DIALOG_CODEC_DAI "da7219-hifi" -#define MAX98373_CODEC_DAI "max98373-aif1" -#define MAXIM_DEV0_NAME "i2c-MX98373:00" -#define MAXIM_DEV1_NAME "i2c-MX98373:01" struct hdmi_pcm { struct list_head head; @@ -28,7 +32,7 @@ struct hdmi_pcm { }; struct card_private { - struct snd_soc_jack headset; + struct snd_soc_jack headset_jack; struct list_head hdmi_pcm_list; struct snd_soc_jack hdmi[3]; }; @@ -70,14 +74,6 @@ static const struct snd_kcontrol_new controls[] = { SOC_DAPM_PIN_SWITCH("Right Spk"), }; -static const struct snd_kcontrol_new m98360a_controls[] = { - SOC_DAPM_PIN_SWITCH("Headphone Jack"), - SOC_DAPM_PIN_SWITCH("Headset Mic"), - SOC_DAPM_PIN_SWITCH("Line Out"), - SOC_DAPM_PIN_SWITCH("Spk"), -}; - -/* For MAX98373 amp */ static const struct snd_soc_dapm_widget widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -103,40 +99,6 @@ static const struct snd_soc_dapm_route audio_map[] = { { "Headset Mic", NULL, "Platform Clock" }, { "Line Out", NULL, "Platform Clock" }, - { "Left Spk", NULL, "Left BE_OUT" }, - { "Right Spk", NULL, "Right BE_OUT" }, - - /* digital mics */ - {"DMic", NULL, "SoC DMIC"}, -}; - -/* For MAX98360A amp */ -static const struct snd_soc_dapm_widget max98360a_widgets[] = { - SND_SOC_DAPM_HP("Headphone Jack", NULL), - SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_LINE("Line Out", NULL), - - SND_SOC_DAPM_SPK("Spk", NULL), - - SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, - platform_clock_control, SND_SOC_DAPM_POST_PMD | - SND_SOC_DAPM_PRE_PMU), - - SND_SOC_DAPM_MIC("SoC DMIC", NULL), -}; - -static const struct snd_soc_dapm_route max98360a_map[] = { - { "Headphone Jack", NULL, "HPL" }, - { "Headphone Jack", NULL, "HPR" }, - - { "MIC", NULL, "Headset Mic" }, - - { "Headphone Jack", NULL, "Platform Clock" }, - { "Headset Mic", NULL, "Platform Clock" }, - { "Line Out", NULL, "Platform Clock" }, - - {"Spk", NULL, "Speaker"}, - /* digital mics */ {"DMic", NULL, "SoC DMIC"}, }; @@ -156,13 +118,12 @@ static struct snd_soc_jack_pin jack_pins[] = { }, }; -static struct snd_soc_jack headset; - static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { + struct card_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_component *component = codec_dai->component; - struct snd_soc_jack *jack; + struct snd_soc_jack *jack = &ctx->headset_jack; int ret; /* Configure sysclk for codec */ @@ -181,25 +142,27 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, - &headset, - jack_pins, - ARRAY_SIZE(jack_pins)); + jack, jack_pins, ARRAY_SIZE(jack_pins)); if (ret) { dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); return ret; } - jack = &headset; snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - snd_soc_component_set_jack(component, jack, NULL); + + ret = snd_soc_component_set_jack(component, jack, NULL); + if (ret) { + dev_err(rtd->dev, "fail to set component jack, ret %d\n", ret); + return ret; + } return ret; } -static int ssp1_hw_params(struct snd_pcm_substream *substream, +static int max98373_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *runtime = asoc_substream_to_rtd(substream); @@ -208,7 +171,7 @@ static int ssp1_hw_params(struct snd_pcm_substream *substream, for (j = 0; j < runtime->dai_link->num_codecs; j++) { struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, j); - if (!strcmp(codec_dai->component->name, MAXIM_DEV0_NAME)) { + if (!strcmp(codec_dai->component->name, MAX_98373_DEV0_NAME)) { /* vmon_slot_no = 0 imon_slot_no = 1 for TX slots */ ret = snd_soc_dai_set_tdm_slot(codec_dai, 0x3, 3, 4, 16); if (ret < 0) { @@ -216,7 +179,7 @@ static int ssp1_hw_params(struct snd_pcm_substream *substream, return ret; } } - if (!strcmp(codec_dai->component->name, MAXIM_DEV1_NAME)) { + if (!strcmp(codec_dai->component->name, MAX_98373_DEV1_NAME)) { /* vmon_slot_no = 2 imon_slot_no = 3 for TX slots */ ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xC, 3, 4, 16); if (ret < 0) { @@ -229,19 +192,8 @@ static int ssp1_hw_params(struct snd_pcm_substream *substream, return 0; } -static struct snd_soc_ops ssp1_ops = { - .hw_params = ssp1_hw_params, -}; - -static struct snd_soc_codec_conf max98373_codec_conf[] = { - { - .dlc = COMP_CODEC_CONF(MAXIM_DEV0_NAME), - .name_prefix = "Right", - }, - { - .dlc = COMP_CODEC_CONF(MAXIM_DEV1_NAME), - .name_prefix = "Left", - }, +static const struct snd_soc_ops max98373_ops = { + .hw_params = max98373_hw_params, }; static int hdmi_init(struct snd_soc_pcm_runtime *rtd) @@ -285,13 +237,6 @@ SND_SOC_DAILINK_DEF(ssp0_codec, SND_SOC_DAILINK_DEF(ssp1_pin, DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); -SND_SOC_DAILINK_DEF(ssp1_amps, - DAILINK_COMP_ARRAY( - /* Left */ COMP_CODEC(MAXIM_DEV0_NAME, MAX98373_CODEC_DAI), - /* Right */ COMP_CODEC(MAXIM_DEV1_NAME, MAX98373_CODEC_DAI))); - -SND_SOC_DAILINK_DEF(ssp1_m98360a, - DAILINK_COMP_ARRAY(COMP_CODEC("MX98360A:00", "HiFi"))); SND_SOC_DAILINK_DEF(dmic_pin, DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); @@ -328,8 +273,7 @@ static struct snd_soc_dai_link dais[] = { .no_pcm = 1, .dpcm_playback = 1, .dpcm_capture = 1, /* IV feedback */ - .ops = &ssp1_ops, - SND_SOC_DAILINK_REG(ssp1_pin, ssp1_amps, platform), + SND_SOC_DAILINK_REG(ssp1_pin, max_98373_components, platform), }, { .name = "SSP0-Codec", @@ -383,8 +327,8 @@ static struct snd_soc_dai_link dais[] = { } }; -static struct snd_soc_card card_da7219_m98373 = { - .name = "da7219max", +static struct snd_soc_card card_da7219 = { + .name = "da7219", /* the sof- prefix is added by the core */ .owner = THIS_MODULE, .dai_link = dais, .num_links = ARRAY_SIZE(dais), @@ -394,72 +338,68 @@ static struct snd_soc_card card_da7219_m98373 = { .num_dapm_widgets = ARRAY_SIZE(widgets), .dapm_routes = audio_map, .num_dapm_routes = ARRAY_SIZE(audio_map), - .codec_conf = max98373_codec_conf, - .num_configs = ARRAY_SIZE(max98373_codec_conf), - .fully_routed = true, - .late_probe = card_late_probe, -}; - -static struct snd_soc_card card_da7219_m98360a = { - .name = "da7219max98360a", - .owner = THIS_MODULE, - .dai_link = dais, - .num_links = ARRAY_SIZE(dais), - .controls = m98360a_controls, - .num_controls = ARRAY_SIZE(m98360a_controls), - .dapm_widgets = max98360a_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98360a_widgets), - .dapm_routes = max98360a_map, - .num_dapm_routes = ARRAY_SIZE(max98360a_map), .fully_routed = true, .late_probe = card_late_probe, }; static int audio_probe(struct platform_device *pdev) { - static struct snd_soc_card *card; - struct snd_soc_acpi_mach *mach; + struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; struct card_private *ctx; + unsigned long board_quirk = 0; int ret; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; - /* By default dais[0] is configured for max98373 */ - if (!strcmp(pdev->name, "sof_da7219_mx98360a")) { - dais[0] = (struct snd_soc_dai_link) { - .name = "SSP1-Codec", - .id = 0, - .no_pcm = 1, - .dpcm_playback = 1, - .ignore_pmdown_time = 1, - SND_SOC_DAILINK_REG(ssp1_pin, ssp1_m98360a, platform) }; + if (pdev->id_entry && pdev->id_entry->driver_data) + board_quirk = (unsigned long)pdev->id_entry->driver_data; + + /* backward-compatible with existing devices */ + if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) + card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max98360a", + GFP_KERNEL); + else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) + card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max", + GFP_KERNEL); + + dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk); + + /* speaker amp */ + if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { + max_98360a_dai_link(&dais[0]); + } else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { + dais[0].codecs = max_98373_components; + dais[0].num_codecs = ARRAY_SIZE(max_98373_components); + dais[0].init = max_98373_spk_codec_init; + dais[0].ops = &max98373_ops; /* use local ops */ + + max_98373_set_codec_conf(&card_da7219); } INIT_LIST_HEAD(&ctx->hdmi_pcm_list); - card = (struct snd_soc_card *)pdev->id_entry->driver_data; - card->dev = &pdev->dev; - mach = pdev->dev.platform_data; - ret = snd_soc_fixup_dai_links_platform_name(card, + card_da7219.dev = &pdev->dev; + + ret = snd_soc_fixup_dai_links_platform_name(&card_da7219, mach->mach_params.platform); if (ret) return ret; - snd_soc_card_set_drvdata(card, ctx); + snd_soc_card_set_drvdata(&card_da7219, ctx); - return devm_snd_soc_register_card(&pdev->dev, card); + return devm_snd_soc_register_card(&pdev->dev, &card_da7219); } static const struct platform_device_id board_ids[] = { { .name = "sof_da7219_mx98373", - .driver_data = (kernel_ulong_t)&card_da7219_m98373, + .driver_data = (kernel_ulong_t)(SOF_MAX98373_SPEAKER_AMP_PRESENT), }, { .name = "sof_da7219_mx98360a", - .driver_data = (kernel_ulong_t)&card_da7219_m98360a, + .driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT), }, { } }; @@ -468,7 +408,7 @@ MODULE_DEVICE_TABLE(platform, board_ids); static struct platform_driver audio = { .probe = audio_probe, .driver = { - .name = "sof_da7219_max98_360a_373", + .name = "sof_da7219", .pm = &snd_soc_pm_ops, }, .id_table = board_ids, @@ -476,7 +416,9 @@ static struct platform_driver audio = { module_platform_driver(audio) /* Module information */ -MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver"); +MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver for Dialog codec"); MODULE_AUTHOR("Yong Zhi "); +MODULE_AUTHOR("Brent Lu "); MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); From patchwork Fri Sep 15 12:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723959 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 61597EE645A for ; Fri, 15 Sep 2023 12:46:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8A6B6E94; Fri, 15 Sep 2023 14:46:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8A6B6E94 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694782013; bh=1kwE9seIr5/tHV4m+d3hWE9sBvRHG8fh4F5WRVDEh7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=g8eayyqtLu8H+dl7Qd7Hk9kja8ZrrgAivcsQvHn4sgbVq2IBPxr8mEN58wNhYycIW 5bGFtD478mEsPiqBe9Bu7aGR9xlXjQuE5NJBPKCSw+FWY7bhXsNgLilzVgliXv9Kl0 6zGykKaFBpvLEduOCvCYhsxPUzn5Ww2iB06DTD8I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34598F80676; Fri, 15 Sep 2023 14:41:27 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 368EAF8065E; Fri, 15 Sep 2023 14:41:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6A839F80601; Fri, 15 Sep 2023 14:41:04 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 9F741F805E6 for ; Fri, 15 Sep 2023 14:40:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9F741F805E6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=T5PAglZQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781658; x=1726317658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1kwE9seIr5/tHV4m+d3hWE9sBvRHG8fh4F5WRVDEh7I=; b=T5PAglZQYGY0Ollu5spnJIiInwB+lyTDwQj2oU8caUl5yO+WZEhRN5Sp Hnk3/c0QsbOUUXUsrsIm1DHQCkZYJbXneDpw8+8GN7FkgJcMPNd3z0ODR GuxquQQsoKPV+hNS2St47ewnsJK1+IjX0pyuqClTpqPJphIchvemUryrK NTBrvtPmkMIvxtLJrbGL8mtUMjAEOmG/2ACAa0RrtVB4rUjlKJf0vKZBq 1kkYCHOWqyTnPG9KxdGa0yhR6gFeBZX6fe/HR5kTu023IXZJFmF9b1CJZ 8wJVbGIUqF9xPhuO30j+1QVX9ApSlCHltunl4+rCEkjV3aGGXpy4cT04K Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653264" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653264" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304717" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304717" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:53 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 18/19] ASoC: Intel: sof_da7219: add adl_mx98360_da7219 board config Date: Fri, 15 Sep 2023 20:48:51 +0800 Message-Id: <20230915124852.1696857-19-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: NFF62TFM5DLYTGGHL7LTABWZ7WCKYLS7 X-Message-ID-Hash: NFF62TFM5DLYTGGHL7LTABWZ7WCKYLS7 X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu This configuration supports ADL boards which implement DA7219 on SSP0 and MAX98360A on SSP1. DA7219 uses PLL bypass mode to avoid WCLK locking problem. To use this mode, MCLK frequency must be 12.288 or 24.576MHz. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/sof_da7219.c | 192 ++++++++++++++++-- .../intel/common/soc-acpi-intel-adl-match.c | 7 + 2 files changed, 178 insertions(+), 21 deletions(-) diff --git a/sound/soc/intel/boards/sof_da7219.c b/sound/soc/intel/boards/sof_da7219.c index c204c3dfd133..9fe9fe5e795d 100644 --- a/sound/soc/intel/boards/sof_da7219.c +++ b/sound/soc/intel/boards/sof_da7219.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../../codecs/da7219.h" #include "hda_dsp_common.h" #include "sof_maxim_common.h" @@ -23,6 +24,9 @@ #define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(0) #define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(1) +/* Board Quirks */ +#define SOF_DA7219_JSL_BOARD BIT(2) + #define DIALOG_CODEC_DAI "da7219-hifi" struct hdmi_pcm { @@ -35,6 +39,8 @@ struct card_private { struct snd_soc_jack headset_jack; struct list_head hdmi_pcm_list; struct snd_soc_jack hdmi[3]; + + unsigned int pll_bypass:1; }; static int platform_clock_control(struct snd_soc_dapm_widget *w, @@ -42,9 +48,14 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, { struct snd_soc_dapm_context *dapm = w->dapm; struct snd_soc_card *card = dapm->card; + struct card_private *ctx = snd_soc_card_get_drvdata(card); struct snd_soc_dai *codec_dai; int ret = 0; + if (ctx->pll_bypass) + return ret; + + /* PLL SRM mode */ codec_dai = snd_soc_card_get_codec_dai(card, DIALOG_CODEC_DAI); if (!codec_dai) { dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); @@ -57,6 +68,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, if (ret) dev_err(card->dev, "failed to stop PLL: %d\n", ret); } else if (SND_SOC_DAPM_EVENT_ON(event)) { + dev_dbg(card->dev, "pll srm mode\n"); + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, 0, DA7219_PLL_FREQ_OUT_98304); if (ret) @@ -124,16 +137,38 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_component *component = codec_dai->component; struct snd_soc_jack *jack = &ctx->headset_jack; - int ret; + int mclk_rate, ret; - /* Configure sysclk for codec */ - ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24000000, + mclk_rate = sof_dai_get_mclk(rtd); + if (mclk_rate <= 0) { + dev_err(rtd->dev, "invalid mclk freq %d\n", mclk_rate); + return -EINVAL; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, mclk_rate, SND_SOC_CLOCK_IN); if (ret) { - dev_err(rtd->dev, "can't set codec sysclk configuration\n"); + dev_err(rtd->dev, "fail to set sysclk, ret %d\n", ret); return ret; } + /* + * Use PLL bypass mode if MCLK is available, be sure to set the + * frequency of MCLK to 12.288 or 24.576MHz on topology side. + */ + if (mclk_rate == 12288000 || mclk_rate == 24576000) { + /* PLL bypass mode */ + dev_dbg(rtd->dev, "pll bypass mode, mclk rate %d\n", mclk_rate); + + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_MCLK, 0, 0); + if (ret) { + dev_err(rtd->dev, "fail to set pll, ret %d\n", ret); + return ret; + } + + ctx->pll_bypass = 1; + } + /* * Headset buttons map to the google Reference headset. * These can be configured by userspace. @@ -238,6 +273,11 @@ SND_SOC_DAILINK_DEF(ssp0_codec, SND_SOC_DAILINK_DEF(ssp1_pin, DAILINK_COMP_ARRAY(COMP_CPU("SSP1 Pin"))); +SND_SOC_DAILINK_DEF(ssp2_pin, + DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin"))); +SND_SOC_DAILINK_DEF(dummy_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("snd-soc-dummy", "snd-soc-dummy-dai"))); + SND_SOC_DAILINK_DEF(dmic_pin, DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); SND_SOC_DAILINK_DEF(dmic_codec, @@ -261,10 +301,15 @@ SND_SOC_DAILINK_DEF(idisp3_pin, SND_SOC_DAILINK_DEF(idisp3_codec, DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); +SND_SOC_DAILINK_DEF(idisp4_pin, + DAILINK_COMP_ARRAY(COMP_CPU("iDisp4 Pin"))); +SND_SOC_DAILINK_DEF(idisp4_codec, + DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi4"))); + SND_SOC_DAILINK_DEF(platform, /* subject to be overridden during probe */ DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3"))); -static struct snd_soc_dai_link dais[] = { +static struct snd_soc_dai_link jsl_dais[] = { /* Back End DAI links */ { .name = "SSP1-Codec", @@ -327,11 +372,88 @@ static struct snd_soc_dai_link dais[] = { } }; +static struct snd_soc_dai_link adl_dais[] = { + /* Back End DAI links */ + { + .name = "SSP0-Codec", + .id = 0, + .no_pcm = 1, + .init = da7219_codec_init, + .ignore_pmdown_time = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(ssp0_pin, ssp0_codec, platform), + }, + { + .name = "dmic01", + .id = 1, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform), + }, + { + .name = "dmic16k", + .id = 2, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(dmic16k_pin, dmic_codec, platform), + }, + { + .name = "iDisp1", + .id = 3, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp1_pin, idisp1_codec, platform), + }, + { + .name = "iDisp2", + .id = 4, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp2_pin, idisp2_codec, platform), + }, + { + .name = "iDisp3", + .id = 5, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp3_pin, idisp3_codec, platform), + }, + { + .name = "iDisp4", + .id = 6, + .init = hdmi_init, + .dpcm_playback = 1, + .no_pcm = 1, + SND_SOC_DAILINK_REG(idisp4_pin, idisp4_codec, platform), + }, + { + .name = "SSP1-Codec", + .id = 7, + .no_pcm = 1, + .dpcm_playback = 1, + /* feedback stream or firmware-generated echo reference */ + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(ssp1_pin, max_98373_components, platform), + }, + { + .name = "SSP2-BT", + .id = 8, + .no_pcm = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + SND_SOC_DAILINK_REG(ssp2_pin, dummy_codec, platform), + }, +}; + static struct snd_soc_card card_da7219 = { .name = "da7219", /* the sof- prefix is added by the core */ .owner = THIS_MODULE, - .dai_link = dais, - .num_links = ARRAY_SIZE(dais), .controls = controls, .num_controls = ARRAY_SIZE(controls), .dapm_widgets = widgets, @@ -345,9 +467,10 @@ static struct snd_soc_card card_da7219 = { static int audio_probe(struct platform_device *pdev) { struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; + struct snd_soc_dai_link *dai_links; struct card_private *ctx; unsigned long board_quirk = 0; - int ret; + int ret, amp_idx; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -356,28 +479,49 @@ static int audio_probe(struct platform_device *pdev) if (pdev->id_entry && pdev->id_entry->driver_data) board_quirk = (unsigned long)pdev->id_entry->driver_data; - /* backward-compatible with existing devices */ - if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) - card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max98360a", - GFP_KERNEL); - else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) - card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max", - GFP_KERNEL); + if (board_quirk & SOF_DA7219_JSL_BOARD) { + /* backward-compatible with existing devices */ + if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) + card_da7219.name = devm_kstrdup(&pdev->dev, + "da7219max98360a", + GFP_KERNEL); + else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) + card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max", + GFP_KERNEL); + + dai_links = jsl_dais; + amp_idx = 0; + + card_da7219.num_links = ARRAY_SIZE(jsl_dais); + } else { + dai_links = adl_dais; + amp_idx = 7; + + card_da7219.num_links = ARRAY_SIZE(adl_dais); + } dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk); /* speaker amp */ if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { - max_98360a_dai_link(&dais[0]); + max_98360a_dai_link(&dai_links[amp_idx]); } else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { - dais[0].codecs = max_98373_components; - dais[0].num_codecs = ARRAY_SIZE(max_98373_components); - dais[0].init = max_98373_spk_codec_init; - dais[0].ops = &max98373_ops; /* use local ops */ + dai_links[amp_idx].codecs = max_98373_components; + dai_links[amp_idx].num_codecs = ARRAY_SIZE(max_98373_components); + dai_links[amp_idx].init = max_98373_spk_codec_init; + if (board_quirk & SOF_DA7219_JSL_BOARD) { + dai_links[amp_idx].ops = &max98373_ops; /* use local ops */ + } else { + /* TBD: implement the amp for later platform */ + dev_err(&pdev->dev, "max98373 not support yet\n"); + return -EINVAL; + } max_98373_set_codec_conf(&card_da7219); } + card_da7219.dai_link = dai_links; + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); card_da7219.dev = &pdev->dev; @@ -395,10 +539,16 @@ static int audio_probe(struct platform_device *pdev) static const struct platform_device_id board_ids[] = { { .name = "sof_da7219_mx98373", - .driver_data = (kernel_ulong_t)(SOF_MAX98373_SPEAKER_AMP_PRESENT), + .driver_data = (kernel_ulong_t)(SOF_MAX98373_SPEAKER_AMP_PRESENT | + SOF_DA7219_JSL_BOARD), }, { .name = "sof_da7219_mx98360a", + .driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT | + SOF_DA7219_JSL_BOARD), + }, + { + .name = "adl_mx98360_da7219", .driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT), }, { } diff --git a/sound/soc/intel/common/soc-acpi-intel-adl-match.c b/sound/soc/intel/common/soc-acpi-intel-adl-match.c index 4e9787870f60..b513eceb60c3 100644 --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c @@ -614,6 +614,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { .quirk_data = &adl_rt5650_amp, .sof_tplg_filename = "sof-adl-rt5650.tplg", }, + { + .id = "DLGS7219", + .drv_name = "adl_mx98360_da7219", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &adl_max98360a_amp, + .sof_tplg_filename = "sof-adl-max98360a-da7219.tplg", + }, /* place amp-only boards in the end of table */ { .id = "CSC3541", From patchwork Fri Sep 15 12:48:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Bard" X-Patchwork-Id: 723162 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3F637EE6457 for ; Fri, 15 Sep 2023 12:47:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 72348E84; Fri, 15 Sep 2023 14:46:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 72348E84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1694782028; bh=seFLRDX7sQMghpahCaXfUPpjzxPsuqdphMzdpg6AJ7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ffYDhIamhyPaFTEHvjXDDmVXmr1I2m26tPIjd8JFlsqdoSTeSknAZTxKs4X2ljF4g 7VriNtSXGi0yFGJVc5WmAHi2N5ENhaTYpUrgQ6umHqvFaYDvq4RS/rJyu+gNIz8UrU t+MmuKPwdy3Nu3RQTVHn98ssYJ++FSmBwyWtQ+lU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9995FF80680; Fri, 15 Sep 2023 14:41:28 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 0D463F80680; Fri, 15 Sep 2023 14:41:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E88A9F8060D; Fri, 15 Sep 2023 14:41:05 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (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 CAEB1F805F8 for ; Fri, 15 Sep 2023 14:40:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CAEB1F805F8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Os72Zkn3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694781660; x=1726317660; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=seFLRDX7sQMghpahCaXfUPpjzxPsuqdphMzdpg6AJ7A=; b=Os72Zkn3atSYeJh1MAL1arffXfna3loRJrWYsKoD7jvWlrLyT5PQBVYC NBXVicVXrE4RjKtZvjLBo2HclA8bPw65VVh3ceJPkkqJRNuuwN9LvlyQp s9Y1h963AkNyc9bSFUBZo+oARSHOBjYkjdHPVGe2AD+A2cdeTUaS26ruL PDDYwLgtIorS6Jewo2AAHLPQ5eooD5HcLc+FPH6UVFn+Ec97x7Gtqlrzb CEM2IJgLapsXfDTgSjvtIiuMQ1kpJKObVGGA7cdcRR563QPYAaYqfrk78 P06sQyveiNMyzW4syxyl32xIRB72L9fXk2QjQqGGtY2rn/AOgM2UXjgQZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="358653273" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="358653273" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="774304738" X-IronPort-AV: E=Sophos;i="6.02,149,1688454000"; d="scan'208";a="774304738" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2023 05:40:55 -0700 From: Bard Liao To: broonie@kernel.org, tiwai@suse.de Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, bard.liao@intel.com, peter.ujfalusi@linux.intel.com, brent.lu@intel.com, uday.m.bhat@intel.com, balamurugan.c@intel.com Subject: [PATCH 19/19] ASoC: Intel: sof_da7219: use ssp-common module to detect codec Date: Fri, 15 Sep 2023 20:48:52 +0800 Message-Id: <20230915124852.1696857-20-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> References: <20230915124852.1696857-1-yung-chuan.liao@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: 7ADZEAQDRGJG5TWABPCG2KRABPGHA4LP X-Message-ID-Hash: 7ADZEAQDRGJG5TWABPCG2KRABPGHA4LP X-MailFrom: yung-chuan.liao@linux.intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Brent Lu Use ssp-common module to detect codec and amplifier type in driver probe function and remove all quirks about amplifier type. Signed-off-by: Brent Lu Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao --- sound/soc/intel/boards/Kconfig | 1 + sound/soc/intel/boards/sof_da7219.c | 45 ++++++++++++------- .../intel/common/soc-acpi-intel-jsl-match.c | 12 ++--- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 6c97e22f248c..fa3252b6f1bf 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -621,6 +621,7 @@ config SND_SOC_INTEL_SOF_DA7219_MACH select SND_SOC_MAX98373_I2C select SND_SOC_DMIC select SND_SOC_INTEL_SOF_MAXIM_COMMON + select SND_SOC_INTEL_SOF_SSP_COMMON help This adds support for ASoC machine driver for SOF platforms with Dialog DA7219 I2S audio codec. diff --git a/sound/soc/intel/boards/sof_da7219.c b/sound/soc/intel/boards/sof_da7219.c index 9fe9fe5e795d..6a71d5871938 100644 --- a/sound/soc/intel/boards/sof_da7219.c +++ b/sound/soc/intel/boards/sof_da7219.c @@ -17,12 +17,7 @@ #include "../../codecs/da7219.h" #include "hda_dsp_common.h" #include "sof_maxim_common.h" - -/* Speaker amp type - * TBD: use ssp-common module for type detection - */ -#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(0) -#define SOF_MAX98373_SPEAKER_AMP_PRESENT BIT(1) +#include "sof_ssp_common.h" /* Board Quirks */ #define SOF_DA7219_JSL_BOARD BIT(2) @@ -39,6 +34,8 @@ struct card_private { struct snd_soc_jack headset_jack; struct list_head hdmi_pcm_list; struct snd_soc_jack hdmi[3]; + enum sof_ssp_codec codec_type; + enum sof_ssp_codec amp_type; unsigned int pll_bypass:1; }; @@ -479,15 +476,24 @@ static int audio_probe(struct platform_device *pdev) if (pdev->id_entry && pdev->id_entry->driver_data) board_quirk = (unsigned long)pdev->id_entry->driver_data; + ctx->codec_type = sof_ssp_detect_codec_type(&pdev->dev); + ctx->amp_type = sof_ssp_detect_amp_type(&pdev->dev); + if (board_quirk & SOF_DA7219_JSL_BOARD) { /* backward-compatible with existing devices */ - if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) + switch (ctx->amp_type) { + case CODEC_MAX98360A: card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max98360a", GFP_KERNEL); - else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) + break; + case CODEC_MAX98373: card_da7219.name = devm_kstrdup(&pdev->dev, "da7219max", GFP_KERNEL); + break; + default: + break; + } dai_links = jsl_dais; amp_idx = 0; @@ -503,9 +509,11 @@ static int audio_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "board_quirk = %lx\n", board_quirk); /* speaker amp */ - if (board_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { + switch (ctx->amp_type) { + case CODEC_MAX98360A: max_98360a_dai_link(&dai_links[amp_idx]); - } else if (board_quirk & SOF_MAX98373_SPEAKER_AMP_PRESENT) { + break; + case CODEC_MAX98373: dai_links[amp_idx].codecs = max_98373_components; dai_links[amp_idx].num_codecs = ARRAY_SIZE(max_98373_components); dai_links[amp_idx].init = max_98373_spk_codec_init; @@ -518,6 +526,10 @@ static int audio_probe(struct platform_device *pdev) } max_98373_set_codec_conf(&card_da7219); + break; + default: + dev_err(&pdev->dev, "invalid amp type %d\n", ctx->amp_type); + return -EINVAL; } card_da7219.dai_link = dai_links; @@ -538,18 +550,16 @@ static int audio_probe(struct platform_device *pdev) static const struct platform_device_id board_ids[] = { { - .name = "sof_da7219_mx98373", - .driver_data = (kernel_ulong_t)(SOF_MAX98373_SPEAKER_AMP_PRESENT | - SOF_DA7219_JSL_BOARD), + .name = "jsl_mx98373_da7219", + .driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD), }, { - .name = "sof_da7219_mx98360a", - .driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT | - SOF_DA7219_JSL_BOARD), + .name = "jsl_mx98360_da7219", + .driver_data = (kernel_ulong_t)(SOF_DA7219_JSL_BOARD), }, { .name = "adl_mx98360_da7219", - .driver_data = (kernel_ulong_t)(SOF_MAX98360A_SPEAKER_AMP_PRESENT), + /* no quirk needed for this board */ }, { } }; @@ -572,3 +582,4 @@ MODULE_AUTHOR("Brent Lu "); MODULE_LICENSE("GPL v2"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); +MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_SSP_COMMON); diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c index f56bd7d656e9..342bbbb48ca7 100644 --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c @@ -14,7 +14,7 @@ static const struct snd_soc_acpi_codecs essx_83x6 = { .codecs = { "ESSX8316", "ESSX8326", "ESSX8336"}, }; -static const struct snd_soc_acpi_codecs jsl_7219_98373_codecs = { +static const struct snd_soc_acpi_codecs mx98373_spk = { .num_codecs = 1, .codecs = {"MX98373"} }; @@ -52,14 +52,16 @@ static const struct snd_soc_acpi_codecs rt5682_rt5682s_hp = { struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { { .id = "DLGS7219", - .drv_name = "sof_da7219_mx98373", + .drv_name = "jsl_mx98373_da7219", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &mx98373_spk, .sof_tplg_filename = "sof-jsl-da7219.tplg", - .machine_quirk = snd_soc_acpi_codec_list, - .quirk_data = &jsl_7219_98373_codecs, }, { .id = "DLGS7219", - .drv_name = "sof_da7219_mx98360a", + .drv_name = "jsl_mx98360_da7219", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &mx98360a_spk, .sof_tplg_filename = "sof-jsl-da7219-mx98360a.tplg", }, {