From patchwork Fri Apr 15 16:23:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 8852181 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6C85EBF29F for ; Fri, 15 Apr 2016 16:24:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FCC920142 for ; Fri, 15 Apr 2016 16:24:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1CFD82013D for ; Fri, 15 Apr 2016 16:24:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1E73C2668B7; Fri, 15 Apr 2016 18:24:22 +0200 (CEST) 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,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 44A0F266811; Fri, 15 Apr 2016 18:23:44 +0200 (CEST) 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 1DC6326682C; Fri, 15 Apr 2016 18:23:42 +0200 (CEST) Received: from smtp-proxy001.phy.lolipop.jp (smtp-proxy001.phy.lolipop.jp [157.7.104.42]) by alsa0.perex.cz (Postfix) with ESMTP id E1C87265162 for ; Fri, 15 Apr 2016 18:23:34 +0200 (CEST) Received: from smtp-proxy001.phy.lolipop.lan (HELO smtp-proxy001.phy.lolipop.jp) (172.19.44.42) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp-proxy001.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Sat, 16 Apr 2016 01:23:30 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp-proxy001.phy.lolipop.jp (LOLIPOP-Fsecure); Sat, 16 Apr 2016 01:23:24 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sat, 16 Apr 2016 01:23:23 +0900 Message-Id: <1460737404-19699-3-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1460737404-19699-1-git-send-email-o-takashi@sakamocchi.jp> References: <1460737404-19699-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, stefanr@s5r6.in-berlin.de, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 2/3] firewire-lib: compute the value of second field in cycle count for IR context 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 In callback function of isochronous context, modules can queue packets to certain isochronous cycles. Although the cycle to queue a packet is deterministic by calculation, this module don't implement the calculation because it's useless for processing. In future, the cycle count is going to be printed with Linux tracing framework to help developers. This commit is the preparation. The cycle count is computed by cycle unit, and correctly arranged for corresponding packets. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 46f1167..4d86da0 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -566,6 +566,13 @@ static inline u32 increment_cycle_count(u32 cycle, unsigned int addend) return cycle; } +static inline u32 decrement_cycle_count(u32 cycle, unsigned int subtrahend) +{ + if (cycle < subtrahend) + cycle += 8 * CYCLES_PER_SECOND; + return cycle - subtrahend; +} + static void out_stream_callback(struct fw_iso_context *context, u32 tstamp, size_t header_length, void *header, void *private_data) @@ -607,6 +614,7 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp, unsigned int payload_quadlets, max_payload_quadlets; unsigned int data_blocks; __be32 *buffer, *headers = header; + u32 cycle; if (s->packet_index < 0) return; @@ -614,10 +622,16 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp, /* The number of packets in buffer */ packets = header_length / IN_PACKET_HEADER_SIZE; + cycle = compute_cycle_count(tstamp); + + /* Align to actual cycle count for the last packet. */ + cycle = decrement_cycle_count(cycle, packets); + /* For buffer-over-run prevention. */ max_payload_quadlets = amdtp_stream_get_max_payload(s) / 4; for (p = 0; p < packets; p++) { + cycle = increment_cycle_count(cycle, 1); buffer = s->buffer.packets[s->packet_index].buffer; /* The number of quadlets in this packet */