Skip to content

Commit b431f16

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-motu: add support for MOTU 896
MOTU 896 is a second model in MOTU FireWire series, produced in 2001. This model consists of three chips: * Texas Instruments TSB41AB2 (Physical layer for IEEE 1394 bus) * Philips Semiconductors PDI 1394L21BE (Link layer for IEEE 1394 bus and packet processing layer) * QuickLogic QuickRAM QL4016 (Data block processing layer and digital signal processing) This commit adds a support for the model, with its unique protocol as version 1. The features of this protocol are: * no MIDI support. * Rx packets have no data chunks for control and status messages. * Tx packets have 2 bytes for control and status messages in the end of each data block. * The most of settings are represented in bit flag in one quadlet address (0x'ffff'f000'0b14). * It's selectable to use signal on optical interface, however the device has no register specific to it. The state has effect just to whether to exclude differed data chunks. * The internal multiplexer is not configured by software. Just after powering on, the device has a quirk to fail handling transaction. I recommend users to connect the device enough after powering on. $ python3 crpp < /sys/bus/firewire/devices/fw1/config_rom ROM header and bus information block ----------------------------------------------------------------- 400 04102814 bus_info_length 4, crc_length 16, crc 10260 404 31333934 bus_name "1394" 408 20001000 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 1 (4) 40c 0001f200 company_id 0001f2 | 410 0000d645 device_id 000000d645 | EUI-64 0001f2000000d645 root directory ----------------------------------------------------------------- 414 0004c65c directory_length 4, crc 50780 418 030001f2 vendor 41c 0c0083c0 node capabilities per IEEE 1394 420 8d000006 --> eui-64 leaf at 438 424 d1000001 --> unit directory at 428 unit directory at 428 ----------------------------------------------------------------- 428 0003ab34 directory_length 3, crc 43828 42c 120001f2 specifier id 430 13000002 version 434 17102801 model eui-64 leaf at 438 ----------------------------------------------------------------- 438 0002057d leaf_length 2, crc 1405 43c 0001f200 company_id 0001f2 | 440 0000d645 device_id 000000d645 | EUI-64 0001f2000000d645 Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d13d6b2 commit b431f16

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed

sound/firewire/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ config SND_FIREWIRE_MOTU
166166
help
167167
Say Y here to enable support for FireWire devices which MOTU produced:
168168
* 828
169+
* 896
169170
* 828mk2
170171
* Traveler
171172
* Ultralite

sound/firewire/motu/motu-protocol-v1.c

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,62 @@
5353
#define CLK_828_STATUS_FLAG_SRC_SPDIF_ON_OPT_OR_COAX 0x00000002
5454
#define CLK_828_STATUS_FLAG_SRC_ADAT_ON_OPT_OR_DSUB 0x00000001
5555

56+
// Status register for MOTU 896 (0x'ffff'f000'0b14).
57+
//
58+
// 0x20000000: fetch PCM frames from communication IC to DAC.
59+
// 0x08000000: speed of word clock signal output on BNC interface.
60+
// 0x00000000: follow to system clock.
61+
// 0x08000000: half of system clock.
62+
// 0x01000000: Route main output to headphone output.
63+
// 0x00ffff00: input to monitor.
64+
// 0x00000000: none
65+
// 0x00004800: analog-1/2
66+
// 0x00005a00: analog-3/4
67+
// 0x00006c00: analog-5/6
68+
// 0x00007e00: analog-7/8
69+
// 0x00104800: AES/EBU-1/2
70+
// 0x00004000: analog-1
71+
// 0x00004900: analog-2
72+
// 0x00005200: analog-3
73+
// 0x00005b00: analog-4
74+
// 0x00006400: analog-5
75+
// 0x00006d00: analog-6
76+
// 0x00007600: analog-7
77+
// 0x00007f00: analog-8
78+
// 0x00104000: AES/EBU-1
79+
// 0x00104900: AES/EBU-2
80+
// 0x00000060: sample rate conversin for AES/EBU input/output.
81+
// 0x00000000: None
82+
// 0x00000020: input signal is converted to system rate
83+
// 0x00000040: output is slave to input, ignoring system rate
84+
// 0x00000060: output is double rate than system rate
85+
// 0x00000018: nominal rate of sampling clock.
86+
// 0x00000000: 44.1 kHz
87+
// 0x00000008: 48.0 kHz
88+
// 0x00000010: 88.2 kHz
89+
// 0x00000018: 96.0 kHz
90+
// 0x00000007: source of sampling clock.
91+
// 0x00000000: internal
92+
// 0x00000001: ADAT on optical interface
93+
// 0x00000002: AES/EBU on XLR
94+
// 0x00000004: word clock on BNC
95+
// 0x00000005: ADAT on Dsub 9pin
96+
97+
#define CLK_896_STATUS_OFFSET 0x0b14
98+
#define CLK_896_STATUS_FLAG_FETCH_ENABLE 0x20000000
99+
#define CLK_896_STATUS_FLAG_MAIN_TO_HP 0x01000000
100+
#define CLK_896_STATUS_MASK_SRC 0x00000007
101+
#define CLK_896_STATUS_FLAG_SRC_INTERNAL 0x00000000
102+
#define CLK_896_STATUS_FLAG_SRC_ADAT_ON_OPT 0x00000001
103+
#define CLK_896_STATUS_FLAG_SRC_AESEBU 0x00000002
104+
#define CLK_896_STATUS_FLAG_SRC_WORD 0x00000004
105+
#define CLK_896_STATUS_FLAG_SRC_ADAT_ON_DSUB 0x00000005
106+
#define CLK_896_STATUS_MASK_RATE 0x00000018
107+
#define CLK_896_STATUS_FLAG_RATE_44100 0x00000000
108+
#define CLK_896_STATUS_FLAG_RATE_48000 0x00000008
109+
#define CLK_896_STATUS_FLAG_RATE_88200 0x00000010
110+
#define CLK_896_STATUS_FLAG_RATE_96000 0x00000018
111+
56112
static void parse_clock_rate_828(u32 data, unsigned int *rate)
57113
{
58114
if (data & CLK_828_STATUS_FLAG_RATE_48000)
@@ -74,10 +130,45 @@ static int get_clock_rate_828(struct snd_motu *motu, unsigned int *rate)
74130
return 0;
75131
}
76132

133+
static int parse_clock_rate_896(u32 data, unsigned int *rate)
134+
{
135+
switch (data & CLK_896_STATUS_MASK_RATE) {
136+
case CLK_896_STATUS_FLAG_RATE_44100:
137+
*rate = 44100;
138+
break;
139+
case CLK_896_STATUS_FLAG_RATE_48000:
140+
*rate = 48000;
141+
break;
142+
case CLK_896_STATUS_FLAG_RATE_88200:
143+
*rate = 88200;
144+
break;
145+
case CLK_896_STATUS_FLAG_RATE_96000:
146+
*rate = 96000;
147+
break;
148+
default:
149+
return -ENXIO;
150+
}
151+
152+
return 0;
153+
}
154+
155+
static int get_clock_rate_896(struct snd_motu *motu, unsigned int *rate)
156+
{
157+
__be32 reg;
158+
int err;
159+
160+
err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
161+
if (err < 0)
162+
return err;
163+
return parse_clock_rate_896(be32_to_cpu(reg), rate);
164+
}
165+
77166
int snd_motu_protocol_v1_get_clock_rate(struct snd_motu *motu, unsigned int *rate)
78167
{
79168
if (motu->spec == &snd_motu_spec_828)
80169
return get_clock_rate_828(motu, rate);
170+
else if (motu->spec == &snd_motu_spec_896)
171+
return get_clock_rate_896(motu, rate);
81172
else
82173
return -ENXIO;
83174
}
@@ -101,10 +192,48 @@ static int set_clock_rate_828(struct snd_motu *motu, unsigned int rate)
101192
return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg));
102193
}
103194

