All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX
@ 2020-05-10  7:42 Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency Takashi Sakamoto
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:42 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel

Hi,

Fireface 802 was shipped by RME GmbH in 2014. This model is one of latter
models of Fireface series and support both of IEEE 1394 bus and USB.
Furthermore, it supports two types of remote control unit (Basic
Remote and Advanced Remote Control) with by 9pin mini-din connector.

This patchset adds support for this model as a part of devices available
by ALSA firewire stack (therefore it's not a device of USB). Userspace
applications can transfer PCM frames and MIDI messages via ALSA PCM
and Rawmidi interfaces.

Fireface UFX is also supported since its internal design is almost the
same as Fireface 802 in a point of packet communication. The support is
untested and the status is 'request for test'.

As well as the other models of RME Fireface series, audio output
includes periodical hissing noise. This is not solved yet.

Furthermore, capture of MIDI messages requires assist of userspace
application. For the detail, please read comment in
'sound/firewire/fireface/ff-protocol-latter.c'.

Regards

Takashi Sakamoto (6):
  ALSA: fireface: fix configuration error for nominal sampling transfer
    frequency
  ALSA: fireface: start IR context immediately
  ALSA: fireface: code refactoring to add enumeration constants for
    model identification
  ALSA: fireface: code refactoring for name of sound card
  ALSA: fireface: add support for RME FireFace 802
  ALSA: fireface: add support for Fireface UFX (untested)

 sound/firewire/Kconfig                       |  2 +
 sound/firewire/fireface/ff-protocol-latter.c | 58 +++++++++++++------
 sound/firewire/fireface/ff-stream.c          | 10 +---
 sound/firewire/fireface/ff.c                 | 61 +++++++++++++++++---
 sound/firewire/fireface/ff.h                 | 11 +++-
 5 files changed, 103 insertions(+), 39 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
@ 2020-05-10  7:42 ` Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 2/6] ALSA: fireface: start IR context immediately Takashi Sakamoto
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:42 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel, stable

128000 and 192000 are congruence modulo 32000, thus it's wrong to
distinguish them as multiple of 32000 and 48000 by modulo 32000 at
first.

Additionally, used condition statement to detect quadruple speed can
cause missing bit flag.

Furthermore, counter to ensure the configuration is wrong and it
causes false positive.

This commit fixes the above three bugs.

Cc: <stable@vger.kernel.org>
Fixes: 60aec494b389 ("ALSA: fireface: support allocate_resources operation in latter protocol")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireface/ff-protocol-latter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c
index 0e4c3a9ed5e4..76ae568489ef 100644
--- a/sound/firewire/fireface/ff-protocol-latter.c
+++ b/sound/firewire/fireface/ff-protocol-latter.c
@@ -107,18 +107,18 @@ static int latter_allocate_resources(struct snd_ff *ff, unsigned int rate)
 	int err;
 
 	// Set the number of data blocks transferred in a second.
-	if (rate % 32000 == 0)
-		code = 0x00;
+	if (rate % 48000 == 0)
+		code = 0x04;
 	else if (rate % 44100 == 0)
 		code = 0x02;
-	else if (rate % 48000 == 0)
-		code = 0x04;
+	else if (rate % 32000 == 0)
+		code = 0x00;
 	else
 		return -EINVAL;
 
 	if (rate >= 64000 && rate < 128000)
 		code |= 0x08;
-	else if (rate >= 128000 && rate < 192000)
+	else if (rate >= 128000)
 		code |= 0x10;
 
 	reg = cpu_to_le32(code);
@@ -140,7 +140,7 @@ static int latter_allocate_resources(struct snd_ff *ff, unsigned int rate)
 		if (curr_rate == rate)
 			break;
 	}
-	if (count == 10)
+	if (count > 10)
 		return -ETIMEDOUT;
 
 	for (i = 0; i < ARRAY_SIZE(amdtp_rate_table); ++i) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/6] ALSA: fireface: start IR context immediately
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency Takashi Sakamoto
@ 2020-05-10  7:42 ` Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 3/6] ALSA: fireface: code refactoring to add enumeration constants for model identification Takashi Sakamoto
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:42 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel, stable

In the latter models of RME Fireface series, device start to transfer
packets several dozens of milliseconds. On the other hand, ALSA fireface
driver starts IR context 2 milliseconds after the start. This results
in loss to handle incoming packets on the context.

