diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2018-12-16 11:32:30 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-12-16 12:18:25 +0300 |
commit | 76ea46887729d0765b1fd39291a69c2c6781ada0 (patch) | |
tree | abe9281f7614100aa7c9808c961a7880383bd6ac /sound/firewire/fireface/ff-stream.c | |
parent | d4a0b6cbf26ce7c22bcb070595957590736fec85 (diff) | |
download | linux-76ea46887729d0765b1fd39291a69c2c6781ada0.tar.xz |
ALSA: fireface: code refactoring to handle multiplier mode
Fireface 400/800 use three modes against the number of data channels in
data block for both tx/rx packets.
This commit adds refactoring for it. Some enumerators are added to
represent each of mode and a function is added to calculate the mode
from sampling frequency code (sfc).
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/fireface/ff-stream.c')
-rw-r--r-- | sound/firewire/fireface/ff-stream.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/firewire/fireface/ff-stream.c b/sound/firewire/fireface/ff-stream.c index e6fa6362dab7..e6a8229a9d82 100644 --- a/sound/firewire/fireface/ff-stream.c +++ b/sound/firewire/fireface/ff-stream.c @@ -10,19 +10,23 @@ #define CALLBACK_TIMEOUT_MS 200 -static int get_rate_mode(unsigned int rate, unsigned int *mode) +int snd_ff_stream_get_multiplier_mode(enum cip_sfc sfc, + enum snd_ff_stream_mode *mode) { - int i; - - for (i = 0; i < CIP_SFC_COUNT; i++) { - if (amdtp_rate_table[i] == rate) - break; - } - - if (i == CIP_SFC_COUNT) + static const enum snd_ff_stream_mode modes[] = { + [CIP_SFC_32000] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_44100] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_48000] = SND_FF_STREAM_MODE_LOW, + [CIP_SFC_88200] = SND_FF_STREAM_MODE_MID, + [CIP_SFC_96000] = SND_FF_STREAM_MODE_MID, + [CIP_SFC_176400] = SND_FF_STREAM_MODE_HIGH, + [CIP_SFC_192000] = SND_FF_STREAM_MODE_HIGH, + }; + + if (sfc >= CIP_SFC_COUNT) return -EINVAL; - *mode = ((int)i - 1) / 2; + *mode = modes[sfc]; return 0; } @@ -33,10 +37,18 @@ static int get_rate_mode(unsigned int rate, unsigned int *mode) */ static int keep_resources(struct snd_ff *ff, unsigned int rate) { - int mode; + enum snd_ff_stream_mode mode; + int i; int err; - err = get_rate_mode(rate, &mode); + for (i = 0; i < CIP_SFC_COUNT; ++i) { + if (amdtp_rate_table[i] == rate) + break; + } + if (i == CIP_SFC_COUNT) + return -EINVAL; + + err = snd_ff_stream_get_multiplier_mode(i, &mode); if (err < 0) return err; @@ -81,7 +93,7 @@ static int switch_fetching_mode(struct snd_ff *ff, bool enable) int err; count = 0; - for (i = 0; i < SND_FF_STREAM_MODES; ++i) + for (i = 0; i < SND_FF_STREAM_MODE_COUNT; ++i) count = max(count, ff->spec->pcm_playback_channels[i]); reg = kcalloc(count, sizeof(__le32), GFP_KERNEL); |