Commit a655f75c authored by Takashi Iwai's avatar Takashi Iwai

ALSA: pcm_dmaengine: Remove hardcoded PCM formats

Use the standard PCM helper function to figure out the sample bytes
instead of hardcodec PCM format checks in
snd_hwparams_to_dma_slave_config().

The patch also extends the format check for 8 bytes formats although
no one should match so far.
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent afb5a779
...@@ -63,23 +63,19 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, ...@@ -63,23 +63,19 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream,
struct dma_slave_config *slave_config) struct dma_slave_config *slave_config)
{ {
enum dma_slave_buswidth buswidth; enum dma_slave_buswidth buswidth;
int bits;
switch (params_format(params)) { bits = snd_pcm_format_physical_width(params_format(params));
case SNDRV_PCM_FORMAT_S8: if (bits < 8 || bits > 64)
return -EINVAL;
else if (bits == 8)
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
break; else if (bits == 16)
case SNDRV_PCM_FORMAT_S16_LE:
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
break; else if (bits <= 32)
case SNDRV_PCM_FORMAT_S18_3LE:
case SNDRV_PCM_FORMAT_S20_3LE:
case SNDRV_PCM_FORMAT_S24_LE:
case SNDRV_PCM_FORMAT_S32_LE:
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
break; else
default: buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES;
return -EINVAL;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
slave_config->direction = DMA_MEM_TO_DEV; slave_config->direction = DMA_MEM_TO_DEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment