From patchwork Tue May 10 10:48:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Chen X-Patchwork-Id: 571231 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 479C0C433FE for ; Tue, 10 May 2022 12:25:30 +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 7515C18D0; Tue, 10 May 2022 14:24:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7515C18D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1652185528; bh=X9OFzLsQnWbP2/imtLgj2cpqY/ekaOkvsMGLWNA7TmQ=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=XSqCCqvEgOcEjRj+ncI++A/aBUFAfp0OasbFqxvyR4OvE8WUXbqnLRfTzkDik42KJ BH3SIYqAOllu4hR/H9Nk6C/YS3Vj2vTq2Ygj6VU4taZOsD1gDHofhUkZN6WLNrNwOx qdi8Qu9l8IaUWUubx1e+FjwtQj5drKqEtThtaBJY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 437F8F80549; Tue, 10 May 2022 14:21:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3E8DF8019D; Tue, 10 May 2022 12:48:47 +0200 (CEST) Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A72D5F8011C for ; Tue, 10 May 2022 12:48:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A72D5F8011C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=wistron-corp-partner-google-com.20210112.gappssmtp.com header.i=@wistron-corp-partner-google-com.20210112.gappssmtp.com header.b="ZPJGsNyK" Received: by mail-pj1-x1032.google.com with SMTP id iq10so15557236pjb.0 for ; Tue, 10 May 2022 03:48:44 -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=bam77pW4WQ0BjM14bDRbAzEv9hcIsmwj3Yj+IFh8xIE=; b=ZPJGsNyKRAOZbvpKi9FIImkEHmnu+lLPrjrKvHNuFoO+q3sE+uOS2y6ZgeheRIOv3b RKd2ns5C8BZO/HEYGt2TCwkgIj7IKrngYAknECuZ8vvFKjcbM50OGCo4rnpkXa2Zi3w2 jElI7Z5/dCIG/2CTi31hYbpP5HKW++iWRn9PKgxwQ2xcNKJFCvTnvmVoeKOgZHuIRvZ1 XQ6H7G3NMdRWu7OkVL42neCrXqcIMxyYu1ZWMnMp2Tc5ny3VCod7bfFRmwbmP5uZGRXx EpVOzSFMcGEe0c14WcjIvbqBvE9iS8vfqWj5ys+H5l3ktyPh32r4ETh9bT2Hgf7QCMRy bRLQ== 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=bam77pW4WQ0BjM14bDRbAzEv9hcIsmwj3Yj+IFh8xIE=; b=RoyPduvxjmbKDRDKZLLTQ5bfbG58RtA+c3kTYzFidrFogyxHecinyowNz82dl6ONgb zIB5YljyGez2QAeBSVqpQQLYP6Hl1skE5iR31YgkrNdbOaN6aYlT3IRvFCpZTJXsEFM0 1YF/13pMBycFJimemXbWAKoTSNRq4Ze0lqty97U/Ko9qre8Nrn9xrpoI3F6yYFK+DEiC 1+y5VKU/ZVZk3UtyeEuuqIsxGnmI1HB5ZGZ/aeSqGRpxXc3rCZm6Mivdj2c0NbdEF88r TFAk8gGF9BtKNQPHF62Ohz2pt8mjqZG02KXZVWQOadTtL6fVXf3sSxX97TL18KrsokoE Nhzg== X-Gm-Message-State: AOAM531SFcVQ1gBv1YD/bEvXxaUrlgUVKDdcQUK7G3xDk/Vz59JrE2b3 YWQG0o6g7yoGH1AmdD9uBbpID/nsdXf+EUBtH+M= X-Google-Smtp-Source: ABdhPJztJqTzISk4eY1BjsrTXTuUHRQ204kQt7PPOb8vACKLz1xdoGao5WkwswUO1kvtMFYZRp7vAQ== X-Received: by 2002:a17:903:290:b0:15c:1c87:e66c with SMTP id j16-20020a170903029000b0015c1c87e66cmr20352223plr.61.1652179722170; Tue, 10 May 2022 03:48:42 -0700 (PDT) Received: from localhost.localdomain ([2402:7500:477:8ff1:8756:be0d:f5eb:1876]) by smtp.gmail.com with ESMTPSA id p10-20020a17090a930a00b001cd4989ff65sm1506878pjo.44.2022.05.10.03.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 03:48:41 -0700 (PDT) From: Terry Chen To: alsa-devel@alsa-project.org Subject: [PATCH] [v2] ASoC: Intel: sof_cs42l42: adding support for ADL configuration and BT offload audio Date: Tue, 10 May 2022 18:48:29 +0800 Message-Id: <20220510104829.1466968-1-terry_chen@wistron.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 May 2022 14:21:49 +0200 Cc: terry_chen@wistron.corp-partner.google.com, cezary.rojewski@intel.com, casey.g.bowman@intel.com, kai.vehmanen@linux.intel.com, linux-kernel@vger.kernel.org, tiwai@suse.com, yang.jie@linux.intel.com, pierre-louis.bossart@linux.intel.com, mark_hsieh@wistron.corp-partner.google.com, liam.r.girdwood@linux.intel.com, mac.chiang@intel.com, broonie@kernel.org, seanpaul@chromium.org, cujomalainey@chromium.org, brent.lu@intel.com, vamshi.krishna.gopal@intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To be able to do 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 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: 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) enum { LINK_NONE = 0, @@ -50,6 +55,7 @@ enum { LINK_SPK = 2, LINK_DMIC = 3, LINK_HDMI = 4, + LINK_BT = 5, }; /* Default: SSP2 */ @@ -278,6 +284,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, @@ -467,9 +480,52 @@ 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) +{ + int ret = 0; + + /* 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 ret; +} + 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) { @@ -522,6 +578,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: @@ -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; ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) @@ -568,6 +632,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; @@ -578,9 +645,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; @@ -621,6 +690,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 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_machines[] = { .sof_fw_filename = "sof-adl.ri", .sof_tplg_filename = "sof-adl-cs35l41.tplg", }, + { + .id = "10134242", + .drv_name = "adl_mx98360a_cs4242", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &adl_max98360a_amp, + .sof_fw_filename = "sof-adl.ri", + .sof_tplg_filename = "sof-adl-max98360a-rt5682.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_adl_machines);