From patchwork Fri Jul 8 11:00:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brent Lu X-Patchwork-Id: 12911000 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 C1BA4C433EF for ; Fri, 8 Jul 2022 11:02:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B9D4A164D; Fri, 8 Jul 2022 13:01:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B9D4A164D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1657278128; bh=/wjtNKClKiwgx+CFJjG7HC5vs4Liykwkw/ovK1d+1uY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=d1/53lnTBVlLIrLpYeLWQHfsC+Bp0ZpAZ+w2fBQoGcQ0DyS+Z2d8N7i49ZMY7f49H f1bZvkdZtWlaPeUrUcGTXZuBe7v+PuH5akI6Sk0rWZubONrNbzFrhR2q+glsVuoGsY vSzFASVHRaqjaZKr0o3Fez0XgXDDRs/Z3B5ib40Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 64AA6F80538; Fri, 8 Jul 2022 13:00:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 68F63F800C5; Fri, 8 Jul 2022 13:00:57 +0200 (CEST) Received: from mga12.intel.com (mga12.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 A19D6F800C5 for ; Fri, 8 Jul 2022 13:00:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A19D6F800C5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EZpwjjmu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657278051; x=1688814051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/wjtNKClKiwgx+CFJjG7HC5vs4Liykwkw/ovK1d+1uY=; b=EZpwjjmuNkesiW11WQ3VQgk2MehJFj/nkuHV/gNdBe7VOYVz0PVCi9HV jllosX383zMd5JoHqa4azdZj7o5HOK9ZnvMxGCnIilfgPYUsAymZopOh3 Qm/GEd0IHzVvRs1UDFAyc6HzwcduvQyFgVxDsRQ41QS3CuAFoP9sW3YaH TK3SjsI42WJKALb+gcAeNNtmgm4YNyCR614cfituLfhs+Li91eFoZrTfS UhbKNA4DKkdK3/Up/OWPibwkh+8B3J4Snx/Zitfj0d2rrSb0g6OVxLoUi qYb2TsZEJJD/rt1Xv0X0GqQI8e1bjNqjbs+Ibs1yc2wXx3gsMDq9I+ck6 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10401"; a="264035552" X-IronPort-AV: E=Sophos;i="5.92,255,1650956400"; d="scan'208";a="264035552" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2022 04:00:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,255,1650956400"; d="scan'208";a="651524670" Received: from brentlu-brix.itwn.intel.com ([10.5.253.25]) by fmsmga008.fm.intel.com with ESMTP; 08 Jul 2022 04:00:40 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Subject: [PATCH v8 1/2] ASoC: Intel: sof_cs42l42: support BT offload audio Date: Fri, 8 Jul 2022 19:00:29 +0800 Message-Id: <20220708110030.658468-2-brent.lu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220708110030.658468-1-brent.lu@intel.com> References: <20220708110030.658468-1-brent.lu@intel.com> MIME-Version: 1.0 Cc: Libin Yang , Cezary Rojewski , Ajye Huang , Kai Vehmanen , Rander Wang , Peter Ujfalusi , Takashi Iwai , Pierre-Louis Bossart , Gongjun Song , Ranjani Sridharan , Liam Girdwood , Mac Chiang , Mark Brown , Muralidhar Reddy , Akihiko Odaki , David Lin , Bard Liao , Brent Lu , linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add the capability to machine driver of creating DAI Link for BT offload. Although BT offload always uses SSP2 port but we reserve the flexibility to assign the port number in macro. Signed-off-by: Brent Lu --- sound/soc/intel/boards/sof_cs42l42.c | 75 ++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c index a1a14d6d7c23..3d53bb420c66 100644 --- a/sound/soc/intel/boards/sof_cs42l42.c +++ b/sound/soc/intel/boards/sof_cs42l42.c @@ -41,8 +41,13 @@ #define SOF_CS42L42_DAILINK_MASK (GENMASK(24, 10)) #define SOF_CS42L42_DAILINK(link1, link2, link3, link4, link5) \ ((((link1) | ((link2) << 3) | ((link3) << 6) | ((link4) << 9) | ((link5) << 12)) << SOF_CS42L42_DAILINK_SHIFT) & SOF_CS42L42_DAILINK_MASK) -#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(25) -#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(26) +#define SOF_BT_OFFLOAD_PRESENT BIT(25) +#define SOF_CS42L42_SSP_BT_SHIFT 26 +#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, @@ -50,6 +55,7 @@ enum { LINK_SPK = 2, LINK_DMIC = 3, LINK_HDMI = 4, + LINK_BT = 5, }; static struct snd_soc_jack_pin jack_pins[] = { @@ -290,6 +296,13 @@ static struct snd_soc_dai_link_component dmic_component[] = { } }; +static struct snd_soc_dai_link_component dummy_component[] = { + { + .name = "snd-soc-dummy", + .dai_name = "snd-soc-dummy-dai", + } +}; + static int create_spk_amp_dai_links(struct device *dev, struct snd_soc_dai_link *links, struct snd_soc_dai_link_component *cpus, @@ -479,9 +492,50 @@ static int create_hdmi_dai_links(struct device *dev, return -ENOMEM; } +static int create_bt_offload_dai_links(struct device *dev, + struct snd_soc_dai_link *links, + struct snd_soc_dai_link_component *cpus, + int *id, int ssp_bt) +{ + /* bt offload */ + if (!(sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)) + return 0; + + links[*id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", + ssp_bt); + if (!links[*id].name) + goto devm_err; + + links[*id].id = *id; + links[*id].codecs = dummy_component; + links[*id].num_codecs = ARRAY_SIZE(dummy_component); + links[*id].platforms = platform_component; + links[*id].num_platforms = ARRAY_SIZE(platform_component); + + links[*id].dpcm_playback = 1; + 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_bt); + if (!links[*id].cpus->dai_name) + goto devm_err; + + (*id)++; + + return 0; + +devm_err: + 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) { @@ -534,6 +588,14 @@ static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *dev, goto devm_err; } break; + case LINK_BT: + ret = create_bt_offload_dai_links(dev, links, cpus, &id, ssp_bt); + if (ret < 0) { + dev_err(dev, "fail to create bt offload dai links, ret %d\n", + ret); + goto devm_err; + } + break; case LINK_NONE: /* caught here if it's not used as terminator in macro */ default: @@ -555,7 +617,7 @@ static int sof_audio_probe(struct platform_device *pdev) struct snd_soc_acpi_mach *mach; struct sof_card_private *ctx; int dmic_be_num, hdmi_num; - int ret, ssp_amp, ssp_codec; + int ret, ssp_bt, ssp_amp, ssp_codec; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -580,6 +642,9 @@ static int sof_audio_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "sof_cs42l42_quirk = %lx\n", sof_cs42l42_quirk); + ssp_bt = (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >> + SOF_CS42L42_SSP_BT_SHIFT; + ssp_amp = (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >> SOF_CS42L42_SSP_AMP_SHIFT; @@ -590,9 +655,11 @@ static int sof_audio_probe(struct platform_device *pdev) if (sof_cs42l42_quirk & SOF_SPEAKER_AMP_PRESENT) 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, - dmic_be_num, hdmi_num); + ssp_bt, dmic_be_num, hdmi_num); if (!dai_links) return -ENOMEM; From patchwork Fri Jul 8 11:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brent Lu X-Patchwork-Id: 12911006 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 4ABF1CCA47B for ; Fri, 8 Jul 2022 11:04:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7F2251614; Fri, 8 Jul 2022 13:03:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7F2251614 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1657278240; bh=HttklPYMVqCkBKla4Z5JeQC9Wp5Ab2UuWXTG+/ppt9Q=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jvJ4KmUEkemHj+LGszvCwBuitybRU9LSzI2vCRlDB6Fx54Mvz32CFgk8xrPfwmrJa S2Fo5iPTUFu+KMaAD5+9yuBeXmbmSAYPqY7kTZ/lYHepp7ycUr4PUirbrnkN/mGsnH tiXJ2Q2PIs0bHPHd8Jx+Q6elxCI8do+7N/Ajdrwc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 300C2F80166; Fri, 8 Jul 2022 13:03:10 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B57DDF80084; Fri, 8 Jul 2022 13:03:09 +0200 (CEST) Received: from mga12.intel.com (mga12.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 01BE3F80084 for ; Fri, 8 Jul 2022 13:03:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 01BE3F80084 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iF3iBtY8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657278184; x=1688814184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HttklPYMVqCkBKla4Z5JeQC9Wp5Ab2UuWXTG+/ppt9Q=; b=iF3iBtY8aVXapre1CSosdy7Kqq8Fs56rkbrzwnGDeFXZnO8b8K4paUCy YWApePRHGhMpn9ICMm2qNQwZl93jIvdK/9qNwFfAszG74oq0zDltFhhvx I+cYEM/eZJsIh1STeO4fzCA2335NMXt2cQRA/MYxoql2FezhPUIpJCSzU yBagOSF62F8FYeecXeNMjisUnflc3cNaj24idXL0DqLXmCFSxWlw++7+v KTPU8N/B7scRc6ZPVfnJrRYGeJ+j2MR7Y8pqXi2P+76ldEGh2p9/v+teA 2SewGS03tFZM63t2uU/DsVVTgDnbn4/GKZVAsfy8gTDYxCwvf54egduS5 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10401"; a="264035912" X-IronPort-AV: E=Sophos;i="5.92,255,1650956400"; d="scan'208";a="264035912" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2022 04:02:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,255,1650956400"; d="scan'208";a="651526186" Received: from brentlu-brix.itwn.intel.com ([10.5.253.25]) by fmsmga008.fm.intel.com with ESMTP; 08 Jul 2022 04:02:55 -0700 From: Brent Lu To: alsa-devel@alsa-project.org Subject: [PATCH v8 2/2] ASoC: Intel: sof_cs42l42: add adl_mx98360a_cs4242 board config Date: Fri, 8 Jul 2022 19:00:30 +0800 Message-Id: <20220708110030.658468-3-brent.lu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220708110030.658468-1-brent.lu@intel.com> References: <20220708110030.658468-1-brent.lu@intel.com> MIME-Version: 1.0 Cc: Libin Yang , Cezary Rojewski , Ajye Huang , Kai Vehmanen , Rander Wang , Peter Ujfalusi , Takashi Iwai , Pierre-Louis Bossart , Gongjun Song , Ranjani Sridharan , Liam Girdwood , Mac Chiang , Mark Brown , Muralidhar Reddy , Akihiko Odaki , David Lin , Bard Liao , Brent Lu , linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This patch adds driver data for adl_mx98360a_cs4242 which supports two max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on SSP0 running on ADL platform. Signed-off-by: Brent Lu --- sound/soc/intel/boards/sof_cs42l42.c | 11 +++++++++++ sound/soc/intel/common/soc-acpi-intel-adl-match.c | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c index 3d53bb420c66..85ffd065895d 100644 --- a/sound/soc/intel/boards/sof_cs42l42.c +++ b/sound/soc/intel/boards/sof_cs42l42.c @@ -700,6 +700,17 @@ static const struct platform_device_id board_ids[] = { 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 | + SOF_CS42L42_SSP_BT(2) | + SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_BT)), + }, { } }; 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 c1385161cdc8..fea087d3fa15 100644 --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c @@ -479,6 +479,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machines[] = { .drv_name = "adl_rt5682", .sof_tplg_filename = "sof-adl-rt5682.tplg", }, + { + .id = "10134242", + .drv_name = "adl_mx98360a_cs4242", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &adl_max98360a_amp, + .sof_tplg_filename = "sof-adl-max98360a-cs42l42.tplg", + }, /* place amp-only boards in the end of table */ { .id = "CSC3541",