From patchwork Thu Apr 15 01:56:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 12204087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98286C433ED for ; Thu, 15 Apr 2021 01:57:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA9706115C for ; Thu, 15 Apr 2021 01:57:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA9706115C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 424A3165E; Thu, 15 Apr 2021 03:56:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 424A3165E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1618451841; bh=Gr8bvKM/nEpTYPkbWY7IYtAOvACCW0edNBgxMu0kHuA=; h=Date:From:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=m8IncN4pUXXK7glFlpmASe83zYy7X5bC93dnpChTeRPzctGuTF+RaHqe1NHWS3AdH nTycow0bkKw6I109FFPzudpMQVhH+PgJS7Hu96tr2TNvYZQdjP5hcNgfwi+tt+zXbB ArCMSYmbaLngU5UK5jqas85wYuqH5lPnqmWOk6PI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B142DF8021D; Thu, 15 Apr 2021 03:56:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B19DAF8022B; Thu, 15 Apr 2021 03:56:28 +0200 (CEST) Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by alsa1.perex.cz (Postfix) with ESMTP id 1D0CFF800FF for ; Thu, 15 Apr 2021 03:56:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1D0CFF800FF Date: 15 Apr 2021 10:56:14 +0900 X-IronPort-AV: E=Sophos;i="5.82,223,1613401200"; d="scan'208";a="78343223" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Apr 2021 10:56:14 +0900 Received: from mercury.renesas.com (unknown [10.166.252.133]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 8944D401325E; Thu, 15 Apr 2021 10:56:14 +0900 (JST) Message-ID: <87a6q0z4xt.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH] ASoC: soc-pcm: fixup soc_pcm_params_symmetry() User-Agent: Wanderlust/2.15.9 Emacs/26.3 Mule/6.0 To: Mark Brown MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Kuninori Morimoto commit 3a9067211122 ("ASoC: soc-pcm: cleanup soc_pcm_params_symmetry()") cleanups soc_pcm_params_symmetry() by addig new __soc_pcm_params_symmetry() macro. It checks symmetry first, and checks each DAI settings if symmetry was true. But original code checked symmetric_rate : DAI_Link / CPU (A) symmetric_channels : DAI_Link / CPU / Codec (B) symmetric_sample_bits : DAI_Link / CPU / Codec (B) (A) was using for_each_rtd_cpu_dais() (B) was using for_each_rtd_dais() Current code is using (B) for all symmetric_xxx. This is bug. One note is that we can use .be_hw_params_fixup in DPCM case. This means, BE settings might be fixuped/updated by FE. It can be happen not only for rate, but for channels/sample_bits too. And also, DPCM uses dummy-DAI which will be used for all DPCM connectoin. ALSA SoC will clean DAI params (a) if it was last user (b). But dummy-DAI is used from many place, it might not be cleaned. static int soc_pcm_hw_clean(...) { ... for_each_rtd_dais(rtd, i, dai) { ... (b) if (snd_soc_dai_active(dai) == 1) (a) soc_pcm_set_dai_params(dai, NULL); ... } ... } The solution maybe (A1) Symmetric checks CPU only (A2) Symmetric checks both CPU / Codec, but ignores dummy-DAI This patch selects A1. For example, if Sound Card is exchanging all rate to 48kHz by using .be_hw_params_fixup() on DPCM, below can be happen. It is using 44100 Hz, but has mismatch between dummy-DAI which is keeping 48kHz from 1st aplay. # aplay 44100.wav # aplay 44100.wav => [kernel] be.ak4613-hifi: ASoC: unmatched rate symmetry: 44100 - 48000 [kernel] be.ak4613-hifi: ASoC: hw_params BE failed -22 [kernel] fe.rsnd-dai.0: ASoC: hw_params BE failed -22 aplay: set_params:1407: Unable to install hw params: ACCESS: RW_INTERLEAVED FORMAT: S16_LE SUBFORMAT: STD SAMPLE_BITS: 16 FRAME_BITS: 32 CHANNELS: 2 RATE: 44100 PERIOD_TIME: (23219 23220) PERIOD_SIZE: 1024 PERIOD_BYTES: 4096 PERIODS: 4 BUFFER_TIME: (92879 92880) BUFFER_SIZE: 4096 BUFFER_BYTES: 16384 TICK_TIME: 0 Fixes: 3a9067211122 ("ASoC: soc-pcm: cleanup soc_pcm_params_symmetry()") Signed-off-by: Kuninori Morimoto --- Hi Mark This patch is needed for latest linus tree (= for v5.12). Please let me know if you want (A2). sound/soc/soc-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 02968a4e52b4..92e95e4aef9f 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -388,7 +388,7 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, #define __soc_pcm_params_symmetry(name) \ symmetry = rtd->dai_link->symmetric_##name; \ - for_each_rtd_dais(rtd, i, dai) \ + for_each_rtd_cpu_dais(rtd, i, dai) \ symmetry |= dai->driver->symmetric_##name; \ \ if (symmetry) \