ASoC: omap-mcbsp: Use sDMA packet mode instead of frame mode
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Fri, 14 Sep 2012 12:05:49 +0000 (15:05 +0300)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 22 Sep 2012 15:12:57 +0000 (11:12 -0400)
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>
sound/soc/omap/omap-mcbsp.c

index 2e91a86b6114eea9aa7af0699a28a7197f03ef38..fe3debcc2d0ba9bce2784d5d6b067b90ba7dcf82 100644 (file)
@@ -81,9 +81,6 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
         */
        if (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
                words = 1;
 
@@ -251,6 +248,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
                dma_data->set_threshold = omap_mcbsp_set_threshold;
                if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
                        int period_words, max_thrsh;
+                       int divider = 0;
 
                        period_words = params_period_bytes(params) / (wlen / 8);
                        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
@@ -258,34 +256,23 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
                        else
                                max_thrsh = mcbsp->max_rx_thres;
                        /*
-                        * If the period contains less or equal number of words,
-                        * we are using the original threshold mode setup:
-                        * McBSP threshold = sDMA frame size = period_size
-                        * Otherwise we switch to sDMA packet mode:
-                        * McBSP threshold = sDMA packet size
-                        * sDMA frame size = period size
+                        * Use sDMA packet mode if McBSP is in threshold mode:
+                        * If period words less than the FIFO size the packet
+                        * size is set to the number of period words, otherwise
+                        * Look for the biggest threshold value which divides
+                        * the period size evenly.
                         */
-                       if (period_words > max_thrsh) {
-                               int divider = 0;
-
-                               /*
-                                * Look for the biggest threshold value, which
-                                * divides the period size evenly.
-                                */
-                               divider = period_words / max_thrsh;
-                               if (period_words % max_thrsh)
-                                       divider++;
-                               while (period_words % divider &&
-                                       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;
-                       }
+                       divider = period_words / max_thrsh;
+                       if (period_words % max_thrsh)
+                               divider++;
+                       while (period_words % divider &&
+                               divider < period_words)
+                               divider++;
+                       if (divider == period_words)
+                               return -EINVAL;
+
+                       pkt_size = period_words / divider;
+                       sync_mode = OMAP_DMA_SYNC_PACKET;
                } else if (channels > 1) {
                        /* Use packet mode for non mono streams */
                        pkt_size = channels;