Skip to content

Commit

Permalink
ASoC: davinci-mcasp: Code cleanup in davinci_mcasp_hw_params()
Browse files Browse the repository at this point in the history
Rearrange the code in the function for readability.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Peter Ujfalusi authored and Mark Brown committed Feb 3, 2014
1 parent 135014a commit a7e46bd
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions sound/soc/davinci/davinci-mcasp.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,8 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
u8 fifo_level;
u8 slots = mcasp->tdm_slots;
u8 active_serializers;
int channels;
int channels = params_channels(params);
int ret;
struct snd_interval *pcm_channels = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS);

/* If mcasp is BCLK master we need to set BCLK divider */
if (mcasp->bclk_master) {
Expand All @@ -627,19 +625,10 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
cpu_dai, 1, mcasp->sysclk_freq / bclk_freq);
}

channels = pcm_channels->min;

active_serializers = (channels + slots - 1) / slots;

ret = mcasp_common_hw_param(mcasp, substream->stream, channels);
if (ret)
return ret;

if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
fifo_level = mcasp->txnumevt * active_serializers;
else
fifo_level = mcasp->rxnumevt * active_serializers;

if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
ret = mcasp_dit_hw_param(mcasp);
else
Expand Down Expand Up @@ -680,6 +669,13 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}

/* Calculate FIFO level */
active_serializers = (channels + slots - 1) / slots;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
fifo_level = mcasp->txnumevt * active_serializers;
else
fifo_level = mcasp->rxnumevt * active_serializers;

if (mcasp->version == MCASP_VERSION_2 && !fifo_level)
dma_params->acnt = 4;
else
Expand Down

0 comments on commit a7e46bd

Please sign in to comment.