195+
static int set_clock_rate_896(struct snd_motu *motu, unsigned int rate)
196+
{
197+
unsigned int flag;
198+
__be32 reg;
199+
u32 data;
200+
int err;
201+
202+
err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
203+
if (err < 0)
204+
return err;
205+
data = be32_to_cpu(reg);
206+
207+
switch (rate) {
208+
case 44100:
209+
flag = CLK_896_STATUS_FLAG_RATE_44100;
210+
break;
211+
case 48000:
212+
flag = CLK_896_STATUS_FLAG_RATE_48000;
213+
break;
214+
case 88200:
215+
flag = CLK_896_STATUS_FLAG_RATE_88200;
216+
break;
217+
case 96000:
218+
flag = CLK_896_STATUS_FLAG_RATE_96000;
219+
break;
220+
default:
221+
return -EINVAL;
222+
}
223+
224+
data &= ~CLK_896_STATUS_MASK_RATE;
225+
data |= flag;
226+
227+
reg = cpu_to_be32(data);
228+
return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
229+
}
230+
104231
int snd_motu_protocol_v1_set_clock_rate(struct snd_motu *motu, unsigned int rate)
105232
{
106233
if (motu->spec == &snd_motu_spec_828)
107234
return set_clock_rate_828(motu, rate);
235+
else if (motu->spec == &snd_motu_spec_896)
236+
return set_clock_rate_896(motu, rate);
108237
else
109238
return -ENXIO;
110239
}
@@ -137,10 +266,46 @@ static int get_clock_source_828(struct snd_motu *motu, enum snd_motu_clock_sourc
137266
return 0;
138267
}
139268

