All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net
Subject: [PATCH 8/8] ALSA: fireface: add support for Fireface 800 with MIDI functionality only
Date: Tue, 11 Dec 2018 19:17:35 +0900	[thread overview]
Message-ID: <20181211101735.13735-9-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20181211101735.13735-1-o-takashi@sakamocchi.jp>

Fireface 800 is a flagship model of RME GmbH for audio and music units
on IEEE 1394 bus, shipped 2004. This model consists of four chips:
 - TI TSB81BA3D for physical layer on cable environment of EEE 1394 bus
 - TI TSB82AA2 for link layer for 1394 OHCI bus bridge to PCI bus
 - Xilinx Spartan-3 FPGA XC3S400
 - Xilinx High-Performance CPLD XC9572XL

This commit adds support Fireface 800. In this time, the support is
restricted to its MIDI functionality, thus this commit adds some
condition statements to avoid touching streaming functionality.

Unlike Fireface 400, Fireface 800 has no functionality to suppress
asynchronous transactions for MIDI messages except for unregister of
listen address in controller side, thus the feature is available as is.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/Kconfig                      |  1 +
 sound/firewire/fireface/Makefile            |  3 +-
 sound/firewire/fireface/ff-protocol-ff800.c | 27 +++++++++++
 sound/firewire/fireface/ff.c                | 51 ++++++++++++++++-----
 sound/firewire/fireface/ff.h                |  1 +
 5 files changed, 70 insertions(+), 13 deletions(-)
 create mode 100644 sound/firewire/fireface/ff-protocol-ff800.c

diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index 44cedb65bb88..052e00590259 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -162,5 +162,6 @@ config SND_FIREFACE
 	help
 	 Say Y here to include support for RME fireface series.
 	  * Fireface 400
+	  * Fireface 800
 
 endif # SND_FIREWIRE
diff --git a/sound/firewire/fireface/Makefile b/sound/firewire/fireface/Makefile
index 8f807284ba54..79a7d6d99d72 100644
--- a/sound/firewire/fireface/Makefile
+++ b/sound/firewire/fireface/Makefile
@@ -1,3 +1,4 @@
 snd-fireface-objs := ff.o ff-transaction.o ff-midi.o ff-proc.o amdtp-ff.o \
-		     ff-stream.o ff-pcm.o ff-hwdep.o ff-protocol-ff400.o
+		     ff-stream.o ff-pcm.o ff-hwdep.o ff-protocol-ff400.o \
+		     ff-protocol-ff800.o
 obj-$(CONFIG_SND_FIREFACE) += snd-fireface.o
diff --git a/sound/firewire/fireface/ff-protocol-ff800.c b/sound/firewire/fireface/ff-protocol-ff800.c
new file mode 100644
index 000000000000..d24439734304
--- /dev/null
+++ b/sound/firewire/fireface/ff-protocol-ff800.c
@@ -0,0 +1,27 @@
+/*
+ * ff-protocol-ff800.c - a part of driver for RME Fireface series
+ *
+ * Copyright (c) 2018 Takashi Sakamoto
+ *
+ * Licensed under the terms of the GNU General Public License, version 2.
+ */
+
+#include "ff.h"
+
+static void ff800_handle_midi_msg(struct snd_ff *ff, __le32 *buf, size_t length)
+{
+	int i;
+
+	for (i = 0; i < length / 4; i++) {
+		u8 byte = le32_to_cpu(buf[i]) & 0xff;
+		struct snd_rawmidi_substream *substream;
+
+		substream = READ_ONCE(ff->tx_midi_substreams[0]);
+		if (substream)
+			snd_rawmidi_receive(substream, &byte, 1);
+	}
+}
+
+const struct snd_ff_protocol snd_ff_protocol_ff800 = {
+	.handle_midi_msg	= ff800_handle_midi_msg,
+};
diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index 2ce5e115b0eb..d486984c0e5b 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -31,7 +31,8 @@ static void ff_card_free(struct snd_card *card)
 {
 	struct snd_ff *ff = card->private_data;
 
-	snd_ff_stream_destroy_duplex(ff);
+	if (ff->spec->protocol->begin_session)
+		snd_ff_stream_destroy_duplex(ff);
 	snd_ff_transaction_unregister(ff);
 }
 
