From: Takashi Iwai Subject: Re: [PATCH 2/2] ALSA: hda: support for wallclock timestamps Date: Fri, 15 Jun 2012 12:34:27 +0200 Message-ID: References: <1339619192-2733-1-git-send-email-pierre-louis.bossart@linux.intel.com> <1339619192-2733-3-git-send-email-pierre-louis.bossart@linux.intel.com> <4FDB083E.9060903@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 4950E246D1 for ; Fri, 15 Jun 2012 12:34:28 +0200 (CEST) In-Reply-To: <4FDB083E.9060903@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Fri, 15 Jun 2012 05:02:38 -0500, Pierre-Louis Bossart wrote: > > > >> +struct azx_timecounter { > >> + cycle_t cycle_last; > >> + cycle_t mask; > >> + cycle_t elapsed_cycles; > >> + u64 initial_time_nsec; > >> + u32 mult; > >> + u32 shift; > >> +}; > > > > Any reason not using the normal struct timecounter stuff? > > Most of the open codes can be replaced gracefully with functions / > > macros there, I guess. > > Yes there is a reason. The conversion from wall clock cycles to ns is a > fractional operation (125/3 ratio from 24 MHz to 1 GHz). If you do this > conversion to ns every time, you will accumulate rounding errors. That > doesn't seem like a very good design if the precision depends on the > duration of the track... Hm, OK. It's a shortcoming in the generic timecounter code, IMO. It might make more sense to fix there. BTW, the calculation mult can be simplified with clocksource_khz2multi(). > On top of this, I couldn't find a way to pass the 'chip' argument in the > cyclecounter .read() operation to map it to azx_read. You can use container_of(). Takashi