This commit changes to start IR context immediately instead of
postponement. For Fireface 800, this affects nothing because the device
transfer packets 100 milliseconds or so after the start and this is
within wait timeout.

Cc: <stable@vger.kernel.org>
Fixes: acfedcbe1ce4 ("ALSA: firewire-lib: postpone to start IR context")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireface/ff-stream.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c
index 63b79c4a5405..5452115c0ef9 100644
--- a/sound/firewire/fireface/ff-stream.c
+++ b/sound/firewire/fireface/ff-stream.c
@@ -184,7 +184,6 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
 	 */
 	if (!amdtp_stream_running(&ff->rx_stream)) {
 		int spd = fw_parent_device(ff->unit)->max_speed;
-		unsigned int ir_delay_cycle;
 
 		err = ff->spec->protocol->begin_session(ff, rate);
 		if (err < 0)
@@ -200,14 +199,7 @@ int snd_ff_stream_start_duplex(struct snd_ff *ff, unsigned int rate)
 		if (err < 0)
 			goto error;
 
-		// The device postpones start of transmission mostly for several
-		// cycles after receiving packets firstly.
-		if (ff->spec->protocol == &snd_ff_protocol_ff800)
-			ir_delay_cycle = 800;	// = 100 msec
-		else
-			ir_delay_cycle = 16;	// = 2 msec
-
-		err = amdtp_domain_start(&ff->domain, ir_delay_cycle);
+		err = amdtp_domain_start(&ff->domain, 0);
 		if (err < 0)
 			goto error;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/6] ALSA: fireface: code refactoring to add enumeration constants for model identification
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 2/6] ALSA: fireface: start IR context immediately Takashi Sakamoto
@ 2020-05-10  7:42 ` Takashi Sakamoto
  2020-05-10  7:42 ` [PATCH 4/6] ALSA: fireface: code refactoring to decide name of sound card Takashi Sakamoto
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:42 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel

In RME fireface series, version field of unit directory in configuration
ROM is used to distinguish each model. The value of field is known and
it's better to use enumeration constants for code representation.

This commit adds enumeration constants for model identification.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireface/ff.c | 6 +++---
 sound/firewire/fireface/ff.h | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index b62a4fd22407..b295e40a425d 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -189,7 +189,7 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 				  IEEE1394_MATCH_MODEL_ID,
 		.vendor_id	= OUI_RME,
 		.specifier_id	= OUI_RME,
-		.version	= 0x000001,
+		.version	= SND_FF_UNIT_VERSION_FF800,
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ff800,
 	},
@@ -201,7 +201,7 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 				  IEEE1394_MATCH_MODEL_ID,
 		.vendor_id	= OUI_RME,
 		.specifier_id	= OUI_RME,
-		.version	= 0x000002,
+		.version	= SND_FF_UNIT_VERSION_FF400,
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ff400,
 	},
@@ -213,7 +213,7 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 				  IEEE1394_MATCH_MODEL_ID,
 		.vendor_id	= OUI_RME,
 		.specifier_id	= OUI_RME,
-		.version	= 0x000004,
+		.version	= SND_FF_UNIT_VERSION_UCX,
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ucx,
 	},
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index dc7a20f75983..62ad921c3706 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -34,6 +34,12 @@
 #define SND_FF_IN_MIDI_PORTS		2
 #define SND_FF_OUT_MIDI_PORTS		2
 
+enum snd_ff_unit_version {
+	SND_FF_UNIT_VERSION_FF800	= 0x000001,
+	SND_FF_UNIT_VERSION_FF400	= 0x000002,
+	SND_FF_UNIT_VERSION_UCX		= 0x000004,
+};
+
 enum snd_ff_stream_mode {
 	SND_FF_STREAM_MODE_LOW = 0,
 	SND_FF_STREAM_MODE_MID,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/6] ALSA: fireface: code refactoring to decide name of sound card
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
                   ` (2 preceding siblings ...)
  2020-05-10  7:42 ` [PATCH 3/6] ALSA: fireface: code refactoring to add enumeration constants for model identification Takashi Sakamoto
@ 2020-05-10  7:42 ` Takashi Sakamoto
  2020-05-10  7:43 ` [PATCH 5/6] ALSA: fireface: add support for RME FireFace 802 Takashi Sakamoto
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:42 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel

