Blob Blame History Raw
From 791a485f2da392df00341ed4c0c14780fd320d92 Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date: Mon, 13 Jan 2020 17:46:30 +0900
Subject: [PATCH] ALSA: dice: add support for Alesis MasterControl
Git-commit: 791a485f2da392df00341ed4c0c14780fd320d92
Patch-mainline: v5.6-rc1
References: jsc#SLE-16518

Alesis MasterControl was shipped 2009 and already discontinued. This model
consists of:
 * TSB41AB2 for physical layer of IEEE 1394
 * WaveFront Dice II STD for link layer and protocol implementation
 * FreeScale DSPB56374AE

Although the firmware of this model can respond against read transaction
to address space for TCAT extension protocol, the content is not valid
for protocol extension. This results in sound card without any PCM/MIDI
interfaces.

$ ./firewire-request /dev/fw1 read 0xffffe0200000 0x48
Result: 000: 00 00 00 20 00 00 04 94 00 00 04 b4 00 00 00 b4
Result: 010: 00 00 05 68 00 00 00 24 00 00 05 8c 00 00 00 48
Result: 020: 00 00 00 20 00 00 00 08 00 00 00 20 00 00 00 20
Result: 030: 00 00 00 10 00 00 00 08 00 00 00 08 00 00 00 04
Result: 040: 00 00 00 00 00 00 00 00

This commit adds support the model by adding hard-coded stream formats.

$ python3 ~/git/linux-firewire-utils/src/crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  04041ad7  bus_info_length 4, crc_length 4, crc 6871
404  31333934  bus_name "1394"
408  e0ff8112  irmc 1, cmc 1, isc 1, bmc 0, pmc 0, cyc_clk_acc 255,
               max_rec 8 (512), max_rom 1, gen 1, spd 2 (S400)
40c  00059504  company_id 000595     | Alesis Corporation
410  008003f5  device_id 04008003f5  | EUI-64 00059504008003f5

               root directory
               -----------------------------------------------------------------
414  0006a620  directory_length 6, crc 42528
418  03000595  vendor: Alesis Corporation
41c  8100000a  --> descriptor leaf at 444
420  17000002  model
424  8100000d  --> descriptor leaf at 458
428  0c0087c0  node capabilities per IEEE 1394
42c  d1000001  --> unit directory at 430

               unit directory at 430
               -----------------------------------------------------------------
430  00041b9f  directory_length 4, crc 7071
434  12000595  specifier id: Alesis Corporation
438  13000001  version: audio
43c  17000002  model
440  8100000d  --> descriptor leaf at 474

               descriptor leaf at 444
               -----------------------------------------------------------------
444  000494c2  leaf_length 4, crc 38082
448  00000000  textual descriptor
44c  00000000  minimal ASCII
450  416c6573  "Ales"
454  69730000  "is"

               descriptor leaf at 458
               -----------------------------------------------------------------
458  0006c2ec  leaf_length 6, crc 49900
45c  00000000  textual descriptor
460  00000000  minimal ASCII
464  4d617374  "Mast"
468  6572436f  "erCo"
46c  6e74726f  "ntro"
470  6c000000  "l"

               descriptor leaf at 474
               -----------------------------------------------------------------
474  0006c2ec  leaf_length 6, crc 49900
478  00000000  textual descriptor
47c  00000000  minimal ASCII
480  4d617374  "Mast"
484  6572436f  "erCo"
488  6e74726f  "ntro"
48c  6c000000  "l"

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200113084630.14305-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>

---
 sound/firewire/dice/dice-alesis.c | 24 ++++++++++++++++++++++++
 sound/firewire/dice/dice.c        |  8 ++++++++
 sound/firewire/dice/dice.h        |  1 +
 3 files changed, 33 insertions(+)

diff --git a/sound/firewire/dice/dice-alesis.c b/sound/firewire/dice/dice-alesis.c
index f5b325263b67..0916864511d5 100644
--- a/sound/firewire/dice/dice-alesis.c
+++ b/sound/firewire/dice/dice-alesis.c
@@ -50,3 +50,27 @@ int snd_dice_detect_alesis_formats(struct snd_dice *dice)
 
 	return 0;
 }
+
+int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice)
+{
+	int i;
+
+	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_LOW]	= 16;
+	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_LOW]	= 12;
+	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_MIDDLE]	= 12;
+	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_MIDDLE]	= 4;
+	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_HIGH]	= 8;
+	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_HIGH]	= 0;
+
+	for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i) {
+		dice->rx_pcm_chs[0][i] = 6;
+		dice->rx_pcm_chs[1][i] = 0;
+	}
+
+	for (i = 0; i < MAX_STREAMS; ++i) {
+		dice->tx_midi_ports[i] = 2;
+		dice->rx_midi_ports[i] = 2;
+	}
+
+	return 0;
+}
diff --git a/sound/firewire/dice/dice.c b/sound/firewire/dice/dice.c
index 13eeb3f52bb6..06c94f009dfb 100644
--- a/sound/firewire/dice/dice.c
+++ b/sound/firewire/dice/dice.c
@@ -355,6 +355,14 @@ static const struct ieee1394_device_id dice_id_table[] = {
 		.model_id	= MODEL_ALESIS_IO_BOTH,
 		.driver_data = (kernel_ulong_t)snd_dice_detect_alesis_formats,
 	},
+	// Alesis MasterControl.
+	{
+		.match_flags	= IEEE1394_MATCH_VENDOR_ID |
+				  IEEE1394_MATCH_MODEL_ID,
+		.vendor_id	= OUI_ALESIS,
+		.model_id	= 0x000002,
+		.driver_data = (kernel_ulong_t)snd_dice_detect_alesis_mastercontrol_formats,
+	},
 	/* Mytek Stereo 192 DSD-DAC. */
 	{
 		.match_flags	= IEEE1394_MATCH_VENDOR_ID |
diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h
index 16366773e22e..7fbffcab94c2 100644
--- a/sound/firewire/dice/dice.h
+++ b/sound/firewire/dice/dice.h
@@ -229,6 +229,7 @@ int snd_dice_create_midi(struct snd_dice *dice);
 
 int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice);
 int snd_dice_detect_alesis_formats(struct snd_dice *dice);
+int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice);
 int snd_dice_detect_extension_formats(struct snd_dice *dice);
 int snd_dice_detect_mytek_formats(struct snd_dice *dice);
 int snd_dice_detect_presonus_formats(struct snd_dice *dice);
-- 
2.16.4