From 55799c5ab99e8762e58c387e39f9fa36e8f14158 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Thu, 8 Jun 2017 09:11:03 +0900 Subject: ALSA: firewire: arrange common PCM info/constraints for AMDTP engine applications In ALSA firewire stack, 8 drivers uses IEC 61883-1/6 engine for data transmission. They have common PCM info/constraints and duplicated codes. This commit unifies the codes into fireiwre-lib. Signed-off-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/firewire/digi00x/digi00x-pcm.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'sound/firewire/digi00x') diff --git a/sound/firewire/digi00x/digi00x-pcm.c b/sound/firewire/digi00x/digi00x-pcm.c index f76cf5e383db..796f4b4645f5 100644 --- a/sound/firewire/digi00x/digi00x-pcm.c +++ b/sound/firewire/digi00x/digi00x-pcm.c @@ -58,31 +58,11 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, static int pcm_init_hw_params(struct snd_dg00x *dg00x, struct snd_pcm_substream *substream) { - static const struct snd_pcm_hardware hardware = { - .info = SNDRV_PCM_INFO_BATCH | - SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_JOINT_DUPLEX | - SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID, - .rates = SNDRV_PCM_RATE_44100 | - SNDRV_PCM_RATE_48000 | - SNDRV_PCM_RATE_88200 | - SNDRV_PCM_RATE_96000, - .rate_min = 44100, - .rate_max = 96000, - .channels_min = 10, - .channels_max = 18, - .period_bytes_min = 4 * 18, - .period_bytes_max = 4 * 18 * 2048, - .buffer_bytes_max = 4 * 18 * 2048 * 2, - .periods_min = 2, - .periods_max = UINT_MAX, - }; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_hardware *hw = &runtime->hw; struct amdtp_stream *s; int err; - substream->runtime->hw = hardware; if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { substream->runtime->hw.formats = SNDRV_PCM_FMTBIT_S32; @@ -92,6 +72,15 @@ static int pcm_init_hw_params(struct snd_dg00x *dg00x, s = &dg00x->rx_stream; } + hw->channels_min = 10; + hw->channels_max = 18; + + hw->rates = SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_88200 | + SNDRV_PCM_RATE_96000; + snd_pcm_limit_hw_rates(runtime); + err = snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, hw_rule_channels, NULL, -- cgit v1.2.3