Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdHGNiL (ORCPT ); Mon, 7 Aug 2017 09:38:11 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:35844 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751375AbdHGNiJ (ORCPT ); Mon, 7 Aug 2017 09:38:09 -0400 Subject: Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period interrupt emulation To: Clemens Ladisch Cc: alsa-devel@alsa-project.org, xen-devel@lists.xen.org, linux-kernel@vger.kernel.org, Oleksandr Andrushchenko , tiwai@suse.com References: <1502091796-14413-1-git-send-email-andr2000@gmail.com> <1502091796-14413-9-git-send-email-andr2000@gmail.com> <4ce45eec-8657-66c4-c8c7-b851250da46a@ladisch.de> From: Oleksandr Andrushchenko Message-ID: <45738e58-7ed2-8315-8d9c-138c3d3a2ecc@gmail.com> Date: Mon, 7 Aug 2017 16:38:06 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <4ce45eec-8657-66c4-c8c7-b851250da46a@ladisch.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1851 Lines: 45 On 08/07/2017 04:11 PM, Clemens Ladisch wrote: > Oleksandr Andrushchenko wrote: >> On 08/07/2017 01:27 PM, Clemens Ladisch wrote: >>> You have to implement period interrupts (and the .pointer callback) >>> based on when the samples are actually moved from/to the backend. >> Do you think I can implement this in a slightly different way, >> without a timer at all, by updating >> substream->runtime->hw_ptr_base explicitly in the frontend driver? > As far as I am aware, hw_ptr_base is an internal field that drivers > are not supposed to change. I know that and always considered not a good solution, this is why I have timer to emulate things > Just use your own variable, and return it from the .pointer callback. this can work, but see below >> So, that way, whenever I get an ack/response from the backend that it has >> successfully played the buffer > That response should come after every period. > How does that interface work? For the buffer received in .copy_user/.copy_kernel we send a request to the backend and get response back (async) when it has copied the bytes into HW/mixer/etc, so the buffer at frontend side can be reused. So, the amount of bytes in this exchange is not necessarily a multiply of the period. Also, there is no way to synchronize period sizes in the front driver and backend to make those equal. There is also no event from the backend in the protocol to tell that the period has elapsed, so sending data in period's size buffers will not probably help because of possible underruns > Is it possible to change the period size, > or at least to detect what it is? Unfortunately no, this is not in the protocol. > > > Regards, > Clemens you can see the protocol at [1] Thank you, Oleksandr [1] https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/include/xen/interface/io/sndif.h?h=for-next