Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbdHGKf3 (ORCPT ); Mon, 7 Aug 2017 06:35:29 -0400 Received: from webclient5.webclient5.de ([136.243.32.179]:40974 "EHLO webclient5.webclient5.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbdHGKf2 (ORCPT ); Mon, 7 Aug 2017 06:35:28 -0400 X-Greylist: delayed 503 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Aug 2017 06:35:27 EDT Subject: Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period interrupt emulation To: Oleksandr Andrushchenko 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> From: Clemens Ladisch Message-ID: Date: Mon, 7 Aug 2017 12:27:01 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1502091796-14413-9-git-send-email-andr2000@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1155 Lines: 27 Oleksandr Andrushchenko wrote: > Front sound driver has no real interrupts, so > playback/capture period passed interrupt needs to be emulated: > this is done via timer. Add required timer operations, > this is based on sound/drivers/dummy.c. A 'real' sound card use the interrupt to synchronize the stream position between the hardware and the driver. The hardware triggers an interrupt immediately after a period has been completely read (for playback) from the ring buffer by the DMA unit; this tells the driver that it is now again allowed to write to that part of the buffer. The dummy driver has no hardware that accesses the buffer, so the period interrupts are not synchronized to anything. This is not a suitable implementation when the samples are actually used. If you issue interrupts based on the system timer, the position reported by the .pointer callback and the position where the hardware (backend) actually accesses the buffer will diverge, which will eventually corrupt data. You have to implement period interrupts (and the .pointer callback) based on when the samples are actually moved from/to the backend. Regards, Clemens