Commit dffb360e authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode

When McBSP is configured in threshold mode we can use sDMA packet mode in
all cases.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: default avatarJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 2dde5b90
...@@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream) ...@@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
*/ */
if (dma_data->packet_size) if (dma_data->packet_size)
words = dma_data->packet_size; words = dma_data->packet_size;
else if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
words = snd_pcm_lib_period_bytes(substream) /
(mcbsp->wlen / 8);
else else
words = 1; words = 1;
...@@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
dma_data->set_threshold = omap_mcbsp_set_threshold; dma_data->set_threshold = omap_mcbsp_set_threshold;
if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
int period_words, max_thrsh; int period_words, max_thrsh;
int divider = 0;
period_words = params_period_bytes(params) / (wlen / 8); period_words = params_period_bytes(params) / (wlen / 8);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
...@@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
else else
max_thrsh = mcbsp->max_rx_thres; max_thrsh = mcbsp->max_rx_thres;
/* /*
* If the period contains less or equal number of words, * Use sDMA packet mode if McBSP is in threshold mode:
* we are using the original threshold mode setup: * If period words less than the FIFO size the packet
* McBSP threshold = sDMA frame size = period_size * size is set to the number of period words, otherwise
* Otherwise we switch to sDMA packet mode: * Look for the biggest threshold value which divides
* McBSP threshold = sDMA packet size * the period size evenly.
* sDMA frame size = period size
*/ */
if (period_words > max_thrsh) { divider = period_words / max_thrsh;
int divider = 0; if (period_words % max_thrsh)
divider++;
/* while (period_words % divider &&
* Look for the biggest threshold value, which divider < period_words)
* divides the period size evenly. divider++;
*/ if (divider == period_words)
divider = period_words / max_thrsh; return -EINVAL;
if (period_words % max_thrsh)
divider++; pkt_size = period_words / divider;
while (period_words % divider && sync_mode = OMAP_DMA_SYNC_PACKET;
divider < period_words)
divider++;
if (divider == period_words)
return -EINVAL;
pkt_size = period_words / divider;
sync_mode = OMAP_DMA_SYNC_PACKET;
} else {
sync_mode = OMAP_DMA_SYNC_FRAME;
}
} else if (channels > 1) { } else if (channels > 1) {
/* Use packet mode for non mono streams */ /* Use packet mode for non mono streams */
pkt_size = channels; pkt_size = channels;
......
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