From patchwork Mon Nov 1 08:00:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12596043 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2C22C433EF for ; Mon, 1 Nov 2021 08:03:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C3CBB610A2 for ; Mon, 1 Nov 2021 08:03:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C3CBB610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org 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 C122116CA; Mon, 1 Nov 2021 09:02:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C122116CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1635753798; bh=xkn4YHb6rptgE9jOZf7AvbiHtULKfHMCgupPxFwtkXA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VwvDzWMSDlycgsqx/8nGaenzD/ZtSxAuqQ1uYk3HH59QqoZ4sNzPf+jnkJHPrH2wY DXsruQKWqtgdgyf3tCj+PRABfMXNS1yjvuNxHcUhNYyklQcuDy1Ysh250yp59d0npO +myd02+X7ZAVBKF6wysgcqEmxf+O+OwLQLHA+l1Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AD27FF804FE; Mon, 1 Nov 2021 09:01:27 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 15800F804EC; Mon, 1 Nov 2021 09:01:08 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03on061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe09::61b]) (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 E0CA4F8010A for ; Mon, 1 Nov 2021 09:01:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E0CA4F8010A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="X7/8oyK5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKeNsGJd4t8dx2JCM1Q9uIF/OdXjUBhjkbzI734CpZ3VFtuEQp6ycckrWUJM/aBiYp8CgC3mUyqTZ/W86fi3Sds0usxssR9kJlscZ2+BCeuMQFvNTeiMtLkIKq9zxWPS0yuE2TXGQmF1X9Sp5h9cL3A6UPVWmuo+QKZJfS8NNyLBLxPosqPXRPkkP7gz3hC/kRW+5Y+wm7ZlnDW+zKS9uOm8VpdzvCC4Cmyuqa7t4nl96JW1nKdSAcgr/5MtvI7BEGWt1TRWy9337VecirdkkToL24RPTsjC8CNRsh672n0TWteUuZXZWtpjvXD00n/c9pXlPaalwR/2zlczOZmcbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F/3xGWUwSSLI5yvDRcxvTWnoQRrkSl9b0fOqNKLsC4o=; b=BGBkJFnGtBuy/sjDpLw+N+/LVwYxcIBH4E3wOgVFN9Vt57I3uk8Ml4sVu/K7CxzPGIPDy6f79UBs6psaz0aqAEubLdl/1Q8HNnKAImKiF3h0hueB3AtLPZnp8LnPRgd6kRaUbX40FsLVDXc8iceCUVs1KnU+84ieTVAmv/83Vi7NaH2gSRnIiVhImU0aGOT4phODwJ1AU4Pr3DjV4VKBLgirYXa2FR9G5c5YwK4bA8dw2CYvkMOHckFzdNdlc2td/m2ndf4jQX5SAJ+2GQF+9HhK7rJjWcCZpHOTWY8vRY6BKVjlgVmm9LjptTunZWemmSJpgEfzEtfPolIskdF3Ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F/3xGWUwSSLI5yvDRcxvTWnoQRrkSl9b0fOqNKLsC4o=; b=X7/8oyK5o4OvN3KVnqctIbC5eZ+cNczsAvbq0pSW4AKQkAnRrBJx0ngbD1pyn8wUjpc+ygCWjDqDkSoAe9x0mQn6NEPzNnnJnUFtQFYpzlTH/xd5gxc1g4rj0wVPZrPVLFKuDvmeGtt/kVrLx1S/v5qOdfMvMwjzPvVf+etwKJI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR0401MB2430.eurprd04.prod.outlook.com (2603:10a6:800:2b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Mon, 1 Nov 2021 08:00:51 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::85af:f8be:aa99:ba5f%3]) with mapi id 15.20.4649.019; Mon, 1 Nov 2021 08:00:51 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 3/6] ASoC: SOF: topology: Add support for Mediatek AFE DAI Date: Mon, 1 Nov 2021 10:00:23 +0200 Message-Id: <20211101080026.297360-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211101080026.297360-1-daniel.baluta@oss.nxp.com> References: <20211101080026.297360-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR07CA0070.eurprd07.prod.outlook.com (2603:10a6:207:4::28) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5719:1500:cdb2:376b:257c:429a) by AM3PR07CA0070.eurprd07.prod.outlook.com (2603:10a6:207:4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.9 via Frontend Transport; Mon, 1 Nov 2021 08:00:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a3925e6-9b90-44b9-d058-08d99d0db901 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2430: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:608; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c7kgBUQJzIdYrbtdk//+16HYBYX5h6YyQsydMZejR0UVjY+xVQsuex2IiAHrDGTmelImFJlHD6DLMOqs2C8xYkCof2SUuv3qRND80zYCuQgnI1o0ZB0pA0PXTSD2mJprFt0R+XYWAwyRhb7uD5uWpBE9ucIbp0ChyddWFnz3A6QEL16GoXQ8ibk686qUjWmAKDvrkr3TpHvQvHlYXbjQ7wq8JPfWSiehK8PcrSv6uDkHmDOMLWf/KdS9RXBBXY+YF/vIdK9J38MjYJSbRLX339vGf/sOtC6egNzPXq4gFTHJlk+LLDmXQvPUYyU3sqxmMgPM2RbEZ8Z9i7j2Ti+Xnw+in8JV22TpP4HrD58OvSdQjvd7YpbweeHAEKLn1KI+ONz4ez0rMmNo2YcWuDizICFUTB2mgdJG7AZheHmsMMmqeQEfNMYqeStAFhWV1AX73KYTTTnhsOE78xAfINT34o8o1ZuZ1WdErIosWEU7DTN9pzYZpCW+I1Q7SmgQlznpjKqpSuDYnN+Hbi++3DGp0g9md+I1VKoGcidPZkKg4vjKXVDQtcYmp5nxOM77RV9zuWDrEhKwNNFP3D2dcfNn54GHWFXtDGyM1kJNz9D5yX6iCLMj5Jzfp3GeC/phBaNBcrU/dBMst/KGom52otrLIg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(316002)(8676002)(508600001)(54906003)(6486002)(8936002)(6506007)(1076003)(5660300002)(52116002)(6666004)(44832011)(6512007)(66476007)(2906002)(7416002)(2616005)(66946007)(38100700002)(186003)(86362001)(66556008)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0C6yzBAiIWGDbT2juqa50qEA2mDM?= =?utf-8?q?FEzgK0IOHaOC0rExxI7KNlZO0zi1a/pMsMLnbbsv2/JWUCWqRBSDVLdB8rqQ69Y9G?= =?utf-8?q?bXLjnyqEkcUcBXHwE7hX/aCkgUSUehfPfeyduq0fAYQEQEM7ckbi4WX/SSh7wnujx?= =?utf-8?q?zjYnjpG4v5ndz7FGXvAhVq9aONv0IV5t5BFFYf0z3hDQ+XiJHphwcRKehZTBp1OcL?= =?utf-8?q?y4iQhqLaq5cmgxmuusUhTXixsCmWyGHXwaheMcMgttfNE/768HgE1wiyn1GMSWmRB?= =?utf-8?q?LOOhznRJvahHCyAR0tAUztKgmH2jSqNTf8doRjVD1YDz2LQpRz/mvMxVsZ7J1RqvF?= =?utf-8?q?Kwvafz5dlAbWuOsXGW8vBR6itRA00ky6pZYP/XOu4tuDzeBD8YAWGmcaeOt9P6gTJ?= =?utf-8?q?av0MS8dMCGRovHh6KGzDDZfT909xsR/eFysW1KN5jCMesyQVh/Yyyt+vex08UEkm6?= =?utf-8?q?MiHdILbrt0RndiTTde8rU/N/dix0Z/J2QuGSsPTbcfIsv0F/uSNk9C2Fg553eeiic?= =?utf-8?q?MOtOCpNGA+wntVOu2kj0uo6Z9RtXRX37iYmZCDI8R0zEfPcuoFcRe43w1AfsiyVt+?= =?utf-8?q?MB9Bl9XDOWXEqUq4VfhgJ9t4LOTyxSXiwt3QTS80i6iWayUJO9sPxIK71ah0lLIo9?= =?utf-8?q?6mUoU7VwKSm5C6tvYbwzr3DtGXhKnLTMgDY2pbWQQdSS1jNzw31faOVgOXmL+G1ef?= =?utf-8?q?ttl8cUKbuh761Gu24Ia1YCFimvfQJWdoG0uBi5nlk6KOXBlWN/YBxxGfj8dW00Dkz?= =?utf-8?q?DYZtPKhm7S6OlivoF/QcJl9brL0YKELF10Ou4F0TIXvo2rAVShNaSsAtGbis97ZjB?= =?utf-8?q?/7U3dnbYnlsX2PWRjwboz+uagqQ+aybIbS7NP/e8eFfm5zlYc84MjGMVFi7FWEPjY?= =?utf-8?q?RsPnlWYNYohdsfznkjdhfYYXVzktp+99o90WC5TACI2Z8eobImCGzwmafSPBSGhLx?= =?utf-8?q?2GNUENHumX487jttPdyzN6ixVKImlWkxx1Xb9ItylYSWyglKGGd41/rgPodu4V8VF?= =?utf-8?q?rFq/anEv3SZpnu7x9UAKF+9thPphdAlIwd4CU67ViQnFzLcdzZ+2q8s3QhJkKfysU?= =?utf-8?q?2nu5Kc5l+LDDWToZkkk5MJ8gmjgB+VeO525AnBWXkj9Jgtwr4Q5/qQPYAfjifW6UY?= =?utf-8?q?/XhpYZFWe9gjOoQAjvEX3nwAVBzI3dcg5GjOogA18P5Qi6We/ZJ090O7sipJKOksq?= =?utf-8?q?hsYWBU8EJatbW2qjFMrq+P8YKoGcMwY7CDlbaoKQVxVvWFeg43yMk4XiWx70n0geb?= =?utf-8?q?3jddB4Tc3oiPTC8nCYnMb7an+SRvtkQmpslqTVsrXS96tJx5LACb1ifOXhoS4pARv?= =?utf-8?q?trLPS9ageiXXjJwYg9LkreJGTDEJPcqzbnKyiZgjHXSKw4qjpdYySnYVd8bVTELrK?= =?utf-8?q?VjBGp064AeZIulQ7AYq/7wA7J+5T1FNYQAO8f59kQmucd1VyzZwNvXX8Zw7LnEBhu?= =?utf-8?q?pA/4knA67oU7++1RVyhEd1pN/2QuCmaLuYlAq9qkiHr37d+fy29IklzQ5Yuz3pU78?= =?utf-8?q?1fprl2Aqv7CpasUEHOgIh7kZgIS3icHhdyigEy1fEpOh7U9At0uYsywXzMQSrB4NX?= =?utf-8?q?n13SUt4BsVtecxQW7g2GlrJ5uJrvFkkkBOsc7ZcS+XI4N9l04yJoDxk1/q5zieZMU?= =?utf-8?q?1igXnuyY6J?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a3925e6-9b90-44b9-d058-08d99d0db901 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2021 08:00:51.4964 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j9uQ3BhtHT6RXS6CO8rgbLIRvMtKjBwPbEPHXxujxvvsAR2La/mvrC6d9VGM0FeapHyaSUE2gcyNeOY8R6MrEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2430 Cc: guennadi.liakhovetski@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, Daniel Baluta , ranjani.sridharan@linux.intel.com, lgirdwood@gmail.com, linux-mediatek@lists.infradead.org, YC Hung , pierre-louis.bossart@linux.intel.com, peter.ujfalusi@linux.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" From: YC Hung Add new sof dai and config to pass topology file configuration to SOF firmware running on Mediatek platform DSP core. Add mediatek audio front end(AFE) to the list of supported sof_dais Signed-off-by: YC Hung Reviewed-by: Péter Ujfalusi Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Signed-off-by: Daniel Baluta --- include/sound/sof/dai-mediatek.h | 23 +++++++++++++ include/sound/sof/dai.h | 3 ++ sound/soc/sof/pcm.c | 12 +++++++ sound/soc/sof/topology.c | 59 ++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 include/sound/sof/dai-mediatek.h diff --git a/include/sound/sof/dai-mediatek.h b/include/sound/sof/dai-mediatek.h new file mode 100644 index 000000000000..62dd4720558d --- /dev/null +++ b/include/sound/sof/dai-mediatek.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ +/* + * Copyright(c) 2021 Mediatek Corporation. All rights reserved. + * + * Author: Bo Pan + */ + +#ifndef __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ +#define __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__ + +#include + +struct sof_ipc_dai_mtk_afe_params { + struct sof_ipc_hdr hdr; + u32 channels; + u32 rate; + u32 format; + u32 stream_id; + u32 reserved[4]; /* reserve for future */ +} __packed; + +#endif + diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index 3782127a7095..5132bc60f54b 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -13,6 +13,7 @@ #include #include #include +#include /* * DAI Configuration. @@ -70,6 +71,7 @@ enum sof_ipc_dai_type { SOF_DAI_AMD_BT, /**< AMD ACP BT*/ SOF_DAI_AMD_SP, /**< AMD ACP SP */ SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */ + SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */ }; /* general purpose DAI configuration */ @@ -97,6 +99,7 @@ struct sof_ipc_dai_config { struct sof_ipc_dai_acp_params acpbt; struct sof_ipc_dai_acp_params acpsp; struct sof_ipc_dai_acp_params acpdmic; + struct sof_ipc_dai_mtk_afe_params afe; }; } __packed; diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index e40c2212a999..1bf7e60be772 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -807,6 +807,18 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa channels->min = dai->dai_config->esai.tdm_slots; channels->max = dai->dai_config->esai.tdm_slots; + dev_dbg(component->dev, + "rate_min: %d rate_max: %d\n", rate->min, rate->max); + dev_dbg(component->dev, + "channels_min: %d channels_max: %d\n", + channels->min, channels->max); + break; + case SOF_DAI_MEDIATEK_AFE: + rate->min = dai->dai_config->afe.rate; + rate->max = dai->dai_config->afe.rate; + channels->min = dai->dai_config->afe.channels; + channels->max = dai->dai_config->afe.channels; + dev_dbg(component->dev, "rate_min: %d rate_max: %d\n", rate->min, rate->max); dev_dbg(component->dev, diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 2f2aa63943b2..b3ad3a604918 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -379,6 +379,7 @@ static const struct sof_dai_types sof_dais[] = { {"ACP", SOF_DAI_AMD_BT}, {"ACPSP", SOF_DAI_AMD_SP}, {"ACPDMIC", SOF_DAI_AMD_DMIC}, + {"AFE", SOF_DAI_MEDIATEK_AFE}, }; static enum sof_ipc_dai_type find_dai(const char *name) @@ -806,6 +807,19 @@ static const struct sof_topology_token led_tokens[] = { get_token_u32, offsetof(struct snd_sof_led_control, direction), 0}, }; +/* AFE */ +static const struct sof_topology_token afe_tokens[] = { + {SOF_TKN_MEDIATEK_AFE_RATE, + SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_mtk_afe_params, rate), 0}, + {SOF_TKN_MEDIATEK_AFE_CH, + SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, + offsetof(struct sof_ipc_dai_mtk_afe_params, channels), 0}, + {SOF_TKN_MEDIATEK_AFE_FORMAT, + SND_SOC_TPLG_TUPLE_TYPE_STRING, get_token_comp_format, + offsetof(struct sof_ipc_dai_mtk_afe_params, format), 0}, +}; + static int sof_parse_uuid_tokens(struct snd_soc_component *scomp, void *object, const struct sof_topology_token *tokens, @@ -2991,6 +3005,48 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, int index, return ret; } +static int sof_link_afe_load(struct snd_soc_component *scomp, int index, + struct snd_soc_dai_link *link, + struct snd_soc_tplg_link_config *cfg, + struct snd_soc_tplg_hw_config *hw_config, + struct sof_ipc_dai_config *config) +{ + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); + struct snd_soc_tplg_private *private = &cfg->priv; + struct snd_soc_dai *dai; + u32 size = sizeof(*config); + int ret; + + config->hdr.size = size; + + /* get any bespoke DAI tokens */ + ret = sof_parse_tokens(scomp, &config->afe, afe_tokens, + ARRAY_SIZE(afe_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "parse afe tokens failed %d\n", + le32_to_cpu(private->size)); + return ret; + } + + dev_dbg(scomp->dev, "AFE config rate %d channels %d format:%d\n", + config->afe.rate, config->afe.channels, config->afe.format); + + dai = snd_soc_find_dai(link->cpus); + if (!dai) { + dev_err(scomp->dev, "%s: failed to find dai %s", __func__, link->cpus->dai_name); + return -EINVAL; + } + + config->afe.stream_id = DMA_CHAN_INVALID; + + ret = sof_set_dai_config(sdev, size, link, config); + if (ret < 0) + dev_err(scomp->dev, "failed to process afe dai link %s", link->name); + + return ret; +} + static int sof_link_dmic_load(struct snd_soc_component *scomp, int index, struct snd_soc_dai_link *link, struct snd_soc_tplg_link_config *cfg, @@ -3286,6 +3342,9 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, ret = sof_link_acp_dmic_load(scomp, index, link, cfg, hw_config + curr_conf, config); break; + case SOF_DAI_MEDIATEK_AFE: + ret = sof_link_afe_load(scomp, index, link, cfg, hw_config + curr_conf, config); + break; default: dev_err(scomp->dev, "error: invalid DAI type %d\n", common_config.type); ret = -EINVAL;