From: Eduardo Valentin <eduardo.valentin@nokia.com>
To: Linux-OMAP <linux-omap@vger.kernel.org>,
ALSA-Devel <alsa-devel@vger.kernel.org>
Cc: Jarkko Nikula <jhnikula@gmail.com>,
"\\\"Ujfalusi Peter (Nokia-D/Tampere)\\\""
<peter.ujfalusi@nokia.com>,
"Nurkkala Eero.An (EXT-Offcode/Oulu)"
<ext-Eero.Nurkkala@nokia.com>,
Eduardo Valentin <eduardo.valentin@nokia.com>
Subject: [PATCHv3 19/20] ASoC: OMAP: Use McBSP threshold to playback and capture
Date: Thu, 13 Aug 2009 17:35:32 +0300 [thread overview]
Message-ID: <1250174133-451-20-git-send-email-eduardo.valentin@nokia.com> (raw)
In-Reply-To: <1250174133-451-19-git-send-email-eduardo.valentin@nokia.com>
This patch changes the way DMA is done in omap-pcm.c
in order to reduce power consumption. There is no need
to have so much SW control in order to have DMA in idle
state during audio streaming. Configuring McBSP threshold value
and DMA to FRAME_SYNC are sufficient.
Signed-off-by: Eduardo Valentin <eduardo.valentin@nokia.com>
---
sound/soc/omap/omap-mcbsp.c | 47 +++++++++++++++++++++++++++++++++++++-----
sound/soc/omap/omap-pcm.c | 7 +++++-
sound/soc/omap/omap-pcm.h | 2 +
3 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index 0272d3f..8a7b5ef 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -139,28 +139,59 @@ static const unsigned long omap34xx_mcbsp_port[][2] = {
static const unsigned long omap34xx_mcbsp_port[][2] = {};
#endif
+static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+ struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
+ int samples = snd_pcm_lib_period_bytes(substream) >> 1;
+
+ /* Configure McBSP internal buffer usage */
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ omap_mcbsp_set_tx_threshold(mcbsp_data->bus_id, samples - 1);
+ else
+ omap_mcbsp_set_rx_threshold(mcbsp_data->bus_id, samples - 1);
+}
+
static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
+ int bus_id = mcbsp_data->bus_id;
int err = 0;
- if (cpu_is_omap343x() && mcbsp_data->bus_id == 1) {
+ if (!cpu_dai->active)
+ err = omap_mcbsp_request(bus_id);
+
+ if (cpu_is_omap343x()) {
+ int max_period;
+
/*
* McBSP2 in OMAP3 has 1024 * 32-bit internal audio buffer.
* Set constraint for minimum buffer size to the same than FIFO
* size in order to avoid underruns in playback startup because
* HW is keeping the DMA request active until FIFO is filled.
*/
+ if (bus_id == 1)
+ snd_pcm_hw_constraint_minmax(substream->runtime,
+ SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
+ 4096, UINT_MAX);
+
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+ max_period = omap_mcbsp_get_max_tx_threshold(bus_id);
+ else
+ max_period = omap_mcbsp_get_max_rx_threshold(bus_id);
+
+ max_period++;
+ max_period <<= 1;
+
snd_pcm_hw_constraint_minmax(substream->runtime,
- SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 4096, UINT_MAX);
+ SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
+ 32, max_period);
}
- if (!cpu_dai->active)
- err = omap_mcbsp_request(mcbsp_data->bus_id);
-
return err;
}
@@ -220,7 +251,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
struct omap_mcbsp_reg_cfg *regs = &mcbsp_data->regs;
int dma, bus_id = mcbsp_data->bus_id, id = cpu_dai->id;
- int wlen, channels, wpf;
+ int wlen, channels, wpf, sync_mode = OMAP_DMA_SYNC_ELEMENT;
unsigned long port;
unsigned int format;
@@ -236,6 +267,9 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
} else if (cpu_is_omap343x()) {
dma = omap24xx_dma_reqs[bus_id][substream->stream];
port = omap34xx_mcbsp_port[bus_id][substream->stream];
+ omap_mcbsp_dai_dma_params[id][substream->stream].set_threshold =
+ omap_mcbsp_set_threshold;
+ sync_mode = OMAP_DMA_SYNC_FRAME;
} else {
return -ENODEV;
}
@@ -243,6 +277,7 @@ static int omap_mcbsp_dai_hw_params(struct snd_pcm_substream *substream,
substream->stream ? "Audio Capture" : "Audio Playback";
omap_mcbsp_dai_dma_params[id][substream->stream].dma_req = dma;
omap_mcbsp_dai_dma_params[id][substream->stream].port_addr = port;
+ omap_mcbsp_dai_dma_params[id][substream->stream].sync_mode = sync_mode;
cpu_dai->dma_data = &omap_mcbsp_dai_dma_params[id][substream->stream];
if (mcbsp_data->configured) {
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index 5d41371..5e24e08 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -148,7 +148,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream)
*/
dma_params.data_type = OMAP_DMA_DATA_TYPE_S16;
dma_params.trigger = dma_data->dma_req;
- dma_params.sync_mode = OMAP_DMA_SYNC_ELEMENT;
+ dma_params.sync_mode = dma_data->sync_mode;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
dma_params.src_amode = OMAP_DMA_AMODE_POST_INC;
dma_params.dst_amode = OMAP_DMA_AMODE_CONSTANT;
@@ -186,6 +186,7 @@ static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct omap_runtime_data *prtd = runtime->private_data;
+ struct omap_pcm_dma_data *dma_data = prtd->dma_data;
unsigned long flags;
int ret = 0;
@@ -195,6 +196,10 @@ static int omap_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
prtd->period_index = 0;
+ /* Configure McBSP internal buffer usage */
+ if (dma_data->set_threshold)
+ dma_data->set_threshold(substream);
+
omap_start_dma(prtd->dma_ch);
break;
diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h
index 8d9d269..38a821d 100644
--- a/sound/soc/omap/omap-pcm.h
+++ b/sound/soc/omap/omap-pcm.h
@@ -29,6 +29,8 @@ struct omap_pcm_dma_data {
char *name; /* stream identifier */
int dma_req; /* DMA request line */
unsigned long port_addr; /* transmit/receive register */
+ int sync_mode; /* DMA sync mode */
+ void (*set_threshold)(struct snd_pcm_substream *substream);
};
extern struct snd_soc_platform omap_soc_platform;
--
1.6.2.GIT
next prev parent reply other threads:[~2009-08-13 14:48 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-13 14:35 [PATCHv3 00/20] OMAP ASoC changes in DMA utilization Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 01/20] OMAP: McBSP: Provide functions for ASoC frame syncronization Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 02/20] OMAP: McBSP: Add IRQEN, IRQSTATUS, THRESHOLD2 and THRESHOLD1 registers Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 03/20] OMAP: McBSP: Use appropriate value for startup delay Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 04/20] OMAP: McBSP: Add transmit/receive threshold handler Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 05/20] OMAP: McBSP: Create and export max_(r|t)x_thres property Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 06/20] OMAP3: McBSP: Lower the maximum buffersize for McBSP1, 3, 4, 5 Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 06/20] OMAP3: McBSP: Lower the maximum buffersize for McBSP1,3,4,5 Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 07/20] OMAP: McBSP: Rename thres sysfs symbols Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 08/20] OMAP: McBSP: Add link DMA mode selection Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 09/20] OMAP: McBSP: Wakeups utilized Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 10/20] OMAP: McBSP: Change wakeup signals Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 11/20] OMAP: McBSP: Retain McBSP FCLK clockactivity Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 12/20] OMAP: McBSP: Configure NO IDLE mode for DMA mode different of threshold Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 13/20] OMAP: McBSP: Do not enable wakeups for no-idle mode Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 14/20] OMAP: McBSP: Let element DMA mode hit retention also Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 15/20] ASoC: OMAP: Make DMA 64 aligned Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 16/20] ASoC: OMAP: Enable DMA burst mode Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 17/20] ASoC: Add runtime check for RFIG and XFIG Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 18/20] ASoC: Always syncronize audio transfers on frames Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 19/20] ASoC: OMAP: Use McBSP threshold to playback and capture Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin [this message]
2009-08-13 14:35 ` [PATCHv3 20/20] ASoC: OMAP: Use DMA operating mode of McBSP Eduardo Valentin
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 18/20] ASoC: Always syncronize audio transfers on frames Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 17/20] ASoC: Add runtime check for RFIG and XFIG Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 15/20] ASoC: OMAP: Make DMA 64 aligned Eduardo Valentin
2009-08-14 3:19 ` [PATCHv3 14/20] OMAP: McBSP: Let element DMA mode hit retention also Woodruff, Richard
2009-08-14 4:40 ` Eero Nurkkala
2009-08-14 4:40 ` Eero Nurkkala
2009-08-13 14:35 ` Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 12/20] OMAP: McBSP: Configure NO IDLE mode for DMA mode different of threshold Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 11/20] OMAP: McBSP: Retain McBSP FCLK clockactivity Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 09/20] OMAP: McBSP: Wakeups utilized Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 02/20] OMAP: McBSP: Add IRQEN, IRQSTATUS, THRESHOLD2 and THRESHOLD1 registers Eduardo Valentin
2009-08-13 14:35 ` [PATCHv3 01/20] OMAP: McBSP: Provide functions for ASoC frame syncronization Eduardo Valentin
2009-08-17 8:22 ` [PATCHv3 00/20] OMAP ASoC changes in DMA utilization Peter Ujfalusi
2009-08-17 9:07 ` Jarkko Nikula
2009-08-17 11:36 ` Eduardo Valentin
2009-08-17 11:52 ` Mark Brown
2009-08-17 11:45 ` Eduardo Valentin
2009-08-17 11:36 ` Eduardo Valentin
2009-08-17 9:07 ` Jarkko Nikula
2009-08-17 8:22 ` Peter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250174133-451-20-git-send-email-eduardo.valentin@nokia.com \
--to=eduardo.valentin@nokia.com \
--cc=alsa-devel@vger.kernel.org \
--cc=ext-Eero.Nurkkala@nokia.com \
--cc=jhnikula@gmail.com \
--cc=linux-omap@vger.kernel.org \
--cc=peter.ujfalusi@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.