Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5595186imu; Tue, 13 Nov 2018 08:51:47 -0800 (PST) X-Google-Smtp-Source: AJdET5cLEZ7VwvGu1u3s9krgtKcNnNnyPqUFASmtSHhLCqkTUpnx2I7O1qCNBJiZyJKDvso9Aycm X-Received: by 2002:a17:902:7587:: with SMTP id j7mr4269932pll.191.1542127907256; Tue, 13 Nov 2018 08:51:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542127907; cv=none; d=google.com; s=arc-20160816; b=V4/kxGb5z8nhQgpeBGMv0kCmO78a4cueBriHXe1Y8kafPtOWtZj3IbDrzMAiOIw99g hlIIEx3T/cL/blMgRCy+gcYy3I57jAQDstnT8QyTTmtDsd6hxQHfWQWSj55tvKVH7GQ3 QknP37EVREur6bO/hxSqxGMhbmXNFrHIAwCB3y50v0kPK3HrMPuz8mWTH9FN5u1Yzmt8 jEGdeBUn+kL/0u3/mHoN70s5Le2kdL3VOZZ3zy0mS6thBRVk/g7aIPj4S5+LEKefemwG olxC9ADvX5COKiA2/0h7ftofFClIY1YDXpzj/328mkXiQcdYzUlcii0l7RGC1WWoAepN SqZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=NlSeUnbiz1lXIVv6dZ9Y3oGqHW7EDbnvJ+FM6Dolvm0=; b=IIYExn3Hmtuw5YFSQhchRSke9GL0BM9vjcWXnH0QdCUcYrYhxSzSM0r60Vr+njpj4m owiL8nv498ehlSpYJaDJlzFRjIrw3fEznHqDheH7qXRNfOoPH3PDVoxiY7oAtOtiRp8c sAKg145M2XbxuhGsXpBc++JnfkjQeVCHVb3QBU3lQhdUjo6sx9AlOZXYPSndI4XevoTA 6Cdz6zpPue9OHFFfcft4R8xxmTgZVvBhICL9Wveu6EOpbvtOfOPptc0r8pCTdckmxyJ9 /kTvrBExlhYB6+Y6JhdfSKdFftY2yZ1O/DvGWSO7dzCsjs3m4gCjTQkeKUY9KlYui5lM LoSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5-v6si19511061pgi.27.2018.11.13.08.51.09; Tue, 13 Nov 2018 08:51:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731172AbeKNCtf (ORCPT + 99 others); Tue, 13 Nov 2018 21:49:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:46992 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726517AbeKNCte (ORCPT ); Tue, 13 Nov 2018 21:49:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5EB87B634; Tue, 13 Nov 2018 16:50:39 +0000 (UTC) Date: Tue, 13 Nov 2018 17:50:37 +0100 Message-ID: From: Takashi Iwai To: Mike Brady Cc: Stefan Wahren , devel@driverdev.osuosl.org, alsa-devel@alsa-project.org, f.fainelli@gmail.com, Eric Anholt , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, linux-rpi-kernel@lists.infradead.org, nishka.dasgupta_ug18@ashoka.edu.in, Kirill Marinushkin , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] ARM: staging: bcm2835-audio: interpolate audio delay In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/26 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 11 Nov 2018 19:21:29 +0100, Mike Brady wrote: > > /* hardware definition */ > static const struct snd_pcm_hardware snd_bcm2835_playback_hw = { > .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | > SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | > - SNDRV_PCM_INFO_DRAIN_TRIGGER | SNDRV_PCM_INFO_SYNC_APPLPTR), > + SNDRV_PCM_INFO_BATCH | SNDRV_PCM_INFO_DRAIN_TRIGGER | > + SNDRV_PCM_INFO_SYNC_APPLPTR), As already mentioned, the addition of SNDRV_PCM_INFO_BATCH should be irrelevant with this change. Please create another patch to add this and clarify it in the changelog. > diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c > index 4e6110d778bd..574df7d7a1fa 100644 > --- a/sound/core/pcm_lib.c > +++ b/sound/core/pcm_lib.c > @@ -229,19 +229,38 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream, > (runtime->audio_tstamp_report.actual_type == > SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { > > - /* > - * provide audio timestamp derived from pointer position > - * add delay only if requested > - */ > + // provide audio timestamp derived from pointer position > > audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; > > - if (runtime->audio_tstamp_config.report_delay) { > + /* > + * If the runtime->delay is greater than zero, it's a > + * genuine delay, e.g. a delay due to a hardware fifo. > + * > + * But if the runtime->delay is less than zero, it's an > + * interpolated estimate of the number of frames output > + * since the hardware pointer was last updated. > + * > + * It would be calculated in the pointer callback. > + * For example, for the bcm_2835 driver, it is calculated in > + * snd_bcm2835_pcm_pointer(). > + */ > + > + if (runtime->delay < 0) { > + // The delay is an interpolated estimate... > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) > - audio_frames -= runtime->delay; > - else > - audio_frames += runtime->delay; > + audio_frames += runtime->delay; > + } else { > + // The delay is a real delay. Add it if requested. > + if (runtime->audio_tstamp_config.report_delay) { > + if (substream->stream == > + SNDRV_PCM_STREAM_PLAYBACK) > + audio_frames -= runtime->delay; > + else > + audio_frames += runtime->delay; > + } > } Well, honestly speaking, I'm really not fond of changing the PCM core just for this. Can we make bcm audio driver providing the finer pointer update instead? If we have a module option to disable that behavior, it's an enough excuse in case anyone really cares about the accuracy. thanks, Takashi