aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/imx
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-10 10:02:37 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-10 10:02:37 -0500
commitfad837c16cdd856c68ce2e1335ad0fe836ed8ecd (patch)
tree1a6babdc2ac7e5388c482e93505fdfaf5ff97f61 /sound/soc/imx
parent51c6ab130642ed975681df843c772dda48a1d2ed (diff)
parent57d54889cd00db2752994b389ba714138652e60c (diff)
Merge commit 'v2.6.34-rc1' into for-2.6.35
Diffstat (limited to 'sound/soc/imx')
-rw-r--r--sound/soc/imx/imx-pcm-fiq.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/sound/soc/imx/imx-pcm-fiq.c b/sound/soc/imx/imx-pcm-fiq.c
index 5532579ece4d..d9cb9849b033 100644
--- a/sound/soc/imx/imx-pcm-fiq.c
+++ b/sound/soc/imx/imx-pcm-fiq.c
@@ -35,22 +35,25 @@
35struct imx_pcm_runtime_data { 35struct imx_pcm_runtime_data {
36 int period; 36 int period;
37 int periods; 37 int periods;
38 unsigned long dma_addr;
39 int dma;
40 unsigned long offset; 38 unsigned long offset;
39 unsigned long last_offset;
41 unsigned long size; 40 unsigned long size;
42 unsigned long period_cnt;
43 void *buf;
44 struct timer_list timer; 41 struct timer_list timer;
45 int period_time; 42 int poll_time;
46}; 43};
47 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
48static void imx_ssi_timer_callback(unsigned long data) 50static void imx_ssi_timer_callback(unsigned long data)
49{ 51{
50 struct snd_pcm_substream *substream = (void *)data; 52 struct snd_pcm_substream *substream = (void *)data;
51 struct snd_pcm_runtime *runtime = substream->runtime; 53 struct snd_pcm_runtime *runtime = substream->runtime;
52 struct imx_pcm_runtime_data *iprtd = runtime->private_data; 54 struct imx_pcm_runtime_data *iprtd = runtime->private_data;
53 struct pt_regs regs; 55 struct pt_regs regs;
56 unsigned long delta;
54 57
55 get_fiq_regs(&regs); 58 get_fiq_regs(&regs);
56 59
@@ -59,9 +62,25 @@ static void imx_ssi_timer_callback(unsigned long data)
59 else 62 else
60 iprtd->offset = regs.ARM_r9 & 0xffff; 63 iprtd->offset = regs.ARM_r9 & 0xffff;
61 64
62 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 */
63 add_timer(&iprtd->timer); 82 add_timer(&iprtd->timer);
64 snd_pcm_period_elapsed(substream); 83
65} 84}
66 85
67static struct fiq_handler fh = { 86static struct fiq_handler fh = {
@@ -76,9 +95,10 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
76 95
77 iprtd->size = params_buffer_bytes(params); 96 iprtd->size = params_buffer_bytes(params);
78 iprtd->periods = params_periods(params); 97 iprtd->periods = params_periods(params);
79 iprtd->period = params_period_bytes(params); 98 iprtd->period = params_period_bytes(params) ;
80 iprtd->offset = 0; 99 iprtd->offset = 0;
81 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));
82 102
83 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 103 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
84 104
@@ -114,7 +134,7 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
114 case SNDRV_PCM_TRIGGER_START: 134 case SNDRV_PCM_TRIGGER_START:
115 case SNDRV_PCM_TRIGGER_RESUME: 135 case SNDRV_PCM_TRIGGER_RESUME:
116 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 136 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
117 iprtd->timer.expires = jiffies + iprtd->period_time; 137 imx_ssi_set_next_poll(iprtd);
118 add_timer(&iprtd->timer); 138 add_timer(&iprtd->timer);
119 if (++fiq_enable == 1) 139 if (++fiq_enable == 1)
120 enable_fiq(imx_pcm_fiq); 140 enable_fiq(imx_pcm_fiq);