diff options
author | Nicolin Chen <Guangyu.Chen@freescale.com> | 2013-12-20 03:41:01 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-12-21 09:47:24 -0500 |
commit | 1d7003092771bd2feec30e2f3e5a06aa33479e08 (patch) | |
tree | d59b9655cff0319ff40c8824d209e6f5a5cfa047 | |
parent | 1fb2d9d7465bcbb519c582fa4a3bd04ff4fce2d2 (diff) |
ASoC: fsl_sai: Use snd_pcm_format_width()
Use common helper function snd_pcm_format_width() to make code neater.
Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Reviewed-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/fsl/fsl_sai.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 69a375f48efe..e68102e63521 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c | |||
@@ -244,9 +244,10 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, | |||
244 | struct snd_pcm_hw_params *params, | 244 | struct snd_pcm_hw_params *params, |
245 | struct snd_soc_dai *cpu_dai) | 245 | struct snd_soc_dai *cpu_dai) |
246 | { | 246 | { |
247 | u32 val_cr4, val_cr5, val_mr, reg_cr4, reg_cr5, reg_mr, word_width; | 247 | u32 val_cr4, val_cr5, val_mr, reg_cr4, reg_cr5, reg_mr; |
248 | unsigned int channels = params_channels(params); | 248 | unsigned int channels = params_channels(params); |
249 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | 249 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); |
250 | u32 word_width = snd_pcm_format_width(params_format(params)); | ||
250 | 251 | ||
251 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 252 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
252 | reg_cr4 = FSL_SAI_TCR4; | 253 | reg_cr4 = FSL_SAI_TCR4; |
@@ -267,20 +268,6 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, | |||
267 | val_cr5 &= ~FSL_SAI_CR5_W0W_MASK; | 268 | val_cr5 &= ~FSL_SAI_CR5_W0W_MASK; |
268 | val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; | 269 | val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; |
269 | 270 | ||
270 | switch (params_format(params)) { | ||
271 | case SNDRV_PCM_FORMAT_S16_LE: | ||
272 | word_width = 16; | ||
273 | break; | ||
274 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
275 | word_width = 20; | ||
276 | break; | ||
277 | case SNDRV_PCM_FORMAT_S24_LE: | ||
278 | word_width = 24; | ||
279 | break; | ||
280 | default: | ||
281 | return -EINVAL; | ||
282 | } | ||
283 | |||
284 | val_cr4 |= FSL_SAI_CR4_SYWD(word_width); | 271 | val_cr4 |= FSL_SAI_CR4_SYWD(word_width); |
285 | val_cr5 |= FSL_SAI_CR5_WNW(word_width); | 272 | val_cr5 |= FSL_SAI_CR5_WNW(word_width); |
286 | val_cr5 |= FSL_SAI_CR5_W0W(word_width); | 273 | val_cr5 |= FSL_SAI_CR5_W0W(word_width); |