@@ -56,9 +57,11 @@ static void do_registration(struct work_struct *work)
 
 	name_card(ff);
 
-	err = snd_ff_stream_init_duplex(ff);
-	if (err < 0)
-		goto error;
+	if (ff->spec->protocol->begin_session) {
+		err = snd_ff_stream_init_duplex(ff);
+		if (err < 0)
+			goto error;
+	}
 
 	snd_ff_proc_init(ff);
 
@@ -66,13 +69,15 @@ static void do_registration(struct work_struct *work)
 	if (err < 0)
 		goto error;
 
-	err = snd_ff_create_pcm_devices(ff);
-	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_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)
@@ -121,7 +126,7 @@ static void snd_ff_update(struct fw_unit *unit)
 
 	snd_ff_transaction_reregister(ff);
 
-	if (ff->registered)
+	if (ff->registered && ff->spec->protocol->begin_session)
 		snd_ff_stream_update_duplex(ff);
 }
 
@@ -145,6 +150,16 @@ static void snd_ff_remove(struct fw_unit *unit)
 	fw_unit_put(ff->unit);
 }
 
+static const struct snd_ff_spec spec_ff800 = {
+	.name = "Fireface800",
+	.midi_in_ports = 1,
+	.midi_out_ports = 1,
+	.protocol = &snd_ff_protocol_ff800,
+	.regs = {
+		[SND_FF_REG_TYPE_MIDI_HIGH_ADDR] = 0x000200000320ull,
+	},
+};
+
 static const struct snd_ff_spec spec_ff400 = {
 	.name = "Fireface400",
 	.pcm_capture_channels = {18, 14, 10},
@@ -158,6 +173,18 @@ static const struct snd_ff_spec spec_ff400 = {
 };
 
 static const struct ieee1394_device_id snd_ff_id_table[] = {
+	/* Fireface 800 */
+	{
+		.match_flags	= IEEE1394_MATCH_VENDOR_ID |
+				  IEEE1394_MATCH_SPECIFIER_ID |
+				  IEEE1394_MATCH_VERSION |
+				  IEEE1394_MATCH_MODEL_ID,
+		.vendor_id	= OUI_RME,
+		.specifier_id	= OUI_RME,
+		.version	= 0x000001,
+		.model_id	= 0x101800,
+		.driver_data	= (kernel_ulong_t)&spec_ff800,
+	},
 	/* Fireface 400 */
 	{
 		.match_flags	= IEEE1394_MATCH_VENDOR_ID |
@@ -165,7 +192,7 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 				  IEEE1394_MATCH_VERSION |
 				  IEEE1394_MATCH_MODEL_ID,
 		.vendor_id	= OUI_RME,
-		.specifier_id	= 0x000a35,
+		.specifier_id	= OUI_RME,
 		.version	= 0x000002,
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ff400,
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index 178a96cb6e2a..6e4a8197d3ca 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -114,6 +114,7 @@ struct snd_ff_protocol {
 	int (*switch_fetching_mode)(struct snd_ff *ff, bool enable);
 };
 
+extern const struct snd_ff_protocol snd_ff_protocol_ff800;
 extern const struct snd_ff_protocol snd_ff_protocol_ff400;
 
 int snd_ff_transaction_get_clock(struct snd_ff *ff, unsigned int *rate,
-- 
2.19.1

  parent reply	other threads:[~2018-12-11 10:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 10:17 [PATCH 0/8] ALSA: fireface: add support for Fireface 800 with MIDI functionality only Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 1/8] ALSA: fireface: share some registers for status of clock synchronization Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 2/8] ALSA: fireface: share status and configuration dump Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 3/8] ALSA: fireface: share helper function to get current sampling rate and clock source Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 4/8] ALSA: fireface: add support for second optical interface for ADAT stream Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 5/8] ALSA: fireface: share register for async transaction of MIDI messages Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 6/8] ALSA: fireface: add driver data for register for MIDI high address Takashi Sakamoto
2018-12-11 10:17 ` [PATCH 7/8] ALSA: fireface: localize a handler for MIDI messages on tx transaction Takashi Sakamoto
2018-12-11 10:17 ` Takashi Sakamoto [this message]
2018-12-11 13:59 ` [PATCH 0/8] ALSA: fireface: add support for Fireface 800 with MIDI functionality only Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181211101735.13735-9-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sourceforge.net \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.