ASoC: omap-mcbsp: dma_op_mode changes
cover 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(-)
Signature · 1 line
1.7.8.5
PATCH 1/2 ASoC: omap-mcbsp: Use DMA packet mode for non mono streams on OMAP3+
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.
--- sound/soc/omap/omap-mcbsp.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
sound/soc/omap/omap-mcbsp.c +17 -13
@@ -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 */
Signature · 1 line
1.7.8.5
Re: [PATCH 1/2] ASoC: omap-mcbsp: Use DMA packet mode for non mono streams on OMAP3+
Quoted 10 lines · Peter Ujfalusi
Take the DMA packet mode into use when the McBSP is configured in element
dma_op_modeif 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 <[email protected]>--- 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 :-)
Signature · 1 line
Jarkko
Re: [PATCH 1/2] ASoC: omap-mcbsp: Use DMA packet mode for non mono streams on OMAP3+
Hi Jarkko,
Quoted 2 lines · Jarkko Nikula
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.
Quoted 3 lines
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.
Signature · 1 line
Péter
PATCH 2/2 ASoC: omap-mcbsp: Remove unused FRAME dma_op_mode
In reply to Peter UjfalusiThe frame dma_op_mode has never been used, and it is just creating confusion for users/developers.
--- 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(-)
sound/soc/omap/mcbsp.c +1 -1
@@ -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,
sound/soc/omap/mcbsp.h +0 -1
@@ -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)
sound/soc/omap/omap-mcbsp.c +0 -1
@@ -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;
Signature · 1 line
1.7.8.5
Quoted 4 lines · Peter Ujfalusi
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
Jarkko Nikula
Acked-byQuoted 9 lines · Mark Brown
Quoted 4 lines · Peter Ujfalusi
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 <[email protected]>