From patchwork Thu Feb 9 12:28:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 54927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp306263wrn; Thu, 9 Feb 2023 04:32:13 -0800 (PST) X-Google-Smtp-Source: AK7set87NpOtLfkMa+WJYWjkmJ/9BCxTnM2E45gIBoBpSK5g5xcnqcINvXsIHF7GhiDroTjjEnLv X-Received: by 2002:a50:8ac2:0:b0:4aa:b216:3e23 with SMTP id k2-20020a508ac2000000b004aab2163e23mr11529921edk.30.1675945933582; Thu, 09 Feb 2023 04:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675945933; cv=none; d=google.com; s=arc-20160816; b=GHE1qxWbuWzlPaO6NKzcMQP9sVBJcZ1vZNP5KgI45a94uzTACiRt8ursTZRyYHk3dR 3SfOdTZQjXiYqyOyuKpVcBRnfiL1F1o4NuYT5Tg4c1a14azKwGgpcBXfk2qc6iSaAuSC AqEHfeVHMzmmKBgqDI2yVNM16XXz0YIKbKKFPl+wL3k9PMXJPegnZeG+BBZ5JjA951mo 1wiFlSefnpKQok1XySiMl18SzbEYcDnUtUislZS8QcAc0JBauCHHc5D7OtQb53NSg/sV B4vXbWL7wxHmWr/w6CsQooAJBskr6Z8k2aXtLu/E/NnmzcZt3Rj6WVHtV60eJv7DgOVN DRow== 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=la+zSqZHnDH4NrBUp1B5sU6rN4yJdP2UMwQ4cL39N1A=; b=zV3f63A0sKnIG1WbAWpf05px9rb8QqjV3zlcDGeiPS0MdIP59uCvUkOM54pLRjIHr+ xCKY9AuXqfBnVDsBptD3VVbKJsszRPaGcblX6Na3Gungc4+gxuv3+GeiAw0g6Ys783c2 v5SuKjAQs8x15+FJG5K9ivsFQ5LayOUfCvPOL3JCfu36MziDPkSLGNf/RriACTNLIsJ6 lrSfmGcg93oLPAQSr2pTUxfMWJgNgbyqZdM7zp4zdc3HQtMtxaxvT6Mbuy0Do4NVbXQi hQG8sJ7DKWxj/uzuoZ33LV/Uvr0Ae4E716iH1NbgRyNEYeE7Agl/LHBJL1WaAeGkecJd 4OvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NjJeO8Gg; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d12-20020a50ea8c000000b0045fca739593si2120509edo.188.2023.02.09.04.31.49; Thu, 09 Feb 2023 04:32:13 -0800 (PST) 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=@linaro.org header.s=google header.b=NjJeO8Gg; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjBIM2u (ORCPT + 99 others); Thu, 9 Feb 2023 07:28:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbjBIM2W (ORCPT ); Thu, 9 Feb 2023 07:28:22 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C0F923C62 for ; Thu, 9 Feb 2023 04:28:20 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id a2so1590099wrd.6 for ; Thu, 09 Feb 2023 04:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=la+zSqZHnDH4NrBUp1B5sU6rN4yJdP2UMwQ4cL39N1A=; b=NjJeO8GgEt5hDiYdbv5bupUhixSFr+wUIsKkd+sY5GLYBTq3Hm+wfWYDNRbQCj3qyY lOCho4plKkO9xSwt3s6vP5IOL3mcbj0Ex52Mfmy1ajY5I7d5jaohXOg55uyzw2cgg3KI zgy84M8Q2FOmONb5dw8Q94MiDi+jbATkcD7EUUIhhDRYnFxgGTlyP3aKIr+4McvVWIGu STr+HyKJGeHESpFdQIBMdibvzGHzG6bf02K5nMsod7TWj1YZmiLmmXL3cwAnjnQVSnB3 FMVlG4qroocbJHKg/bHiL9zWuyvnSsHQmeD/CtqPUwprP2y2DmVZaIuGXhyRuxevolhG 7wIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=la+zSqZHnDH4NrBUp1B5sU6rN4yJdP2UMwQ4cL39N1A=; b=UnvmK6DUkOKqRYH848vIuWqlFVYj66Qc3ixVxfzSDeRUnG0qNb9wh3ZhO4uMA1kzBH JrQOsPSonmCv27fbGyQx36iH2CgDx4X7Wp3kRHuSyskyA6TCQbZIGgkeguw5oVS50cT6 QTntz2MCnQeEqJbc09VRRj+kRW8XgftEJkR6RalmXgF+sneqxivdusCLvpCHEj9fO+lf XXzPwSFzU13Xla0zSnxep1vcqKzE2vmXxm5sV3zerf72eWXNqpaKMy33tSDmNl3IxYKR Ss0Y4kxN/u5iytQ3G4JghkXlicrOtrDVabWkJl/B+pGfjAuzW9JqCjkOZmU1VtHMgsBO 7HJQ== X-Gm-Message-State: AO0yUKXAehZMMmOQ66DJGgq3g9aMCGGKyPArn6RftIva4NGay2423Mva jv/sh+k+MBevWWrHhdRJaeK62A== X-Received: by 2002:adf:f9cc:0:b0:2c3:e7d8:245c with SMTP id w12-20020adff9cc000000b002c3e7d8245cmr10617613wrr.13.1675945699206; Thu, 09 Feb 2023 04:28:19 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id o8-20020a5d58c8000000b002c3f0a4ce98sm1134763wrf.98.2023.02.09.04.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 04:28:18 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, steev@kali.org, johan+linaro@kernel.org, quic_bjorande@quicinc.com, Srinivas Kandagatla Subject: [PATCH 3/8] ASoC: qcom: q6apm-dai: Add SNDRV_PCM_INFO_BATCH flag Date: Thu, 9 Feb 2023 12:28:01 +0000 Message-Id: <20230209122806.18923-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230209122806.18923-1-srinivas.kandagatla@linaro.org> References: <20230209122806.18923-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 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_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757356683226735438?= X-GMAIL-MSGID: =?utf-8?q?1757356683226735438?= At the moment, playing audio with PulseAudio with the qdsp6 driver results in distorted sound. It seems like its timer-based scheduling does not work properly with qdsp6 since setting tsched=0 in the PulseAudio configuration avoids the issue. Apparently this happens when the pointer() callback is not accurate enough. There is a SNDRV_PCM_INFO_BATCH flag that can be used to stop PulseAudio from using timer-based scheduling by default. According to https://www.alsa-project.org/pipermail/alsa-devel/2014-March/073816.html: The flag is being used in the sense explained in the previous audio meeting -- the data transfer granularity isn't fine enough but aligned to the period size (or less). q6apm-dai reports the position as multiple of prtd->pcm_count = snd_pcm_lib_period_bytes(substream) so it indeed just a multiple of the period size. Therefore adding the flag here seems appropriate and makes audio work out of the box. Comment log inspired by Stephan Gerhold sent for q6asm-dai.c few years back. Fixes: 9b4fe0f1cd79 ("ASoC: qdsp6: audioreach: add q6apm-dai support") Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6apm-dai.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/qcom/qdsp6/q6apm-dai.c b/sound/soc/qcom/qdsp6/q6apm-dai.c index bd35067a4052..7f02f5b2c33f 100644 --- a/sound/soc/qcom/qdsp6/q6apm-dai.c +++ b/sound/soc/qcom/qdsp6/q6apm-dai.c @@ -64,7 +64,8 @@ struct q6apm_dai_data { static struct snd_pcm_hardware q6apm_dai_hardware_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_BATCH), .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE), .rates = SNDRV_PCM_RATE_8000_48000, .rate_min = 8000, @@ -82,7 +83,8 @@ static struct snd_pcm_hardware q6apm_dai_hardware_capture = { static struct snd_pcm_hardware q6apm_dai_hardware_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME), + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | + SNDRV_PCM_INFO_BATCH), .formats = (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE), .rates = SNDRV_PCM_RATE_8000_192000, .rate_min = 8000,