ALSA: firewire-motu: refactoring protocol v2 for clock source getter

This commit splits the method to get clock source 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-13-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Sakamoto 2020-05-19 20:16:39 +09:00 committed by Takashi Iwai
parent 739bdbaec7
commit 2b8f050e4e

View File

@ -78,14 +78,10 @@ int snd_motu_protocol_v2_set_clock_rate(struct snd_motu *motu,
sizeof(reg));
}
static int get_clock_source(struct snd_motu *motu, u32 data,
enum snd_motu_clock_source *src)
static int detect_clock_source_optical_model(struct snd_motu *motu, u32 data,
enum snd_motu_clock_source *src)
{
unsigned int index = data & V2_CLOCK_SRC_MASK;
if (index > 5)
return -EIO;
switch (index) {
switch (data) {
case 0:
*src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
break;
@ -118,12 +114,48 @@ static int get_clock_source(struct snd_motu *motu, u32 data,
*src = SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB;
break;
default:
return -EIO;
*src = SND_MOTU_CLOCK_SOURCE_UNKNOWN;
break;
}
return 0;
}
static int v2_detect_clock_source(struct snd_motu *motu, u32 data,
enum snd_motu_clock_source *src)
{
switch (data) {
case 0:
*src = SND_MOTU_CLOCK_SOURCE_INTERNAL;
break;
case 2:
*src = SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX;
break;
case 3:
*src = SND_MOTU_CLOCK_SOURCE_SPH;
break;
case 4:
*src = SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC;
break;
default:
*src = SND_MOTU_CLOCK_SOURCE_UNKNOWN;
break;
}
return 0;
}
static int get_clock_source(struct snd_motu *motu, u32 data,
enum snd_motu_clock_source *src)
{
data &= V2_CLOCK_SRC_MASK;
if (motu->spec == &snd_motu_spec_828mk2 ||
motu->spec == &snd_motu_spec_traveler)
return detect_clock_source_optical_model(motu, data, src);
else
return v2_detect_clock_source(motu, data, src);
}
int snd_motu_protocol_v2_get_clock_source(struct snd_motu *motu,
enum snd_motu_clock_source *src)
{