This commit uses enumeration constants as index of table for the
list of name of sound card.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireface/ff.c | 18 ++++++++++++------
 sound/firewire/fireface/ff.h |  3 +--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index b295e40a425d..dd3cd25f2e3b 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -16,12 +16,20 @@ MODULE_LICENSE("GPL v2");
 static void name_card(struct snd_ff *ff)
 {
 	struct fw_device *fw_dev = fw_parent_device(ff->unit);
+	const char *const names[] = {
+		[SND_FF_UNIT_VERSION_FF800]	= "Fireface800",
+		[SND_FF_UNIT_VERSION_FF400]	= "Fireface400",
+		[SND_FF_UNIT_VERSION_UCX]	= "FirefaceUCX",
+	};
+	const char *name;
+
+	name = names[ff->unit_version];
 
 	strcpy(ff->card->driver, "Fireface");
-	strcpy(ff->card->shortname, ff->spec->name);
-	strcpy(ff->card->mixername, ff->spec->name);
+	strcpy(ff->card->shortname, name);
+	strcpy(ff->card->mixername, name);
 	snprintf(ff->card->longname, sizeof(ff->card->longname),
-		 "RME %s, GUID %08x%08x at %s, S%d", ff->spec->name,
+		 "RME %s, GUID %08x%08x at %s, S%d", name,
 		 fw_dev->config_rom[3], fw_dev->config_rom[4],
 		 dev_name(&ff->unit->device), 100 << fw_dev->max_speed);
 }
