Skip to content

Commit 0090c1c

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-motu: add alternative functions to detect packet format for protocol v3
This commit adds alternative functions to detect packet format so that each function corresponds to each model. Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 28c8d3c commit 0090c1c

File tree

2 files changed

+67
-5
lines changed

2 files changed

+67
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu)
345345
calculate_differed_part(&motu->rx_packet_formats, motu->spec->flags,
346346
data, V2_OPT_OUT_IFACE_MASK, V2_OPT_OUT_IFACE_SHIFT);
347347

348+
memcpy(motu->tx_packet_formats.pcm_chunks,
349+
motu->spec->tx_fixed_pcm_chunks,
350+
sizeof(motu->tx_packet_formats.pcm_chunks));
351+
memcpy(motu->rx_packet_formats.pcm_chunks,
352+
motu->spec->rx_fixed_pcm_chunks,
353+
sizeof(motu->rx_packet_formats.pcm_chunks));
348354

349355
if (motu->spec == &snd_motu_spec_828mk2)
350356
return detect_packet_formats_828mk2(motu, data);

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

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ static void calculate_fixed_part(struct snd_motu_packet_format *formats,
165165
{
166166
unsigned char pcm_chunks[3] = {0, 0, 0};
167167

168-
formats->msg_chunks = 2;
169-
170168
pcm_chunks[0] = analog_ports;
171169
pcm_chunks[1] = analog_ports;
172170
if (flags & SND_MOTU_SPEC_SUPPORT_CLOCK_X4)
@@ -278,12 +276,63 @@ static void calculate_differed_part(struct snd_motu_packet_format *formats,
278276
}
279277
}
280278

279+
static int detect_packet_formats_828mk3(struct snd_motu *motu, u32 data)
280+
{
281+
if (data & V3_ENABLE_OPT_IN_IFACE_A) {
282+
if (data & V3_NO_ADAT_OPT_IN_IFACE_A) {
283+
motu->tx_packet_formats.pcm_chunks[0] += 4;
284+
motu->tx_packet_formats.pcm_chunks[1] += 4;
285+
} else {
286+
motu->tx_packet_formats.pcm_chunks[0] += 8;
287+
motu->tx_packet_formats.pcm_chunks[1] += 4;
288+
}
289+
}
290+
291+
if (data & V3_ENABLE_OPT_IN_IFACE_B) {
292+
if (data & V3_NO_ADAT_OPT_IN_IFACE_B) {
293+
motu->tx_packet_formats.pcm_chunks[0] += 4;
294+
motu->tx_packet_formats.pcm_chunks[1] += 4;
295+
} else {
296+
motu->tx_packet_formats.pcm_chunks[0] += 8;
297+
motu->tx_packet_formats.pcm_chunks[1] += 4;
298+
}
299+
}
300+
301+
if (data & V3_ENABLE_OPT_OUT_IFACE_A) {
302+
if (data & V3_NO_ADAT_OPT_OUT_IFACE_A) {
303+
motu->rx_packet_formats.pcm_chunks[0] += 4;
304+
motu->rx_packet_formats.pcm_chunks[1] += 4;
305+
} else {
306+
motu->rx_packet_formats.pcm_chunks[0] += 8;
307+
motu->rx_packet_formats.pcm_chunks[1] += 4;
308+
}
309+
}
310+
311+
if (data & V3_ENABLE_OPT_OUT_IFACE_B) {
312+
if (data & V3_NO_ADAT_OPT_OUT_IFACE_B) {
313+
motu->rx_packet_formats.pcm_chunks[0] += 4;
314+
motu->rx_packet_formats.pcm_chunks[1] += 4;
315+
} else {
316+
motu->rx_packet_formats.pcm_chunks[0] += 8;
317+
motu->rx_packet_formats.pcm_chunks[1] += 4;
318+
}
319+
}
320+
321+
return 0;
322+
}
323+
281324
int snd_motu_protocol_v3_cache_packet_formats(struct snd_motu *motu)
282325
{
283326
__be32 reg;
284327
u32 data;
285328
int err;
286329

330+
motu->tx_packet_formats.pcm_byte_offset = 10;
331+
motu->rx_packet_formats.pcm_byte_offset = 10;
332+
333+
motu->tx_packet_formats.msg_chunks = 2;
334+
motu->rx_packet_formats.msg_chunks = 2;
335+
287336
err = snd_motu_transaction_read(motu, V3_OPT_IFACE_MODE_OFFSET, &reg,
288337
sizeof(reg));
289338
if (err < 0)
@@ -304,10 +353,17 @@ int snd_motu_protocol_v3_cache_packet_formats(struct snd_motu *motu)
304353
V3_ENABLE_OPT_OUT_IFACE_A, V3_NO_ADAT_OPT_OUT_IFACE_A,
305354
V3_ENABLE_OPT_OUT_IFACE_B, V3_NO_ADAT_OPT_OUT_IFACE_B);
306355

307-
motu->tx_packet_formats.pcm_byte_offset = 10;
308-
motu->rx_packet_formats.pcm_byte_offset = 10;
356+
memcpy(motu->tx_packet_formats.pcm_chunks,
357+
motu->spec->tx_fixed_pcm_chunks,
358+
sizeof(motu->tx_packet_formats.pcm_chunks));
359+
memcpy(motu->rx_packet_formats.pcm_chunks,
360+
motu->spec->rx_fixed_pcm_chunks,
361+
sizeof(motu->rx_packet_formats.pcm_chunks));
309362

310-
return 0;
363+
if (motu->spec == &snd_motu_spec_828mk3)
364+
return detect_packet_formats_828mk3(motu, data);
365+
else
366+
return 0;
311367
}
312368

313369

0 commit comments

Comments
 (0)