269+
static int get_clock_source_896(struct snd_motu *motu, enum snd_motu_clock_source *src)
270+
{
271+
__be32 reg;
272+
u32 data;
273+
int err;
274+
275+
err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
276+
if (err < 0)
277+
return err;
278+
data = be32_to_cpu(reg);
279+
280+
switch (data & CLK_896_STATUS_MASK_SRC) {
281+
case CLK_896_STATUS_FLAG_SRC_INTERNAL:
282+
*src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
283+
break;
284+
case CLK_896_STATUS_FLAG_SRC_ADAT_ON_OPT:
285+
*src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT;
286+
break;
287+
case CLK_896_STATUS_FLAG_SRC_AESEBU:
288+
*src = SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR;
289+
break;
290+
case CLK_896_STATUS_FLAG_SRC_WORD:
291+
*src = SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC;
292+
break;
293+
case CLK_896_STATUS_FLAG_SRC_ADAT_ON_DSUB:
294+
*src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB;
295+
break;
296+
default:
297+
return -ENXIO;
298+
}
299+
300+
return 0;
301+
}
302+
140303
int snd_motu_protocol_v1_get_clock_source(struct snd_motu *motu, enum snd_motu_clock_source *src)
141304
{
142305
if (motu->spec == &snd_motu_spec_828)
143306
return get_clock_source_828(motu, src);
307+
else if (motu->spec == &snd_motu_spec_896)
308+
return get_clock_source_896(motu, src);
144309
else
145310
return -ENXIO;
146311
}
@@ -169,10 +334,31 @@ static int switch_fetching_mode_828(struct snd_motu *motu, bool enable)
169334
return snd_motu_transaction_write(motu, CLK_828_STATUS_OFFSET, &reg, sizeof(reg));
170335
}
171336