@@ -101,6 +109,7 @@ static int snd_ff_probe(struct fw_unit *unit,
 	spin_lock_init(&ff->lock);
 	init_waitqueue_head(&ff->hwdep_wait);
 
+	ff->unit_version = entry->version;
 	ff->spec = (const struct snd_ff_spec *)entry->driver_data;
 
 	/* Register this sound card later. */
@@ -145,7 +154,6 @@ 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,
@@ -157,7 +165,6 @@ static const struct snd_ff_spec spec_ff800 = {
 };
 
 static const struct snd_ff_spec spec_ff400 = {
-	.name = "Fireface400",
 	.pcm_capture_channels = {18, 14, 10},
 	.pcm_playback_channels = {18, 14, 10},
 	.midi_in_ports = 2,
@@ -169,7 +176,6 @@ static const struct snd_ff_spec spec_ff400 = {
 };
 
 static const struct snd_ff_spec spec_ucx = {
-	.name = "FirefaceUCX",
 	.pcm_capture_channels = {18, 14, 12},
 	.pcm_playback_channels = {18, 14, 12},
 	.midi_in_ports = 2,
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index 62ad921c3706..0c4fe7cff84d 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -49,8 +49,6 @@ enum snd_ff_stream_mode {
 
 struct snd_ff_protocol;
 struct snd_ff_spec {
-	const char *const name;
-
 	const unsigned int pcm_capture_channels[SND_FF_STREAM_MODE_COUNT];
 	const unsigned int pcm_playback_channels[SND_FF_STREAM_MODE_COUNT];
 
@@ -72,6 +70,7 @@ struct snd_ff {
 	bool registered;
 	struct delayed_work dwork;
 
+	enum snd_ff_unit_version unit_version;
 	const struct snd_ff_spec *spec;
 
 	/* To handle MIDI tx. */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/6] ALSA: fireface: add support for RME FireFace 802
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
                   ` (3 preceding siblings ...)
  2020-05-10  7:42 ` [PATCH 4/6] ALSA: fireface: code refactoring to decide name of sound card Takashi Sakamoto
@ 2020-05-10  7:43 ` Takashi Sakamoto
  2020-05-10  7:43 ` [PATCH 6/6] ALSA: fireface: add support for RME Fireface UFX (untested) Takashi Sakamoto
  2020-05-10 10:05 ` [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Iwai
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:43 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel

Fireface 802 was shipped by RME GmbH in 2014. This model supports later
protocol for management of isochronous communication and synchronization
of sampling transmission frequency.

This model consists of below ICs:
 * TI TSB41AB2
 * Xilinx Spartan-6 FPGA XC6SLX16
 * TI TMS320 C6747
 * SMSC USB3250

Especially, this model just supports IEEE 1394a, against its name which
evokes Fireface 800.

This commit adds support for Fireface 802 (tested). Userspace applications
can transfer PCM frames and MIDI messages via ALSA PCM/Rawmidi interface.
I note that 4 channels for ADAt1 and ADAT2 are disabled at higher sampling
transfer frequency since isochronous resources reservation fails due to
bandwidth limitation of IEEE 1394a.

The value read from LATTER_SYNC_STATUS register is slightly different
from the one of Fireface UCX. The higher 4 bits and lower 4 bits are
swapped within the same byte.

Without any assist of userspace application, transmitted MIDI messages
from the device are not going to be processed. For detail, please refer
to my comment in code of latter protocol.

$ python crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  0404ffff  bus_info_length 4, crc_length 4, crc 65535 (should be 26805)
404  31333934  bus_name "1394"
408  20008000  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 8 (512)
40c  000a3504  company_id 000a35     |
410  38077423  device_id 0438077423  | EUI-64 000a350438077423

               root directory
               -----------------------------------------------------------------
414  0005ffff  directory_length 5, crc 65535 (should be 9514)
418  0c0083c0  node capabilities per IEEE 1394
41c  03000a35  vendor
420  8100000b  --> descriptor leaf at 44c
424  8d000007  --> eui-64 leaf at 440
428  d1000001  --> unit directory at 42c

               unit directory at 42c
               -----------------------------------------------------------------
42c  0004ffff  directory_length 4, crc 65535 (should be 45134)
430  12000a35  specifier id
434  13000005  version
438  17101800  model
43c  81000008  --> descriptor leaf at 45c

               eui-64 leaf at 440
               -----------------------------------------------------------------
440  0002ffff  leaf_length 2, crc 65535 (should be 60131)
444  000a3504  company_id 000a35     |
448  38077423  device_id 0438077423  | EUI-64 000a350438077423

               descriptor leaf at 44c
               -----------------------------------------------------------------
44c  0003ffff  leaf_length 3, crc 65535 (should be 469)
450  00000000  textual descriptor
454  00000000  minimal ASCII
458  524d4521  "RME!"

               descriptor leaf at 45c
               -----------------------------------------------------------------
45c  0005ffff  leaf_length 5, crc 65535 (should be 10561)
460  00000000  textual descriptor
464  00000000  minimal ASCII
468  46697265  "Fire"
46c  66616365  "face"
470  20383032  " 802"

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/Kconfig                       |  1 +
 sound/firewire/fireface/ff-protocol-latter.c | 46 ++++++++++++++------
 sound/firewire/fireface/ff.c                 | 24 ++++++++++
 sound/firewire/fireface/ff.h                 |  1 +
 4 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index 995c2cefc222..4f39ef924a1a 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -165,5 +165,6 @@ config SND_FIREFACE
 	  * Fireface 400
 	  * Fireface 800
 	  * Fireface UCX
+	  * Fireface 802
 
 endif # SND_FIREWIRE
diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c
index 76ae568489ef..ea885e725950 100644
--- a/sound/firewire/fireface/ff-protocol-latter.c
+++ b/sound/firewire/fireface/ff-protocol-latter.c
@@ -16,7 +16,8 @@
 #define LATTER_SYNC_STATUS	0x0000801c0000ULL
 
 static int parse_clock_bits(u32 data, unsigned int *rate,
-			    enum snd_ff_clock_src *src)
+			    enum snd_ff_clock_src *src,
+			    enum snd_ff_unit_version unit_version)
 {
 	static const struct {
 		unsigned int rate;
@@ -43,6 +44,11 @@ static int parse_clock_bits(u32 data, unsigned int *rate,
 	};
 	int i;
 
+	if (unit_version != SND_FF_UNIT_VERSION_UCX) {
+		// e.g. 0x00fe0f20 but expected 0x00eff002.
+		data = ((data & 0xf0f0f0f0) >> 4) | ((data & 0x0f0f0f0f) << 4);
+	}
+
 	for (i = 0; i < ARRAY_SIZE(rate_entries); ++i) {
 		rate_entry = rate_entries + i;
 		if ((data & 0x0f000000) == rate_entry->flag) {
@@ -79,7 +85,7 @@ static int latter_get_clock(struct snd_ff *ff, unsigned int *rate,
 		return err;
 	data = le32_to_cpu(reg);
 
-	return parse_clock_bits(data, rate, src);
+	return parse_clock_bits(data, rate, src, ff->unit_version);
 }
 
 static int latter_switch_fetching_mode(struct snd_ff *ff, bool enable)
@@ -181,14 +187,30 @@ static int latter_begin_session(struct snd_ff *ff, unsigned int rate)
 	__le32 reg;
 	int err;
 
-	if (rate >= 32000 && rate <= 48000)
-		flag = 0x92;
-	else if (rate >= 64000 && rate <= 96000)
-		flag = 0x8e;
-	else if (rate >= 128000 && rate <= 192000)
-		flag = 0x8c;
-	else
-		return -EINVAL;
+	if (ff->unit_version == SND_FF_UNIT_VERSION_UCX) {
+		// For Fireface UCX. Always use the maximum number of data
+		// channels in data block of packet.
+		if (rate >= 32000 && rate <= 48000)
+			flag = 0x92;
+		else if (rate >= 64000 && rate <= 96000)
+			flag = 0x8e;
+		else if (rate >= 128000 && rate <= 192000)
+			flag = 0x8c;
+		else
+			return -EINVAL;
+	} else {
+		// For Fireface 802. Due to bandwidth limitation on
+		// IEEE 1394a (400 Mbps), Analog 1-12 and AES are available
+		// without any ADAT at quadruple speed.
+		if (rate >= 32000 && rate <= 48000)
+			flag = 0x9e;
+		else if (rate >= 64000 && rate <= 96000)
+			flag = 0x96;
+		else if (rate >= 128000 && rate <= 192000)
+			flag = 0x8e;
+		else
+			return -EINVAL;
+	}
 
 	if (generation != fw_parent_device(ff->unit)->card->generation) {
 		err = fw_iso_resources_update(&ff->tx_resources);
@@ -207,8 +229,6 @@ static int latter_begin_session(struct snd_ff *ff, unsigned int rate)
 	if (err < 0)
 		return err;
 
-	// Always use the maximum number of data channels in data block of
-	// packet.
 	reg = cpu_to_le32(flag);
 	return snd_fw_transaction(ff->unit, TCODE_WRITE_QUADLET_REQUEST,
 				  LATTER_ISOC_START, &reg, sizeof(reg), 0);
@@ -263,7 +283,7 @@ static void latter_dump_status(struct snd_ff *ff, struct snd_info_buffer *buffer
 		}
 	}
 
-	err = parse_clock_bits(data, &rate, &src);
+	err = parse_clock_bits(data, &rate, &src, ff->unit_version);
 	if (err < 0)
 		return;
 	label = snd_ff_proc_get_clk_label(src);
diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index dd3cd25f2e3b..e4140116f3cc 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -20,6 +20,7 @@ static void name_card(struct snd_ff *ff)
 		[SND_FF_UNIT_VERSION_FF800]	= "Fireface800",
 		[SND_FF_UNIT_VERSION_FF400]	= "Fireface400",
 		[SND_FF_UNIT_VERSION_UCX]	= "FirefaceUCX",
+		[SND_FF_UNIT_VERSION_802]	= "Fireface802",
 	};
 	const char *name;
 
@@ -186,6 +187,17 @@ static const struct snd_ff_spec spec_ucx = {
 	.midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
 };
 
+static const struct snd_ff_spec spec_802 = {
+	.pcm_capture_channels = {30, 22, 14},
+	.pcm_playback_channels = {30, 22, 14},
+	.midi_in_ports = 1,
+	.midi_out_ports = 1,
+	.protocol = &snd_ff_protocol_latter,
+	.midi_high_addr = 0xffff00000034ull,
+	.midi_addr_range = 0x80,
+	.midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
+};
+
 static const struct ieee1394_device_id snd_ff_id_table[] = {
 	/* Fireface 800 */
 	{
@@ -223,6 +235,18 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ucx,
 	},
+	// Fireface 802.
+	{
+		.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	= SND_FF_UNIT_VERSION_802,
+		.model_id	= 0x101800,
+		.driver_data	= (kernel_ulong_t)&spec_802,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(ieee1394, snd_ff_id_table);
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index 0c4fe7cff84d..1282a57c009f 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -38,6 +38,7 @@ enum snd_ff_unit_version {
 	SND_FF_UNIT_VERSION_FF800	= 0x000001,
 	SND_FF_UNIT_VERSION_FF400	= 0x000002,
 	SND_FF_UNIT_VERSION_UCX		= 0x000004,
+	SND_FF_UNIT_VERSION_802		= 0x000005,
 };
 
 enum snd_ff_stream_mode {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/6] ALSA: fireface: add support for RME Fireface UFX (untested)
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
                   ` (4 preceding siblings ...)
  2020-05-10  7:43 ` [PATCH 5/6] ALSA: fireface: add support for RME FireFace 802 Takashi Sakamoto
@ 2020-05-10  7:43 ` Takashi Sakamoto
  2020-05-10 10:05 ` [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Iwai
  6 siblings, 0 replies; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10  7:43 UTC (permalink / raw)
  To: clemens, tiwai; +Cc: alsa-devel, ffado-devel

Fireface UFX was shipped by RME GmbH in 2010, and now discontinued.
Although this model has some enhanced feature which Fireface 802
doesn't have (e.g. on-board USB mass storage device class, configuration
interface with color display), the functionality relevant to
packet communication on IEEE 1394 bus seems to be the same as
Fireface 802 (e.g. available number of channels for PCM frame in
each sampling transfer frequency).

With the assumption, this commit adds support for Fireface UFX. In ALSA
fireface driver, these two models are handled as the same one.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/Kconfig                       |  1 +
 sound/firewire/fireface/ff-protocol-latter.c |  2 +-
 sound/firewire/fireface/ff.c                 | 17 +++++++++++++++--
 sound/firewire/fireface/ff.h                 |  1 +
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index 4f39ef924a1a..f7ed69d60310 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -164,6 +164,7 @@ config SND_FIREFACE
 	 Say Y here to include support for RME fireface series.
 	  * Fireface 400
 	  * Fireface 800
+	  * Fireface UFX
 	  * Fireface UCX
 	  * Fireface 802
 
diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c
index ea885e725950..8d3b23778eb2 100644
--- a/sound/firewire/fireface/ff-protocol-latter.c
+++ b/sound/firewire/fireface/ff-protocol-latter.c
@@ -199,7 +199,7 @@ static int latter_begin_session(struct snd_ff *ff, unsigned int rate)
 		else
 			return -EINVAL;
 	} else {
-		// For Fireface 802. Due to bandwidth limitation on
+		// For Fireface UFX and 802. Due to bandwidth limitation on
 		// IEEE 1394a (400 Mbps), Analog 1-12 and AES are available
 		// without any ADAT at quadruple speed.
 		if (rate >= 32000 && rate <= 48000)
diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c
index e4140116f3cc..bc39269415d2 100644
--- a/sound/firewire/fireface/ff.c
+++ b/sound/firewire/fireface/ff.c
@@ -19,6 +19,7 @@ static void name_card(struct snd_ff *ff)
 	const char *const names[] = {
 		[SND_FF_UNIT_VERSION_FF800]	= "Fireface800",
 		[SND_FF_UNIT_VERSION_FF400]	= "Fireface400",
+		[SND_FF_UNIT_VERSION_UFX]	= "FirefaceUFX",
 		[SND_FF_UNIT_VERSION_UCX]	= "FirefaceUCX",
 		[SND_FF_UNIT_VERSION_802]	= "Fireface802",
 	};
@@ -187,7 +188,7 @@ static const struct snd_ff_spec spec_ucx = {
 	.midi_rx_addrs = {0xffff00000030ull, 0xffff00000030ull},
 };
 
-static const struct snd_ff_spec spec_802 = {
+static const struct snd_ff_spec spec_ufx_802 = {
 	.pcm_capture_channels = {30, 22, 14},
 	.pcm_playback_channels = {30, 22, 14},
 	.midi_in_ports = 1,
@@ -223,6 +224,18 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 		.model_id	= 0x101800,
 		.driver_data	= (kernel_ulong_t)&spec_ff400,
 	},
+	// Fireface UFX.
+	{
+		.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	= SND_FF_UNIT_VERSION_UFX,
+		.model_id	= 0x101800,
+		.driver_data	= (kernel_ulong_t)&spec_ufx_802,
+	},
 	// Fireface UCX.
 	{
 		.match_flags	= IEEE1394_MATCH_VENDOR_ID |
@@ -245,7 +258,7 @@ static const struct ieee1394_device_id snd_ff_id_table[] = {
 		.specifier_id	= OUI_RME,
 		.version	= SND_FF_UNIT_VERSION_802,
 		.model_id	= 0x101800,
-		.driver_data	= (kernel_ulong_t)&spec_802,
+		.driver_data	= (kernel_ulong_t)&spec_ufx_802,
 	},
 	{}
 };
diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h
index 1282a57c009f..705e7df4f929 100644
--- a/sound/firewire/fireface/ff.h
+++ b/sound/firewire/fireface/ff.h
@@ -37,6 +37,7 @@
 enum snd_ff_unit_version {
 	SND_FF_UNIT_VERSION_FF800	= 0x000001,
 	SND_FF_UNIT_VERSION_FF400	= 0x000002,
+	SND_FF_UNIT_VERSION_UFX		= 0x000003,
 	SND_FF_UNIT_VERSION_UCX		= 0x000004,
 	SND_FF_UNIT_VERSION_802		= 0x000005,
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX
  2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
                   ` (5 preceding siblings ...)
  2020-05-10  7:43 ` [PATCH 6/6] ALSA: fireface: add support for RME Fireface UFX (untested) Takashi Sakamoto
@ 2020-05-10 10:05 ` Takashi Iwai
  2020-05-10 10:17   ` Takashi Sakamoto
  6 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2020-05-10 10:05 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: ffado-devel, alsa-devel, clemens

On Sun, 10 May 2020 09:42:55 +0200,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> Fireface 802 was shipped by RME GmbH in 2014. This model is one of latter
> models of Fireface series and support both of IEEE 1394 bus and USB.
> Furthermore, it supports two types of remote control unit (Basic
> Remote and Advanced Remote Control) with by 9pin mini-din connector.
> 
> This patchset adds support for this model as a part of devices available
> by ALSA firewire stack (therefore it's not a device of USB). Userspace
> applications can transfer PCM frames and MIDI messages via ALSA PCM
> and Rawmidi interfaces.
> 
> Fireface UFX is also supported since its internal design is almost the
> same as Fireface 802 in a point of packet communication. The support is
> untested and the status is 'request for test'.
> 
> As well as the other models of RME Fireface series, audio output
> includes periodical hissing noise. This is not solved yet.
> 
> Furthermore, capture of MIDI messages requires assist of userspace
> application. For the detail, please read comment in
> 'sound/firewire/fireface/ff-protocol-latter.c'.
> 
> Regards
> 
> Takashi Sakamoto (6):
>   ALSA: fireface: fix configuration error for nominal sampling transfer
>     frequency
>   ALSA: fireface: start IR context immediately
>   ALSA: fireface: code refactoring to add enumeration constants for
>     model identification
>   ALSA: fireface: code refactoring for name of sound card
>   ALSA: fireface: add support for RME FireFace 802
>   ALSA: fireface: add support for Fireface UFX (untested)

Would you like me merging the patches although at least one of them is
marked untested?  The code changes look reasonable, so I have no
problem to applying patches themselves to 5.8 branch.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX
  2020-05-10 10:05 ` [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Iwai
@ 2020-05-10 10:17   ` Takashi Sakamoto
  2020-05-10 17:28     ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Sakamoto @ 2020-05-10 10:17 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: ffado-devel, alsa-devel, clemens

Hi,

On Sun, May 10, 2020 at 12:05:58PM +0200, Takashi Iwai wrote:
> On Sun, 10 May 2020 09:42:55 +0200,
> Takashi Sakamoto wrote:
> > 
> > Hi,
> > 
> > Fireface 802 was shipped by RME GmbH in 2014. This model is one of latter
> > models of Fireface series and support both of IEEE 1394 bus and USB.
> > Furthermore, it supports two types of remote control unit (Basic
> > Remote and Advanced Remote Control) with by 9pin mini-din connector.
> > 
> > This patchset adds support for this model as a part of devices available
> > by ALSA firewire stack (therefore it's not a device of USB). Userspace
> > applications can transfer PCM frames and MIDI messages via ALSA PCM
> > and Rawmidi interfaces.
> > 
> > Fireface UFX is also supported since its internal design is almost the
> > same as Fireface 802 in a point of packet communication. The support is
> > untested and the status is 'request for test'.
> > 
> > As well as the other models of RME Fireface series, audio output
> > includes periodical hissing noise. This is not solved yet.
> > 
> > Furthermore, capture of MIDI messages requires assist of userspace
> > application. For the detail, please read comment in
> > 'sound/firewire/fireface/ff-protocol-latter.c'.
> > 
> > Regards
> > 
> > Takashi Sakamoto (6):
> >   ALSA: fireface: fix configuration error for nominal sampling transfer
> >     frequency
> >   ALSA: fireface: start IR context immediately
> >   ALSA: fireface: code refactoring to add enumeration constants for
> >     model identification
> >   ALSA: fireface: code refactoring for name of sound card
> >   ALSA: fireface: add support for RME FireFace 802
> >   ALSA: fireface: add support for Fireface UFX (untested)
> 
> Would you like me merging the patches although at least one of them is
> marked untested?  The code changes look reasonable, so I have no
> problem to applying patches themselves to 5.8 branch.

I'd like you to apply them.

For development I have a theory that untested code should not be merged
(yep, as much as possible). However, in the case, I judged that the
untested code might work or slightly work since there seems to be few
differences between 802 and UFX in a view of vendor-dependent protocol
relevant to packet streaming.

(I guess that the only difference is the return value of LATTER_SYNC_STATUS
register; bit-swap case or not.) 

Even if it doesn't work well, it's convenient to me to leave a chance to
get any feedback from the users.


Thanks

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX
  2020-05-10 10:17   ` Takashi Sakamoto
@ 2020-05-10 17:28     ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2020-05-10 17:28 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: ffado-devel, alsa-devel, clemens

On Sun, 10 May 2020 12:17:41 +0200,
Takashi Sakamoto wrote:
> 
> Hi,
> 
> On Sun, May 10, 2020 at 12:05:58PM +0200, Takashi Iwai wrote:
> > On Sun, 10 May 2020 09:42:55 +0200,
> > Takashi Sakamoto wrote:
> > > 
> > > Hi,
> > > 
> > > Fireface 802 was shipped by RME GmbH in 2014. This model is one of latter
> > > models of Fireface series and support both of IEEE 1394 bus and USB.
> > > Furthermore, it supports two types of remote control unit (Basic
> > > Remote and Advanced Remote Control) with by 9pin mini-din connector.
> > > 
> > > This patchset adds support for this model as a part of devices available
> > > by ALSA firewire stack (therefore it's not a device of USB). Userspace
> > > applications can transfer PCM frames and MIDI messages via ALSA PCM
> > > and Rawmidi interfaces.
> > > 
> > > Fireface UFX is also supported since its internal design is almost the
> > > same as Fireface 802 in a point of packet communication. The support is
> > > untested and the status is 'request for test'.
> > > 
> > > As well as the other models of RME Fireface series, audio output
> > > includes periodical hissing noise. This is not solved yet.
> > > 
> > > Furthermore, capture of MIDI messages requires assist of userspace
> > > application. For the detail, please read comment in
> > > 'sound/firewire/fireface/ff-protocol-latter.c'.
> > > 
> > > Regards
> > > 
> > > Takashi Sakamoto (6):
> > >   ALSA: fireface: fix configuration error for nominal sampling transfer
> > >     frequency
> > >   ALSA: fireface: start IR context immediately
> > >   ALSA: fireface: code refactoring to add enumeration constants for
> > >     model identification
> > >   ALSA: fireface: code refactoring for name of sound card
> > >   ALSA: fireface: add support for RME FireFace 802
> > >   ALSA: fireface: add support for Fireface UFX (untested)
> > 
> > Would you like me merging the patches although at least one of them is
> > marked untested?  The code changes look reasonable, so I have no
> > problem to applying patches themselves to 5.8 branch.
> 
> I'd like you to apply them.
> 
> For development I have a theory that untested code should not be merged
> (yep, as much as possible). However, in the case, I judged that the
> untested code might work or slightly work since there seems to be few
> differences between 802 and UFX in a view of vendor-dependent protocol
> relevant to packet streaming.
> 
> (I guess that the only difference is the return value of LATTER_SYNC_STATUS
> register; bit-swap case or not.) 
> 
> Even if it doesn't work well, it's convenient to me to leave a chance to
> get any feedback from the users.

OK, now applied all six patches.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-05-10 17:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10  7:42 [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 1/6] ALSA: fireface: fix configuration error for nominal sampling transfer frequency Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 2/6] ALSA: fireface: start IR context immediately Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 3/6] ALSA: fireface: code refactoring to add enumeration constants for model identification Takashi Sakamoto
2020-05-10  7:42 ` [PATCH 4/6] ALSA: fireface: code refactoring to decide name of sound card Takashi Sakamoto
2020-05-10  7:43 ` [PATCH 5/6] ALSA: fireface: add support for RME FireFace 802 Takashi Sakamoto
2020-05-10  7:43 ` [PATCH 6/6] ALSA: fireface: add support for RME Fireface UFX (untested) Takashi Sakamoto
2020-05-10 10:05 ` [PATCH 0/6] ALSA: fireface: add support for Fireface 802 and UFX Takashi Iwai
2020-05-10 10:17   ` Takashi Sakamoto
2020-05-10 17:28     ` Takashi Iwai

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.