Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1879456lqe; Tue, 9 Apr 2024 03:17:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCxEuUrmLBdL+NJdQQHHiFAWTfgAGEvqxBjBMkeSru3VL1S3mo5JaKcxZd+brtUo0axRj1uOnmZp3aXsN0SqWEFvSXGUYJfs6CZ+2NOg== X-Google-Smtp-Source: AGHT+IGUccGRJxnY04LAw43szNhqJ6RBmHH+ClHLcutjpGEcolTASzw/uk81RP1GtYPRvi9RElvJ X-Received: by 2002:a17:907:7da3:b0:a4a:3679:5514 with SMTP id oz35-20020a1709077da300b00a4a36795514mr11079632ejc.48.1712657851494; Tue, 09 Apr 2024 03:17:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712657851; cv=pass; d=google.com; s=arc-20160816; b=qgKF7JfYEsi4yzrwmIgrUQEdtZk/qlD0yF/V7J5f82VKpqMhfsPoQT8qXV1hpMHaAg WqhARGKNvr7xHll+KPnZTJYeuKxfvoKgFphMVa09hra80pWiNH6gMh/xaYzSKdm0vVe8 p7aELS5oSpPNUH1iOftWYfuOxWSNqZ8UYMOz5Xe8t4GEIRElRnHZUsDFssqwskiLVpHR VgRHxiwRtRBDdL4zx8CZMmHYUdK0I6+csgdy5vREV9Y9d8zC33JlZjgawmxu9453Em7h xqJMOG9erQDbV8bjVLRlWC6P/E7QiKCVpqy/ghWxq8HA0N/R9MU7T8aJ+OzSdv9sZAhq ajWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=7NcmXEnrMpeqj5XdDn0TZRLtlA98rvyn+21w0bXYsqc=; fh=GO8ou5+Pv/KQxPTkoTYvmXCZ/y5MPMKbmMIlpFM68ZA=; b=ogF40e29B8fN4ePFuxPpguOimNdTJ5z79ve9jbiiqn4ItugDNktQU/OOA5+bRLeFnA YQbvky7DYvXC+claPIKTTVQA/m0yqAquTp8Jk48haUt0krMQsT7mW/uulRZdmL+NFbXp IUPqEDgfE1msvnnDPe9TsR6vS7+OWa3lsofCHE/K2o8MIVrSxJkxCI21NQ92gNzDUonq 3/nlwPQ/4VNAFyzBcsvSbsaApvSqxsA1UlIEtr4K71KRt/KbVLCIzmGyxOUTbtVfrryF lAFkIOCxXc3P4KCYLAsb8th7YKqdgKQlUoZyMJBeWs13ubQuP4A4TCmur6jTjrGm3Ylo +rIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=mp+uMK8j; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-136649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136649-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hp16-20020a1709073e1000b00a51a47b1e84si4790689ejc.1011.2024.04.09.03.17.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 03:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=mp+uMK8j; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-136649-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136649-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1440D1F226C8 for ; Tue, 9 Apr 2024 10:17:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AEE0212EBF3; Tue, 9 Apr 2024 10:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="mp+uMK8j" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 652BD12EBCB for ; Tue, 9 Apr 2024 10:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712657641; cv=none; b=U8BDKK+a1CnRh3ca5bO/X1TwhHiRpiwLMF1F2FpzmgY5a5ZU0da7IS09ID+4TW4aY2XtwjSk0Ed0YW2lLZ+UZdN81f9VEahK6qmz2lCGUheNwy+0WVFNvyGdvqsbxebd1Y6uzgk02hFGsGBzWWd3JDWSyPoZh6TlF/IvBEAw4go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712657641; c=relaxed/simple; bh=ZWQsTQOXgV6ywBnpOyoYdC9ond5oUki1yr+VbuWucdg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f4mMr8jLvT7HelsMPX87yA8iwyr6HbZk3xBTgrDKvpwxKtXyNS0cFyuAzCiwZZDgMdZzVP8V67wF9Zxx4jaxELsQe+tbOi1tJNzQBFooh6Ph4hOUSMyOeL7Jxb4GpO7EULj93+EsIV3ano34Q92/xCey13AIqFCGbby+B6CSog8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=mp+uMK8j; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d8a2cbe1baso7501521fa.0 for ; Tue, 09 Apr 2024 03:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1712657636; x=1713262436; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7NcmXEnrMpeqj5XdDn0TZRLtlA98rvyn+21w0bXYsqc=; b=mp+uMK8jtNQ+DjnmBNSGB2h5t5jR/japQBOwJ0t8J1hwovrNkoINCPY6/ilU5qMO4/ XyPL+DbsXiNKRcf63x3jiuZ4H4HwqiY7Uc1pURih0bUDrZyBHouWoeNMAWKh6gWSAvPJ NAMQGSPUs5RBVOyr6CqfDdN+R58hL/7GAskk7lcTq0FuLF1PnqZPJ/geFqV7OsKCqu8U PW9W0cj9Hb05HF29neofdY8Dc8XqC0Kka/MEeByK+eyBaoiMym7+Y1DtSyY5nT3A7Nr1 RE0umTLxWj+evMyaTUJaK+v7c5vgCAFQ5pywQEgtqqDrvDtv+lDDpzxnhKf8pcXmjmon psbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712657636; x=1713262436; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7NcmXEnrMpeqj5XdDn0TZRLtlA98rvyn+21w0bXYsqc=; b=rGs/u1T0+oeGkx4LVKJcKgdHvTgjnVUh+n1mq9axzXv7lVQw5Zb98otFjPUIQlr5qo cIGnlleSjr984Ib1MdjlVLjvQtkxPWIywfLhlj5fP4O8cgWxzcoNsVS3GzroUxjO72Cw z0XJi7yfhSE4Qbe4hLD9Zn+GkCnx34ViNvgpMW2e+wpZjYvPzldGEtHub/DJMJydE5Qz 7XF5PM27NRQ8JVXWtaqaA1RcoCd0AfPRQmX+/pyLpps9WQHZVBMLRgeTGkSjufqIW8Pq RY0CwnSIHPTJH44ie2urMgjmvWnynBj7HyMtOG2G7hhB/NwOjgXHptz5kHMRQ2hwQ+Km 9duA== X-Forwarded-Encrypted: i=1; AJvYcCUTLxSZd19te1UF2OQ0TnbQcrEXnfcmCxa+a9j/c0Q3DIEzNAoZFbrO7YU9IB707bPLKDfI3pBGjS92nd1UDXzDz4qaliltTi8YTt3I X-Gm-Message-State: AOJu0YxO86ZdVjAea8+np0egZsIerdy76vdUabrBDIxF6i17+4mWaK+1 0YpqXIXzBnkxbUuAa1eW9d4i256w+ucnvAt/eIRfPkakrBot0K0dY3+WNhbljweYf5StHB1aDwo eexI= X-Received: by 2002:a2e:8189:0:b0:2d8:b74c:ee72 with SMTP id e9-20020a2e8189000000b002d8b74cee72mr133335ljg.23.1712657636371; Tue, 09 Apr 2024 03:13:56 -0700 (PDT) Received: from [127.0.1.1] ([93.5.22.158]) by smtp.googlemail.com with ESMTPSA id r7-20020a05600c458700b00416b035c2d8sm1124149wmo.3.2024.04.09.03.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 03:13:55 -0700 (PDT) From: Alexandre Mergnat Date: Tue, 09 Apr 2024 12:13:31 +0200 Subject: [PATCH v2 10/18] ASoC: mediatek: mt8365: Add PCM DAI support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240226-audio-i350-v2-10-3043d483de0d@baylibre.com> References: <20240226-audio-i350-v2-0-3043d483de0d@baylibre.com> In-Reply-To: <20240226-audio-i350-v2-0-3043d483de0d@baylibre.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Lee Jones , Flora Fu , Jaroslav Kysela , Takashi Iwai , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Catalin Marinas , Will Deacon , Rob Herring Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Alexandre Mergnat X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8166; i=amergnat@baylibre.com; h=from:subject:message-id; bh=ZWQsTQOXgV6ywBnpOyoYdC9ond5oUki1yr+VbuWucdg=; b=owEBbQKS/ZANAwAKAStGSZ1+MdRFAcsmYgBmFRTTZ9Uto4DiLQwkUQSBOWyc7ws2SrVhONIbSMIn NhG8uNyJAjMEAAEKAB0WIQQjG17X8+qqcA5g/osrRkmdfjHURQUCZhUU0wAKCRArRkmdfjHURaCEEA C0qXVB+yY4q8zkpkVpj32/cvb8/7X1GXZGNs0/Cojw9o3CQ/7YmbKww0EmfhX9TMt3JVaAqKo6dAmM HBVKzUplBiN0mzeqY9PAr3LPehDI25z1I1pMvcFXDt7NK/lN2qEqVnoORonl5LDMIOsOaQZ4wqi2jk RnhvgzrDruJY5jm9uhLf8Ok151SAdv+fpmxa8iJdy1B+qZETw/pqVvOBr1NBaOPWwnyeN2mnl+UKkW Ld+sh1lHzDz/M6156KIoMGYGwEnexTtsjo5lie1kLSVO4cqfIPcimCoFWEbdFj47u/EuEhD90AOoPz H1J6FGnTQw76ucuQpU1ffOPoK6h4FLcGD4mFloa+D3cgP4NjhquKZOY6rWO3ONsQLHL1oqZLxfBwS0 HASPLyzI0DqNSGwAHLrmT9/DuQsZcofR/erbfJiDqSBNKpU7BX45Hr6UZcRPwnsaDCqmU9ZT+ERfi9 arBy2bUmSfgP9u0ENxRO27XbdG+kXJtrtt8FCt5kXnGqrvykXXBUIfXw+sX66aK9TUgWq5SShygU5E ej9Jl5QfuWkzSLBK9xPwIgIdi+lDVmnsvLEDMtoti1Tz9NDTt5jSgFhZK7lzk4SnEcD7xNwABl8+rZ 9DKblm96Qkzsdiy4JI/6k9hCUsfyz9U+jHZKqUvhZ7C0cC+6k24w3dU0tVFQ== X-Developer-Key: i=amergnat@baylibre.com; a=openpgp; fpr=231B5ED7F3EAAA700E60FE8B2B46499D7E31D445 Add Pulse Code Modulation Device Audio Interface support for MT8365 SoC. Signed-off-by: Alexandre Mergnat --- sound/soc/mediatek/mt8365/mt8365-dai-pcm.c | 293 +++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c b/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c new file mode 100644 index 000000000000..a5de47c69620 --- /dev/null +++ b/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c @@ -0,0 +1,293 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Mediatek 8365 ALSA SoC Audio DAI PCM Control + * + * Copyright (c) 2024 MediaTek Inc. + * Authors: Jia Zeng + * Alexandre Mergnat + */ + +#include +#include +#include +#include "mt8365-afe-clk.h" +#include "mt8365-afe-common.h" + +struct mt8365_pcm_intf_data { + bool slave_mode; + bool lrck_inv; + bool bck_inv; + unsigned int format; +}; + +/* DAI Drivers */ + +static void mt8365_dai_enable_pcm1(struct mtk_base_afe *afe) +{ + regmap_update_bits(afe->regmap, PCM_INTF_CON1, + PCM_INTF_CON1_EN, PCM_INTF_CON1_EN); +} + +static void mt8365_dai_disable_pcm1(struct mtk_base_afe *afe) +{ + regmap_update_bits(afe->regmap, PCM_INTF_CON1, + PCM_INTF_CON1_EN, 0x0); +} + +static int mt8365_dai_configure_pcm1(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + struct mt8365_afe_private *afe_priv = afe->platform_priv; + struct mt8365_pcm_intf_data *pcm_priv = afe_priv->dai_priv[MT8365_AFE_IO_PCM1]; + bool slave_mode = pcm_priv->slave_mode; + bool lrck_inv = pcm_priv->lrck_inv; + bool bck_inv = pcm_priv->bck_inv; + unsigned int fmt = pcm_priv->format; + unsigned int bit_width = dai->sample_bits; + unsigned int val = 0; + + if (!slave_mode) { + val |= PCM_INTF_CON1_MASTER_MODE | + PCM_INTF_CON1_BYPASS_ASRC; + + if (lrck_inv) + val |= PCM_INTF_CON1_SYNC_OUT_INV; + if (bck_inv) + val |= PCM_INTF_CON1_BCLK_OUT_INV; + } else { + val |= PCM_INTF_CON1_SLAVE_MODE; + + if (lrck_inv) + val |= PCM_INTF_CON1_SYNC_IN_INV; + if (bck_inv) + val |= PCM_INTF_CON1_BCLK_IN_INV; + + // TODO: add asrc setting + } + + val |= FIELD_PREP(PCM_INTF_CON1_FORMAT_MASK, fmt); + + if (fmt == MT8365_PCM_FORMAT_PCMA || + fmt == MT8365_PCM_FORMAT_PCMB) + val |= PCM_INTF_CON1_SYNC_LEN(1); + else + val |= PCM_INTF_CON1_SYNC_LEN(bit_width); + + switch (substream->runtime->rate) { + case 48000: + val |= PCM_INTF_CON1_FS_48K; + break; + case 32000: + val |= PCM_INTF_CON1_FS_32K; + break; + case 16000: + val |= PCM_INTF_CON1_FS_16K; + break; + case 8000: + val |= PCM_INTF_CON1_FS_8K; + break; + default: + return -EINVAL; + } + + if (bit_width > 16) + val |= PCM_INTF_CON1_24BIT | PCM_INTF_CON1_64BCK; + else + val |= PCM_INTF_CON1_16BIT | PCM_INTF_CON1_32BCK; + + val |= PCM_INTF_CON1_EXT_MODEM; + + regmap_update_bits(afe->regmap, PCM_INTF_CON1, + PCM_INTF_CON1_CONFIG_MASK, val); + + return 0; +} + +static int mt8365_dai_pcm1_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + + if (snd_soc_dai_active(dai)) + return 0; + + mt8365_afe_enable_main_clk(afe); + + return 0; +} + +static void mt8365_dai_pcm1_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + + if (snd_soc_dai_active(dai)) + return; + + mt8365_dai_disable_pcm1(afe); + mt8365_afe_disable_main_clk(afe); +} + +static int mt8365_dai_pcm1_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + int ret; + + if ((snd_soc_dai_stream_active_playback(dai) + + snd_soc_dai_stream_active_capture(dai)) > 1) { + dev_info(afe->dev, "%s '%s' active(%u-%u) already\n", + __func__, snd_pcm_stream_str(substream), + snd_soc_dai_stream_active_playback(dai), + snd_soc_dai_stream_active_capture(dai)); + return 0; + } + + ret = mt8365_dai_configure_pcm1(substream, dai); + if (ret) + return ret; + + mt8365_dai_enable_pcm1(afe); + + return 0; +} + +static int mt8365_dai_pcm1_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); + struct mt8365_afe_private *afe_priv = afe->platform_priv; + struct mt8365_pcm_intf_data *pcm_priv = afe_priv->dai_priv[MT8365_AFE_IO_PCM1]; + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + pcm_priv->format = MT8365_PCM_FORMAT_I2S; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + pcm_priv->bck_inv = false; + pcm_priv->lrck_inv = false; + break; + case SND_SOC_DAIFMT_NB_IF: + pcm_priv->bck_inv = false; + pcm_priv->lrck_inv = true; + break; + case SND_SOC_DAIFMT_IB_NF: + pcm_priv->bck_inv = true; + pcm_priv->lrck_inv = false; + break; + case SND_SOC_DAIFMT_IB_IF: + pcm_priv->bck_inv = true; + pcm_priv->lrck_inv = true; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + pcm_priv->slave_mode = true; + break; + case SND_SOC_DAIFMT_CBS_CFS: + pcm_priv->slave_mode = false; + break; + default: + return -EINVAL; + } + + return 0; +} + +static const struct snd_soc_dai_ops mt8365_dai_pcm1_ops = { + .startup = mt8365_dai_pcm1_startup, + .shutdown = mt8365_dai_pcm1_shutdown, + .prepare = mt8365_dai_pcm1_prepare, + .set_fmt = mt8365_dai_pcm1_set_fmt, +}; + +static struct snd_soc_dai_driver mtk_dai_pcm_driver[] = { + { + .name = "PCM1", + .id = MT8365_AFE_IO_PCM1, + .playback = { + .stream_name = "PCM1 Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, + .capture = { + .stream_name = "PCM1 Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, + .ops = &mt8365_dai_pcm1_ops, + .symmetric_rate = 1, + .symmetric_sample_bits = 1, + } +}; + +/* DAI widget */ + +static const struct snd_soc_dapm_widget mtk_dai_pcm_widgets[] = { + SND_SOC_DAPM_OUTPUT("PCM1 Out"), + SND_SOC_DAPM_INPUT("PCM1 In"), +}; + +/* DAI route */ + +static const struct snd_soc_dapm_route mtk_dai_pcm_routes[] = { + {"PCM1 Playback", NULL, "O07"}, + {"PCM1 Playback", NULL, "O08"}, + {"PCM1 Out", NULL, "PCM1 Playback"}, + + {"I09", NULL, "PCM1 Capture"}, + {"I22", NULL, "PCM1 Capture"}, + {"PCM1 Capture", NULL, "PCM1 In"}, +}; + +static int init_pcmif_priv_data(struct mtk_base_afe *afe) +{ + struct mt8365_afe_private *afe_priv = afe->platform_priv; + struct mt8365_pcm_intf_data *pcmif_priv; + + pcmif_priv = devm_kzalloc(afe->dev, sizeof(struct mt8365_pcm_intf_data), + GFP_KERNEL); + if (!pcmif_priv) + return -ENOMEM; + + afe_priv->dai_priv[MT8365_AFE_IO_PCM1] = pcmif_priv; + return 0; +} + +int mt8365_dai_pcm_register(struct mtk_base_afe *afe) +{ + struct mtk_base_afe_dai *dai; + + dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); + if (!dai) + return -ENOMEM; + + list_add(&dai->list, &afe->sub_dais); + dai->dai_drivers = mtk_dai_pcm_driver; + dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_pcm_driver); + dai->dapm_widgets = mtk_dai_pcm_widgets; + dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_pcm_widgets); + dai->dapm_routes = mtk_dai_pcm_routes; + dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_pcm_routes); + return init_pcmif_priv_data(afe); +} -- 2.25.1