Message ID | 20231023095453.4860-3-maso.huang@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1182736vqx; Mon, 23 Oct 2023 02:57:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/popiKDENjzuK/5WlshGaO5rIemKNKKyrzklrGXTEBSvE9V94XxETNz/+pcje8GMHCj6o X-Received: by 2002:a05:6a20:9153:b0:17b:2c56:70bc with SMTP id x19-20020a056a20915300b0017b2c5670bcmr10800660pzc.10.1698055029104; Mon, 23 Oct 2023 02:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698055029; cv=none; d=google.com; s=arc-20160816; b=EOKRvfN31SITtiRUbNtLS1hmIXnMgRU3w33iiVAcBzoYFIAvsGkY0VV1R9CjcIUbZv Q9LyvCM7yYoN3mKbGeA+X6xZ7BdPQxCW841IUkoVwHH0IHiCBUDsMkgGt7397v8fTRZI avjbkWs4owa9QxOZSMMtxwAwn9y5gyiZ512oe4+qhSoBDyL3/19VJHbDe0kok+sJpNTq jFvIzx40PvajI5ADbtIBgr5kcz6GELOwpBCiNJ7NXujd89lumh4td6+4xq/Doh2iKUyH zWffX7dFWGYAhBZnOAHBTBRJktsXdIRwmUvYiPloMXJ+p6IglwWnA3XFNRMo0mogR7pl Mzww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Jkw7gW1AVmrX/Nr58wDn+UzhFqI704qvqC+4AjLfSfk=; fh=JK4CFQ8GWUIPGXLDWWc8KlajGC5ELjySWqtosj4q5Ec=; b=bjNc8JGzoTypXPKuorGVD3yE+KVD+fGFE30HeA9X/FU+u/Z4w443IIP/iWBv9YRv/M KJ/jn0HOSEsjdqWeynTMxBjB2Do7nNLMT6okDN6Fs7JBtfJdTyHVOWU+DHASgj6Hm9mQ +aQ+zL1wlZbJWazQHR00SLgjHoQ+7nxAirdfKXR9Y+kju2TkFlq1JTE22mznSnw/SFAB sjwgBtX3jgbVjvuBQrEk6HMj1D/aUCh/O8ln+ShGESGZvmDlPlWznSiSC0TILJJ7chbO 8Z2zvOee/EACAm2f8ZCG47Vf4uNB2fzsMpNtSnvobT2miED3bIdefyYdVBs8LXuOSBOr RyTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XA0HCV06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d38-20020a631d66000000b005781e99d048si6069159pgm.889.2023.10.23.02.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 02:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=XA0HCV06; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6DA478040EF8; Mon, 23 Oct 2023 02:57:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233683AbjJWJ4u (ORCPT <rfc822;aposhian.dev@gmail.com> + 27 others); Mon, 23 Oct 2023 05:56:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232476AbjJWJ4K (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 23 Oct 2023 05:56:10 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDDC71BFE for <linux-kernel@vger.kernel.org>; Mon, 23 Oct 2023 02:55:20 -0700 (PDT) X-UUID: 44c815d8718a11eea33bb35ae8d461a2-20231023 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Jkw7gW1AVmrX/Nr58wDn+UzhFqI704qvqC+4AjLfSfk=; b=XA0HCV06g16G5cGuD7lwpieNY/w9MmEQD40b36NsbEBaDZcQQJphhre0qOIktGsewPPzD7H2wdInihYEfx0zjMBDwNpWHl39jFMfx6EdO5qrQ+vbnxAGHfHX8jYOxrG9K5BbXP04mFRcZwI9ZpRUevLfxKcXFO9IDyaL+DQemH0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:be9aa962-ec20-4742-a659-0ddef35e5e58,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:5f78ec9,CLOUDID:c8550b7d-ccd9-4df5-91ce-9df5fea3ae01,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,LES:1,SPR:NO, DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 44c815d8718a11eea33bb35ae8d461a2-20231023 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from <maso.huang@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1444177331; Mon, 23 Oct 2023 17:55:16 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Mon, 23 Oct 2023 17:55:15 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Mon, 23 Oct 2023 17:55:15 +0800 From: Maso Huang <maso.huang@mediatek.com> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org> CC: Maso Huang <maso.huang@mediatek.com> Subject: [PATCH 2/2] ASoC: mediatek: mt7986: add sample rate checker Date: Mon, 23 Oct 2023 17:54:53 +0800 Message-ID: <20231023095453.4860-3-maso.huang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231023095453.4860-1-maso.huang@mediatek.com> References: <20231023095453.4860-1-maso.huang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--1.222300-8.000000 X-TMASE-MatchedRID: xvSVK/1RoEatDMl6rQjWQgPZZctd3P4B9DuzN5Up01sOUs4CTUgKyzDK cAWm/vH3OfAiJ/eonC1mJS6k736MTF+1yB6ph7kzngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPI34T 9cYMsdwzHaTdqG3iWhhuHbDe2QawKVRjg2m4p6wZby31Am35MsCb7uY8ruzzlbTNil8EW6FkBjo g7tEcVQ80AvBonNwk5yqhYRUc589COh+wyNBrFXDJiNuKohDcKzKSG3JdyKAPqtV2AGMNPaiHWP YzouJUy X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.222300-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 4D0FF03452DC1FE5C8A4082C1A7BBA4D960451FB6C3A5B663ADC3AABEF886F3E2000:8 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 02:57:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780539750261381555 X-GMAIL-MSGID: 1780539750261381555 |
Series |
ASoC: mediatek: Remove redundant code and add sample rate checker of MT7986 SoC
|
|
Commit Message
Maso Huang (黃加竹)
Oct. 23, 2023, 9:54 a.m. UTC
mt7986 only supports 8/12/16/24/32/48/96/192 kHz
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
---
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 22 +++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
Comments
Il 23/10/23 11:54, Maso Huang ha scritto: > mt7986 only supports 8/12/16/24/32/48/96/192 kHz > > Signed-off-by: Maso Huang <maso.huang@mediatek.com> > --- > sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 22 +++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > index e523d33846fe..270852ce3dd9 100644 > --- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > +++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > @@ -237,12 +237,26 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream, > struct snd_pcm_hw_params *params, > struct snd_soc_dai *dai) > { > + unsigned int rate = params_rate(params); > struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); > > - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); > - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); > - > - return 0; > + switch (rate) { > + case 8000: > + case 12000: > + case 16000: > + case 24000: > + case 32000: > + case 48000: > + case 96000: > + case 192000: > + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); > + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); > + return 0; > + default: > + dev_warn(afe->dev, "%s(), sample rate: %d is not supported\n", __func__, rate); > + dev_warn(afe->dev, "%s(), only support 8/12/16/24/32/48/96/192 kHz\n", __func__); That's better: dev_err(afe->dev, "Sample rate %d invalid. Supported rates: 8/12/16/24/32/48/96/192 kHz\n", rate, __func__); after which, Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Regards, Angelo
On Mon, 2023-10-23 at 13:07 +0200, AngeloGioacchino Del Regno wrote: > Il 23/10/23 11:54, Maso Huang ha scritto: > > mt7986 only supports 8/12/16/24/32/48/96/192 kHz > > > > Signed-off-by: Maso Huang <maso.huang@mediatek.com> > > --- > > sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 22 > > +++++++++++++++++---- > > 1 file changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > > b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > > index e523d33846fe..270852ce3dd9 100644 > > --- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > > +++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c > > @@ -237,12 +237,26 @@ static int mtk_dai_etdm_hw_params(struct > > snd_pcm_substream *substream, > > struct snd_pcm_hw_params *params, > > struct snd_soc_dai *dai) > > { > > + unsigned int rate = params_rate(params); > > struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); > > > > - mtk_dai_etdm_config(afe, params, dai, > > SNDRV_PCM_STREAM_PLAYBACK); > > - mtk_dai_etdm_config(afe, params, dai, > > SNDRV_PCM_STREAM_CAPTURE); > > - > > - return 0; > > + switch (rate) { > > + case 8000: > > + case 12000: > > + case 16000: > > + case 24000: > > + case 32000: > > + case 48000: > > + case 96000: > > + case 192000: > > + mtk_dai_etdm_config(afe, params, dai, > > SNDRV_PCM_STREAM_PLAYBACK); > > + mtk_dai_etdm_config(afe, params, dai, > > SNDRV_PCM_STREAM_CAPTURE); > > + return 0; > > + default: > > + dev_warn(afe->dev, "%s(), sample rate: %d is not > > supported\n", __func__, rate); > > + dev_warn(afe->dev, "%s(), only support > > 8/12/16/24/32/48/96/192 kHz\n", __func__); > > That's better: > > dev_err(afe->dev, > "Sample rate %d invalid. Supported rates: > 8/12/16/24/32/48/96/192 kHz\n", > rate, __func__); > > after which, > > Reviewed-by: AngeloGioacchino Del Regno < > angelogioacchino.delregno@collabora.com> > > Regards, > Angelo > > Hi Angelo, Thanks for your review! I'll refine it in v2. Best regards, Maso
diff --git a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c index e523d33846fe..270852ce3dd9 100644 --- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c @@ -237,12 +237,26 @@ static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { + unsigned int rate = params_rate(params); struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai); - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); - mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); - - return 0; + switch (rate) { + case 8000: + case 12000: + case 16000: + case 24000: + case 32000: + case 48000: + case 96000: + case 192000: + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK); + mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE); + return 0; + default: + dev_warn(afe->dev, "%s(), sample rate: %d is not supported\n", __func__, rate); + dev_warn(afe->dev, "%s(), only support 8/12/16/24/32/48/96/192 kHz\n", __func__); + return -EINVAL; + } } static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd,