Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp852112lqp; Thu, 23 May 2024 01:45:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeFf48oA3SvQFYVyKxlmxfkuRmVFPdikn6UBKHwzeiG/Ql7Mgnw20sWToesY0viDA/MD/eyzJgNOoA1ZAU0PWITRZ7wMrc1k1fcyjUfA== X-Google-Smtp-Source: AGHT+IGnMXFjohO33YuJiZ0IdGsDo7KVQrdMDPWfh4+lDz6Iw3a2pGxKIqC8kMSBa3EKKVTeMMAh X-Received: by 2002:a92:c542:0:b0:36d:bb9f:988a with SMTP id e9e14a558f8ab-371f98eeffbmr42792925ab.4.1716453922821; Thu, 23 May 2024 01:45:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716453922; cv=pass; d=google.com; s=arc-20160816; b=aWfYs8RWnquOsuS3O8gZmGUegFCWNxvu/ml8T4Y2ELuvr9VEYOXZhisuY8o9osMCZs h6AogUclL5ZZ8a2/X9foGYWYYPzdf7Is54xU6/1lJJBHiGfTzdMIi5muqEeOQ8CgJquv sST5Zftn37vtpav7P+gBDDn9/oJO9L0m6VVq8g2PkALTczPT8RH3/W8Fjd7WdO2oYAw4 9r7oiFVfOxi+B+YUkxBQpEthc2tPxMSs6xDNWGMIsUl1UhclgX4geSeCzGWZh/DTFIvn ud6YXoTf3qvwJCeRMoa9/Es08DEbSeW5qQCXSCPuSg3YkHyGmHZivMNtUyI/QHYDtp4S vqhg== 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=p+lssBGSn+n/xzcTvQL1M2hdgB2wIDrq7dLYSF+UV8E=; b=YBdN47uakKi6YClksYOlyT7UnWrg2UYPZda9fD8AWQ2hmcSHOO+/FfQfk4g87CI7n+ XdhX26CKs1Rj+dpDm5VTRvrz0uy/DmXUgibLCpCuH5Psa6wC7QoHaqjouhoE36qXx0rM Y3tqKvYsRIG1z6qP1s/sle2KF7bWWhInz7lCLPtwzccfcjRNO67ZA2FcKbZFhe2bKjzd K1z5VOvvnUq/HKFXwfZObxVnjoXshExlyvtW+y5AKNlGp1dFHLin5AaTuy7mu5WQy2h9 3pSIkiK0NNZhWcYbqzfBWd0Q+U23KA1q2l3oCRcv25OO+L2Q3e8PDvnHNg5ogwMO94rB 0ctQ==; 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=CKFEHQP6; 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-187196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187196-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412a4dcaesi28210183a12.736.2024.05.23.01.45.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=CKFEHQP6; 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-187196-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187196-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7BC622830CA for ; Thu, 23 May 2024 08:45:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8EA7148823; Thu, 23 May 2024 08:43:00 +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="CKFEHQP6" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 108641448C0 for ; Thu, 23 May 2024 08:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716453779; cv=none; b=UadXt22E6SVLAH608zL1LJblOB75eC4AlL8dKKaz12mCp2bvE4Cb9neSXi7YxTdzssTKHS+U7JCOPcrUnaZyiKDM3DPDuWkSFNQSzcXKSKcyloqoIENSslFl/EIBasoHsJtN/fCqdbUTZbSxiSazR5CsFCdR2dLFAJFebNOn2UY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716453779; c=relaxed/simple; bh=txa86VmZPoKRrts0NhHm2alf69zeqTA6ECXyv2H4sDU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dCeOz6ZVKUxw51JZNu3b74IHXUp9A2gAVFpARK3xpEorAuuF3QYsbHPrFacM+WCfUN5nO6Fsrf51YOC5YUvhZ9AvoXhziURCosuBF9NrSYeiKpIDyR+k2qFtRqj6GvyLFue2abM6wm2+dsdK59QTftMj0nMvJ43VypADYp/hB3c= 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=CKFEHQP6; arc=none smtp.client-ip=209.85.208.173 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-f173.google.com with SMTP id 38308e7fff4ca-2e3b1b6e9d1so86945401fa.2 for ; Thu, 23 May 2024 01:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1716453775; x=1717058575; 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=CKFEHQP6XuR9lbePPn7rmesmbVKJuQ5f/7l7dS9UbrTVDQpO4+Ch+om2MFWu9f7pz1 XLRpBCf2mqspR/GTurW4xabDVsYOj0NL0pgyJ3lq/OSZ0SGz3vHlBZBP5ZldRRZk2Ydm 9ZJMNghR2hvbdYni1yFbwyxKtAXGy1KdmYjkgyJWzIhJJxqQS3SRXublMZUu89H+RI+P f+qcutTwQuz5sKevp5R4uDSQ/j7i4ytJy3OrEyDT4RjR2sDHG6oTdjYnZfxwc35Q0n1X /ZU/b9ywcndthE8sdsVaT3+oYWwu6bHvH3TFR+9JrnaHuCKeFrNCN98I/m9E8HhkdiRH lGZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716453775; x=1717058575; 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=QbOyw9af4YsmIx5tPWms87NmtN9tec02Pdr9hWEHeRyTxDkOeE55qsjpJoN8Z7v0Hq SvRUuCQqw7q0Ywk72VGZtBDYPPFmmYaSFKneruVjfLmEEQXr12n63zPlBap+ULLZU0Hg cyIv+ACFXYxf6NE9L9ybA2RCOK3jNV9sQ8dX5EH7sX0EM/vpqswLP39B/70DXw2xn6dc bYE7M7Y3xumvc9KjZhjLBdUUhdDfutwcJqlfOHs3Uhn8WEXooymMwRwD9y3CvnnVpDXk oUnUBNtnjm4moVm81sstATs6u5zu9SAopf1m5oB9rUuPNtlSEeMIbkwpQdXvfjRX79db RrAg== X-Forwarded-Encrypted: i=1; AJvYcCUoCZngoN410TDy/WaE1nT5mNxf0iz0zxVGHQWbT+zLlg5Wx8CjLUz2FmHJ0EyAcKHuwDzxjdY28BmWInHb79zF29c3eEAu3P8befH0 X-Gm-Message-State: AOJu0Yx/tIOE+SMhvfNRUm8Au3Z4UTUyCohE+5i9/sTudfR41pF3GOTe J12rtdsa2Q6oZd60k7LlFn0CQjD40SxUZ/ZEV4p8LbSj8iFj32EAQM38K2FInDI= X-Received: by 2002:a2e:95d4:0:b0:2e1:d44b:db9c with SMTP id 38308e7fff4ca-2e9492c7dd5mr25433371fa.0.1716453775462; Thu, 23 May 2024 01:42:55 -0700 (PDT) Received: from [127.0.1.1] ([93.5.22.158]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-42100f3e03asm18556645e9.17.2024.05.23.01.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:42:54 -0700 (PDT) From: Alexandre Mergnat Date: Thu, 23 May 2024 10:42:38 +0200 Subject: [PATCH 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-e7e2569df481@baylibre.com> References: <20240226-audio-i350-v5-0-e7e2569df481@baylibre.com> In-Reply-To: <20240226-audio-i350-v5-0-e7e2569df481@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+MdRFAcsmYgBmTwF/hRnpFVJH5jG9NA0r6ktvLas3xx1ghW/176tz I/NIa0GJAjMEAAEKAB0WIQQjG17X8+qqcA5g/osrRkmdfjHURQUCZk8BfwAKCRArRkmdfjHURfsED/ 9mjb26gN6ZJA6v2JhDkX9rLsk/T9FeeYT2HxAwEkRB28wer2E7FHK2VWbTWGMVddW5hzVgIC/IvVzd 0A7zfKOr6Ktdmo+mOpj64Xp90OlFyQyx0CUV/hf8c7zH7/3o4+wYCyeKfKex5Skbh5hV0boDw9KS4w E+xD7qutLc3iBRHzd7vAusihTn868CnNUkz/+s3S983QKLW6cR922MjlOPuHG8I6NY1ZcUpGuVN8fa KQHJoeLIJNmwp+czjMkP14RyfzZAdPpSiRAZkMpcyE9kZ6m/ikzB7zh2RseUGy2RKFsBTygUdQlEdY zg0SJQVYUKf0JJy+uYH94DrdyRsm3iqO5EvGWSFz4oz3NkVkqI7eWAliQP6uf93EbmrgZt+hpX+T77 6u8PnLzSyoqq2XTahDy8XDI04nNykEwDIOdRF2TCOpd5oa0O86jwTuGSo4hMIITBSjzFKgkW+jD5Wg ayHJpU/g3YWJ2VH/f2nvCUNrYBka/yG8hNxrztmnOUi3Ku8s/X+4Z0B7kCBlarbY8ZQM2O8dacROvN 2Z6/mYUxalBbbvDnKxDuciYBcq6hrHEDU/VQS7Z8dLHTxBKRRmNUrAWgpEaaOqvYRKAb2PDLFzZO4l 1ntFH1+c35UF6+hahq454wOewb69oeMRWQr+VlwqGMtUzKrUV23Q0gUgBtyA== 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