[alsa-devel] [PATCH 0/2] ASoC: omap-mcbsp: dma_op_mode changes
Hello,
Removing the frame dm_op_mode, and using packet mode in element mode on OMAP3+ to transfer 1 sample at the time between the McBSP FIFO and memory.
Regards, Peter --- Peter Ujfalusi (2): ASoC: omap-mcbsp: Use DMA packet mode for non mono streams on OMAP3+ ASoC: omap-mcbsp: Remove unused FRAME dma_op_mode
sound/soc/omap/mcbsp.c | 2 +- sound/soc/omap/mcbsp.h | 1 - sound/soc/omap/omap-mcbsp.c | 31 +++++++++++++++++-------------- 3 files changed, 18 insertions(+), 16 deletions(-)
Take the DMA packet mode into use when the McBSP is configured in element dma_op_mode if the stream is not mono. In this way we transfer one sample from/to McBSP FIFO upon DMA request. This change only affects OMAP3+ versions, where the McBSP ports have FIFO.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/omap-mcbsp.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 6912ac7..418dc3c 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -71,18 +71,17 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
- /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ - if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) - /* - * Configure McBSP threshold based on either: - * packet_size, when the sDMA is in packet mode, or - * based on the period size. - */ - if (dma_data->packet_size) - words = dma_data->packet_size; - else - words = snd_pcm_lib_period_bytes(substream) / - (mcbsp->wlen / 8); + /* + * Configure McBSP threshold based on either: + * packet_size, when the sDMA is in packet mode, or based on the + * period size in THRESHOLD mode, otherwise use McBSP threshold = 1 + * for mono streams. + */ + 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;
@@ -230,6 +229,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, unsigned int format, div, framesize, master;
dma_data = &mcbsp->dma_data[substream->stream]; + channels = params_channels(params);
switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: @@ -283,6 +283,10 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, } else { sync_mode = OMAP_DMA_SYNC_FRAME; } + } else if (channels > 1) { + /* Use packet mode for non mono streams */ + pkt_size = channels; + sync_mode = OMAP_DMA_SYNC_PACKET; } }
@@ -301,7 +305,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, regs->rcr1 &= ~(RFRLEN1(0x7f) | RWDLEN1(7)); regs->xcr1 &= ~(XFRLEN1(0x7f) | XWDLEN1(7)); format = mcbsp->fmt & SND_SOC_DAIFMT_FORMAT_MASK; - wpf = channels = params_channels(params); + wpf = channels; if (channels == 2 && (format == SND_SOC_DAIFMT_I2S || format == SND_SOC_DAIFMT_LEFT_J)) { /* Use dual-phase frames */
On 03/15/2012 12:37 PM, Peter Ujfalusi wrote:
Take the DMA packet mode into use when the McBSP is configured in element dma_op_mode if the stream is not mono. In this way we transfer one sample from/to McBSP FIFO upon DMA request. This change only affects OMAP3+ versions, where the McBSP ports have FIFO.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com
sound/soc/omap/omap-mcbsp.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
Out of curiosity, I guess this will decrease a memory bus or DMA controller load a bit. Can you see any difference with the SW tools (top, etc) under some system load or do you need some on-chip observability to be able to measure effect of this transfer pattern change?
Just willing to learn here :-)
Hi Jarkko,
On 03/16/2012 09:00 AM, Jarkko Nikula wrote:
Out of curiosity, I guess this will decrease a memory bus or DMA controller load a bit.
Yes it will slightly decrease the load on those. It will also decrease the number of DMA requests going from McBSP to the sDMA controller.
Can you see any difference with the SW tools (top, etc) under some system load or do you need some on-chip observability to be able to measure effect of this transfer pattern change?
I can not see difference between the old element/packet-element/threshold mode from user space point of view. I think the effect can be seen in an optimized system more. The decreased load on SDRAM/sDMA should help with the performance, less DMA request means less frequent activity, which should decrease power consumption.
Other good thing might be is that now the DMA moves in sample steps, and not in words.
The frame dma_op_mode has never been used, and it is just creating confusion for users/developers.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com --- sound/soc/omap/mcbsp.c | 2 +- sound/soc/omap/mcbsp.h | 1 - sound/soc/omap/omap-mcbsp.c | 1 - 3 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c index e5f4444..ec6832c 100644 --- a/sound/soc/omap/mcbsp.c +++ b/sound/soc/omap/mcbsp.c @@ -754,7 +754,7 @@ THRESHOLD_PROP_BUILDER(max_tx_thres); THRESHOLD_PROP_BUILDER(max_rx_thres);
static const char *dma_op_modes[] = { - "element", "threshold", "frame", + "element", "threshold", };
static ssize_t dma_op_mode_show(struct device *dev, diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h index a944fcc..179a822 100644 --- a/sound/soc/omap/mcbsp.h +++ b/sound/soc/omap/mcbsp.h @@ -217,7 +217,6 @@ enum { /********************** McBSP DMA operating modes **************************/ #define MCBSP_DMA_MODE_ELEMENT 0 #define MCBSP_DMA_MODE_THRESHOLD 1 -#define MCBSP_DMA_MODE_FRAME 2
/********************** McBSP WAKEUPEN bit definitions *********************/ #define RSYNCERREN BIT(0) diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 418dc3c..27144a6 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -245,7 +245,6 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream, } if (mcbsp->pdata->buffer_size) { dma_data->set_threshold = omap_mcbsp_set_threshold; - /* TODO: Currently, MODE_ELEMENT == MODE_FRAME */ if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) { int period_words, max_thrsh;
On Thu, Mar 15, 2012 at 12:37:12PM +0200, Peter Ujfalusi wrote:
Hello,
Removing the frame dm_op_mode, and using packet mode in element mode on OMAP3+ to transfer 1 sample at the time between the McBSP FIFO and memory.
Both
Acked-by: Mark Brown broonie@opensource.wolfsonmicro.com
On 03/15/2012 02:22 PM, Mark Brown wrote:
On Thu, Mar 15, 2012 at 12:37:12PM +0200, Peter Ujfalusi wrote:
Hello,
Removing the frame dm_op_mode, and using packet mode in element mode on OMAP3+ to transfer 1 sample at the time between the McBSP FIFO and memory.
Both
Acked-by: Mark Brown broonie@opensource.wolfsonmicro.com
Acked-by: Jarkko Nikula jarkko.nikula@bitmer.com
participants (3)
-
Jarkko Nikula
-
Mark Brown
-
Peter Ujfalusi