aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl/imx-pcm-fiq.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/fsl/imx-pcm-fiq.c')
-rw-r--r--sound/soc/fsl/imx-pcm-fiq.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c
index 41740e488820..c75d43bb2e92 100644
--- a/sound/soc/fsl/imx-pcm-fiq.c
+++ b/sound/soc/fsl/imx-pcm-fiq.c
@@ -42,7 +42,8 @@ struct imx_pcm_runtime_data {
42 struct hrtimer hrt; 42 struct hrtimer hrt;
43 int poll_time_ns; 43 int poll_time_ns;
44 struct snd_pcm_substream *substream; 44 struct snd_pcm_substream *substream;
45 atomic_t running; 45 atomic_t playing;
46 atomic_t capturing;
46}; 47};
47 48
48static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt) 49static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
@@ -52,7 +53,7 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
52 struct snd_pcm_substream *substream = iprtd->substream; 53 struct snd_pcm_substream *substream = iprtd->substream;
53 struct pt_regs regs; 54 struct pt_regs regs;
54 55
55 if (!atomic_read(&iprtd->running)) 56 if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing))
56 return HRTIMER_NORESTART; 57 return HRTIMER_NORESTART;
57 58
58 get_fiq_regs(&regs); 59 get_fiq_regs(&regs);
@@ -106,7 +107,6 @@ static int snd_imx_pcm_prepare(struct snd_pcm_substream *substream)
106 return 0; 107 return 0;
107} 108}
108 109
109static int fiq_enable;
110static int imx_pcm_fiq; 110static int imx_pcm_fiq;
111 111
112static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 112static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -118,23 +118,27 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
118 case SNDRV_PCM_TRIGGER_START: 118 case SNDRV_PCM_TRIGGER_START:
119 case SNDRV_PCM_TRIGGER_RESUME: 119 case SNDRV_PCM_TRIGGER_RESUME:
120 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 120 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
121 atomic_set(&iprtd->running, 1); 121 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
122 atomic_set(&iprtd->playing, 1);
123 else
124 atomic_set(&iprtd->capturing, 1);
122 hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns), 125 hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns),
123 HRTIMER_MODE_REL); 126 HRTIMER_MODE_REL);
124 if (++fiq_enable == 1) 127 enable_fiq(imx_pcm_fiq);
125 enable_fiq(imx_pcm_fiq);
126
127 break; 128 break;
128 129
129 case SNDRV_PCM_TRIGGER_STOP: 130 case SNDRV_PCM_TRIGGER_STOP:
130 case SNDRV_PCM_TRIGGER_SUSPEND: 131 case SNDRV_PCM_TRIGGER_SUSPEND:
131 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 132 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
132 atomic_set(&iprtd->running, 0); 133 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
133 134 atomic_set(&iprtd->playing, 0);
134 if (--fiq_enable == 0) 135 else
136 atomic_set(&iprtd->capturing, 0);
137 if (!atomic_read(&iprtd->playing) &&
138 !atomic_read(&iprtd->capturing))
135 disable_fiq(imx_pcm_fiq); 139 disable_fiq(imx_pcm_fiq);
136
137 break; 140 break;
141
138 default: 142 default:
139 return -EINVAL; 143 return -EINVAL;
140 } 144 }
@@ -182,7 +186,8 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
182 186
183 iprtd->substream = substream; 187 iprtd->substream = substream;
184 188
185 atomic_set(&iprtd->running, 0); 189 atomic_set(&iprtd->playing, 0);
190 atomic_set(&iprtd->capturing, 0);
186 hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 191 hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
187 iprtd->hrt.function = snd_hrtimer_callback; 192 iprtd->hrt.function = snd_hrtimer_callback;
188 193