From patchwork Wed Mar 5 10:48: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: 3772871 X-Patchwork-Delegate: tiwai@suse.de 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 369B39F1EE for ; Wed, 5 Mar 2014 10:59:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D1442021E for ; Wed, 5 Mar 2014 10:59:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 02BBE20211 for ; Wed, 5 Mar 2014 10:59:52 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 90442265896; Wed, 5 Mar 2014 11:59:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 3055B265887; Wed, 5 Mar 2014 11:51:53 +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 031D32659D0; Wed, 5 Mar 2014 11:51:50 +0100 (CET) Received: from smtp311.phy.lolipop.jp (smtp311.phy.lolipop.jp [210.157.22.79]) by alsa0.perex.cz (Postfix) with ESMTP id B29E4265887 for ; Wed, 5 Mar 2014 11:49:05 +0100 (CET) Received: from smtp311.phy.lolipop.lan (HELO smtp311.phy.lolipop.jp) (172.17.1.11) (smtp-auth username m12129643-o-takashi, mechanism plain) by smtp311.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Wed, 05 Mar 2014 19:49:05 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp311.phy.lolipop.jp (LOLIPOP-Fsecure); Wed, 05 Mar 2014 19:48:28 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz Date: Wed, 5 Mar 2014 19:48:05 +0900 Message-Id: <1394016507-15761-18-git-send-email-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1394016507-15761-1-git-send-email-o-takashi@sakamocchi.jp> References: <5316963F.1000206@sakamocchi.jp> <1394016507-15761-1-git-send-email-o-takashi@sakamocchi.jp> Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net Subject: [alsa-devel] [PATCH 17/39] firewire-lib: Add quirks for Fireworks 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 This commit adds three modifications for Echo Audio's Fireworks quirks. 1.Making this module to support both TAG0 and TAG1 In IEC 61883-1, each common isochronous packet (CIP) has 'tag' field in its packet header. The value is generally 0x01 (CIP header is included = TAG1). But Fireworks in 'IEC 61883 compliant' mode transmits 'no data' packet with 0x00 (No CIP header is included = TAG0) but the packet includes CIP structure. To process 'presentation timestamp' for duplex streams synchronization correctly, this packets needs to be handled. 2.Making this module to calculate data block size and not to check continuity One of Fireworks device, AudioFirePre8, always reports 8 data block size in in-packets and the data block counter is incremented by 8. But actual value is different. 3.Making this module to have the numebr of first data blocks for MIDI messages in out-packet Fireworks can pick up MIDI messages in first 8 data blocks and ignore in other data blocks. I confirm these quirks in firmware version between 4.8 and 5.8 with Windows. I didn't investigate for the other versions. But according to contact person in Echo Audio, there is no differences between firmwares installed by Windows or OS X. --- sound/firewire/amdtp.c | 50 +++++++++++++++++++++++++------------------------- sound/firewire/amdtp.h | 2 ++ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c index 402b8e4..f961d26 100644 --- a/sound/firewire/amdtp.c +++ b/sound/firewire/amdtp.c @@ -88,6 +88,8 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit, s->sort_table = NULL; s->left_packets = NULL; + s->blocks_for_midi = UINT_MAX; + return 0; } EXPORT_SYMBOL(amdtp_stream_init); @@ -556,8 +558,14 @@ static void amdtp_fill_midi(struct amdtp_stream *s, buffer[s->midi_position] = 0x00; b = (u8 *)&buffer[s->midi_position]; + /* + * NOTE: + * Fireworks ignores midi messages in more than first 8 + * data blocks of an packet. + */ port = (s->data_block_counter + f) % 8; - if ((s->midi[port] == NULL) || + if ((f >= s->blocks_for_midi) || + (s->midi[port] == NULL) || (snd_rawmidi_transmit(s->midi[port], b + 1, 1) <= 0)) { b[0] = 0x80; b[1] = 0x00; /* confirm to be zero */ @@ -710,7 +718,7 @@ static void handle_in_packet(struct amdtp_stream *s, __be32 *buffer) { u32 cip_header[2]; - unsigned int data_block_quadlets, data_blocks, data_block_counter; + unsigned int data_blocks; struct snd_pcm_substream *pcm; cip_header[0] = be32_to_cpu(buffer[0]); @@ -735,27 +743,16 @@ static void handle_in_packet(struct amdtp_stream *s, AMDTP_FDF_NO_DATA)) return; - data_block_quadlets = - (cip_header[1] & AMDTP_DBS_MASK) >> AMDTP_DBS_SHIFT; - /* avoid division by zero */ - if (data_block_quadlets == 0) { - dev_info_ratelimited(&s->unit->device, - "Detect invalid value in dbs field: %08X\n", - data_block_quadlets); - return; - } - - data_blocks = (payload_quadlets - 2) / data_block_quadlets; - data_block_counter = cip_header[1] & AMDTP_DBC_MASK; - - /* check packet continuity */ - s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; - if (s->data_block_counter != data_block_counter) { - dev_info_ratelimited(&s->unit->device, - "Detect uncontinuity of CIP packets\n"); - s->data_block_counter = data_block_counter; - return; - } + /* + * This module don't use the value of dbs and dbc beceause Echo + * AudioFirePre8 reports inappropriate value. + * + * This model always reports a fixed value "8" as data block size at + * any sampling rates but actually data block size is different. + * Additionally the value of data block count always incremented by + * "8" at any sampling rates but actually it's different. + */ + data_blocks = (payload_quadlets - 2) / s->data_block_quadlets; buffer += 2; @@ -1033,11 +1030,14 @@ int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed) goto err_context; } while (s->packet_index > 0); - /* NOTE: TAG1 matches CIP. This just affects in stream */ + /* + * NOTE: TAG1 matches CIP. This just affects in stream. + * Fireworks transmits NODATA packets with TAG0. + */ s->data_block_counter = 0; s->callbacked = false; err = fw_iso_context_start(s->context, -1, 0, - FW_ISO_CONTEXT_MATCH_TAG1); + FW_ISO_CONTEXT_MATCH_TAG0 | FW_ISO_CONTEXT_MATCH_TAG1); if (err < 0) goto err_context; diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h index 861f509..dce3903 100644 --- a/sound/firewire/amdtp.h +++ b/sound/firewire/amdtp.h @@ -113,6 +113,8 @@ struct amdtp_stream { bool pointer_flush; struct snd_rawmidi_substream *midi[AMDTP_MAX_CHANNELS_FOR_MIDI * 8]; + /* quirk: the first count of data blocks in an AMDTP packet for MIDI */ + unsigned int blocks_for_midi; bool callbacked; wait_queue_head_t callback_wait;