Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp638027lqs; Fri, 14 Jun 2024 00:32:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvN3xk9j3a/dmJ0yKMxvHWPMT3KJzlVA4GCZKYjz6xmnjwuGLKM51PanCGGp2xxUJf/2nxtAQx3VTCNT93cFpZKevLn7zYjacCt3zv5A== X-Google-Smtp-Source: AGHT+IEJCV9E7+ZKre0CRXYoUU2JxajTAyJ7E9JiGQGbNSsKHatcwbBpZThf7yFYuwLoQkQ5HDaZ X-Received: by 2002:ad4:42cd:0:b0:6b2:a68e:6cf5 with SMTP id 6a1803df08f44-6b2a68e735fmr49172146d6.5.1718350371427; Fri, 14 Jun 2024 00:32:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718350371; cv=pass; d=google.com; s=arc-20160816; b=Vodtqry1jv7usHLPLZlo6qy+4AtVR2s27a1vMqZ6/8C0PNGGi/NpVSz0dB4EqKJFe2 ZEjrW2KUdSmbnGQlDDayhYPRLRpRmeK5LsPMKW8mrBpO6jv2pz7UQMqb3vQLJ9Rivskv I8WK4GQOy1erdTJaOwdjU+rsaB6M62/h/bFmgAvV4mQcWzXeo7pwCd6TJyA8rSbrn1pf XwXnQ2CT8yaayu2hOu/PlZkYDGEi3UKJlXWSpsu+vXhY0dchRJ0hAOKWoGAOn4j9xZ9s Lk4kfxsRtFEMJnNKncqPJBiY86IsnvqZF4IMEj2TKbpeIwy/7VAbl2yxEfKg8Qt66b0K qW5Q== 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=RotGzbqUHvqHDCuN+GP71eTRfv5/+PABGOxY4Zbxn4g=; fh=7O7fjD5BhiyEHS+e4lugbwN/NLAXZxZj6gX5KHuBjLg=; b=ITN/AY5AOTHxwHOeFuxY23Ywx9nt7mHvfcZCwikynABoIqa6TH/WZGBE3sxyb1bFDB Zi+Hn6g14yNAdI3a4pmjeGv8QdK2zL9zgcxf/Q/ESNAXIAu23VqImE+2UXo67UnLvT5H ILzB9nkvG1Lsjdb/3W3xr6vhBimqRU7wk0Q8g93hcvyoR2epyquhnzGflq61FanwxBSV N3x+s/oqV7a/cNFzWrQnXgA8iswARJy4dpXkwF3K449a7zQclcu1Y7P3QpbL829O20GH lbs6e/eDV++LWgaIth4ibci0dFQq7r2XXT5hCJF4xrxIywbHsKwUOkipKQdKQB3URdh5 Aivw==; 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=ISl5+ukk; 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-214457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214457-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b2a5b2b7f0si33627466d6.382.2024.06.14.00.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 00:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ISl5+ukk; 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-214457-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214457-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 866B31C259C4 for ; Fri, 14 Jun 2024 07:30:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D010188CA5; Fri, 14 Jun 2024 07:28:20 +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="ISl5+ukk" Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 344D2186E4A for ; Fri, 14 Jun 2024 07:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718350098; cv=none; b=ig0aw34D1bJfZWtGpM/sHRs63TMl7pFtDcrMlorSnxjdZFr6vpJDHuLnA2i98Mz3/D3JoJsQppGJBi8c5S2bjjhMSBoOyzLuIq6Dgu/vktG6r4gTTULxhXSNJU+hVb52dPcNVWQ4JKjDClbE+0sgHcafHrzErZooaNAnymVETSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718350098; c=relaxed/simple; bh=txa86VmZPoKRrts0NhHm2alf69zeqTA6ECXyv2H4sDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AvudQ614RKQUgAIG/jG+JFTyP+QLr5VPMthmJBbEsLKB+4V2XuWS4TXZT49W1rt91T7+MejhjuK+w7ta2kvAqGTYpwKtfNknZ23ftgzQoofCNRLZ4hOQLeRbcN4gTraPOyfoCBocNODJQpVXI9L1la3fnTZXsZLT/IWXuCOLJR8= 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=ISl5+ukk; arc=none smtp.client-ip=209.85.128.48 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-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42249a4f9e4so13350885e9.2 for ; Fri, 14 Jun 2024 00:28:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718350094; x=1718954894; 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=RotGzbqUHvqHDCuN+GP71eTRfv5/+PABGOxY4Zbxn4g=; b=ISl5+ukkqXGE3UvxoCL45m9WTtrvst8LPHJhorEWjxGKzQkmxH0FG3DX2dJg7XUsPO yVfOPzEDn5Us5BODDyW88N+6bsNAw6I0ZlIyvZCE2KCprC6Nu47z3eDjxYBPQnDfNI2n OukDqzLErx7k3UmMOZc7dJ2PMPYsRJLf0Ics8r0VGQEjcoAxl538yW7RnNNhF81k+AuA Gpe5q1BI+zLTSXbhLVzQYv6sj+YCzn1ew4vRdDHy13vW3GRNvRIJJkMarWopO/WOgEe+ /TlinAXvaSqFdjCWoXsxIX4ePlERj+SM+aC4FV3WP1BWf5l2F0ZoK3ORz7ZSff7mMp2C B9Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718350094; x=1718954894; 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=RotGzbqUHvqHDCuN+GP71eTRfv5/+PABGOxY4Zbxn4g=; b=Ac6yZUvSEYTf4vRYYrSTr3D2AMvOBBA/g4lLGFCnxRfor8MkFprKvhu/1KkKv2i7J4 GZ4QrJgvzBGDg1lCaOZENMy/mDeEjYvlT+Ja1mwGvwpFynw2+OjmUcMZjxVQdBe03JVC ZM97+u1D6Cws2Ek3IEmc7pekkUwyIDlWFeCUh4YR9aEEnb9qsmtZepzKt2dkhZJFp0qu 3cCXkCdtWkaeMXdNESDKgADaAI2kTFeW6cbrGxJPJYZAOpWX0vfOOwQPf8mhXhqUXNTw tQWfYourkFIMo++e2yM4VMQi5mPNAqmlVkbBU17wqxAtrldteuz/FqqF9ZDPdfNxOhrR UMQg== X-Forwarded-Encrypted: i=1; AJvYcCVAQLlQmowQ+oEuDRZ8oiz/rByAxlm+0CBI5uddrP0cqYtECBzhNKdrwwOZBORGBFQtBdKEWTro4h5dL3rf/Myk53317l4XXWIxmm9N X-Gm-Message-State: AOJu0YzfOFaMBfOgtGotDdMSdEi+whJMBsSzahri28bT1BXzOaOejorC b7bpOlkmueQZmRfrNk4mHnURgmi6vM/1FP1BsMQEJRwBOSBE2a5bNteemGZC8YU= X-Received: by 2002:a05:600c:45c7:b0:422:727c:70b1 with SMTP id 5b1f17b1804b1-4230481f0cbmr18287745e9.8.1718350094514; Fri, 14 Jun 2024 00:28:14 -0700 (PDT) Received: from [127.0.1.1] ([93.5.22.158]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36075104b2esm3535773f8f.101.2024.06.14.00.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 00:28:14 -0700 (PDT) From: Alexandre Mergnat Date: Fri, 14 Jun 2024 09:27:52 +0200 Subject: [PATCH RESEND v5 09/16] 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-v5-9-54827318b453@baylibre.com> References: <20240226-audio-i350-v5-0-54827318b453@baylibre.com> In-Reply-To: <20240226-audio-i350-v5-0-54827318b453@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 , Krzysztof Kozlowski 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=8252; i=amergnat@baylibre.com; h=from:subject:message-id; bh=txa86VmZPoKRrts0NhHm2alf69zeqTA6ECXyv2H4sDU=; b=owEBbQKS/ZANAwAKAStGSZ1+MdRFAcsmYgBma/D/ouIPzweFOD2UrYVdP93SbaWQdekXHP7sXy6T PE+4xmeJAjMEAAEKAB0WIQQjG17X8+qqcA5g/osrRkmdfjHURQUCZmvw/wAKCRArRkmdfjHURVJgD/ 94bVgWW2k6YfJ0HdjF90/PrnnNsO3i8gQvFktnPTJ+YzlGHxVJy/7j9ed7+PUqe9nzmpXSf/iGxgfh IQyBpYXJ2oF6ziFuG17yzJxmIJfoKHlnyTFRtfY9rlCnyboHWk2xiRSxkqwbUsG+X3mgDYSkuHS86/ C/samCgMJMjw7281JMlQBpMWmAs9lITsg/TvMgC3Mr+26thUOyFydZPkLIbKp2YY2BGuIscBHtGl41 vvvyn7TmL4gUrSJaQRDOcfMoZTmf6HSBr+MTN64hutPA0mFnZhraGhUEaAkfKr+k/rjCVCzGrCFd4D QzWleauwn3d+029w+RoNAZVoQkIxJHJCpI1+0Sboiodwy22b7/Jxg+j+HgCvwU0KLz/f6s1KngMR7t ZpoXG7BwmoKO+VNGWmLOj26farKPEWOEtm2POjK+7k7mcq2DOqrNiYBnxJSsPBxfuCKNaa4r/RUTCx AHtN9CGxd2MZ26c/G1cqJZekuDywFTO97nGly5FrGPFtSrUwmRCsS8ltbEcEudXjl6cih04wWCQguh 7acd6UeXKVOZBklh4ZWm6sFZ8HcCXTJFT3o0JocUMxCoHcoBzX3m0gEqkAsV1quZogU7R29MohJ0g5 +xHSz5gcmXLdbw2crZyb6KnYJfm7bJVF4tnlniyYpD9pdQlMhJiAy8xmP3sQ== X-Developer-Key: i=amergnat@baylibre.com; a=openpgp; fpr=231B5ED7F3EAAA700E60FE8B2B46499D7E31D445 Add Pulse Code Modulation Device Audio Interface support for MT8365 SoC. Reviewed-by: AngeloGioacchino Del Regno 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..6be991d53333 --- /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