From nobody Fri May 8 10:48:39 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81622C433EF for ; Wed, 4 May 2022 12:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349410AbiEDM2h (ORCPT ); Wed, 4 May 2022 08:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344781AbiEDM2f (ORCPT ); Wed, 4 May 2022 08:28:35 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E632F3A5 for ; Wed, 4 May 2022 05:24:59 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id n18so1261662plg.5 for ; Wed, 04 May 2022 05:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wistron-corp-partner-google-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ia6J6ecVQth7LprTSYDN+sS3yG8ad7uwU+6MUPOPuF8=; b=FsrUXo2XEvi2QZtsILA1nLRZMe1fOrx4bHf+qcaexl0Kcl14X0E3aJynR8L6TqvWfb bnDqboIJGJ83Ol4+pjBy+d2lsWgwNGGa7IX6NSye5quUqvtI37hBGxwH9c6aSnDaYeI8 1U9f+Yk7pXctvYr1pbsviflRW2B+GhgeOoIOp9Dzt9Op7qG9GOUYNWfeXcYKaR4r4OWx Czces0d8gnTA2qSiHXkagAhZ07ma/vdWAORvA/KnV5MZhD1c8LxGaMEAZS68MXrwXhKw ZPnbDLcgSMMskkrx98sb6EiFF1TWI4tUt7kwmn+KklhToWSDXQyj0D6L8+EI03V112Oq OOcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ia6J6ecVQth7LprTSYDN+sS3yG8ad7uwU+6MUPOPuF8=; b=W0PO7NxNliLio5hmLbbQ1Gy9BMdkFWb0+c7OLhzNKI7yqMNGQ6qLI017ys33hjgjgE Peoun1SofMXArM1RXVHxWpU8oFtTFM/v6N6CBDD3SPqvRPiy1mQhRhYghrGgberdJlRQ mR91kCHjKzHj0pEkobB5pW42aaCBcUevkIkbjoRl/+UC92hQlvUwZ2ycJbxlJ6eBzoo2 GxFfoxNHnQ8oPsFNqwPTu+lt3c5WZlm7Ifip2K6e6CWJ6dv6rOPvjOMo15hfuwzHuYYU Zrx9Ssj3cfjNfYWNJkVZSqSOBrD5RPcfwxMbfLScyIMcQSUqLj/PxMvHT+wweSYKxUMH 8luw== X-Gm-Message-State: AOAM532DTgEkwM78JFyoHgVotSo3thvWHugWQOBb4qlKZ32tQYHxvjjs PSUfTKyv7SJr9/3jAbkFt8pMHw== X-Google-Smtp-Source: ABdhPJyKtl8PI8gw+2iG8YOLfDIa8Ut3L4qs8z4nVM+/Jd1+LR4X2IThA9GRDetdxR1rckk5xXFDRQ== X-Received: by 2002:a17:902:f541:b0:15e:ba32:12b0 with SMTP id h1-20020a170902f54100b0015eba3212b0mr6754240plf.90.1651667098731; Wed, 04 May 2022 05:24:58 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:57a:4e1a:8455:9f66:5a20:586a]) by smtp.gmail.com with ESMTPSA id j18-20020a170902da9200b0015e8d4eb2aasm1095517plx.244.2022.05.04.05.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 05:24:58 -0700 (PDT) From: Terry Chen To: alsa-devel@alsa-project.org Cc: cezary.rojewski@intel.com, pierre-louis.bossart@linux.intel.com, liam.r.girdwood@linux.intel.com, yang.jie@linux.intel.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, brent.lu@intel.com, cujomalainey@chromium.org, seanpaul@chromium.org, terry_chen@wistron.corp-partner.google.com, casey.g.bowman@intel.com, mark_hsieh@wistron.corp-partner.google.com, vamshi.krishna.gopal@intel.com, mac.chiang@intel.com, kai.vehmanen@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: Intel: sof_cs42l42: add support for adl_mx98360a_cs4242 and BT offload audio Date: Wed, 4 May 2022 20:24:50 +0800 Message-Id: <20220504122450.117256-1-terry_chen@wistron.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Also add the capability to machine=20 driver of creating DAI Link for BT offload. Although BT offload=20 always uses SSP2 port but we reserve the flexibility to assign=20 the port number in macro. Signed-off-by: Terry Chen --- sound/soc/intel/boards/sof_cs42l42.c | 88 ++++++++++++++++++- .../intel/common/soc-acpi-intel-adl-match.c | 8 ++ 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/= sof_cs42l42.c index ce78c18798876..4ac4f51c7c115 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) =20 enum { LINK_NONE =3D 0, @@ -50,6 +55,7 @@ enum { LINK_SPK =3D 2, LINK_DMIC =3D 3, LINK_HDMI =3D 4, + LINK_BT =3D 5, }; =20 /* Default: SSP2 */ @@ -278,6 +284,13 @@ static struct snd_soc_dai_link_component dmic_componen= t[] =3D { } }; =20 +static struct snd_soc_dai_link_component dummy_component[] =3D { + { + .name =3D "snd-soc-dummy", + .dai_name =3D "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, @@ -467,9 +480,52 @@ static int create_hdmi_dai_links(struct device *dev, return -ENOMEM; } =20 +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) +{ + int ret =3D 0; + + /* bt offload */ + if (!(sof_cs42l42_quirk & SOF_BT_OFFLOAD_PRESENT)) + return 0; + + links[*id].name =3D devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", + ssp_bt); + if (!links[*id].name) + goto devm_err; + + links[*id].id =3D *id; + links[*id].codecs =3D dummy_component; + links[*id].num_codecs =3D ARRAY_SIZE(dummy_component); + links[*id].platforms =3D platform_component; + links[*id].num_platforms =3D ARRAY_SIZE(platform_component); + + links[*id].dpcm_playback =3D 1; + links[*id].dpcm_capture =3D 1; + links[*id].no_pcm =3D 1; + links[*id].cpus =3D &cpus[*id]; + links[*id].num_cpus =3D 1; + + links[*id].cpus->dai_name =3D 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 ret; +} + static struct snd_soc_dai_link *sof_card_dai_links_create(struct device *d= ev, int ssp_codec, int ssp_amp, + int ssp_bt, int dmic_be_num, int hdmi_num) { @@ -522,6 +578,14 @@ static struct snd_soc_dai_link *sof_card_dai_links_cre= ate(struct device *dev, goto devm_err; } break; + case LINK_BT: + ret =3D 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: @@ -543,7 +607,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; =20 ctx =3D devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -568,6 +632,9 @@ static int sof_audio_probe(struct platform_device *pdev) =20 dev_dbg(&pdev->dev, "sof_cs42l42_quirk =3D %lx\n", sof_cs42l42_quirk); =20 + ssp_bt =3D (sof_cs42l42_quirk & SOF_CS42L42_SSP_BT_MASK) >> + SOF_CS42L42_SSP_BT_SHIFT; + ssp_amp =3D (sof_cs42l42_quirk & SOF_CS42L42_SSP_AMP_MASK) >> SOF_CS42L42_SSP_AMP_SHIFT; =20 @@ -578,9 +645,11 @@ static int sof_audio_probe(struct platform_device *pde= v) =20 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++; =20 dai_links =3D 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; =20 @@ -621,6 +690,17 @@ static const struct platform_device_id board_ids[] =3D= { SOF_CS42L42_SSP_AMP(1)) | SOF_CS42L42_DAILINK(LINK_HP, LINK_DMIC, LINK_HDMI, LINK_SPK, LINK_NON= E), }, + { + .name =3D "adl_mx98360a_cs4242", + .driver_data =3D (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 7c8cd00457f81..3f40519250a90 100644 --- a/sound/soc/intel/common/soc-acpi-intel-adl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-adl-match.c @@ -384,6 +384,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_adl_machin= es[] =3D { .sof_fw_filename =3D "sof-adl.ri", .sof_tplg_filename =3D "sof-adl-cs35l41.tplg", }, + { + .id =3D "10134242", + .drv_name =3D "adl_mx98360a_cs4242", + .machine_quirk =3D snd_soc_acpi_codec_list, + .quirk_data =3D &adl_max98360a_amp, + .sof_fw_filename =3D "sof-adl.ri", + .sof_tplg_filename =3D "sof-adl-max98360a-rt5682.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines); --=20 2.31.0