From patchwork Tue Oct 24 03:50:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWFzbyBIdWFuZyAo6buD5Yqg56u5KQ==?= X-Patchwork-Id: 157237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1699670vqx; Mon, 23 Oct 2023 20:51:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE16gQ916+1HjEZeCIz5Ia5Y8q8PdrZKVqwNYdiNrfnSK3/nupZvtzaYN9L31uncKeMHvcC X-Received: by 2002:a17:902:e414:b0:1b8:94e9:e7cb with SMTP id m20-20020a170902e41400b001b894e9e7cbmr6471797ple.21.1698119485546; Mon, 23 Oct 2023 20:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698119485; cv=none; d=google.com; s=arc-20160816; b=LfTIv6DS63I08cNY7LpOAvw2YprFijbeWt8IpsIxcsnFc9+fqDk4EAd82glMA4MsVJ ou+RR4Ozdy7rJWaALLENcjtL9MhO5BHVsoQ+fLz1HdXmTqEwpFyu4Pq3x9JqXfrgCLT3 rrJidqizDQVCsyDOz6h2gjh1C8OvQ0bS9YVUQ/Mv2O1l5iQ3xE6kZBq2Ewb7rFDipzWu Kdn/BZqoM3qcLbFMxUFQF56albuQv7TudUVM2dv42I5aA3nszJJKHBjvaXLaH2oKyZjP iY/QInSo+GlLADYj55fuitMXUA382al+76RoVFKXVtNS/FlhKJbE/xX4PTgnab/X5+zw axyg== 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=Hzi+kjq1QCG+TxJwfKjMZ8NZ7VLcxkHOjhgyuRv3grs=; fh=JK4CFQ8GWUIPGXLDWWc8KlajGC5ELjySWqtosj4q5Ec=; b=hwNBK2g0WR6oF3j0HpoksO+YvC9rRWmHFffhVHhen2aMb9Em9CsB4m7ukO1ka1b1Zn m/WsyUlUdiSzjIORSDRSxio8iBGigcK17F0ooMMw+wtuuOJ+rIdpMLo5X3mkQQvr04dZ kmEohIWQjo4+JHCeOkP7PAl7GBnizixVz7/V6uFZlA5kka5XojriEnJGpl4DP3U2IAjj Jr6EPGj/KjA9fXtfAHkHZca5jb0jvbaabnnk3IEdGsS1RwvaVCAGu07YLF/1Wt/uqVv8 WtdRBsXKBAPE6g3whJ3EZ3cEWsK74rt+wQ3NBVhxIaW3WPR6ThU4WT54nI4GsE04DNlN hwyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ZAtbjqhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id jm17-20020a17090304d100b001c0c4be62basi7491646plb.617.2023.10.23.20.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:51:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ZAtbjqhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 5FB438077910; Mon, 23 Oct 2023 20:51:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbjJXDvM (ORCPT + 27 others); Mon, 23 Oct 2023 23:51:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232082AbjJXDvB (ORCPT ); Mon, 23 Oct 2023 23:51:01 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C747111 for ; Mon, 23 Oct 2023 20:50:59 -0700 (PDT) X-UUID: 86e65fba722011eea33bb35ae8d461a2-20231024 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=Hzi+kjq1QCG+TxJwfKjMZ8NZ7VLcxkHOjhgyuRv3grs=; b=ZAtbjqhLEC3Phj/sfE1wRmh7bYNDNxDQDQabtBKbODJfpmQkSqAbe7YLSOCz1/2tStXGtxgmFew7lArJYnNG1eS+NZIp6Mo44oeKdiQbZ4B+tDg8l+qplYQ0Nq8kurcegbjaYAr1x/n70y7HMAH7gzidwsF4mRHVsZup+q1xYZU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:24b6c52f-7136-465e-bf3f-a467d2bd27cb,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:c4153dd7-04a0-4e50-8742-3543eab8cb8e,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 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 86e65fba722011eea33bb35ae8d461a2-20231024 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1219510997; Tue, 24 Oct 2023 11:50:52 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) 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; Tue, 24 Oct 2023 11:50:50 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Tue, 24 Oct 2023 11:50:50 +0800 From: Maso Huang To: Liam Girdwood , Mark Brown , Matthias Brugger , AngeloGioacchino Del Regno , Jaroslav Kysela , Takashi Iwai , , , , CC: Maso Huang Subject: [PATCH v2 3/3] ASoC: mediatek: mt7986: add sample rate checker Date: Tue, 24 Oct 2023 11:50:19 +0800 Message-ID: <20231024035019.11732-4-maso.huang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231024035019.11732-1-maso.huang@mediatek.com> References: <20231024035019.11732-1-maso.huang@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--0.254500-8.000000 X-TMASE-MatchedRID: WkwGkWg/ZspKHSI+NapVgED6z8N1m1ALjZfFaL+4qfbfUZT83lbkEEFN G6vV64NpO3riJykx75rW3uke8Pv2jOF/B1jEjV+6syw+ZJnFumSO7tU+Bv65zZsoi2XrUn/Jn6K dMrRsL14qtq5d3cxkNRqXnrxrKCOXCZj5fT4j8U275XnfFOTeSbM3sLfmvJJnL8byqNXfKSxrcR mc7SDNwoCTKY6V6aLxs+jdM0RxJufk5os5jdQqLeFh/bIV6nmTF0aD5ljt43pMcHZD6gqu7wxMj fifIXfowkvVoA11Twp+3BndfXUhXQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--0.254500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: D6FCDEDC649C83FF83C52FDACE0A28DEEB531C3639EE048AE42732BB07E90FCF2000:8 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:51:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780607337907982094 X-GMAIL-MSGID: 1780607337907982094 mt7986 only supports 8/12/16/24/32/48/96/192 kHz Signed-off-by: Maso Huang Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 23 +++++++++++++++++---- 1 file changed, 19 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..d57971413a04 100644 --- a/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c +++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c @@ -237,12 +237,27 @@ 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_err(afe->dev, + "Sample rate %d invalid. Supported rates: 8/12/16/24/32/48/96/192 kHz\n", + rate); + return -EINVAL; + } } static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd,