From nobody Sat Sep 21 23:07:53 2024 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4329CCA47C for ; Tue, 12 Jul 2022 15:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233646AbiGLPLe (ORCPT ); Tue, 12 Jul 2022 11:11:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbiGLPLN (ORCPT ); Tue, 12 Jul 2022 11:11:13 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19B3CC019; Tue, 12 Jul 2022 08:04:56 -0700 (PDT) X-UUID: 83acdd81f6fa4a089f9325c73368882e-20220712 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:324cab27-89b4-4e02-9d0e-5b6333fe9559,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:0f94e32,CLOUDID:d61049d7-5d6d-4eaf-a635-828a3ee48b7c,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 83acdd81f6fa4a089f9325c73368882e-20220712 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1393213205; Tue, 12 Jul 2022 23:04:48 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Tue, 12 Jul 2022 23:04:47 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 12 Jul 2022 23:04:46 +0800 From: Jiaxin Yu To: , , CC: , , , , , , , , , , , Jiaxin Yu Subject: [PATCH v9 3/8] ASoC: mediatek: mt8186: add mt8186-mt6366 common driver Date: Tue, 12 Jul 2022 23:04:37 +0800 Message-ID: <20220712150442.32504-4-jiaxin.yu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712150442.32504-1-jiaxin.yu@mediatek.com> References: <20220712150442.32504-1-jiaxin.yu@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add mt8186-mt6366 common driver for mt8186 series machine. Signed-off-by: Jiaxin Yu Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt8186/Makefile | 1 + .../mediatek/mt8186/mt8186-mt6366-common.c | 57 +++++++++++++++++++ .../mediatek/mt8186/mt8186-mt6366-common.h | 17 ++++++ 3 files changed, 75 insertions(+) create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-common.c create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-common.h diff --git a/sound/soc/mediatek/mt8186/Makefile b/sound/soc/mediatek/mt8186= /Makefile index 7626bb3499dd..bdca1a3b3ff0 100644 --- a/sound/soc/mediatek/mt8186/Makefile +++ b/sound/soc/mediatek/mt8186/Makefile @@ -15,5 +15,6 @@ snd-soc-mt8186-afe-objs :=3D \ mt8186-dai-hostless.o \ mt8186-dai-tdm.o \ mt8186-misc-control.o \ + mt8186-mt6366-common.o =20 obj-$(CONFIG_SND_SOC_MT8186) +=3D snd-soc-mt8186-afe.o diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c b/sound/soc/m= ediatek/mt8186/mt8186-mt6366-common.c new file mode 100644 index 000000000000..4e66603d4cdb --- /dev/null +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-common.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// mt8186-mt6366-common.c +// -- MT8186 MT6366 ALSA common driver +// +// Copyright (c) 2022 MediaTek Inc. +// Author: Jiaxin Yu +// +#include + +#include "../../codecs/mt6358.h" +#include "../common/mtk-afe-platform-driver.h" +#include "mt8186-afe-common.h" +#include "mt8186-mt6366-common.h" + +int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *cmpnt_afe =3D + snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct snd_soc_component *cmpnt_codec =3D + asoc_rtd_to_codec(rtd, 0)->component; + struct mtk_base_afe *afe =3D snd_soc_component_get_drvdata(cmpnt_afe); + struct mt8186_afe_private *afe_priv =3D afe->platform_priv; + struct snd_soc_dapm_context *dapm =3D &rtd->card->dapm; + int ret; + + /* set mtkaif protocol */ + mt6358_set_mtkaif_protocol(cmpnt_codec, + MT6358_MTKAIF_PROTOCOL_1); + afe_priv->mtkaif_protocol =3D MT6358_MTKAIF_PROTOCOL_1; + + ret =3D snd_soc_dapm_sync(dapm); + if (ret) { + dev_err(rtd->dev, "failed to snd_soc_dapm_sync\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mt8186_mt6366_init); + +int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card, + struct snd_soc_dai_link *link, + struct device_node *node, + char *link_name) +{ + int ret; + + if (node && strcmp(link->name, link_name) =3D=3D 0) { + ret =3D snd_soc_of_get_dai_link_codecs(card->dev, node, link); + if (ret < 0) + return dev_err_probe(card->dev, ret, "get dai link codecs fail\n"); + } + + return 0; +} +EXPORT_SYMBOL_GPL(mt8186_mt6366_card_set_be_link); diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-common.h b/sound/soc/m= ediatek/mt8186/mt8186-mt6366-common.h new file mode 100644 index 000000000000..907d8f5e46b1 --- /dev/null +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-common.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * mt8186-mt6366-common.h + * + * Copyright (c) 2022 MediaTek Inc. + * Author: Jiaxin Yu + */ + +#ifndef _MT8186_MT6366_COMMON_H_ +#define _MT8186_MT6366_COMMON_H_ + +int mt8186_mt6366_init(struct snd_soc_pcm_runtime *rtd); +int mt8186_mt6366_card_set_be_link(struct snd_soc_card *card, + struct snd_soc_dai_link *link, + struct device_node *node, + char *link_name); +#endif --=20 2.18.0