337+
static int switch_fetching_mode_896(struct snd_motu *motu, bool enable)
338+
{
339+
__be32 reg;
340+
u32 data;
341+
int err;
342+
343+
err = snd_motu_transaction_read(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
344+
if (err < 0)
345+
return err;
346+
data = be32_to_cpu(reg);
347+
348+
data &= ~(CLK_896_STATUS_FLAG_FETCH_ENABLE | CLK_896_STATUS_FLAG_MAIN_TO_HP);
349+
if (enable)
350+
data |= (CLK_896_STATUS_FLAG_FETCH_ENABLE | CLK_896_STATUS_FLAG_MAIN_TO_HP);
351+
352+
reg = cpu_to_be32(data);
353+
return snd_motu_transaction_write(motu, CLK_896_STATUS_OFFSET, &reg, sizeof(reg));
354+
}
355+
172356
int snd_motu_protocol_v1_switch_fetching_mode(struct snd_motu *motu, bool enable)
173357
{
174358
if (motu->spec == &snd_motu_spec_828)
175359
return switch_fetching_mode_828(motu, enable);
360+
else if (motu->spec == &snd_motu_spec_896)
361+
return switch_fetching_mode_896(motu, enable);
176362
else
177363
return -ENXIO;
178364
}
@@ -204,6 +390,27 @@ static int detect_packet_formats_828(struct snd_motu *motu)
204390
return 0;
205391
}
206392

393+
static int detect_packet_formats_896(struct snd_motu *motu)
394+
{
395+
// 24bit PCM frames follow to source packet header without message chunk.
396+
motu->tx_packet_formats.pcm_byte_offset = 4;
397+
motu->rx_packet_formats.pcm_byte_offset = 4;
398+
399+
// No message chunk in data block.
400+
motu->tx_packet_formats.msg_chunks = 0;
401+
motu->rx_packet_formats.msg_chunks = 0;
402+
403+
// Always enable optical interface for ADAT signal since the device have no registers
404+
// to refer to current configuration.
405+
motu->tx_packet_formats.pcm_chunks[0] += 8;
406+
motu->tx_packet_formats.pcm_chunks[1] += 8;
407+
408+
motu->rx_packet_formats.pcm_chunks[0] += 8;
409+
motu->rx_packet_formats.pcm_chunks[1] += 8;
410+
411+
return 0;
412+
}
413+
207414
int snd_motu_protocol_v1_cache_packet_formats(struct snd_motu *motu)
208415
{
209416
memcpy(motu->tx_packet_formats.pcm_chunks, motu->spec->tx_fixed_pcm_chunks,
@@ -213,6 +420,8 @@ int snd_motu_protocol_v1_cache_packet_formats(struct snd_motu *motu)
213420

214421
if (motu->spec == &snd_motu_spec_828)
215422
return detect_packet_formats_828(motu);
423+
else if (motu->spec == &snd_motu_spec_896)
424+
return detect_packet_formats_896(motu);
216425
else
217426
return 0;
218427
}
@@ -223,3 +432,9 @@ const struct snd_motu_spec snd_motu_spec_828 = {
223432
.tx_fixed_pcm_chunks = {10, 0, 0},
224433
.rx_fixed_pcm_chunks = {10, 0, 0},
225434
};
435+
436+
const struct snd_motu_spec snd_motu_spec_896 = {
437+
.name = "896",
438+
.tx_fixed_pcm_chunks = {10, 10, 0},
439+
.rx_fixed_pcm_chunks = {10, 10, 0},
440+
};

sound/firewire/motu/motu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static void motu_bus_update(struct fw_unit *unit)
151151

152152
static const struct ieee1394_device_id motu_id_table[] = {
153153
SND_MOTU_DEV_ENTRY(0x000001, &snd_motu_spec_828),
154+
SND_MOTU_DEV_ENTRY(0x000002, &snd_motu_spec_896),
154155
SND_MOTU_DEV_ENTRY(0x000003, &snd_motu_spec_828mk2),
155156
SND_MOTU_DEV_ENTRY(0x000009, &snd_motu_spec_traveler),
156157
SND_MOTU_DEV_ENTRY(0x00000d, &snd_motu_spec_ultralite),

sound/firewire/motu/motu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct snd_motu_spec {
123123
};
124124

125125
extern const struct snd_motu_spec snd_motu_spec_828;
126+
extern const struct snd_motu_spec snd_motu_spec_896;
126127

127128
extern const struct snd_motu_spec snd_motu_spec_828mk2;
128129
extern const struct snd_motu_spec snd_motu_spec_traveler;

0 commit comments

Comments
 (0)