From patchwork Sun Dec 16 08:32:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10732379 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 DF7CC746 for ; Sun, 16 Dec 2018 08:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFA4129DC4 for ; Sun, 16 Dec 2018 08:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D7F29DC8; Sun, 16 Dec 2018 08:33:05 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09A4729DC4 for ; Sun, 16 Dec 2018 08:33:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id ECBB22679E4; Sun, 16 Dec 2018 09:32:57 +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 B2155267944; Sun, 16 Dec 2018 09:32:53 +0100 (CET) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by alsa0.perex.cz (Postfix) with ESMTP id 2A46726793A for ; Sun, 16 Dec 2018 09:32:50 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id u18so4696302plq.7 for ; Sun, 16 Dec 2018 00:32:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u21Tk6FegrmulCUaNq2u7Y2Ua5rNPL47jRlAR9DTqis=; b=Dyr5yPmOfKQ4sDA/OPSIPZDmMjr+eYopcDjLKPvyKCZROZ0Ddijmbe6pS7vCCOydr7 0scVRzQiH4loJGE0h6cBmoObNlGjIK/KixGmRlVnW4goCXBgYDcFOuAtD56R6WJbukGP R0wzXipduBfcO3iKMgJgyh39JHoIYFY7Qe+V+4Da9hEu46w4WzoahiAEK8U7tzszIB9I v6/ZV8h8ENZxtoW/wZublRlJLnEH9ysOnnegC5rs81YBFN5Tg4syekSLrBqwR6/XSnGK namGTXw9m33JX5ScHEoiZlQaa+vipMHetIrHsAJkaXKiYzHqm+Z7NsjS+DbHdVyfbJa+ AytQ== X-Gm-Message-State: AA+aEWbcfCb6b1qEtjxQfams2RLELqcqRa4/mecHzB3P5Pkh+MNSsSu4 WqonmwEehq0e9M6P9YOjuCzpF+dX X-Google-Smtp-Source: AFSGD/XvOPLTT59MNSdfnk/9YCYiL6h7h1Q1a5psYk5gT/N1vsNqfY+hp37f+Mcw32kloMiX2+ySrw== X-Received: by 2002:a17:902:6b49:: with SMTP id g9mr8732120plt.98.1544949169920; Sun, 16 Dec 2018 00:32:49 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:bcf1:29e1:e2b3:875b]) by smtp.gmail.com with ESMTPSA id d11sm13712984pgi.25.2018.12.16.00.32.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Dec 2018 00:32:49 -0800 (PST) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 16 Dec 2018 17:32:29 +0900 Message-Id: <20181216083233.11358-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181216083233.11358-1-o-takashi@sakamocchi.jp> References: <20181216083233.11358-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 1/5] ALSA: fireface: share helper function to switch fetching mode 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Both of Fireface 400/800 have the same register to switch frame fetching mode regardless of difference of available number of PCM frames in rx isochronous packet. This commit moves a helper function from model-dependent implementation. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-ff400.c | 30 ---------------- sound/firewire/fireface/ff-stream.c | 38 +++++++++++++++++++-- sound/firewire/fireface/ff.h | 1 - 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-ff400.c b/sound/firewire/fireface/ff-protocol-ff400.c index fd257051d4a4..374009545936 100644 --- a/sound/firewire/fireface/ff-protocol-ff400.c +++ b/sound/firewire/fireface/ff-protocol-ff400.c @@ -76,35 +76,6 @@ static void ff400_finish_session(struct snd_ff *ff) FF400_ISOC_COMM_STOP, ®, sizeof(reg), 0); } -static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable) -{ - __le32 *reg; - int i; - int err; - - reg = kcalloc(18, sizeof(__le32), GFP_KERNEL); - if (reg == NULL) - return -ENOMEM; - - if (!enable) { - /* - * Each quadlet is corresponding to data channels in a data - * blocks in reverse order. Precisely, quadlets for available - * data channels should be enabled. Here, I take second best - * to fetch PCM frames from all of data channels regardless of - * stf. - */ - for (i = 0; i < 18; ++i) - reg[i] = cpu_to_le32(0x00000001); - } - - err = snd_fw_transaction(ff->unit, TCODE_WRITE_BLOCK_REQUEST, - SND_FF_REG_FETCH_PCM_FRAMES, reg, - sizeof(__le32) * 18, 0); - kfree(reg); - return err; -} - static void ff400_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length) { int i; @@ -146,5 +117,4 @@ const struct snd_ff_protocol snd_ff_protocol_ff400 = { .handle_midi_msg = ff400_handle_midi_msg, .begin_session = ff400_begin_session, .finish_session = ff400_finish_session, - .switch_fetching_mode = ff400_switch_fetching_mode, }; diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index 59ca2e84d41c..e6fa6362dab7 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -73,10 +73,44 @@ static void release_resources(struct snd_ff *ff) fw_iso_resources_free(&ff->rx_resources); } +static int switch_fetching_mode(struct snd_ff *ff, bool enable) +{ + unsigned int count; + __le32 *reg; + int i; + int err; + + count = 0; + for (i = 0; i < SND_FF_STREAM_MODES; ++i) + count = max(count, ff->spec->pcm_playback_channels[i]); + + reg = kcalloc(count, sizeof(__le32), GFP_KERNEL); + if (!reg) + return -ENOMEM; + + if (!enable) { + /* + * Each quadlet is corresponding to data channels in a data + * blocks in reverse order. Precisely, quadlets for available + * data channels should be enabled. Here, I take second best + * to fetch PCM frames from all of data channels regardless of + * stf. + */ + for (i = 0; i < count; ++i) + reg[i] = cpu_to_le32(0x00000001); + } + + err = snd_fw_transaction(ff->unit, TCODE_WRITE_BLOCK_REQUEST, + SND_FF_REG_FETCH_PCM_FRAMES, reg, + sizeof(__le32) * count, 0); + kfree(reg); + return err; +} + static inline void finish_session(struct snd_ff *ff) { ff->spec->protocol->finish_session(ff); - ff->spec->protocol->switch_fetching_mode(ff, false); + switch_fetching_mode(ff, false); } static int init_stream(struct snd_ff *ff, enum amdtp_stream_direction dir) @@ -188,7 +222,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate) goto error; } - err = ff->spec->protocol->switch_fetching_mode(ff, true); + err = switch_fetching_mode(ff, true); if (err < 0) goto error; } diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 6e4a8197d3ca..17332d9ae3f2 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -111,7 +111,6 @@ struct snd_ff_protocol { void (*handle_midi_msg)(struct snd_ff *ff, __le32 *buf, size_t length); int (*begin_session)(struct snd_ff *ff, unsigned int rate); void (*finish_session)(struct snd_ff *ff); - int (*switch_fetching_mode)(struct snd_ff *ff, bool enable); }; extern const struct snd_ff_protocol snd_ff_protocol_ff800; From patchwork Sun Dec 16 08:32:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10732381 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 53D76746 for ; Sun, 16 Dec 2018 08:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E2329DC4 for ; Sun, 16 Dec 2018 08:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 386DC29DC8; Sun, 16 Dec 2018 08:33:14 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6237829DC4 for ; Sun, 16 Dec 2018 08:33:13 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 558FF267ABC; Sun, 16 Dec 2018 09:32:59 +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 29D60267946; Sun, 16 Dec 2018 09:32:55 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by alsa0.perex.cz (Postfix) with ESMTP id 20EDE26793A for ; Sun, 16 Dec 2018 09:32:52 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id g9so4691910plo.3 for ; Sun, 16 Dec 2018 00:32:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DLI05SQmjMsQIwAZGxs67SmKgAXHhQ96M1UzPl9+T4k=; b=ho8SkGK5ImeJf0UYwxfhLiST0tta7L2zOR2U9vo0oTOat0ctUWB40ukjobYHUUVaCx SCYUBxqDI7DxcE2CfbJoG5xjdIxarLpDGiB70RwzSAcFALgikwaUOvhOm1spC5SVxhi7 dfNYqG7cCgNRdvkPWd0WoyVDzoTY2jFAYC8CxD56yM1eVG/Z/MW6n0HMJfVFKfkgwiib KwYgqxg9qDI9ww2qcBGSznIjMeq1pVnxDizp/Y1ouS//Z4J1IYKo8SHzkN1OIFW1Uxai qyxDFOsfyLNA4Vg9VwOHrb8H4tykrn1Aan9WgBaMlCxx/EAFBxEmusanEStYtruqz7WB dBtg== X-Gm-Message-State: AA+aEWYm21DCY9DC7qJO7OtKE/VdwIhOR318mFCiEIbK0WUDl+sL9VDf n3mT6Ujeu0mTrFRZCSR0FeiUfN19 X-Google-Smtp-Source: AFSGD/VlYxUsYlgRbJtL35WDngNyMNqb3cFsa1G3eqqkn3ZfZojgliO129hZnm0aDbDsTHSIakvukA== X-Received: by 2002:a17:902:be0e:: with SMTP id r14mr8284905pls.124.1544949171782; Sun, 16 Dec 2018 00:32:51 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:bcf1:29e1:e2b3:875b]) by smtp.gmail.com with ESMTPSA id d11sm13712984pgi.25.2018.12.16.00.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Dec 2018 00:32:51 -0800 (PST) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 16 Dec 2018 17:32:30 +0900 Message-Id: <20181216083233.11358-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181216083233.11358-1-o-takashi@sakamocchi.jp> References: <20181216083233.11358-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 2/5] ALSA: fireface: code refactoring to handle multiplier mode 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Fireface 400/800 use three modes against the number of data channels in data block for both tx/rx packets. This commit adds refactoring for it. Some enumerators are added to represent each of mode and a function is added to calculate the mode from sampling frequency code (sfc). Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-pcm.c | 33 ++++++++++++++++--------- sound/firewire/fireface/ff-stream.c | 38 +++++++++++++++++++---------- sound/firewire/fireface/ff.h | 15 +++++++++--- 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/sound/firewire/fireface/ff-pcm.c b/sound/firewire/fireface/ff-pcm.c index 63b0be6f05e8..d0bc96b20a65 100644 --- a/sound/firewire/fireface/ff-pcm.c +++ b/sound/firewire/fireface/ff-pcm.c @@ -8,11 +8,6 @@ #include "ff.h" -static inline unsigned int get_multiplier_mode_with_index(unsigned int index) -{ - return ((int)index - 1) / 2; -} - static int hw_rule_rate(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { @@ -24,10 +19,16 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, struct snd_interval t = { .min = UINT_MAX, .max = 0, .integer = 1 }; - unsigned int i, mode; + unsigned int i; for (i = 0; i < ARRAY_SIZE(amdtp_rate_table); i++) { - mode = get_multiplier_mode_with_index(i); + enum snd_ff_stream_mode mode; + int err; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); + if (err < 0) + continue; + if (!snd_interval_test(c, pcm_channels[mode])) continue; @@ -49,10 +50,16 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, struct snd_interval t = { .min = UINT_MAX, .max = 0, .integer = 1 }; - unsigned int i, mode; + unsigned int i; for (i = 0; i < ARRAY_SIZE(amdtp_rate_table); i++) { - mode = get_multiplier_mode_with_index(i); + enum snd_ff_stream_mode mode; + int err; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); + if (err < 0) + continue; + if (!snd_interval_test(r, amdtp_rate_table[i])) continue; @@ -66,7 +73,6 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, static void limit_channels_and_rates(struct snd_pcm_hardware *hw, const unsigned int *pcm_channels) { - unsigned int mode; unsigned int rate, channels; int i; @@ -76,7 +82,12 @@ static void limit_channels_and_rates(struct snd_pcm_hardware *hw, hw->rate_max = 0; for (i = 0; i < ARRAY_SIZE(amdtp_rate_table); i++) { - mode = get_multiplier_mode_with_index(i); + enum snd_ff_stream_mode mode; + int err; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); + if (err < 0) + continue; channels = pcm_channels[mode]; if (pcm_channels[mode] == 0) diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index e6fa6362dab7..e6a8229a9d82 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -10,19 +10,23 @@ #define CALLBACK_TIMEOUT_MS 200 -static int get_rate_mode(unsigned int rate, unsigned int *mode) +int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, + enum snd_ff_stream_mode *mode) { - int i; - - for (i = 0; i < CIP_SFC_COUNT; i++) { - if (amdtp_rate_table[i] == rate) - break; - } - - if (i == CIP_SFC_COUNT) + static const enum snd_ff_stream_mode modes[] = { + [CIP_SFC_32000] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_44100] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_48000] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_88200] = SND_FF_STREAM_MODE_MID, + [CIP_SFC_96000] = SND_FF_STREAM_MODE_MID, + [CIP_SFC_176400] = SND_FF_STREAM_MODE_HIGH, + [CIP_SFC_192000] = SND_FF_STREAM_MODE_HIGH, + }; + + if (sfc >= CIP_SFC_COUNT) return -EINVAL; - *mode = ((int)i - 1) / 2; + *mode = modes[sfc]; return 0; } @@ -33,10 +37,18 @@ static int get_rate_mode(unsigned int rate, unsigned int *mode) */ static int keep_resources(struct snd_ff *ff, unsigned int rate) { - int mode; + enum snd_ff_stream_mode mode; + int i; int err; - err = get_rate_mode(rate, &mode); + for (i = 0; i < CIP_SFC_COUNT; ++i) { + if (amdtp_rate_table[i] == rate) + break; + } + if (i == CIP_SFC_COUNT) + return -EINVAL; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); if (err < 0) return err; @@ -81,7 +93,7 @@ static int switch_fetching_mode(struct snd_ff *ff, bool enable) int err; count = 0; - for (i = 0; i < SND_FF_STREAM_MODES; ++i) + for (i = 0; i < SND_FF_STREAM_MODE_COUNT; ++i) count = max(count, ff->spec->pcm_playback_channels[i]); reg = kcalloc(count, sizeof(__le32), GFP_KERNEL); diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 17332d9ae3f2..9fdda4fbdbba 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -31,8 +31,6 @@ #include "../amdtp-stream.h" #include "../iso-resources.h" -#define SND_FF_STREAM_MODES 3 - #define SND_FF_MAXIMIM_MIDI_QUADS 9 #define SND_FF_IN_MIDI_PORTS 2 #define SND_FF_OUT_MIDI_PORTS 2 @@ -42,6 +40,13 @@ #define SND_FF_REG_FETCH_PCM_FRAMES 0x0000801c0000ull #define SND_FF_REG_CLOCK_CONFIG 0x0000801c0004ull +enum snd_ff_stream_mode { + SND_FF_STREAM_MODE_LOW = 0, + SND_FF_STREAM_MODE_MID, + SND_FF_STREAM_MODE_HIGH, + SND_FF_STREAM_MODE_COUNT, +}; + enum snd_ff_reg_type { SND_FF_REG_TYPE_MIDI_HIGH_ADDR = 0, SND_FF_REG_TYPE_COUNT, @@ -51,8 +56,8 @@ struct snd_ff_protocol; struct snd_ff_spec { const char *const name; - const unsigned int pcm_capture_channels[SND_FF_STREAM_MODES]; - const unsigned int pcm_playback_channels[SND_FF_STREAM_MODES]; + const unsigned int pcm_capture_channels[SND_FF_STREAM_MODE_COUNT]; + const unsigned int pcm_playback_channels[SND_FF_STREAM_MODE_COUNT]; unsigned int midi_in_ports; unsigned int midi_out_ports; @@ -129,6 +134,8 @@ int amdtp_ff_add_pcm_hw_constraints(struct amdtp_stream *s, int amdtp_ff_init(struct amdtp_stream *s, struct fw_unit *unit, enum amdtp_stream_direction dir); +int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, + enum snd_ff_stream_mode *mode); int snd_ff_stream_init_duplex(struct snd_ff *ff); void snd_ff_stream_destroy_duplex(struct snd_ff *ff); int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate); From patchwork Sun Dec 16 08:32:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10732383 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 56B5B1575 for ; Sun, 16 Dec 2018 08:33:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4490229DC4 for ; Sun, 16 Dec 2018 08:33:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 366CF29DC8; Sun, 16 Dec 2018 08:33:24 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6796329DC4 for ; Sun, 16 Dec 2018 08:33:23 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 231DF267AD2; Sun, 16 Dec 2018 09:33:03 +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 AEE882679EF; Sun, 16 Dec 2018 09:32:56 +0100 (CET) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by alsa0.perex.cz (Postfix) with ESMTP id C5257267946 for ; Sun, 16 Dec 2018 09:32:54 +0100 (CET) Received: by mail-pl1-f196.google.com with SMTP id 101so4696604pld.6 for ; Sun, 16 Dec 2018 00:32:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sYKzFIviZIR45DCfu7tq+logIGeDakGwgZJ5qcVRHw4=; b=XiSKVa11d+nK22B1flnvkHdbjG4+CdfOOSWONf+qfxF4HYPR0ztTXAW90ydUsQNr02 mYMfej1+Ljzc7Jr7dR+y5MGDi3QAL8WBOCVNQbg2Kan7QkSaBhFLMnitAUe0XKc9vBgh e0s2/H8Dg5QE/qGBKlFBtwUJkNgDscAu6cZK3ab5NazGZ5/oHGgTSgwF+dUo270Mt1bv gXiw4y2MetTE/+lNoqopsJVvZH5BvCD0lCPwYrRzQGxHgmAJkc1Tw/JFN/CJletrbyfo AW1EMzAQGGQI/modSK760dsbtAOgAPugiDCWjqcdgaJzkrbkbFxLFxV1kFS3DDTenIR0 40ew== X-Gm-Message-State: AA+aEWaDT50WwiclCfIMC+7H/nyRNK80EDZxN6bFq17ceJBqJne7ZAAc Cf8umPuqXIoFEFuji44C4gU= X-Google-Smtp-Source: AFSGD/XJjJM3hYrjIl8ZFOMg5kv/7KOpiduiRb+k4cIJgRGjlmiGi8GwQxT6UWf9hgF4OsB5ZPHs5Q== X-Received: by 2002:a17:902:8ec9:: with SMTP id x9mr8951926plo.27.1544949173691; Sun, 16 Dec 2018 00:32:53 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:bcf1:29e1:e2b3:875b]) by smtp.gmail.com with ESMTPSA id d11sm13712984pgi.25.2018.12.16.00.32.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Dec 2018 00:32:53 -0800 (PST) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 16 Dec 2018 17:32:31 +0900 Message-Id: <20181216083233.11358-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181216083233.11358-1-o-takashi@sakamocchi.jp> References: <20181216083233.11358-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 3/5] ALSA: fireface: allocate isochronous resources in mode-specific implementation 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The way to maintain isochronous resources on bus is different between Fireface 400/800. This commit is a preparation. This commit moves a function to allocate resource to model-dependent implementation. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-ff400.c | 51 +++++++++++++-- sound/firewire/fireface/ff-stream.c | 72 +++++++-------------- 2 files changed, 68 insertions(+), 55 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-ff400.c b/sound/firewire/fireface/ff-protocol-ff400.c index 374009545936..2280fab9b3c7 100644 --- a/sound/firewire/fireface/ff-protocol-ff400.c +++ b/sound/firewire/fireface/ff-protocol-ff400.c @@ -15,19 +15,60 @@ #define FF400_TX_PACKET_FORMAT 0x00008010050cull #define FF400_ISOC_COMM_STOP 0x000080100510ull -static int ff400_begin_session(struct snd_ff *ff, unsigned int rate) +/* + * Fireface 400 manages isochronous channel number in 3 bit field. Therefore, + * we can allocate between 0 and 7 channel. + */ +static int keep_resources(struct snd_ff *ff, unsigned int rate) { - __le32 reg; - int i, err; + enum snd_ff_stream_mode mode; + int i; + int err; - /* Check whether the given value is supported or not. */ + // Check whether the given value is supported or not. for (i = 0; i < CIP_SFC_COUNT; i++) { if (amdtp_rate_table[i] == rate) break; } - if (i == CIP_SFC_COUNT) + if (i >= CIP_SFC_COUNT) return -EINVAL; + err = snd_ff_stream_get_multiplier_mode(i, &mode); + if (err < 0) + return err; + + /* Keep resources for in-stream. */ + ff->tx_resources.channels_mask = 0x00000000000000ffuLL; + err = fw_iso_resources_allocate(&ff->tx_resources, + amdtp_stream_get_max_payload(&ff->tx_stream), + fw_parent_device(ff->unit)->max_speed); + if (err < 0) + return err; + + /* Keep resources for out-stream. */ + err = amdtp_ff_set_parameters(&ff->rx_stream, rate, + ff->spec->pcm_playback_channels[mode]); + if (err < 0) + return err; + ff->rx_resources.channels_mask = 0x00000000000000ffuLL; + err = fw_iso_resources_allocate(&ff->rx_resources, + amdtp_stream_get_max_payload(&ff->rx_stream), + fw_parent_device(ff->unit)->max_speed); + if (err < 0) + fw_iso_resources_free(&ff->tx_resources); + + return err; +} + +static int ff400_begin_session(struct snd_ff *ff, unsigned int rate) +{ + __le32 reg; + int err; + + err = keep_resources(ff, rate); + if (err < 0) + return err; + /* Set the number of data blocks transferred in a second. */ reg = cpu_to_le32(rate); err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index e6a8229a9d82..a490e4553721 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -31,54 +31,6 @@ int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, return 0; } -/* - * Fireface 400 manages isochronous channel number in 3 bit field. Therefore, - * we can allocate between 0 and 7 channel. - */ -static int keep_resources(struct snd_ff *ff, unsigned int rate) -{ - enum snd_ff_stream_mode mode; - int i; - int err; - - for (i = 0; i < CIP_SFC_COUNT; ++i) { - if (amdtp_rate_table[i] == rate) - break; - } - if (i == CIP_SFC_COUNT) - return -EINVAL; - - err = snd_ff_stream_get_multiplier_mode(i, &mode); - if (err < 0) - return err; - - /* Keep resources for in-stream. */ - err = amdtp_ff_set_parameters(&ff->tx_stream, rate, - ff->spec->pcm_capture_channels[mode]); - if (err < 0) - return err; - ff->tx_resources.channels_mask = 0x00000000000000ffuLL; - err = fw_iso_resources_allocate(&ff->tx_resources, - amdtp_stream_get_max_payload(&ff->tx_stream), - fw_parent_device(ff->unit)->max_speed); - if (err < 0) - return err; - - /* Keep resources for out-stream. */ - err = amdtp_ff_set_parameters(&ff->rx_stream, rate, - ff->spec->pcm_playback_channels[mode]); - if (err < 0) - return err; - ff->rx_resources.channels_mask = 0x00000000000000ffuLL; - err = fw_iso_resources_allocate(&ff->rx_resources, - amdtp_stream_get_max_payload(&ff->rx_stream), - fw_parent_device(ff->unit)->max_speed); - if (err < 0) - fw_iso_resources_free(&ff->tx_resources); - - return err; -} - static void release_resources(struct snd_ff *ff) { fw_iso_resources_free(&ff->tx_resources); @@ -214,9 +166,29 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate) * packets. Then, the device transfers packets. */ if (!amdtp_stream_running(&ff->rx_stream)) { - err = keep_resources(ff, rate); + enum snd_ff_stream_mode mode; + int i; + + for (i = 0; i < CIP_SFC_COUNT; ++i) { + if (amdtp_rate_table[i] == rate) + break; + } + if (i >= CIP_SFC_COUNT) + return -EINVAL; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); if (err < 0) - goto error; + return err; + + err = amdtp_ff_set_parameters(&ff->tx_stream, rate, + ff->spec->pcm_capture_channels[mode]); + if (err < 0) + return err; + + err = amdtp_ff_set_parameters(&ff->rx_stream, rate, + ff->spec->pcm_playback_channels[mode]); + if (err < 0) + return err; err = ff->spec->protocol->begin_session(ff, rate); if (err < 0) From patchwork Sun Dec 16 08:32:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10732385 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 413A41575 for ; Sun, 16 Dec 2018 08:33:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3018329DC4 for ; Sun, 16 Dec 2018 08:33:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2303029DC8; Sun, 16 Dec 2018 08:33:31 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A69429DC4 for ; Sun, 16 Dec 2018 08:33:30 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9C0DC267AD4; Sun, 16 Dec 2018 09:33:04 +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 6250A267AC1; Sun, 16 Dec 2018 09:32:59 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by alsa0.perex.cz (Postfix) with ESMTP id 76221267944 for ; Sun, 16 Dec 2018 09:32:56 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id c72so4869610pfc.6 for ; Sun, 16 Dec 2018 00:32:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DtYNmYU7hJR2lxTndOCWuDrWTpUhG6BAm7uu5z3d8Cw=; b=iXE7HykWjmtfc5l3H/2CmawRjLB15G5jwYkAF9Eq5mVMXuN/3tQiGFhofg36xSZU9E 63gg2cTYFOOsbP8veXbSKFSy/NKSxuQoDHRXuQ53Ay4/wxrtd+FApmTMAJiTrTxcEJiW vFNhjmyPvIyaPrfSvbyJVgu9IpSOeblJHrPBVcNL4LYUQZZnJ4CjV13q9DPOtL7uz70U /xlZdsnNfL3olTOOCaM1ivLRLRQnkM30l7n7L+qlCMvN/q+7siNRgQypfHK32R4CJyMw TweahiucsMf9bPdsGzFNDFhPk6ziuKTvWNM2um+axhRD8+GxWlnuQO0y78HndDRFcBXt XK+g== X-Gm-Message-State: AA+aEWYQgYm0GMFBG1L314TgQRWOzyp52YvGnxzocTadA7V9rcfon4F+ frUlbndH8rbUDVXtCb//34Q= X-Google-Smtp-Source: AFSGD/VA2++UbcjMxpBHw+jz7p5F7xlaYOBYo6hRaR8UnDX8wMK/veYL9dEljM2MQimBa/KjWyBhRQ== X-Received: by 2002:a62:2606:: with SMTP id m6mr8733574pfm.133.1544949175595; Sun, 16 Dec 2018 00:32:55 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:bcf1:29e1:e2b3:875b]) by smtp.gmail.com with ESMTPSA id d11sm13712984pgi.25.2018.12.16.00.32.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Dec 2018 00:32:55 -0800 (PST) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 16 Dec 2018 17:32:32 +0900 Message-Id: <20181216083233.11358-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181216083233.11358-1-o-takashi@sakamocchi.jp> References: <20181216083233.11358-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 4/5] ALSA: fireface: add support for packet streaming on Fireface 800 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds a functionality to multiplex PCM frames into isochronous packets and demultiplex PCM frames from isochronous packets for ALSA PCM applications. Fireface 800 voluntarily maintains resources for tx isochronous communication. It performs reservation of isochronous channel and allocation/update of bandwidth in some cases below: - at a first request to allocation after bus resets - at requests to allocation when further bandwidth is required When request is grant and the unit is prepared, read data from 0x0000801c0008 represents isochronous channel for tx stream, then the unit can handle requests to start communication. If driver send the request without checking the register, the unit takes panic to continue bus resets. The unit starts transmission of tx packets after receiving several rx packets from driver. I note that the unit can process tx/rx packets and generate/record sound regardless of HOST LED. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-ff800.c | 116 ++++++++++++++++++++ sound/firewire/fireface/ff.c | 29 +++-- 2 files changed, 129 insertions(+), 16 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-ff800.c b/sound/firewire/fireface/ff-protocol-ff800.c index d24439734304..2acbf6039770 100644 --- a/sound/firewire/fireface/ff-protocol-ff800.c +++ b/sound/firewire/fireface/ff-protocol-ff800.c @@ -6,8 +6,122 @@ * Licensed under the terms of the GNU General Public License, version 2. */ +#include + #include "ff.h" +#define FF800_STF 0x0000fc88f000 +#define FF800_RX_PACKET_FORMAT 0x0000fc88f004 +#define FF800_ALLOC_TX_STREAM 0x0000fc88f008 +#define FF800_ISOC_COMM_START 0x0000fc88f00c +#define FF800_TX_S800_FLAG 0x00000800 +#define FF800_ISOC_COMM_STOP 0x0000fc88f010 + +#define FF800_TX_PACKET_ISOC_CH 0x0000801c0008 + +static int allocate_rx_resources(struct snd_ff *ff) +{ + u32 data; + __le32 reg; + int err; + + // Controllers should allocate isochronous resources for rx stream. + err = fw_iso_resources_allocate(&ff->rx_resources, + amdtp_stream_get_max_payload(&ff->rx_stream), + fw_parent_device(ff->unit)->max_speed); + if (err < 0) + return err; + + // Set isochronous channel and the number of quadlets of rx packets. + data = ff->rx_stream.data_block_quadlets << 3; + data = (data << 8) | ff->rx_resources.channel; + reg = cpu_to_le32(data); + return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, + FF800_RX_PACKET_FORMAT, ®, sizeof(reg), 0); +} + +static int allocate_tx_resources(struct snd_ff *ff) +{ + __le32 reg; + unsigned int count; + unsigned int tx_isoc_channel; + int err; + + reg = cpu_to_le32(ff->tx_stream.data_block_quadlets); + err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, + FF800_ALLOC_TX_STREAM, ®, sizeof(reg), 0); + if (err < 0) + return err; + + // Wait till the format of tx packet is available. + count = 0; + while (count++ < 10) { + u32 data; + err = snd_fw_transaction(ff->unit, TCODE_READ_QUADLET_REQUEST, + FF800_TX_PACKET_ISOC_CH, ®, sizeof(reg), 0); + if (err < 0) + return err; + + data = le32_to_cpu(reg); + if (data != 0xffffffff) { + tx_isoc_channel = data; + break; + } + + msleep(50); + } + if (count >= 10) + return -ETIMEDOUT; + + // NOTE: this is a makeshift to start OHCI 1394 IR context in the + // channel. On the other hand, 'struct fw_iso_resources.allocated' is + // not true and it's not deallocated at stop. + ff->tx_resources.channel = tx_isoc_channel; + + return 0; +} + +static int ff800_begin_session(struct snd_ff *ff, unsigned int rate) +{ + __le32 reg; + int err; + + reg = cpu_to_le32(rate); + err = snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, + FF800_STF, ®, sizeof(reg), 0); + if (err < 0) + return err; + + // If starting isochronous communication immediately, change of STF has + // no effect. In this case, the communication runs based on former STF. + // Let's sleep for a bit. + msleep(100); + + err = allocate_rx_resources(ff); + if (err < 0) + return err; + + err = allocate_tx_resources(ff); + if (err < 0) + return err; + + reg = cpu_to_le32(0x80000000); + reg |= cpu_to_le32(ff->tx_stream.data_block_quadlets); + if (fw_parent_device(ff->unit)->max_speed == SCODE_800) + reg |= cpu_to_le32(FF800_TX_S800_FLAG); + return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, + FF800_ISOC_COMM_START, ®, sizeof(reg), 0); +} + +static void ff800_finish_session(struct snd_ff *ff) +{ + __le32 reg; + + reg = cpu_to_le32(0x80000000); + snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, + FF800_ISOC_COMM_STOP, ®, sizeof(reg), 0); +} + static void ff800_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length) { int i; @@ -24,4 +138,6 @@ static void ff800_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length) const struct snd_ff_protocol snd_ff_protocol_ff800 = { .handle_midi_msg = ff800_handle_midi_msg, + .begin_session = ff800_begin_session, + .finish_session = ff800_finish_session, }; diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c index d486984c0e5b..f7a752930060 100644 --- a/sound/firewire/fireface/ff.c +++ b/sound/firewire/fireface/ff.c @@ -31,8 +31,7 @@ static void ff_card_free(struct snd_card *card) { struct snd_ff *ff = card->private_data; - if (ff->spec->protocol->begin_session) - snd_ff_stream_destroy_duplex(ff); + snd_ff_stream_destroy_duplex(ff); snd_ff_transaction_unregister(ff); } @@ -57,11 +56,9 @@ static void do_registration(struct work_struct *work) name_card(ff); - if (ff->spec->protocol->begin_session) { - err = snd_ff_stream_init_duplex(ff); - if (err < 0) - goto error; - } + err = snd_ff_stream_init_duplex(ff); + if (err < 0) + goto error; snd_ff_proc_init(ff); @@ -69,15 +66,13 @@ static void do_registration(struct work_struct *work) if (err < 0) goto error; - if (ff->spec->protocol->begin_session) { - err = snd_ff_create_pcm_devices(ff); - if (err < 0) - goto error; + err = snd_ff_create_pcm_devices(ff); + if (err < 0) + goto error; - err = snd_ff_create_hwdep_devices(ff); - if (err < 0) - goto error; - } + err = snd_ff_create_hwdep_devices(ff); + if (err < 0) + goto error; err = snd_card_register(ff->card); if (err < 0) @@ -126,7 +121,7 @@ static void snd_ff_update(struct fw_unit *unit) snd_ff_transaction_reregister(ff); - if (ff->registered && ff->spec->protocol->begin_session) + if (ff->registered) snd_ff_stream_update_duplex(ff); } @@ -152,6 +147,8 @@ static void snd_ff_remove(struct fw_unit *unit) static const struct snd_ff_spec spec_ff800 = { .name = "Fireface800", + .pcm_capture_channels = {28, 20, 12}, + .pcm_playback_channels = {28, 20, 12}, .midi_in_ports = 1, .midi_out_ports = 1, .protocol = &snd_ff_protocol_ff800, From patchwork Sun Dec 16 08:32:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 10732387 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 B23E2746 for ; Sun, 16 Dec 2018 08:33:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A081E28751 for ; Sun, 16 Dec 2018 08:33:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91DA4288F7; Sun, 16 Dec 2018 08:33:38 +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,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]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29B4929DC4 for ; Sun, 16 Dec 2018 08:33:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EF359267ADC; Sun, 16 Dec 2018 09:33:05 +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 74A70267AD2; Sun, 16 Dec 2018 09:33:02 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by alsa0.perex.cz (Postfix) with ESMTP id 02BA2267946 for ; Sun, 16 Dec 2018 09:32:58 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id u6so4683829plm.8 for ; Sun, 16 Dec 2018 00:32:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bZ+x/GuBRVU4FlIPIUE91JUIFJn1GCnI7UK8d6WbdN4=; b=aZaByVqGzrYNY8FfUDARZ2IitNaSfeLh5oi2Ecqrjg5bXGkwWFxBrmmXguvlYF6x2A gNRFovV/H8wWpwuNZ4eS6NGUh2kIxpFENnmpRAEvVuxlNbnzISBTlWJ0Ba3EJ7IcRClT 2Ku13CSdJYqjXW9Mj4dhwQ9pVre7/trWRBfsoK0Z5kTYTVZmxzrqBZGJckG6vxxcdXrt ok/8xZvdsq2ZE0oXdDNUQV1NTFIkWt/ntWbm2CV7lPAqKnID4CW0bhB4ZogGFItRrDT9 I0DHbyZq3UIjAHWLLAiMr0hbYk+Vc/G3TjK9pUr7K3pCU4mWt34gCNkfT6MT36xkfxuL 8hjg== X-Gm-Message-State: AA+aEWZtqJzMTOQWdveuBwGgGYX40FNOQ+UllJcmzInxhsyONwQeyqNR 83AT37ZuTHK6klIuODBBiRA= X-Google-Smtp-Source: AFSGD/XHwq698ab1wX3I23idTAd/aMREoO2yex2hTvlL3y+vHwWbMrHELon4160co8fhQLIviacT+w== X-Received: by 2002:a17:902:9a98:: with SMTP id w24mr8934397plp.213.1544949177588; Sun, 16 Dec 2018 00:32:57 -0800 (PST) Received: from localhost.localdomain ([2405:6580:9660:3200:bcf1:29e1:e2b3:875b]) by smtp.gmail.com with ESMTPSA id d11sm13712984pgi.25.2018.12.16.00.32.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Dec 2018 00:32:56 -0800 (PST) From: Takashi Sakamoto To: clemens@ladisch.de, tiwai@suse.de Date: Sun, 16 Dec 2018 17:32:33 +0900 Message-Id: <20181216083233.11358-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181216083233.11358-1-o-takashi@sakamocchi.jp> References: <20181216083233.11358-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net Subject: [alsa-devel] [PATCH 5/5] ALSA: fireface: code refactoring to handle model-specific registers 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP As a result of investigation for Fireface 800, 'struct snd_ff_spec.regs' is just for higher address to receive tx asynchronous packets of MIDI messages, thus it can be simplified. This commit simplifies it. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-transaction.c | 4 ++-- sound/firewire/fireface/ff.c | 8 ++------ sound/firewire/fireface/ff.h | 9 ++------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/sound/firewire/fireface/ff-transaction.c b/sound/firewire/fireface/ff-transaction.c index d8768348067b..5f4ddfd55403 100644 --- a/sound/firewire/fireface/ff-transaction.c +++ b/sound/firewire/fireface/ff-transaction.c @@ -278,7 +278,7 @@ int snd_ff_transaction_reregister(struct snd_ff *ff) addr = (fw_card->node_id << 16) | (ff->async_handler.offset >> 32); reg = cpu_to_le32(addr); return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, - ff->spec->regs[SND_FF_REG_TYPE_MIDI_HIGH_ADDR], + ff->spec->midi_high_addr, ®, sizeof(reg), 0); } @@ -319,7 +319,7 @@ void snd_ff_transaction_unregister(struct snd_ff *ff) /* Release higher 4 bytes of address. */ reg = cpu_to_le32(0x00000000); snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST, - ff->spec->regs[SND_FF_REG_TYPE_MIDI_HIGH_ADDR], + ff->spec->midi_high_addr, ®, sizeof(reg), 0); fw_core_remove_address_handler(&ff->async_handler); diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c index f7a752930060..36575f4159d1 100644 --- a/sound/firewire/fireface/ff.c +++ b/sound/firewire/fireface/ff.c @@ -152,9 +152,7 @@ static const struct snd_ff_spec spec_ff800 = { .midi_in_ports = 1, .midi_out_ports = 1, .protocol = &snd_ff_protocol_ff800, - .regs = { - [SND_FF_REG_TYPE_MIDI_HIGH_ADDR] = 0x000200000320ull, - }, + .midi_high_addr = 0x000200000320ull, }; static const struct snd_ff_spec spec_ff400 = { @@ -164,9 +162,7 @@ static const struct snd_ff_spec spec_ff400 = { .midi_in_ports = 2, .midi_out_ports = 2, .protocol = &snd_ff_protocol_ff400, - .regs = { - [SND_FF_REG_TYPE_MIDI_HIGH_ADDR] = 0x0000801003f4ull, - }, + .midi_high_addr = 0x0000801003f4ull, }; static const struct ieee1394_device_id snd_ff_id_table[] = { diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 9fdda4fbdbba..7dfc7745a914 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -36,7 +36,7 @@ #define SND_FF_OUT_MIDI_PORTS 2 #define SND_FF_REG_SYNC_STATUS 0x0000801c0000ull -/* For block wriet request. */ +/* For block write request. */ #define SND_FF_REG_FETCH_PCM_FRAMES 0x0000801c0000ull #define SND_FF_REG_CLOCK_CONFIG 0x0000801c0004ull @@ -47,11 +47,6 @@ enum snd_ff_stream_mode { SND_FF_STREAM_MODE_COUNT, }; -enum snd_ff_reg_type { - SND_FF_REG_TYPE_MIDI_HIGH_ADDR = 0, - SND_FF_REG_TYPE_COUNT, -}; - struct snd_ff_protocol; struct snd_ff_spec { const char *const name; @@ -63,7 +58,7 @@ struct snd_ff_spec { unsigned int midi_out_ports; const struct snd_ff_protocol *protocol; - u64 regs[SND_FF_REG_TYPE_COUNT]; + u64 midi_high_addr; }; struct snd_ff {