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 <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20200519111641.123211-9-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
28c8d3c91a
commit
0090c1c5f3
|
@ -345,6 +345,12 @@ int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu)
|
|||
calculate_differed_part(&motu->rx_packet_formats, motu->spec->flags,
|
||||
data, V2_OPT_OUT_IFACE_MASK, V2_OPT_OUT_IFACE_SHIFT);
|
||||
|
||||
memcpy(motu->tx_packet_formats.pcm_chunks,
|
||||
motu->spec->tx_fixed_pcm_chunks,
|
||||
sizeof(motu->tx_packet_formats.pcm_chunks));
|
||||
memcpy(motu->rx_packet_formats.pcm_chunks,
|
||||
motu->spec->rx_fixed_pcm_chunks,
|
||||
sizeof(motu->rx_packet_formats.pcm_chunks));
|
||||
|
||||
if (motu->spec == &snd_motu_spec_828mk2)
|
||||
return detect_packet_formats_828mk2(motu, data);
|
||||
|
|
|
@ -165,8 +165,6 @@ static void calculate_fixed_part(struct snd_motu_packet_format *formats,
|
|||
{
|
||||
unsigned char pcm_chunks[3] = {0, 0, 0};
|
||||
|
||||
formats->msg_chunks = 2;
|
||||
|
||||
pcm_chunks[0] = analog_ports;
|
||||
pcm_chunks[1] = analog_ports;
|
||||
if (flags & SND_MOTU_SPEC_SUPPORT_CLOCK_X4)
|
||||
|
@ -278,12 +276,63 @@ static void calculate_differed_part(struct snd_motu_packet_format *formats,
|
|||
}
|
||||
}
|
||||
|
||||
static int detect_packet_formats_828mk3(struct snd_motu *motu, u32 data)
|
||||
{
|
||||
if (data & V3_ENABLE_OPT_IN_IFACE_A) {
|
||||
if (data & V3_NO_ADAT_OPT_IN_IFACE_A) {
|
||||
motu->tx_packet_formats.pcm_chunks[0] += 4;
|
||||
motu->tx_packet_formats.pcm_chunks[1] += 4;
|
||||
} else {
|
||||
motu->tx_packet_formats.pcm_chunks[0] += 8;
|
||||
motu->tx_packet_formats.pcm_chunks[1] += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (data & V3_ENABLE_OPT_IN_IFACE_B) {
|
||||
if (data & V3_NO_ADAT_OPT_IN_IFACE_B) {
|
||||
motu->tx_packet_formats.pcm_chunks[0] += 4;
|
||||
motu->tx_packet_formats.pcm_chunks[1] += 4;
|
||||
} else {
|
||||
motu->tx_packet_formats.pcm_chunks[0] += 8;
|
||||
motu->tx_packet_formats.pcm_chunks[1] += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (data & V3_ENABLE_OPT_OUT_IFACE_A) {
|
||||
if (data & V3_NO_ADAT_OPT_OUT_IFACE_A) {
|
||||
motu->rx_packet_formats.pcm_chunks[0] += 4;
|
||||
motu->rx_packet_formats.pcm_chunks[1] += 4;
|
||||
} else {
|
||||
motu->rx_packet_formats.pcm_chunks[0] += 8;
|
||||
motu->rx_packet_formats.pcm_chunks[1] += 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (data & V3_ENABLE_OPT_OUT_IFACE_B) {
|
||||
if (data & V3_NO_ADAT_OPT_OUT_IFACE_B) {
|
||||
motu->rx_packet_formats.pcm_chunks[0] += 4;
|
||||
motu->rx_packet_formats.pcm_chunks[1] += 4;
|
||||
} else {
|
||||
motu->rx_packet_formats.pcm_chunks[0] += 8;
|
||||
motu->rx_packet_formats.pcm_chunks[1] += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snd_motu_protocol_v3_cache_packet_formats(struct snd_motu *motu)
|
||||
{
|
||||
__be32 reg;
|
||||
u32 data;
|
||||
int err;
|
||||
|
||||
motu->tx_packet_formats.pcm_byte_offset = 10;
|
||||
motu->rx_packet_formats.pcm_byte_offset = 10;
|
||||
|
||||
motu->tx_packet_formats.msg_chunks = 2;
|
||||
motu->rx_packet_formats.msg_chunks = 2;
|
||||
|
||||
err = snd_motu_transaction_read(motu, V3_OPT_IFACE_MODE_OFFSET, ®,
|
||||
sizeof(reg));
|
||||
if (err < 0)
|
||||
|
@ -304,9 +353,16 @@ int snd_motu_protocol_v3_cache_packet_formats(struct snd_motu *motu)
|
|||
V3_ENABLE_OPT_OUT_IFACE_A, V3_NO_ADAT_OPT_OUT_IFACE_A,
|
||||
V3_ENABLE_OPT_OUT_IFACE_B, V3_NO_ADAT_OPT_OUT_IFACE_B);
|
||||
|
||||
motu->tx_packet_formats.pcm_byte_offset = 10;
|
||||
motu->rx_packet_formats.pcm_byte_offset = 10;
|
||||
memcpy(motu->tx_packet_formats.pcm_chunks,
|
||||
motu->spec->tx_fixed_pcm_chunks,
|
||||
sizeof(motu->tx_packet_formats.pcm_chunks));
|
||||
memcpy(motu->rx_packet_formats.pcm_chunks,
|
||||
motu->spec->rx_fixed_pcm_chunks,
|
||||
sizeof(motu->rx_packet_formats.pcm_chunks));
|
||||
|
||||
if (motu->spec == &snd_motu_spec_828mk3)
|
||||
return detect_packet_formats_828mk3(motu, data);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue