Message ID | 20230515052540.9037-2-trevor.wu@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6685911vqo; Sun, 14 May 2023 22:46:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bSKcfKmBxTLKO2DnXwhS4lVS2I0pEYd4ujRfnmN7yD0EwzdyaBHzzwbTmy9Wi6qKe6I0I X-Received: by 2002:a17:90b:108f:b0:252:a4e2:9eaf with SMTP id gj15-20020a17090b108f00b00252a4e29eafmr11406144pjb.28.1684129606286; Sun, 14 May 2023 22:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684129606; cv=none; d=google.com; s=arc-20160816; b=hRPFGM2N4T3orQPCukE9AaOWRtaJGFuaeHJwUpAZtC2Yy0CbC+S6C7L0iK/NGYAu+C C6I1y5dacsYB9oWN643h1YPbD+2m9yy0Ss/5FNiDsY9YqaKVmGihCUEmFiDEpH43WYFN YWUbnIYcBQ5NFeR4CqrI6VPwx1IvuRVPQsqDsgZ6sycsRFDHauBktagC9o3/8nXbZsiX ftLK/8Z67rsC9bmzKnawRkQi6VthwLP8vEOmocv4pMuLPN8AWhx+3IdQSNHczw8Q/mMb jm48NSgZrWDO5gYP6Z+bksuMTbKk93UmAmWv7WcTEoXj8ieWSmKR//V7rRPCXSDT8eZv 2jpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oWjWdFK+UzXUxIC1PHVEcLcVfmOLCn7lAe5Vf/6IX2c=; b=JpH6XEECYfQv/pVLEn7QQxXyCs0CWWro3Tfu9tfxT4krzDNfxZWD4Ykq8cmH+qdx/r 9ogUYLnDkKds7R3a+XY2PYgel5IHUsmjamqaxpiiSG2NuCmNWNZWiGR/Eb6vB+bgR+F2 yUIKQvYcaUa8wD5sTe91nRbKZo5Kc9JSPMYVffADNGW1t7CDbhhqRyzVYGeDKVZUU5Jr N8KFhH2nB6wc7QpbJRl/gnayjsJ9o5UAz1+g6rNpVHVPFX8EZYZEfvSgMfOycvFQTfUU Ypza/jT5d8c1tKuZv+jHi1FGfeH2LntMjHoJAuKG7t4jBM7AoRLYMABuZxLEvlgj+Cs3 8qsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=X9qGVwD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il11-20020a17090b164b00b0024be0f71516si5776514pjb.69.2023.05.14.22.46.34; Sun, 14 May 2023 22:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=X9qGVwD8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235175AbjEOF0E (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Mon, 15 May 2023 01:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234111AbjEOFZ5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 15 May 2023 01:25:57 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F789172B for <linux-kernel@vger.kernel.org>; Sun, 14 May 2023 22:25:51 -0700 (PDT) X-UUID: efb70004f2e011edb20a276fd37b9834-20230515 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=oWjWdFK+UzXUxIC1PHVEcLcVfmOLCn7lAe5Vf/6IX2c=; b=X9qGVwD8xM3qd00EuogpOox0yuFdzKGMEzf1M2F4QUJRHji4E4tj8dyIEiSqDjPoWueHMHKyN0j+0GhVub3YrcAU+3u+k5LEDOeBWPCmold0Qtp8yKR7mZ39qAEa7Uyb8ROrm2ZcXQwcNc8w+iSrVyIznqD6Gb0MlBSQKbJoYgs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.24,REQID:ff97226c-de39-49bb-b7be-fffd7399568d,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:178d4d4,CLOUDID:f8bd2a3b-de1e-4348-bc35-c96f92f1dcbb,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: efb70004f2e011edb20a276fd37b9834-20230515 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from <trevor.wu@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1304088002; Mon, 15 May 2023 13:25:42 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 15 May 2023 13:25:41 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 15 May 2023 13:25:41 +0800 From: Trevor Wu <trevor.wu@mediatek.com> To: <pierre-louis.bossart@linux.intel.com>, <peter.ujfalusi@linux.intel.com>, <yung-chuan.liao@linux.intel.com>, <ranjani.sridharan@linux.intel.com>, <kai.vehmanen@linux.intel.com>, <daniel.baluta@nxp.com>, <broonie@kernel.org>, <lgirdwood@gmail.com>, <tiwai@suse.com>, <perex@perex.cz>, <matthias.bgg@gmail.com>, <angelogioacchino.delregno@collabora.com> CC: <trevor.wu@mediatek.com>, <yc.hung@mediatek.com>, <tinghan.shen@mediatek.com>, <sound-open-firmware@alsa-project.org>, <alsa-devel@alsa-project.org>, <linux-mediatek@lists.infradead.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH 1/2] ASoC: SOF: mediatek: add mt8188 audio support Date: Mon, 15 May 2023 13:25:39 +0800 Message-ID: <20230515052540.9037-2-trevor.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230515052540.9037-1-trevor.wu@mediatek.com> References: <20230515052540.9037-1-trevor.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-MTK: N X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,RDNS_NONE, SPF_HELO_PASS,T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765937886201595761?= X-GMAIL-MSGID: =?utf-8?q?1765937886201595761?= |
Series |
ASoC: SOF: add mt8188 audio support
|
|
Commit Message
Trevor Wu (吳文良)
May 15, 2023, 5:25 a.m. UTC
Add mt8188 dai driver and specify of_machine to support mt8188 audio. Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Yaochun Hung <yc.hung@mediatek.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> --- sound/soc/sof/mediatek/mt8186/mt8186.c | 61 +++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-)
Comments
Il 15/05/23 07:25, Trevor Wu ha scritto: > Add mt8188 dai driver and specify of_machine to support mt8188 audio. > > Signed-off-by: Trevor Wu <trevor.wu@mediatek.com> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> > Reviewed-by: Yaochun Hung <yc.hung@mediatek.com> > Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> > --- > sound/soc/sof/mediatek/mt8186/mt8186.c | 61 +++++++++++++++++++++++++- > 1 file changed, 60 insertions(+), 1 deletion(-) > > diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c > index 419913c8474d..3a9c81418c1f 100644 > --- a/sound/soc/sof/mediatek/mt8186/mt8186.c > +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c > @@ -594,7 +594,65 @@ static const struct sof_dev_desc sof_of_mt8186_desc = { > .ops = &sof_mt8186_ops, > }; > > +/* > + * DL2, DL3, UL4, UL5 are registered as SOF FE, so creating the corresponding > + * SOF BE to complete the pipeline. > + */ > +static struct snd_soc_dai_driver mt8188_dai[] = { > +{ > + .name = "SOF_DL2", > + .playback = { > + .channels_min = 1, > + .channels_max = 2, > + }, > +}, > +{ > + .name = "SOF_DL3", > + .playback = { > + .channels_min = 1, > + .channels_max = 2, > + }, > +}, > +{ > + .name = "SOF_UL4", > + .capture = { > + .channels_min = 1, > + .channels_max = 2, > + }, > +}, > +{ > + .name = "SOF_UL5", > + .capture = { > + .channels_min = 1, > + .channels_max = 2, > + }, > +}, > +}; > + > +/* mt8188 ops */ > +static struct snd_sof_dsp_ops sof_mt8188_ops; > + > +static int sof_mt8188_ops_init(struct snd_sof_dev *sdev) > +{ > + /* common defaults */ > + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct snd_sof_dsp_ops)); Never use sizeof(type), always use destination var size! Anyway, there's more. I don't think we need to perform this memcpy: we'll never see an instance of both mt8186 and mt8188 drivers on the same machine, so you can safely just use sof_mt8186_ops for mt8188... > + > + sof_mt8188_ops.drv = mt8188_dai; ...which obviously means that this becomes sof_mt8186_ops.drv = mt8188_dai; and.... > + sof_mt8186_ops.num_drv = ARRAY_SIZE(mt8188_dai); > + > + return 0; > +} > + > +static struct snd_sof_of_mach sof_mt8188_machs[] = { > + { > + .compatible = "mediatek,mt8188", > + .sof_tplg_filename = "sof-mt8188.tplg", > + }, > + {} > +}; > + > static const struct sof_dev_desc sof_of_mt8188_desc = { > + .of_machines = sof_mt8188_machs, > .ipc_supported_mask = BIT(SOF_IPC), > .ipc_default = SOF_IPC, > .default_fw_path = { > @@ -607,7 +665,8 @@ static const struct sof_dev_desc sof_of_mt8188_desc = { > [SOF_IPC] = "sof-mt8188.ri", > }, > .nocodec_tplg_filename = "sof-mt8188-nocodec.tplg", > - .ops = &sof_mt8186_ops, > + .ops = &sof_mt8188_ops, ...this keeps being sof_mt8186_ops as well. > + .ops_init = sof_mt8188_ops_init, > }; > > static const struct of_device_id sof_of_mt8186_ids[] = { Regards, Angelo
On Mon, May 15, 2023 at 01:25:44PM +0200, AngeloGioacchino Del Regno wrote: > Il 15/05/23 07:25, Trevor Wu ha scritto: > > +{ > > + /* common defaults */ > > + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct snd_sof_dsp_ops)); > Never use sizeof(type), always use destination var size! Anyway, there's more. > > I don't think we need to perform this memcpy: we'll never see an instance of > both mt8186 and mt8188 drivers on the same machine, so you can safely just use > sof_mt8186_ops for mt8188... > > + sof_mt8188_ops.drv = mt8188_dai; > ...which obviously means that this becomes > sof_mt8186_ops.drv = mt8188_dai; This does have the issue that it then means the ops struct isn't const which isn't ideal. It's also not the end of the world though so I don't have super strong feelings.
On 5/15/23 10:05, Mark Brown wrote: > On Mon, May 15, 2023 at 01:25:44PM +0200, AngeloGioacchino Del Regno wrote: >> Il 15/05/23 07:25, Trevor Wu ha scritto: > >>> +{ >>> + /* common defaults */ >>> + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct snd_sof_dsp_ops)); > >> Never use sizeof(type), always use destination var size! Anyway, there's more. >> >> I don't think we need to perform this memcpy: we'll never see an instance of >> both mt8186 and mt8188 drivers on the same machine, so you can safely just use >> sof_mt8186_ops for mt8188... > >>> + sof_mt8188_ops.drv = mt8188_dai; > >> ...which obviously means that this becomes > >> sof_mt8186_ops.drv = mt8188_dai; > > This does have the issue that it then means the ops struct isn't const > which isn't ideal. It's also not the end of the world though so I don't > have super strong feelings. We do the same for Intel devices, we have a common structure which is copied and only the members that differ in specific SOCs are updated. You're right that it's not constant, but it avoids copy-paste of a rather large structure just to change a couple of lines.
On Mon, 2023-05-15 at 10:28 -0500, Pierre-Louis Bossart wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > On 5/15/23 10:05, Mark Brown wrote: > > On Mon, May 15, 2023 at 01:25:44PM +0200, AngeloGioacchino Del > > Regno wrote: > > > Il 15/05/23 07:25, Trevor Wu ha scritto: > > > > +{ > > > > + /* common defaults */ > > > > + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct > > > > snd_sof_dsp_ops)); > > > > > > Never use sizeof(type), always use destination var size! Anyway, > > > there's more. OK, I will use sizeof(sof_mt8188_ops) instead. > > > > > > I don't think we need to perform this memcpy: we'll never see an > > > instance of > > > both mt8186 and mt8188 drivers on the same machine, so you can > > > safely just use > > > sof_mt8186_ops for mt8188... > > > > + sof_mt8188_ops.drv = mt8188_dai; > > > > > > ...which obviously means that this becomes > > > sof_mt8186_ops.drv = mt8188_dai; > > > > This does have the issue that it then means the ops struct isn't > > const > > which isn't ideal. It's also not the end of the world though so I > > don't > > have super strong feelings. > > We do the same for Intel devices, we have a common structure which is > copied and only the members that differ in specific SOCs are updated. > You're right that it's not constant, but it avoids copy-paste of a > rather large structure just to change a couple of lines. Currently, I prefer to follow the same implementation as Intel devices. It's easier to see a different ops exists for mt8188 in sof_of_mt8188_desc and it really avoids copy-paste of a large structure. Additionally, I found a typo in the next line. sof_mt8186_ops.num_drv = ARRAY_SIZE(mt8188_dai); ^ This should be sof_mt8188_ops. I will correct it in V2. Thanks, Trevor
On Mon, 2023-05-15 at 10:28 -0500, Pierre-Louis Bossart wrote: > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > On 5/15/23 10:05, Mark Brown wrote: > > On Mon, May 15, 2023 at 01:25:44PM +0200, AngeloGioacchino Del > > Regno wrote: > > > Il 15/05/23 07:25, Trevor Wu ha scritto: > > > > +{ > > > > + /* common defaults */ > > > > + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct > > > > snd_sof_dsp_ops)); > > > Never use sizeof(type), always use destination var size! Anyway, > > > there's more. OK, I will use sizeof(sof_mt8188_ops) instead. > > > > > > I don't think we need to perform this memcpy: we'll never see an > > > instance of > > > both mt8186 and mt8188 drivers on the same machine, so you can > > > safely just use > > > sof_mt8186_ops for mt8188... > > > > + sof_mt8188_ops.drv = mt8188_dai; > > > ...which obviously means that this becomes > > > sof_mt8186_ops.drv = mt8188_dai; > > > > This does have the issue that it then means the ops struct isn't > > const > > which isn't ideal. It's also not the end of the world though so I > > don't > > have super strong feelings. > > We do the same for Intel devices, we have a common structure which is > copied and only the members that differ in specific SOCs are updated. > You're right that it's not constant, but it avoids copy-paste of a > rather large structure just to change a couple of lines. Currently, I prefer to follow the same implementation as Intel devices. It's easier to see a different ops exists for mt8188 in sof_of_mt8188_desc and it really avoids copy-paste of a large structure. Additionally, I found a typo in the next line. sof_mt8186_ops.num_drv = ARRAY_SIZE(mt8188_dai); ^ This should be sof_mt8188_ops. I will correct it in V2. Thanks, Trevor
diff --git a/sound/soc/sof/mediatek/mt8186/mt8186.c b/sound/soc/sof/mediatek/mt8186/mt8186.c index 419913c8474d..3a9c81418c1f 100644 --- a/sound/soc/sof/mediatek/mt8186/mt8186.c +++ b/sound/soc/sof/mediatek/mt8186/mt8186.c @@ -594,7 +594,65 @@ static const struct sof_dev_desc sof_of_mt8186_desc = { .ops = &sof_mt8186_ops, }; +/* + * DL2, DL3, UL4, UL5 are registered as SOF FE, so creating the corresponding + * SOF BE to complete the pipeline. + */ +static struct snd_soc_dai_driver mt8188_dai[] = { +{ + .name = "SOF_DL2", + .playback = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_DL3", + .playback = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_UL4", + .capture = { + .channels_min = 1, + .channels_max = 2, + }, +}, +{ + .name = "SOF_UL5", + .capture = { + .channels_min = 1, + .channels_max = 2, + }, +}, +}; + +/* mt8188 ops */ +static struct snd_sof_dsp_ops sof_mt8188_ops; + +static int sof_mt8188_ops_init(struct snd_sof_dev *sdev) +{ + /* common defaults */ + memcpy(&sof_mt8188_ops, &sof_mt8186_ops, sizeof(struct snd_sof_dsp_ops)); + + sof_mt8188_ops.drv = mt8188_dai; + sof_mt8186_ops.num_drv = ARRAY_SIZE(mt8188_dai); + + return 0; +} + +static struct snd_sof_of_mach sof_mt8188_machs[] = { + { + .compatible = "mediatek,mt8188", + .sof_tplg_filename = "sof-mt8188.tplg", + }, + {} +}; + static const struct sof_dev_desc sof_of_mt8188_desc = { + .of_machines = sof_mt8188_machs, .ipc_supported_mask = BIT(SOF_IPC), .ipc_default = SOF_IPC, .default_fw_path = { @@ -607,7 +665,8 @@ static const struct sof_dev_desc sof_of_mt8188_desc = { [SOF_IPC] = "sof-mt8188.ri", }, .nocodec_tplg_filename = "sof-mt8188-nocodec.tplg", - .ops = &sof_mt8186_ops, + .ops = &sof_mt8188_ops, + .ops_init = sof_mt8188_ops_init, }; static const struct of_device_id sof_of_mt8186_ids[] = {