Skip to content

Commit 28c8d3c

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-motu: add alternative functions to detect packet format for protocol v2
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 dfbaa4d commit 28c8d3c

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

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

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu,
164164
if (enable)
165165
data |= V2_CLOCK_FETCH_ENABLE;
166166

167-
if (motu->spec->flags & SND_MOTU_SPEC_SUPPORT_CLOCK_X4) {
167+
if (motu->spec == &snd_motu_spec_traveler) {
168168
// Expected for Traveler and 896HD, which implements Altera
169169
// Cyclone EP1C3.
170170
data |= V2_CLOCK_MODEL_SPECIFIC;
@@ -193,8 +193,6 @@ static void calculate_fixed_part(struct snd_motu_packet_format *formats,
193193
{
194194
unsigned char pcm_chunks[3] = {0, 0, 0};
195195

196-
formats->msg_chunks = 2;
197-
198196
pcm_chunks[0] = analog_ports;
199197
pcm_chunks[1] = analog_ports;
200198
if (flags & SND_MOTU_SPEC_SUPPORT_CLOCK_X4)
@@ -268,12 +266,69 @@ static void calculate_differed_part(struct snd_motu_packet_format *formats,
268266
formats->differed_part_pcm_chunks[1] = pcm_chunks[1];
269267
}
270268

269+
static int detect_packet_formats_828mk2(struct snd_motu *motu, u32 data)
270+
{
271+
if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) ==
272+
V2_OPT_IFACE_MODE_ADAT) {
273+
motu->tx_packet_formats.pcm_chunks[0] += 8;
274+
motu->tx_packet_formats.pcm_chunks[1] += 4;
275+
}
276+
277+
if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) ==
278+
V2_OPT_IFACE_MODE_ADAT) {
279+
motu->rx_packet_formats.pcm_chunks[0] += 8;
280+
motu->rx_packet_formats.pcm_chunks[1] += 4;
281+
}
282+
283+
return 0;
284+
}
285+
286+
static int detect_packet_formats_traveler(struct snd_motu *motu, u32 data)
287+
{
288+
if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) ==
289+
V2_OPT_IFACE_MODE_ADAT) {
290+
motu->tx_packet_formats.pcm_chunks[0] += 8;
291+
motu->tx_packet_formats.pcm_chunks[1] += 4;
292+
}
293+
294+
if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) ==
295+
V2_OPT_IFACE_MODE_ADAT) {
296+
motu->rx_packet_formats.pcm_chunks[0] += 8;
297+
motu->rx_packet_formats.pcm_chunks[1] += 4;
298+
}
299+
300+
return 0;
301+
}
302+
303+
static int detect_packet_formats_8pre(struct snd_motu *motu, u32 data)
304+
{
305+
if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) ==
306+
V2_OPT_IFACE_MODE_ADAT) {
307+
motu->tx_packet_formats.pcm_chunks[0] += 8;
308+
motu->tx_packet_formats.pcm_chunks[1] += 8;
309+
}
310+
311+
if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) ==
312+
V2_OPT_IFACE_MODE_ADAT) {
313+
motu->rx_packet_formats.pcm_chunks[0] += 8;
314+
motu->rx_packet_formats.pcm_chunks[1] += 8;
315+
}
316+
317+
return 0;
318+
}
319+
271320
int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu)
272321
{
273322
__be32 reg;
274323
u32 data;
275324
int err;
276325

326+
motu->tx_packet_formats.pcm_byte_offset = 10;
327+
motu->rx_packet_formats.pcm_byte_offset = 10;
328+
329+
motu->tx_packet_formats.msg_chunks = 2;
330+
motu->rx_packet_formats.msg_chunks = 2;
331+
277332
err = snd_motu_transaction_read(motu, V2_IN_OUT_CONF_OFFSET, &reg,
278333
sizeof(reg));
279334
if (err < 0)
@@ -290,10 +345,15 @@ int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu)
290345
calculate_differed_part(&motu->rx_packet_formats, motu->spec->flags,
291346
data, V2_OPT_OUT_IFACE_MASK, V2_OPT_OUT_IFACE_SHIFT);
292347

293-
motu->tx_packet_formats.pcm_byte_offset = 10;
294-
motu->rx_packet_formats.pcm_byte_offset = 10;
295348

296-
return 0;
349+
if (motu->spec == &snd_motu_spec_828mk2)
350+
return detect_packet_formats_828mk2(motu, data);
351+
else if (motu->spec == &snd_motu_spec_traveler)
352+
return detect_packet_formats_traveler(motu, data);
353+
else if (motu->spec == &snd_motu_spec_8pre)
354+
return detect_packet_formats_8pre(motu, data);
355+
else
356+
return 0;
297357
}
298358

299359
const struct snd_motu_spec snd_motu_spec_828mk2 = {

sound/firewire/motu/motu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct snd_motu_packet_format {
3636
unsigned char pcm_byte_offset;
3737

3838
unsigned char msg_chunks;
39+
unsigned char pcm_chunks[3];
3940
unsigned char fixed_part_pcm_chunks[3];
4041
unsigned char differed_part_pcm_chunks[3];
4142
};

0 commit comments

Comments
 (0)