From patchwork Fri Mar 21 11:10:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 3872981 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 31A7F9F370 for ; Fri, 21 Mar 2014 11:25:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54AC320213 for ; Fri, 21 Mar 2014 11:25:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id F1B29200D5 for ; Fri, 21 Mar 2014 11:25:33 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 08F622655BC; Fri, 21 Mar 2014 12:25:33 +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 E2C10265595; Fri, 21 Mar 2014 12:15:38 +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 1BE272655BB; Fri, 21 Mar 2014 12:15:38 +0100 (CET) Received: from smtp310.phy.lolipop.jp (smtp310.phy.lolipop.jp [210.157.22.78]) by alsa0.perex.cz (Postfix) with ESMTP id AA7B026548D for ; Fri, 21 Mar 2014 12:11:17 +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:11:16 +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:10:05 +0900 Message-Id: <1395400229-22957-21-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 20/44] fireworks/firewire-lib: Add a quirk for the meaning of dbc 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 Fireworks has a quirk for the value of dbc field in transmitted packets. For Fireworks, dbc means the end of events in current packet. This is out of specification. For example, AudioFire4: CIP0 CIP1 Payload 01070092 90FFFFFF 02 0107009A 9001E17B 3A <- 010700A2 9001F6E5 3A 010700A2 90FFFFFF 02 010700AA 9001104F 3A <- 010700B2 900125B9 3A 010700BA 90013B23 3A 010700BA 90FFFFFF 02 010700C2 9001548E 3A <- 010700CA 900169F8 3A 010700CA 90FFFFFF 02 010700D2 90018362 3A <- 010700DA 900198CC 3A According to IEC 61883-6, a packet following to empty packet has the same value for its dbc. But for Fireworks, it's incremented and empty packet has the same value as previous packet in dbc field. This commit adds a flag for Fireworks and some codes to checking dbc continuity. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp.c | 14 ++++++++++++-- sound/firewire/amdtp.h | 3 +++ sound/firewire/fireworks/fireworks_stream.c | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 820f7c7..b1b1999 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -700,6 +700,7 @@ static void handle_in_packet(struct amdtp_stream *s, u32 cip_header[2]; unsigned int data_blocks, data_block_quadlets, data_block_counter; struct snd_pcm_substream *pcm = NULL; + bool lost; cip_header[0] = be32_to_cpu(buffer[0]); cip_header[1] = be32_to_cpu(buffer[1]); @@ -738,7 +739,12 @@ static void handle_in_packet(struct amdtp_stream *s, /* Check data block counter continuity */ data_block_counter = cip_header[0] & AMDTP_DBC_MASK; - if (data_block_counter != s->data_block_counter) { + if (!(s->flags & CIP_DBC_IS_END_EVENT)) + lost = data_block_counter != s->data_block_counter; + else + lost = data_block_counter != + ((s->data_block_counter + data_blocks) & 0xff); + if (lost) { dev_info(&s->unit->device, "Detect discontinuity of CIP: %02X %02X\n", s->data_block_counter, data_block_counter); @@ -756,7 +762,11 @@ static void handle_in_packet(struct amdtp_stream *s, amdtp_pull_midi(s, buffer, data_blocks); } - s->data_block_counter = (data_block_counter + data_blocks) & 0xff; + 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; end: if (queue_in_packet(s) < 0) goto err; diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h index 523883c..399e61b 100644 --- a/sound/firewire/amdtp.h +++ b/sound/firewire/amdtp.h @@ -23,6 +23,8 @@ * @CIP_SYNC_TO_DEVICE: In sync to device mode, time stamp in out packets is * generated by in packets. Defaultly this driver generates timestamp. * @CIP_EMPTY_WITH_TAG0: Only for in-stream. Empty in-packets have TAG0. + * @CIP_DBC_IS_END_EVENT: Only for in-stream. The value of dbc in an in-packet + * corresponds to the end of event in the packet. Out of IEC 61883. */ enum cip_flags { CIP_NONBLOCKING = 0x00, @@ -30,6 +32,7 @@ enum cip_flags { CIP_HI_DUALWIRE = 0x02, CIP_SYNC_TO_DEVICE = 0x04, CIP_EMPTY_WITH_TAG0 = 0x08, + CIP_DBC_IS_END_EVENT = 0x10, }; /** diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 15b8a8b..b6698a0 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -183,6 +183,8 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw) goto end; /* Fireworks transmits NODATA packets with TAG0. */ efw->tx_stream.flags |= CIP_EMPTY_WITH_TAG0; + /* Fireworks has its own meaning for dbc. */ + efw->tx_stream.flags |= CIP_DBC_IS_END_EVENT; err = init_stream(efw, &efw->rx_stream); if (err < 0)