Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2330071imm; Thu, 18 Oct 2018 12:48:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ZPu58upoffPfQI1FN8+cQSihWpefivchXIoFkB8Vow9CL7aUpQIwZtM5tzRzYf5fhjUIu X-Received: by 2002:a63:e818:: with SMTP id s24-v6mr28601217pgh.90.1539892089943; Thu, 18 Oct 2018 12:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539892089; cv=none; d=google.com; s=arc-20160816; b=nUx7XMQ2o1iW/C/Z2BTi7XEAjWyx7bPLqzu6EMOLLA+AZ6fEYZNCS5StkR5ApXAz2r KdtWlMqd5GePgIewPqVUQ+nfXoKnie3hZ2imzsiAE6uS1Z6hlCz0RhBdEZvQRqVHbfpC a2/RaC1b8/3B0kKhcVwnq/x7G07lqhSrv4sPn5d3mXmmXX3C2WO8PWJ5QvjKmvLr68Zj 075IYMBrVG5g5LdccuQE2DQmX7KcsXk1G3wYZLTK4HsPopH5jqhLvgMj0SXiCGlUpo2X LHLzODaFy6Wz8+hEfGgc/Q3Mbh2yWjjIuXaNPJOIvtl/UzGAojskYvNA31I/Npx3ISJv 9IqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=YQGVUmD5OSb9TYQ+ssKwRAJeQ+u3I7N+6luQa67HLO4=; b=fUoqWmfmssr39GKwu7w0aGoTcmgSHRmOXsvyq8JZmzOHRdYcQfmlpxPWMm7gdHoTUR 7O3rrGeta1TTVqS2Rm7PW6U8NmKBPcJMAHW/uiNec5cSeMvkMumzlU4xyrfbkGUfCVf+ l3zsnhaZpha8zdX8ErabTE6fZhp34evWrpJG98AyOIHu0XdhkzNUdfzHnTCtC9GHa23f UDZ9uV0/xphAhM1APA9zIyIu+y+uZ8ipTfNI2O/7q3+rFtFKupxeiddbWoEHSzhtlq0w DSBX4ic0jQ8El7A7AH9xa9+nxbzXoVlyEy5o7red1Tg0kn+8SbjIaRC+zj5Jym+Ojlq3 l6CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=egfARMgH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12-v6si21458107pgb.328.2018.10.18.12.47.53; Thu, 18 Oct 2018 12:48:09 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=egfARMgH; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727222AbeJSDtc (ORCPT + 99 others); Thu, 18 Oct 2018 23:49:32 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:45754 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726325AbeJSDtc (ORCPT ); Thu, 18 Oct 2018 23:49:32 -0400 Received: by mail-ed1-f67.google.com with SMTP id m6-v6so5852452eds.12 for ; Thu, 18 Oct 2018 12:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YQGVUmD5OSb9TYQ+ssKwRAJeQ+u3I7N+6luQa67HLO4=; b=egfARMgH+8Ri16SiPsxmML/BDzAK+MoXiWf9Q1YzCkbhFAwlJpOxQTgmJJlc1r8hlO HKoj20b31C2/CoKmoWQjiCu5OOMVSx7etPPD27iJO0nTptM/r//Yr9sVJZDS7dcs8ne3 GPF8xKk9lYRcam+BB2WjvKXzO7XYTQexWNkJbB4Y2/Vk7d4XyxrFxI5hRuQ33lnJxWni VVCCGVfARPvSv4XZf6o2p8wm9HwXqKySTvdNxUljQFWv5Vg58SGpLxxGbhXQimC0GN7o GDJWpdtQsNP2zLq0u4GlxAE00y+3kjst8Gi/YaBSSlpGMXUOj6dNP/4BnTqY3pFhUZiH /ujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YQGVUmD5OSb9TYQ+ssKwRAJeQ+u3I7N+6luQa67HLO4=; b=nzSrCooSY0EsHb829ZRL8ty9/Fk8fJuW3+3/MG4iHKSdX3lqz42Q0zkZgzUqRKn7kV kqGcvC2jV5TNBpJFOWiD1YAUgjwjzYo0GymBPADmq98uEh7jATct8KXZq7TSuqq8Nxco pcPWkTAS9fpi4KUPiRZtJT0+IUsSSlX2GMgKFGryCL/oNxOONyN9sxqBHOZ3uBM2pTkw NbWX29i4sKG82uAu9XVDS2+Bp0Bzq2jLaPMx5I1x+SxqvDZOP2jk3cfHnfSx36VkkkGB IFfd+OzPkdbTokcXlyJ/cxouZ3P8YZNOSb9DlE0h3tzecCVzJo4FZpydKG3bAlp3xV+A Rp9A== X-Gm-Message-State: ABuFfoj5sA0lJZiDuYle8Zi+7GhISYaRfjUxSKJX/mOZU2qyxhWIVKfq ADwVJNnTDI5pxHP5TJtDZGEYN3aFHqU= X-Received: by 2002:a17:906:4452:: with SMTP id i18-v6mr29810479ejp.93.1539892018350; Thu, 18 Oct 2018 12:46:58 -0700 (PDT) Received: from [192.168.1.3] (x4dbc7b03.dyn.telefonica.de. [77.188.123.3]) by smtp.gmail.com with ESMTPSA id d12-v6sm8846623ede.32.2018.10.18.12.46.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 12:46:57 -0700 (PDT) Subject: Re: [PATCH] staging: bcm2835-audio: interpolate audio delay To: Mike Brady Cc: eric@anholt.net, stefan.wahren@i2se.com, gregkh@linuxfoundation.org, f.fainelli@gmail.com, tiwai@suse.de, nishka.dasgupta_ug18@ashoka.edu.in, julia.lawall@lip6.fr, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20181018105715.GA6660@ubuntu> From: Kirill Marinushkin Message-ID: <22867d63-12f1-31f7-acb6-ce9a58fcbe71@gmail.com> Date: Thu, 18 Oct 2018 21:48:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20181018105715.GA6660@ubuntu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Mike, On 10/18/18 12:57, Mike Brady wrote: > + ktime_t now = ktime_get(); > + > + /* Give userspace better delay reporting by interpolating between GPU > + * notifications, assuming audio speed is close enough to the clock > + * used for ktime > + */ > + > + if ((ktime_to_ns(alsa_stream->interpolate_start)) && > + (ktime_compare(alsa_stream->interpolate_start, now) < 0)) { > + u64 interval = > + (ktime_to_ns(ktime_sub(now, > + alsa_stream->interpolate_start))); > + u64 frames_output_in_interval = > + div_u64((interval * runtime->rate), 1000000000); > + snd_pcm_sframes_t frames_output_in_interval_sized = > + -frames_output_in_interval; > + runtime->delay = frames_output_in_interval_sized; > + } This doesn't look like a good solution for me. More like a workaround. What is the root cause of the delay? Best Regards, Kirill