From patchwork Fri Mar 21 11:09:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 3872841 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 13D989F382 for ; Fri, 21 Mar 2014 11:15:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EACB2025B for ; Fri, 21 Mar 2014 11:15:02 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 17A912024F for ; Fri, 21 Mar 2014 11:15:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 321BF265591; Fri, 21 Mar 2014 12:15:00 +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 1AEB5265487; Fri, 21 Mar 2014 12:11:15 +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 6538A265480; Fri, 21 Mar 2014 12:11:12 +0100 (CET) Received: from smtp310.phy.lolipop.jp (smtp310.phy.lolipop.jp [210.157.22.78]) by alsa0.perex.cz (Postfix) with ESMTP id 5894126536B for ; Fri, 21 Mar 2014 12:10:58 +0100 (CET) Received: from smtp310.phy.lolipop.lan (HELO smtp310.phy.lolipop.jp) (172.17.1.10) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp310.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Fri, 21 Mar 2014 20:10:57 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp310.phy.lolipop.jp (LOLIPOP-Fsecure); Fri, 21 Mar 2014 20:10:36 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Fri, 21 Mar 2014 20:09:51 +0900 Message-Id: <1395400229-22957-7-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395400229-22957-1-git-send-email-o-takashi@sakamocchi.jp> References: <1395400229-22957-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, linux1394-devel@lists.sourceforge.net, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 06/44] firewire-lib: Give syt value as parameter to handle_out_packet() 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 For duplex streams with synchronization, drivers should pick up 'presentation timestamp' from in-packets and use the timestamp for out-packets. This commit is preparation for this. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 221a65f..2b70de0 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -257,7 +257,9 @@ static unsigned int calculate_data_blocks(struct amdtp_stream *s) { unsigned int phase, data_blocks; - if (!cip_sfc_is_base_44100(s->sfc)) { + if (s->flags & CIP_BLOCKING) + data_blocks = s->syt_interval; + else if (!cip_sfc_is_base_44100(s->sfc)) { /* Sample_rate / 8000 is an integer, and precomputed. */ data_blocks = s->data_block_state; } else { @@ -616,26 +618,22 @@ static inline int queue_in_packet(struct amdtp_stream *s) amdtp_stream_get_max_payload(s), false); } -static void handle_out_packet(struct amdtp_stream *s, unsigned int cycle) +static void handle_out_packet(struct amdtp_stream *s, unsigned int syt) { __be32 *buffer; - unsigned int index, data_blocks, syt, payload_length; + unsigned int data_blocks, payload_length; struct snd_pcm_substream *pcm; if (s->packet_index < 0) return; - index = s->packet_index; /* this module generate empty packet for 'no data' */ - syt = calculate_syt(s, cycle); - if (!(s->flags & CIP_BLOCKING)) + if (!(s->flags & CIP_BLOCKING) || (syt != CIP_SYT_NO_INFO)) data_blocks = calculate_data_blocks(s); - else if (syt != CIP_SYT_NO_INFO) - data_blocks = s->syt_interval; else data_blocks = 0; - buffer = s->buffer.packets[index].buffer; + buffer = s->buffer.packets[s->packet_index].buffer; buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) | (s->data_block_quadlets << AMDTP_DBS_SHIFT) | s->data_block_counter); @@ -746,7 +744,7 @@ static void out_stream_callback(struct fw_iso_context *context, u32 cycle, void *private_data) { struct amdtp_stream *s = private_data; - unsigned int i, packets = header_length / 4; + unsigned int i, syt, packets = header_length / 4; /* * Compute the cycle of the last queued packet. @@ -755,8 +753,10 @@ static void out_stream_callback(struct fw_iso_context *context, u32 cycle, */ cycle += QUEUE_LENGTH - packets; - for (i = 0; i < packets; ++i) - handle_out_packet(s, ++cycle); + for (i = 0; i < packets; ++i) { + syt = calculate_syt(s, ++cycle); + handle_out_packet(s, syt); + } fw_iso_context_queue_flush(s->context); }