diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2021-06-23 16:59:37 +0900 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-06-23 10:17:26 +0200 |
commit | 53ed8cf625fae18b2557d5b806a50f7c65555f61 (patch) | |
tree | 665e5c994e6391a6f514c08ee66d477fadaf1862 /sound/firewire | |
parent | 184aa6b7e1054b235cea3f53ac2dd9276d674659 (diff) | |
download | linux-53ed8cf625fae18b2557d5b806a50f7c65555f61.tar.gz linux-53ed8cf625fae18b2557d5b806a50f7c65555f61.tar.bz2 linux-53ed8cf625fae18b2557d5b806a50f7c65555f61.zip |
ALSA: firewire-motu: code refactoring for packet format detection in v2 protocol
Current implementation of driver has several similar helper functions
for packet format detection in protocol version 2.
This commit merges them as code refactoring.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210623075941.72562-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r-- | sound/firewire/motu/motu-protocol-v2.c | 79 |
1 files changed, 20 insertions, 59 deletions
diff --git a/sound/firewire/motu/motu-protocol-v2.c b/sound/firewire/motu/motu-protocol-v2.c index 8865308c2c8e..93d5df1ae550 100644 --- a/sound/firewire/motu/motu-protocol-v2.c +++ b/sound/firewire/motu/motu-protocol-v2.c @@ -218,59 +218,9 @@ int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu, } } -static int detect_packet_formats_828mk2(struct snd_motu *motu, u32 data) -{ - if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->tx_packet_formats.pcm_chunks[0] += 8; - motu->tx_packet_formats.pcm_chunks[1] += 4; - } - - if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->rx_packet_formats.pcm_chunks[0] += 8; - motu->rx_packet_formats.pcm_chunks[1] += 4; - } - - return 0; -} - -static int detect_packet_formats_traveler(struct snd_motu *motu, u32 data) -{ - if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->tx_packet_formats.pcm_chunks[0] += 8; - motu->tx_packet_formats.pcm_chunks[1] += 4; - } - - if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->rx_packet_formats.pcm_chunks[0] += 8; - motu->rx_packet_formats.pcm_chunks[1] += 4; - } - - return 0; -} - -static int detect_packet_formats_8pre(struct snd_motu *motu, u32 data) -{ - if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->tx_packet_formats.pcm_chunks[0] += 8; - motu->tx_packet_formats.pcm_chunks[1] += 8; - } - - if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) == - V2_OPT_IFACE_MODE_ADAT) { - motu->rx_packet_formats.pcm_chunks[0] += 8; - motu->rx_packet_formats.pcm_chunks[1] += 8; - } - - return 0; -} - int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu) { + bool has_two_opt_ifaces = (motu->spec == &snd_motu_spec_8pre); __be32 reg; u32 data; int err; @@ -294,14 +244,25 @@ int snd_motu_protocol_v2_cache_packet_formats(struct snd_motu *motu) 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); - else if (motu->spec == &snd_motu_spec_traveler) - return detect_packet_formats_traveler(motu, data); - else if (motu->spec == &snd_motu_spec_8pre) - return detect_packet_formats_8pre(motu, data); - else - return 0; + if (((data & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT) == V2_OPT_IFACE_MODE_ADAT) { + motu->tx_packet_formats.pcm_chunks[0] += 8; + + if (!has_two_opt_ifaces) + motu->tx_packet_formats.pcm_chunks[1] += 4; + else + motu->tx_packet_formats.pcm_chunks[1] += 8; + } + + if (((data & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT) == V2_OPT_IFACE_MODE_ADAT) { + motu->rx_packet_formats.pcm_chunks[0] += 8; + + if (!has_two_opt_ifaces) + motu->rx_packet_formats.pcm_chunks[1] += 4; + else + motu->rx_packet_formats.pcm_chunks[1] += 8; + } + + return 0; } const struct snd_motu_spec snd_motu_spec_828mk2 = { |