diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-10-25 10:33:12 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-10-28 05:18:09 -0400 |
commit | a655f75c7502e5000c8745f458d3dbb9777f4aca (patch) | |
tree | 42b8ce7964a83f932a6ee95cc53c3753bebb648e /sound/core | |
parent | afb5a7793144179bfd856e3c928b69c43e2a1d8a (diff) |
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: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r-- | sound/core/pcm_dmaengine.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c index aa924d9b7986..94d08733cb38 100644 --- a/sound/core/pcm_dmaengine.c +++ b/sound/core/pcm_dmaengine.c | |||
@@ -63,23 +63,19 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, | |||
63 | struct dma_slave_config *slave_config) | 63 | struct dma_slave_config *slave_config) |
64 | { | 64 | { |
65 | enum dma_slave_buswidth buswidth; | 65 | enum dma_slave_buswidth buswidth; |
66 | int bits; | ||
66 | 67 | ||
67 | switch (params_format(params)) { | 68 | bits = snd_pcm_format_physical_width(params_format(params)); |
68 | case SNDRV_PCM_FORMAT_S8: | 69 | if (bits < 8 || bits > 64) |
70 | return -EINVAL; | ||
71 | else if (bits == 8) | ||
69 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; | 72 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; |
70 | break; | 73 | else if (bits == 16) |
71 | case SNDRV_PCM_FORMAT_S16_LE: | ||
72 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; | 74 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; |
73 | break; | 75 | else if (bits <= 32) |
74 | case SNDRV_PCM_FORMAT_S18_3LE: | ||
75 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
76 | case SNDRV_PCM_FORMAT_S24_LE: | ||
77 | case SNDRV_PCM_FORMAT_S32_LE: | ||
78 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; | 76 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; |
79 | break; | 77 | else |
80 | default: | 78 | buswidth = DMA_SLAVE_BUSWIDTH_8_BYTES; |
81 | return -EINVAL; | ||
82 | } | ||
83 | 79 | ||
84 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 80 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
85 | slave_config->direction = DMA_MEM_TO_DEV; | 81 | slave_config->direction = DMA_MEM_TO_DEV; |