From patchwork Fri Feb 28 03:27:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 3737971 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 849699F2F7 for ; Fri, 28 Feb 2014 03:33:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF8B720265 for ; Fri, 28 Feb 2014 03:33:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6F06820255 for ; Fri, 28 Feb 2014 03:33:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 70502265A54; Fri, 28 Feb 2014 04:33:39 +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 9D1B226530F; Fri, 28 Feb 2014 04:28:33 +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 4877A265158; Fri, 28 Feb 2014 04:28:28 +0100 (CET) Received: from smtp311.phy.lolipop.jp (smtp311.phy.lolipop.jp [210.157.22.79]) by alsa0.perex.cz (Postfix) with ESMTP id 668F8264FFB for ; Fri, 28 Feb 2014 04:28:10 +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; Fri, 28 Feb 2014 12:28:09 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp311.phy.lolipop.jp (LOLIPOP-Fsecure); Fri, 28 Feb 2014 12:27:52 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Fri, 28 Feb 2014 12:27:23 +0900 Message-Id: <1393558072-25926-11-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393558072-25926-1-git-send-email-o-takashi@sakamocchi.jp> References: <1393558072-25926-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'. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 3d943d1..43daa32 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -784,6 +784,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) @@ -856,6 +865,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);