From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 93862C433E0 for ; Wed, 12 Aug 2020 14:47:53 +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 1AD8C204FD for ; Wed, 12 Aug 2020 14:47:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="aVm4wbks" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1AD8C204FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.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 6D3E584B; Wed, 12 Aug 2020 16:47:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6D3E584B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1597243671; bh=+f4cBF+p1aUH6nlB5jgKz2o52VlCFCLtr8WJSsFNRt8=; h=Subject:To:References:From:Date:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aVm4wbkskjokmI2oLzPAlPkvj+fmFPphn76+cSmbNyZRCQzGrH3TjBv/cWMjNTykq X+a1D881c/p4nTHKqdW8+sh9pFZTynNNLgfIRtznFKhghGWscQWx6mAb3PWKzKzy0B CgbgH/YW4KakNFDtx/zXOBxIH3AeZUTpqBERUnQQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F0ACDF801DB; Wed, 12 Aug 2020 16:47:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C4EEF8022B; Wed, 12 Aug 2020 16:46:59 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 074C9F800D3 for ; Wed, 12 Aug 2020 16:46:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 074C9F800D3 IronPort-SDR: ZhYBD2016yE5ExpC13RexiwtYjeudpraKMW4D7KBOop+62nXDqgjtMIBfnRrGmBllRfubogYd/ wDcFssc1JbMQ== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="153932144" X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="153932144" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 07:46:43 -0700 IronPort-SDR: o8Cq+YOgWp9qmw+FblQ9WE1g+XI0I+lCaQ85lcRakeBxWtHTZVHrRkPiUyBFVnvecIHwHDQV7P KVCXC9lOfGfw== X-IronPort-AV: E=Sophos;i="5.76,304,1592895600"; d="scan'208";a="469844036" Received: from rkiran1x-mobl1.amr.corp.intel.com (HELO [10.212.203.28]) ([10.212.203.28]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 07:46:42 -0700 Subject: Re: [PATCH v3 2/2] ASoC: Intel: Add period size constraint on strago board To: Takashi Iwai , Yu-Hsuan Hsu References: <3f3baf5e-f73d-9cd6-cbfb-36746071e126@linux.intel.com> <20200811145353.GG6967@sirena.org.uk> <20200811172209.GM6967@sirena.org.uk> From: Pierre-Louis Bossart Message-ID: Date: Wed, 12 Aug 2020 09:46:40 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Cc: Guennadi Liakhovetski , "alsa-devel@alsa-project.org" , Kuninori Morimoto , Kai Vehmanen , "Rojewski, Cezary" , Jie Yang , "linux-kernel@vger.kernel.org" , Takashi Iwai , Liam Girdwood , Sam McNally , Mark Brown , "yuhsuan@google.com" , Ranjani Sridharan , Daniel Stuart , Andy Shevchenko , "Lu, Brent" , Damian van Soelen 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" >>>>>> After doing some experiments, I think I can identify the problem more precisely. >>>>>> 1. aplay can not reproduce this issue because it writes samples >>>>>> immediately when there are some space in the buffer. However, you can >>>>>> add --test-position to see how the delay grows with period size 256. >>>>>>> aplay -Dhw:1,0 --period-size=256 --buffer-size=480 /dev/zero -d 1 -f dat --test-position >>>>>> Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 >>>>>> Hz, Stereo >>>>>> Suspicious buffer position (1 total): avail = 0, delay = 2064, buffer = 512 >>>>>> Suspicious buffer position (2 total): avail = 0, delay = 2064, buffer = 512 >>>>>> Suspicious buffer position (3 total): avail = 0, delay = 2096, buffer = 512 >>>>>> ... >>>>> >>>>> Isn't this about the alignment of the buffer size against the period >>>>> size, not the period size itself? i.e. in the example above, the >>>>> buffer size isn't a multiple of period size, and DSP can't handle if >>>>> the position overlaps the buffer size in a half way. >>>>> >>>>> If that's the problem (and it's an oft-seen restriction), the right >>>>> constraint is >>>>> snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); >>>>> >>>>> >>>>> Takashi >>>> Oh sorry for my typo. The issue happens no matter what buffer size is >>>> set. Actually, even if I want to set 480, it will change to 512 >>>> automatically. >>>> Suspicious buffer position (1 total): avail = 0, delay = 2064, buffer >>>> = 512 <-this one is the buffer size >>> >>> OK, then it means that the buffer size alignment is already in place. >>> >>> And this large delay won't happen if you use period size 240? >>> >>> >>> Takashi >> Yes! If I set the period size to 240, it will not print "Suspicious >> buffer position ..." > > So it sounds like DSP handles the delay report incorrectly. > Then it comes to another question: the driver supports both SOF and > SST. Is there the behavior difference between both DSPs wrt this > delay issue? I still don't get what the issue is. The two following cases work fine with the SST/Atom driver: root@chrx:~# aplay -Dhw:0,0 --period-size=240 --buffer-size=480 /dev/zero -d 2 -f dat --test-position Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo root@chrx:~# aplay -Dhw:0,0 --period-size=960 --buffer-size=4800 /dev/zero -d 2 -f dat --test-position Playing raw data '/dev/zero' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo The existing code has this: /* Make sure, that the period size is always even */ snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, 2); return snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); and with the addition of period size being a multiple of 1ms all requirements should be met?