forked from Minki/linux
ALSA: firewire-motu: refactoring protocol v2 for fetching mode switch
This commit splits the method to switch fetching mode for protocol version 2 so that model-dependent operations are explicitly defined. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20200519111641.123211-15-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
7b47c0d719
commit
506ad56a59
@ -170,52 +170,69 @@ int snd_motu_protocol_v2_get_clock_source(struct snd_motu *motu,
|
|||||||
return get_clock_source(motu, be32_to_cpu(reg), src);
|
return get_clock_source(motu, be32_to_cpu(reg), src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expected for Traveler and 896HD, which implements Altera Cyclone EP1C3.
|
||||||
|
static int switch_fetching_mode_cyclone(struct snd_motu *motu, u32 *data,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
*data |= V2_CLOCK_MODEL_SPECIFIC;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For UltraLite and 8pre, which implements Xilinx Spartan XC3S200.
|
||||||
|
static int switch_fetching_mode_spartan(struct snd_motu *motu, u32 *data,
|
||||||
|
bool enable)
|
||||||
|
{
|
||||||
|
unsigned int rate;
|
||||||
|
enum snd_motu_clock_source src;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = get_clock_source(motu, *data, &src);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = get_clock_rate(*data, &rate);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (src == SND_MOTU_CLOCK_SOURCE_SPH && rate > 48000)
|
||||||
|
*data |= V2_CLOCK_MODEL_SPECIFIC;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu,
|
int snd_motu_protocol_v2_switch_fetching_mode(struct snd_motu *motu,
|
||||||
bool enable)
|
bool enable)
|
||||||
{
|
{
|
||||||
enum snd_motu_clock_source src;
|
if (motu->spec == &snd_motu_spec_828mk2) {
|
||||||
|
// 828mkII implements Altera ACEX 1K EP1K30. Nothing to do.
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
__be32 reg;
|
__be32 reg;
|
||||||
u32 data;
|
u32 data;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
// 828mkII implements Altera ACEX 1K EP1K30. Nothing to do.
|
err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET,
|
||||||
if (motu->spec == &snd_motu_spec_828mk2)
|
®, sizeof(reg));
|
||||||
return 0;
|
|
||||||
|
|
||||||
err = snd_motu_transaction_read(motu, V2_CLOCK_STATUS_OFFSET, ®,
|
|
||||||
sizeof(reg));
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
data = be32_to_cpu(reg);
|
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);
|
data &= ~(V2_CLOCK_FETCH_ENABLE | V2_CLOCK_MODEL_SPECIFIC);
|
||||||
if (enable)
|
if (enable)
|
||||||
data |= V2_CLOCK_FETCH_ENABLE;
|
data |= V2_CLOCK_FETCH_ENABLE;
|
||||||
|
|
||||||
if (motu->spec == &snd_motu_spec_traveler) {
|
if (motu->spec == &snd_motu_spec_traveler)
|
||||||
// Expected for Traveler and 896HD, which implements Altera
|
err = switch_fetching_mode_cyclone(motu, &data, enable);
|
||||||
// Cyclone EP1C3.
|
else
|
||||||
data |= V2_CLOCK_MODEL_SPECIFIC;
|
err = switch_fetching_mode_spartan(motu, &data, enable);
|
||||||
} else {
|
|
||||||
// For UltraLite and 8pre, which implements Xilinx Spartan
|
|
||||||
// XC3S200.
|
|
||||||
unsigned int rate;
|
|
||||||
|
|
||||||
err = get_clock_rate(data, &rate);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (src == SND_MOTU_CLOCK_SOURCE_SPH && rate > 48000)
|
|
||||||
data |= V2_CLOCK_MODEL_SPECIFIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
reg = cpu_to_be32(data);
|
reg = cpu_to_be32(data);
|
||||||
return snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET, ®,
|
return snd_motu_transaction_write(motu, V2_CLOCK_STATUS_OFFSET,
|
||||||
sizeof(reg));
|
®, sizeof(reg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int detect_packet_formats_828mk2(struct snd_motu *motu, u32 data)
|
static int detect_packet_formats_828mk2(struct snd_motu *motu, u32 data)
|
||||||
|
Loading…
Reference in New Issue
Block a user