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;