From patchwork Wed Mar 5 10:47:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 3772781 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6AAF69F1EE for ; Wed, 5 Mar 2014 10:55:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0F3220237 for ; Wed, 5 Mar 2014 10:55:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6A43920211 for ; Wed, 5 Mar 2014 10:55:08 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5E6412658FF; Wed, 5 Mar 2014 11:55:05 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 95E8E2658FE; Wed, 5 Mar 2014 11:49:20 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 22B802658DF; Wed, 5 Mar 2014 11:49:15 +0100 (CET) Received: from smtp311.phy.lolipop.jp (smtp311.phy.lolipop.jp [210.157.22.79]) by alsa0.perex.cz (Postfix) with ESMTP id 85D762650FF for ; Wed, 5 Mar 2014 11:48:57 +0100 (CET) Received: from smtp311.phy.lolipop.lan (HELO smtp311.phy.lolipop.jp) (172.17.1.11) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp311.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Wed, 05 Mar 2014 19:48:56 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp311.phy.lolipop.jp (LOLIPOP-Fsecure); Wed, 05 Mar 2014 19:48:28 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Wed, 5 Mar 2014 19:47:58 +0900 Message-Id: <1394016507-15761-11-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1394016507-15761-1-git-send-email-o-takashi@sakamocchi.jp> References: <5316963F.1000206@sakamocchi.jp> <1394016507-15761-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 10/39] firewire-lib: Add transfer delay to synchronized duplex streams X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, in duplex streams with synchronization mode, this module just pass 'presentation timestamp' from in-packets to out-packets. This is enough to handle actual device but logically the timestamp should include 'transfer delay' and 'processing time'. This means the timestamp in out-packet should be at future. To be simple, this commit add only 'transfer delay'. --- sound/firewire/amdtp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index d3cf7bf..9383392 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -774,6 +774,15 @@ static void packet_sort(struct sort_table *tbl, unsigned int len) } while (i < len); } +static inline void add_transfer_delay(struct amdtp_stream *s, unsigned int *syt) +{ + if (*syt != CIP_SYT_NO_INFO) { + *syt += (s->transfer_delay / TICKS_PER_CYCLE) << 12; + *syt += s->transfer_delay % TICKS_PER_CYCLE; + *syt &= CIP_SYT_MASK; + } +} + static void out_stream_callback(struct fw_iso_context *context, u32 cycle, size_t header_length, void *header, void *private_data) @@ -846,6 +855,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 cycle, (s->flags & CIP_SYNC_TO_DEVICE) && s->sync_slave->callbacked) { syt = be32_to_cpu(buffer[1]) & CIP_SYT_MASK; + add_transfer_delay(s, &syt); handle_out_packet(s->sync_slave, syt); } handle_in_packet(s, tbl[i].payload_size / 4, buffer);