aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-09-14 08:05:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-22 11:12:57 -0400
commitdffb360e64968b95a0a0221ca52234a28cc049c9 (patch)
treea981e452d1bb634a587fc2d8934d1d8dfaea6c3e
parent2dde5b909e117cc95a5e31604f9bfd043e78ad9d (diff)
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: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/omap/omap-mcbsp.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 2e91a86b6114..fe3debcc2d0b 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
81 */ 81 */
82 if (dma_data->packet_size) 82 if (dma_data->packet_size)
83 words = dma_data->packet_size; 83 words = dma_data->packet_size;
84 else if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
85 words = snd_pcm_lib_period_bytes(substream) /
86 (mcbsp->wlen / 8);
87 else 84 else
88 words = 1; 85 words = 1;
89 86
@@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
251 dma_data->set_threshold = omap_mcbsp_set_threshold; 248 dma_data->set_threshold = omap_mcbsp_set_threshold;
252 if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { 249 if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
253 int period_words, max_thrsh; 250 int period_words, max_thrsh;
251 int divider = 0;
254 252
255 period_words = params_period_bytes(params) / (wlen / 8); 253 period_words = params_period_bytes(params) / (wlen / 8);
256 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 254 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
258 else 256 else
259 max_thrsh = mcbsp->max_rx_thres; 257 max_thrsh = mcbsp->max_rx_thres;
260 /* 258 /*
261 * If the period contains less or equal number of words, 259 * Use sDMA packet mode if McBSP is in threshold mode:
262 * we are using the original threshold mode setup: 260 * If period words less than the FIFO size the packet
263 * McBSP threshold = sDMA frame size = period_size 261 * size is set to the number of period words, otherwise
264 * Otherwise we switch to sDMA packet mode: 262 * Look for the biggest threshold value which divides
265 * McBSP threshold = sDMA packet size 263 * the period size evenly.
266 * sDMA frame size = period size
267 */ 264 */
268 if (period_words > max_thrsh) { 265 divider = period_words / max_thrsh;
269 int divider = 0; 266 if (period_words % max_thrsh)
270 267 divider++;
271 /* 268 while (period_words % divider &&
272 * Look for the biggest threshold value, which 269 divider < period_words)
273 * divides the period size evenly. 270 divider++;
274 */ 271 if (divider == period_words)
275 divider = period_words / max_thrsh; 272 return -EINVAL;
276 if (period_words % max_thrsh) 273
277 divider++; 274 pkt_size = period_words / divider;
278 while (period_words % divider && 275 sync_mode = OMAP_DMA_SYNC_PACKET;
279 divider < period_words)
280 divider++;
281 if (divider == period_words)
282 return -EINVAL;
283
284 pkt_size = period_words / divider;
285 sync_mode = OMAP_DMA_SYNC_PACKET;
286 } else {
287 sync_mode = OMAP_DMA_SYNC_FRAME;
288 }
289 } else if (channels > 1) { 276 } else if (channels > 1) {
290 /* Use packet mode for non mono streams */ 277 /* Use packet mode for non mono streams */
291 pkt_size = channels; 278 pkt_size = channels;