diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2019-10-30 11:06:43 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-10-30 12:57:56 +0300 |
commit | bd1073728260e1d2f9589c928b6d8ddb14f5646f (patch) | |
tree | 51ac3c83fd62822acb41ff371ae9d0bc8fca5130 /sound/firewire/motu/motu-protocol-v2.c | |
parent | 4b2079f80aa065b237955e75d0b627943656b0ab (diff) | |
download | linux-bd1073728260e1d2f9589c928b6d8ddb14f5646f.tar.xz |
ALSA: firewire-motu: code refactoring to handle model specific switch for protocol v2
In MOTU FireWire series, devices which support protocol version 2 have
several types of hardware design to process audio data frames for isoc
packet. Roughly devices are categorized into three groups:
- 828mkII
- Traveler/896HD
- UltraLite/8pre FireWire
Some bit flags in register addressed by 0x'ffff'f000'0b14
includes device-specific effects.
This commit cleanups implementation of protocol v2 in this point.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191030080644.1704-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/motu/motu-protocol-v2.c')
-rw-r--r-- | sound/firewire/motu/motu-protocol-v2.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/sound/firewire/motu/motu-protocol-v2.c b/sound/firewire/motu/motu-protocol-v2.c index cb0e58a9f33d..619b6ae73f62 100644 --- a/sound/firewire/motu/motu-protocol-v2.c +++ b/sound/firewire/motu/motu-protocol-v2.c @@ -12,10 +12,8 @@ #define V2_CLOCK_RATE_SHIFT 3 #define V2_CLOCK_SRC_MASK 0x00000007 #define V2_CLOCK_SRC_SHIFT 0 -#define V2_CLOCK_TRAVELER_FETCH_DISABLE 0x04000000 -#define V2_CLOCK_TRAVELER_FETCH_ENABLE 0x03000000 -#define V2_CLOCK_8PRE_FETCH_DISABLE 0x02000000 -#define V2_CLOCK_8PRE_FETCH_ENABLE 0x00000000 +#define V2_CLOCK_FETCH_ENABLE 0x02000000 +#define V2_CLOCK_MODEL_SPECIFIC 0x04000000 #define V2_IN_OUT_CONF_OFFSET 0x0c04 #define V2_OPT_OUT_IFACE_MASK 0x00000c00 @@ -73,11 +71,6 @@ static int v2_set_clock_rate(struct snd_motu *motu, unsigned int rate) data &= ~V2_CLOCK_RATE_MASK; data |= i << V2_CLOCK_RATE_SHIFT; - if (motu->spec == &snd_motu_spec_traveler) { - data &= ~V2_CLOCK_TRAVELER_FETCH_ENABLE; - data |= V2_CLOCK_TRAVELER_FETCH_DISABLE; - } - reg = cpu_to_be32(data); return snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET, ®, sizeof(reg)); @@ -145,42 +138,49 @@ static int v2_get_clock_source(struct snd_motu *motu, static int v2_switch_fetching_mode(struct snd_motu *motu, bool enable) { + enum snd_motu_clock_source src; __be32 reg; u32 data; int err = 0; - if (motu->spec == &snd_motu_spec_traveler || - motu->spec == &snd_motu_spec_8pre) { - err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, - ®, sizeof(reg)); + // 828mkII implements Altera ACEX 1K EP1K30. Nothing to do. + if (motu->spec == &snd_motu_spec_828mk2) + return 0; + + err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, ®, + sizeof(reg)); + if (err < 0) + return err; + data = be32_to_cpu(reg); + + err = get_clock_source(motu, data, &src); + if (err < 0) + return err; + + data &= ~(V2_CLOCK_FETCH_ENABLE | V2_CLOCK_MODEL_SPECIFIC); + if (enable) + data |= V2_CLOCK_FETCH_ENABLE; + + if (motu->spec->flags & SND_MOTU_SPEC_SUPPORT_CLOCK_X4) { + // Expected for Traveler and 896HD, which implements Altera + // Cyclone EP1C3. + data |= V2_CLOCK_MODEL_SPECIFIC; + } else { + // For UltraLite and 8pre, which implements Xilinx Spartan + // XC3S200. + unsigned int rate; + + err = get_clock_rate(data, &rate); if (err < 0) return err; - data = be32_to_cpu(reg); - - if (motu->spec == &snd_motu_spec_traveler) { - data &= ~(V2_CLOCK_TRAVELER_FETCH_DISABLE | - V2_CLOCK_TRAVELER_FETCH_ENABLE); - - if (enable) - data |= V2_CLOCK_TRAVELER_FETCH_ENABLE; - else - data |= V2_CLOCK_TRAVELER_FETCH_DISABLE; - } else if (motu->spec == &snd_motu_spec_8pre) { - data &= ~(V2_CLOCK_8PRE_FETCH_DISABLE | - V2_CLOCK_8PRE_FETCH_ENABLE); - - if (enable) - data |= V2_CLOCK_8PRE_FETCH_DISABLE; - else - data |= V2_CLOCK_8PRE_FETCH_ENABLE; - } - reg = cpu_to_be32(data); - err = snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET, - ®, sizeof(reg)); + if (src == SND_MOTU_CLOCK_SOURCE_SPH && rate > 48000) + data |= V2_CLOCK_MODEL_SPECIFIC; } - return err; + reg = cpu_to_be32(data); + return snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET, ®, + sizeof(reg)); } static void calculate_fixed_part(struct snd_motu_packet_format *formats, |