From patchwork Fri Jun 28 05:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11021473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 268D81708 for ; Fri, 28 Jun 2019 06:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14BEE2869F for ; Fri, 28 Jun 2019 06:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 092702874C; Fri, 28 Jun 2019 06:35:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 154DF286B3 for ; Fri, 28 Jun 2019 06:35:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 62D401689; Fri, 28 Jun 2019 07:55:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 62D401689 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1561701378; bh=9+s5PuJ+bkjTSrBP0c9zd+lhorUeYpSvkoTG3Us+ykc=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aKFT8TieRo3CgqlO9JM2PBA/kcGvIU46HU+yrX511Inn1xNz+dp+KpV8MOJIbRjgp tPLF1VMNiuzyNZPPvRmE8V8GNAZWjZMdMhLfOETiKKrf8/5Q4J/ew9ZZKuYKGdx7V4 bFwNLFZ1j3I9OfuUvIW1oVDsRJsU7Ml1s9Ys0QHI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EF458F89727; Fri, 28 Jun 2019 07:53:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5C5CCF896CB; Fri, 28 Jun 2019 07:53:46 +0200 (CEST) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 238C0F80058 for ; Fri, 28 Jun 2019 07:53:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 238C0F80058 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="c4vZl2+1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TGm9qt4L" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A9E5B21C4D; Fri, 28 Jun 2019 01:53:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 28 Jun 2019 01:53:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=JCqUvIvCYr8cX cWx1KXwpUizQ4qCvN1asM5ajB7ShhM=; b=c4vZl2+1kJWJPJbPczkxuRh4DvzEB ncJ1qfkD/OXU9Gp+SV3EhZNZL8FiHcj+m4BC4G1nE/rTlVV3Q+cCNeMHwcGDBfYa pY4XVaRB0zVheXxy3oo8qhF+sy0CY267MZMNGBIMnMnoWl7dA9BYfnil/XJjOQnq 6+5SbmxzhghVyJgYQHheKFzIyJESMd98j5I0ZWrK4ACb+xrT5lhbj20RFIFL3cBR zTOhI0gbynvkvt9bmb5oNaMiT6nT0snph2U6EGhGmqsMLWPEVbsUanGYE+BWU0sb RfKe5W48SSrPdnsh4Ekn2a65Wyc4NKZvoRC9mhA27Ej0VX5Zih0E1kIDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=JCqUvIvCYr8cXcWx1KXwpUizQ4qCvN1asM5ajB7ShhM=; b=TGm9qt4L NcISxUcxK/Wwooh1RWduQOuLC0NFe9uEuQqkeRroYJLFsMFk4Xb1ZYnFYDgKtXLQ Xqq9fmConhvRpF0TO/G7V08KkJZnmbZ19+qtSUFBQcFFPGAIpIOBKQHsDJJUxE56 z1Vb1tnaha3oLk/fIljionmR3uaYekm7lnnGbzTpev+LTUxwbZ5MrlCEbUJPgXOa ns+y2esy/WOq1Yz1RG5jhDx/H/Lu6LWfPG9CFnBWnLTAP5R0n+uboOOzqs6GYaGv pyepBd+ZvTl5aD5ZXm56sJLM/yukK8VvC+s/tiIKdHFXST9SRdFrYMoSlsmfzfYZ kUIQxsD7kHvUbw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudelgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 4C478380075; Fri, 28 Jun 2019 01:53:36 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 28 Jun 2019 14:53:30 +0900 Message-Id: <20190628055331.1427-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628055331.1427-1-o-takashi@sakamocchi.jp> References: <20190628055331.1427-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 1/2] ALSA: firewire-lib: cache next data_block_counter after probing tracepoints event for IR context X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP For debugging purpose, ALSA IEC 61883-1/6 engine has tracepoints event. In current implementation, next data block counter is stored as current data block counter before probing the event for IR isoc context. It's not good to check current packet parameter. This commit changes to assign the next data block counter after probing the event. Besides, Fireworks devices has a quirk to transfer isoc packet with data block counter for the last data block. For this quirk, the assignment is done before calling data block processing layer. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 48 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index 3aef6a78a188..b341bd86605e 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -519,13 +519,13 @@ static void build_it_pkt_header(struct amdtp_stream *s, unsigned int cycle, static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, unsigned int payload_length, - unsigned int *data_blocks, unsigned int *syt) + unsigned int *data_blocks, unsigned int *dbc, + unsigned int *syt) { u32 cip_header[2]; unsigned int sph; unsigned int fmt; unsigned int fdf; - unsigned int data_block_counter; bool lost; cip_header[0] = be32_to_cpu(buf[0]); @@ -577,17 +577,17 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, } /* Check data block counter continuity */ - data_block_counter = cip_header[0] & CIP_DBC_MASK; + *dbc = cip_header[0] & CIP_DBC_MASK; if (*data_blocks == 0 && (s->flags & CIP_EMPTY_HAS_WRONG_DBC) && s->data_block_counter != UINT_MAX) - data_block_counter = s->data_block_counter; + *dbc = s->data_block_counter; if (((s->flags & CIP_SKIP_DBC_ZERO_CHECK) && - data_block_counter == s->ctx_data.tx.first_dbc) || + *dbc == s->ctx_data.tx.first_dbc) || s->data_block_counter == UINT_MAX) { lost = false; } else if (!(s->flags & CIP_DBC_IS_END_EVENT)) { - lost = data_block_counter != s->data_block_counter; + lost = *dbc != s->data_block_counter; } else { unsigned int dbc_interval; @@ -596,26 +596,18 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, else dbc_interval = *data_blocks; - lost = data_block_counter != - ((s->data_block_counter + dbc_interval) & 0xff); + lost = *dbc != ((s->data_block_counter + dbc_interval) & 0xff); } if (lost) { dev_err(&s->unit->device, "Detect discontinuity of CIP: %02X %02X\n", - s->data_block_counter, data_block_counter); + s->data_block_counter, *dbc); return -EIO; } *syt = cip_header[1] & CIP_SYT_MASK; - if (s->flags & CIP_DBC_IS_END_EVENT) { - s->data_block_counter = data_block_counter; - } else { - s->data_block_counter = - (data_block_counter + *data_blocks) & 0xff; - } - return 0; } @@ -626,6 +618,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, unsigned int *syt, unsigned int index) { const __be32 *cip_header; + unsigned int dbc; int err; *payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; @@ -640,22 +633,33 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, if (!(s->flags & CIP_NO_HEADER)) { cip_header = ctx_header + 2; err = check_cip_header(s, cip_header, *payload_length, - data_blocks, syt); - if (err < 0) - return err; + data_blocks, &dbc, syt); + if (err < 0) { + if (err != -EAGAIN) + return err; + + *data_blocks = 0; + dbc = s->data_block_counter; + } } else { cip_header = NULL; + err = 0; *data_blocks = *payload_length / sizeof(__be32) / s->data_block_quadlets; + dbc = s->data_block_counter; *syt = 0; - s->data_block_counter = - (s->data_block_counter + *data_blocks) & 0xff; } + if (err >= 0 && s->flags & CIP_DBC_IS_END_EVENT) + s->data_block_counter = dbc; + trace_amdtp_packet(s, cycle, cip_header, *payload_length, *data_blocks, index); - return 0; + if (err >= 0 && !(s->flags & CIP_DBC_IS_END_EVENT)) + s->data_block_counter = (dbc + *data_blocks) & 0xff; + + return err; } // In CYCLE_TIMER register of IEEE 1394, 7 bits are used to represent second. On From patchwork Fri Jun 28 05:53:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 11021479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8028017D2 for ; Fri, 28 Jun 2019 06:50:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70C4A286D3 for ; Fri, 28 Jun 2019 06:50:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C6DF2874E; Fri, 28 Jun 2019 06:50:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91CB028500 for ; Fri, 28 Jun 2019 06:50:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 65E95167F; Fri, 28 Jun 2019 07:54:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 65E95167F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1561701332; bh=1ybQadrZXoW6ILTtAUNMBp42Vu8WAIFEdBWZsERYLks=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E/FALTaEQ1I4C0quSDU4P9morgxFCzXRmBCauQg00dGYTPySCjdC5Qb0ULMZoIFgK jLidbvl4Z5deguQbdwWXJ0WNcrhARsGWWMWICVJJ2XVrcKppQWCezejpY/O6toiaWE DQTqyYJluFEEvRSXrsGo45KocayB2BghbF9DOUUA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 36B11F89701; Fri, 28 Jun 2019 07:53:51 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AB55F80058; Fri, 28 Jun 2019 07:53:46 +0200 (CEST) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9ED7DF896B7 for ; Fri, 28 Jun 2019 07:53:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9ED7DF896B7 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="s8u5RSwW"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="R0XnRESr" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3C2B721E90; Fri, 28 Jun 2019 01:53:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 28 Jun 2019 01:53:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=oVga9puNhknlJ P1RkjlXff8lRWYSH/spb0WUuQdSg/U=; b=s8u5RSwWzli7OTjKK3hHfd4cJnNeO 49e1UpDS8yiWe7k23TtOdrmkbQULoNTWgaiy4I//i+ziQ11tqKc1Ky0CRP6Rx2c5 cR7gBud8VRuDJPkpUzwDbRgiZsFztPJs5BytXOgNDGP2IcKomxsrfcUppDnYOdn7 qAUWcwlUPgNJoDNyJ2luBe0M7hxXAw/jA+A7J2UQ8AeztBQBLGYSaUDxmdST/Eu4 hAGqb4jY8vfMOJxSfJy96YkMGqDYiQfBcEI+JBbirAmxrjdCp2Ns5EgHSpV26WUO bFLMcXBWfnsXOLxZ4WZcfrtiEcqvTJfCAcwKtAU1+ksmSlHiMdq0aPNzQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=oVga9puNhknlJP1RkjlXff8lRWYSH/spb0WUuQdSg/U=; b=R0XnRESr Da0A8rxwnnGa9V8d8JlC/ra71zN1/tqZH/qKbpNbdNXyw0EiRbedis24nML3lxc8 JWj2IN4PG/pzzs4aRpIHVM+FHkKKpCkAuFm4o6qShLSLb0yYB4amTFTcUQjpWMTw 01LxwrYUs+R6qSIt8jOutG02roM9h+8OiSLUmoLbRmr7puF09KAeuvNxgV9swTA9 G+R1IEwsscXcwzMKqjW3Arb/DCPxMRdY6ijf38aY9lpy9go2opYeUVYkGSM1mwrs xmRx8PReQV2oSohHvnEfdHu63vdwbZVaRdkmyx3KQuCG/e4sYPfnslRj20ARnlaD ST6XWhrP5nKW+A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrudelgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecukfhppedugedrfedrjeehrddukedune curfgrrhgrmhepmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghh ihdrjhhpnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from workstation.flets-east.jp (ae075181.dynamic.ppp.asahi-net.or.jp [14.3.75.181]) by mail.messagingengine.com (Postfix) with ESMTPA id D3B9D380075; Fri, 28 Jun 2019 01:53:37 -0400 (EDT) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Fri, 28 Jun 2019 14:53:31 +0900 Message-Id: <20190628055331.1427-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628055331.1427-1-o-takashi@sakamocchi.jp> References: <20190628055331.1427-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 2/2] ALSA: firewire-lib: fix to process MIDI conformant data channel for AM824 format X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP In IEC 61883-6, 8 MIDI data streams are multiplexed into single MIDI conformant data channel. The index of stream is calculated by modulo 8 of the value of data block counter. Therefore data block processing layer requires valid value of data block counter. In recent changes of ALSA IEC 61883-1/6 engine, the value of data block counter is changed before calling data block processing layer. This brings miss detection of MIDI messages in non-blocking transmission method is used. This commit fixes the bug by changing chached data block counter after calling data block processing layer. Fixes: e335425b6596 ("ALSA: firewire-lib: split helper function to check incoming CIP header") Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp-stream.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c index b341bd86605e..91b890241840 100644 --- a/sound/firewire/amdtp-stream.c +++ b/sound/firewire/amdtp-stream.c @@ -614,11 +614,10 @@ static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, const __be32 *ctx_header, unsigned int *payload_length, - unsigned int *data_blocks, + unsigned int *data_blocks, unsigned int *dbc, unsigned int *syt, unsigned int index) { const __be32 *cip_header; - unsigned int dbc; int err; *payload_length = be32_to_cpu(ctx_header[0]) >> ISO_DATA_LENGTH_SHIFT; @@ -633,32 +632,28 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle, if (!(s->flags & CIP_NO_HEADER)) { cip_header = ctx_header + 2; err = check_cip_header(s, cip_header, *payload_length, - data_blocks, &dbc, syt); + data_blocks, dbc, syt); if (err < 0) { if (err != -EAGAIN) return err; *data_blocks = 0; - dbc = s->data_block_counter; } } else { cip_header = NULL; err = 0; *data_blocks = *payload_length / sizeof(__be32) / s->data_block_quadlets; - dbc = s->data_block_counter; + *dbc = s->data_block_counter; *syt = 0; } if (err >= 0 && s->flags & CIP_DBC_IS_END_EVENT) - s->data_block_counter = dbc; + s->data_block_counter = *dbc; trace_amdtp_packet(s, cycle, cip_header, *payload_length, *data_blocks, index); - if (err >= 0 && !(s->flags & CIP_DBC_IS_END_EVENT)) - s->data_block_counter = (dbc + *data_blocks) & 0xff; - return err; } @@ -761,7 +756,8 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp, for (i = 0; i < packets; i++) { u32 cycle; unsigned int payload_length; - unsigned int data_block; + unsigned int data_blocks; + unsigned int dbc; unsigned int syt; __be32 *buffer; unsigned int pcm_frames = 0; @@ -771,13 +767,19 @@ static void in_stream_callback(struct fw_iso_context *context, u32 tstamp, cycle = compute_cycle_count(ctx_header[1]); err = parse_ir_ctx_header(s, cycle, ctx_header, &payload_length, - &data_block, &syt, i); + &data_blocks, &dbc, &syt, i); if (err < 0 && err != -EAGAIN) break; + if (err >= 0) { buffer = s->buffer.packets[s->packet_index].buffer; pcm_frames = s->process_data_blocks(s, buffer, - data_block, &syt); + data_blocks, &syt); + + if (!(s->flags & CIP_DBC_IS_END_EVENT)) { + s->data_block_counter = + (dbc + data_blocks) & 0xff; + } } if (queue_in_packet(s, ¶ms) < 0)