* [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data
@ 2010-02-25 12:52 Mark Brown
2010-02-25 12:52 ` [PATCH 2/2] ASoC: Check progress when reporting periods from i.MX FIQ handler Mark Brown
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mark Brown @ 2010-02-25 12:52 UTC (permalink / raw)
To: alsa-devel; +Cc: Sascha Hauer, Mark Brown, Liam Girdwood
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/imx/imx-pcm-fiq.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c
index 5532579..a1c4ce6 100644
--- a/sound/soc/imx/imx-pcm-fiq.c
+++ b/sound/soc/imx/imx-pcm-fiq.c
@@ -35,12 +35,8 @@
struct imx_pcm_runtime_data {
int period;
int periods;
- unsigned long dma_addr;
- int dma;
unsigned long offset;
unsigned long size;
- unsigned long period_cnt;
- void *buf;
struct timer_list timer;
int period_time;
};
--
1.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: Check progress when reporting periods from i.MX FIQ handler
2010-02-25 12:52 [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Mark Brown
@ 2010-02-25 12:52 ` Mark Brown
2010-02-25 12:57 ` [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Liam Girdwood
2010-02-25 14:59 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2010-02-25 12:52 UTC (permalink / raw)
To: alsa-devel; +Cc: Sascha Hauer, Mark Brown, Liam Girdwood
Currently the i.MX FIQ handler is reporting periods as elapsed based
purely on a timer running in the CPU. This means that any clock
mismatch between the CPU and the audio subsystem can result in the
status reported to applications drifting away from the actual status
of the hardware. This is particularly likely at present since the
SSI driver is only capable of operating in slave mode so it's very
likely that the interface will be clocked from a different source.
Instead check the offset reported by the FIQ and only notify when we
have transferred at least one period, re-firing the timer if we didn't
do so. Also factor out the calculation of the timer expiry time for
make it a bit easier to experiment with.
Note that this only improves the situation, problems can still be
triggered.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/imx/imx-pcm-fiq.c | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c
index a1c4ce6..d9cb984 100644
--- a/sound/soc/imx/imx-pcm-fiq.c
+++ b/sound/soc/imx/imx-pcm-fiq.c
@@ -36,17 +36,24 @@ struct imx_pcm_runtime_data {
int period;
int periods;
unsigned long offset;
+ unsigned long last_offset;
unsigned long size;
struct timer_list timer;
- int period_time;
+ int poll_time;
};
+static inline void imx_ssi_set_next_poll(struct imx_pcm_runtime_data *iprtd)
+{
+ iprtd->timer.expires = jiffies + iprtd->poll_time;
+}
+
static void imx_ssi_timer_callback(unsigned long data)
{
struct snd_pcm_substream *substream = (void *)data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct imx_pcm_runtime_data *iprtd = runtime->private_data;
struct pt_regs regs;
+ unsigned long delta;
get_fiq_regs(®s);
@@ -55,9 +62,25 @@ static void imx_ssi_timer_callback(unsigned long data)
else
iprtd->offset = regs.ARM_r9 & 0xffff;
- iprtd->timer.expires = jiffies + iprtd->period_time;
+ /* How much data have we transferred since the last period report? */
+ if (iprtd->offset >= iprtd->last_offset)
+ delta = iprtd->offset - iprtd->last_offset;
+ else
+ delta = runtime->buffer_size + iprtd->offset
+ - iprtd->last_offset;
+
+ /* If we've transferred at least a period then report it and
+ * reset our poll time */
+ if (delta >= runtime->period_size) {
+ snd_pcm_period_elapsed(substream);
+ iprtd->last_offset = iprtd->offset;
+
+ imx_ssi_set_next_poll(iprtd);
+ }
+
+ /* Restart the timer; if we didn't report we'll run on the next tick */
add_timer(&iprtd->timer);
- snd_pcm_period_elapsed(substream);
+
}
static struct fiq_handler fh = {
@@ -72,9 +95,10 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
iprtd->size = params_buffer_bytes(params);
iprtd->periods = params_periods(params);
- iprtd->period = params_period_bytes(params);
+ iprtd->period = params_period_bytes(params) ;
iprtd->offset = 0;
- iprtd->period_time = HZ / (params_rate(params) / params_period_size(params));
+ iprtd->last_offset = 0;
+ iprtd->poll_time = HZ / (params_rate(params) / params_period_size(params));
snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
@@ -110,7 +134,7 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
- iprtd->timer.expires = jiffies + iprtd->period_time;
+ imx_ssi_set_next_poll(iprtd);
add_timer(&iprtd->timer);
if (++fiq_enable == 1)
enable_fiq(imx_pcm_fiq);
--
1.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data
2010-02-25 12:52 [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Mark Brown
2010-02-25 12:52 ` [PATCH 2/2] ASoC: Check progress when reporting periods from i.MX FIQ handler Mark Brown
@ 2010-02-25 12:57 ` Liam Girdwood
2010-02-25 14:59 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-02-25 12:57 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Sascha Hauer
On Thu, 2010-02-25 at 12:52 +0000, Mark Brown wrote:
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Both Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data
2010-02-25 12:52 [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Mark Brown
2010-02-25 12:52 ` [PATCH 2/2] ASoC: Check progress when reporting periods from i.MX FIQ handler Mark Brown
2010-02-25 12:57 ` [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Liam Girdwood
@ 2010-02-25 14:59 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2010-02-25 14:59 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Liam Girdwood
On Thu, Feb 25, 2010 at 12:52:09PM +0000, Mark Brown wrote:
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
both
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> sound/soc/imx/imx-pcm-fiq.c | 4 ----
> 1 files changed, 0 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c
> index 5532579..a1c4ce6 100644
> --- a/sound/soc/imx/imx-pcm-fiq.c
> +++ b/sound/soc/imx/imx-pcm-fiq.c
> @@ -35,12 +35,8 @@
> struct imx_pcm_runtime_data {
> int period;
> int periods;
> - unsigned long dma_addr;
> - int dma;
> unsigned long offset;
> unsigned long size;
> - unsigned long period_cnt;
> - void *buf;
> struct timer_list timer;
> int period_time;
> };
> --
> 1.7.0
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-25 14:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 12:52 [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Mark Brown
2010-02-25 12:52 ` [PATCH 2/2] ASoC: Check progress when reporting periods from i.MX FIQ handler Mark Brown
2010-02-25 12:57 ` [PATCH 1/2] ASoC: Remove a unused variables from i.MX FIQ runtime data Liam Girdwood
2010-02-25 14:59 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).