aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/imx/imx-pcm-fiq.c36
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 a1c4ce6ad408..d9cb9849b033 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 {
36 int period; 36 int period;
37 int periods; 37 int periods;
38 unsigned long offset; 38 unsigned long offset;
39 unsigned long last_offset;
39 unsigned long size; 40 unsigned long size;
40 struct timer_list timer; 41 struct timer_list timer;
41 int period_time; 42 int poll_time;
42}; 43};
43 44
45static inline void imx_ssi_set_next_poll(struct imx_pcm_runtime_data *iprtd)
46{
47 iprtd->timer.expires = jiffies + iprtd->poll_time;
48}
49
44static void imx_ssi_timer_callback(unsigned long data) 50static void imx_ssi_timer_callback(unsigned long data)
45{ 51{
46 struct snd_pcm_substream *substream = (void *)data; 52 struct snd_pcm_substream *substream = (void *)data;
47 struct snd_pcm_runtime *runtime = substream->runtime; 53 struct snd_pcm_runtime *runtime = substream->runtime;
48 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 54 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
49 struct pt_regs regs; 55 struct pt_regs regs;
56 unsigned long delta;
50 57
51 get_fiq_regs(&regs); 58 get_fiq_regs(&regs);
52 59
@@ -55,9 +62,25 @@ static void imx_ssi_timer_callback(unsigned long data)
55 else 62 else
56 iprtd->offset = regs.ARM_r9 & 0xffff; 63 iprtd->offset = regs.ARM_r9 & 0xffff;
57 64
58 iprtd->timer.expires = jiffies + iprtd->period_time; 65 /* How much data have we transferred since the last period report? */
66 if (iprtd->offset >= iprtd->last_offset)
67 delta = iprtd->offset - iprtd->last_offset;
68 else
69 delta = runtime->buffer_size + iprtd->offset
70 - iprtd->last_offset;
71
72 /* If we've transferred at least a period then report it and
73 * reset our poll time */
74 if (delta >= runtime->period_size) {
75 snd_pcm_period_elapsed(substream);
76 iprtd->last_offset = iprtd->offset;
77
78 imx_ssi_set_next_poll(iprtd);
79 }
80
81 /* Restart the timer; if we didn't report we'll run on the next tick */
59 add_timer(&iprtd->timer); 82 add_timer(&iprtd->timer);
60 snd_pcm_period_elapsed(substream); 83
61} 84}
62 85
63static struct fiq_handler fh = { 86static struct fiq_handler fh = {
@@ -72,9 +95,10 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
72 95
73 iprtd->size = params_buffer_bytes(params); 96 iprtd->size = params_buffer_bytes(params);
74 iprtd->periods = params_periods(params); 97 iprtd->periods = params_periods(params);
75 iprtd->period = params_period_bytes(params); 98 iprtd->period = params_period_bytes(params) ;
76 iprtd->offset = 0; 99 iprtd->offset = 0;
77 iprtd->period_time = HZ / (params_rate(params) / params_period_size(params)); 100 iprtd->last_offset = 0;
101 iprtd->poll_time = HZ / (params_rate(params) / params_period_size(params));
78 102
79 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 103 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
80 104
@@ -110,7 +134,7 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
110 case SNDRV_PCM_TRIGGER_START: 134 case SNDRV_PCM_TRIGGER_START:
111 case SNDRV_PCM_TRIGGER_RESUME: 135 case SNDRV_PCM_TRIGGER_RESUME:
112 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 136 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
113 iprtd->timer.expires = jiffies + iprtd->period_time; 137 imx_ssi_set_next_poll(iprtd);
114 add_timer(&iprtd->timer); 138 add_timer(&iprtd->timer);
115 if (++fiq_enable == 1) 139 if (++fiq_enable == 1)
116 enable_fiq(imx_pcm_fiq); 140 enable_fiq(imx_pcm_fiq);