From patchwork Fri Apr 25 13:45:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 4063311 X-Patchwork-Delegate: tiwai@suse.de 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 300ECBFF02 for ; Fri, 25 Apr 2014 14:19:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3497520398 for ; Fri, 25 Apr 2014 14:19:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D3B4F2025A for ; Fri, 25 Apr 2014 14:19:18 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id F2BBD265810; Fri, 25 Apr 2014 16:19:17 +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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 742B52654F1; Fri, 25 Apr 2014 16:00:34 +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 5509D2654E6; Fri, 25 Apr 2014 16:00:31 +0200 (CEST) Received: from smtp310.phy.lolipop.jp (smtp310.phy.lolipop.jp [210.157.22.78]) by alsa0.perex.cz (Postfix) with ESMTP id 04A8E2654F6 for ; Fri, 25 Apr 2014 15:46:28 +0200 (CEST) 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, 25 Apr 2014 22:46:26 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp310.phy.lolipop.jp (LOLIPOP-Fsecure); Fri, 25 Apr 2014 22:45:31 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Fri, 25 Apr 2014 22:45:06 +0900 Message-Id: <1398433530-13136-26-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398433530-13136-1-git-send-email-o-takashi@sakamocchi.jp> References: <1398433530-13136-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 25/49] fireworks/firewire-lib: Add a quirk for fixed interval of reported 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 firmware version 5.5 reports fix interval for dbc in each packet. For example, AudioFire4: CIP0 CIP1 Payload 00070000 900484FF 72 00070008 9004A8FF 72 00070008 90FFFFFF 02 00070010 9004D0FF 72 00070018 9004C4FF 72 00070020 9004E8FF 72 00070020 90FFFFFF 02 00070028 900410FE 72 The interval of each dbc should be 16 except for empty packet but it's still 8. This commit adds a flag for this quirk and codes to refer to a fixed value. Signed-off-by: Takashi Sakamoto --- sound/firewire/amdtp.c | 15 +++++++++++---- sound/firewire/amdtp.h | 3 +++ sound/firewire/fireworks/fireworks.c | 1 + sound/firewire/fireworks/fireworks.h | 1 + sound/firewire/fireworks/fireworks_stream.c | 3 +++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 3903387..4a7cc1f 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -618,7 +618,8 @@ static void handle_in_packet(struct amdtp_stream *s, __be32 *buffer) { u32 cip_header[2]; - unsigned int data_blocks, data_block_quadlets, data_block_counter; + unsigned int data_blocks, data_block_quadlets, data_block_counter, + dbc_interval; struct snd_pcm_substream *pcm = NULL; bool lost; @@ -661,11 +662,17 @@ static void handle_in_packet(struct amdtp_stream *s, /* Check data block counter continuity */ data_block_counter = cip_header[0] & AMDTP_DBC_MASK; - if (!(s->flags & CIP_DBC_IS_END_EVENT)) + if (!(s->flags & CIP_DBC_IS_END_EVENT)) { lost = data_block_counter != s->data_block_counter; - else + } else { + if ((data_blocks > 0) && (s->tx_dbc_interval > 0)) + dbc_interval = s->tx_dbc_interval; + else + dbc_interval = data_blocks; + lost = data_block_counter != - ((s->data_block_counter + data_blocks) & 0xff); + ((s->data_block_counter + dbc_interval) & 0xff); + } if (lost) { dev_info(&s->unit->device, diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h index f334ae5..05f1b8b 100644 --- a/sound/firewire/amdtp.h +++ b/sound/firewire/amdtp.h @@ -119,6 +119,9 @@ struct amdtp_stream { struct snd_rawmidi_substream *midi[AMDTP_MAX_CHANNELS_FOR_MIDI * 8]; + /* quirk: fixed interval of dbc between previos/current packets. */ + unsigned int tx_dbc_interval; + bool callbacked; wait_queue_head_t callback_wait; struct amdtp_stream *sync_slave; diff --git a/sound/firewire/fireworks/fireworks.c b/sound/firewire/fireworks/fireworks.c index 02b3259..25997f1 100644 --- a/sound/firewire/fireworks/fireworks.c +++ b/sound/firewire/fireworks/fireworks.c @@ -84,6 +84,7 @@ get_hardware_info(struct snd_efw *efw) (hwinfo->arm_version >> 16) & 0xff); if (err < 0) goto end; + efw->firmware_version = hwinfo->arm_version; strcpy(efw->card->driver, "Fireworks"); strcpy(efw->card->shortname, hwinfo->model_name); diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h index 9534e93..3f99851 100644 --- a/sound/firewire/fireworks/fireworks.h +++ b/sound/firewire/fireworks/fireworks.h @@ -63,6 +63,7 @@ struct snd_efw { /* for quirks */ bool is_af9; + u32 firmware_version; unsigned int midi_in_ports; unsigned int midi_out_ports; diff --git a/sound/firewire/fireworks/fireworks_stream.c b/sound/firewire/fireworks/fireworks_stream.c index 7447af7..c75c2ef 100644 --- a/sound/firewire/fireworks/fireworks_stream.c +++ b/sound/firewire/fireworks/fireworks_stream.c @@ -201,6 +201,9 @@ int snd_efw_stream_init_duplex(struct snd_efw *efw) /* AudioFire9 always reports wrong dbs. */ if (efw->is_af9) efw->tx_stream.flags |= CIP_WRONG_DBS; + /* Firmware version 5.5 reports fixed interval for dbc. */ + if (efw->firmware_version == 0x5050000) + efw->tx_stream.tx_dbc_interval = 8; err = init_stream(efw, &efw->rx_stream); if (err < 0) {