aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-compress.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-01-24 04:44:29 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-24 05:53:34 -0500
commit15e2e6194a3ae13ffeea9b7c368b54b143f31594 (patch)
treeef54fb50027a44ae8907cc0c78c7585cab5780d7 /sound/soc/soc-compress.c
parent8c3d2aa4cfeaba66be68ef8c351b2e099e50c25b (diff)
ASoC: soc-compress: Serialise compressed ops
Use the pcm_mutex to serialise the compressed ops. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Tested-by: Jeeja KP <jeeja.kp@intel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-compress.c')
-rw-r--r--sound/soc/soc-compress.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 80040f03b021..c48db6391ad5 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -33,6 +33,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
33 struct snd_soc_dai *codec_dai = rtd->codec_dai; 33 struct snd_soc_dai *codec_dai = rtd->codec_dai;
34 int ret = 0; 34 int ret = 0;
35 35
36 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
37
36 if (platform->driver->compr_ops && platform->driver->compr_ops->open) { 38 if (platform->driver->compr_ops && platform->driver->compr_ops->open) {
37 ret = platform->driver->compr_ops->open(cstream); 39 ret = platform->driver->compr_ops->open(cstream);
38 if (ret < 0) { 40 if (ret < 0) {
@@ -61,12 +63,15 @@ static int soc_compr_open(struct snd_compr_stream *cstream)
61 codec_dai->active++; 63 codec_dai->active++;
62 rtd->codec->active++; 64 rtd->codec->active++;
63 65
66 mutex_unlock(&rtd->pcm_mutex);
67
64 return 0; 68 return 0;
65 69
66machine_err: 70machine_err:
67 if (platform->driver->compr_ops && platform->driver->compr_ops->free) 71 if (platform->driver->compr_ops && platform->driver->compr_ops->free)
68 platform->driver->compr_ops->free(cstream); 72 platform->driver->compr_ops->free(cstream);
69out: 73out:
74 mutex_unlock(&rtd->pcm_mutex);
70 return ret; 75 return ret;
71} 76}
72 77
@@ -78,6 +83,8 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
78 struct snd_soc_dai *codec_dai = rtd->codec_dai; 83 struct snd_soc_dai *codec_dai = rtd->codec_dai;
79 struct snd_soc_codec *codec = rtd->codec; 84 struct snd_soc_codec *codec = rtd->codec;
80 85
86 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
87
81 if (cstream->direction == SND_COMPRESS_PLAYBACK) { 88 if (cstream->direction == SND_COMPRESS_PLAYBACK) {
82 cpu_dai->playback_active--; 89 cpu_dai->playback_active--;
83 codec_dai->playback_active--; 90 codec_dai->playback_active--;
@@ -124,6 +131,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
124 SND_SOC_DAPM_STREAM_STOP); 131 SND_SOC_DAPM_STREAM_STOP);
125 } 132 }
126 133
134 mutex_unlock(&rtd->pcm_mutex);
127 return 0; 135 return 0;
128} 136}
129 137
@@ -135,10 +143,12 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
135 struct snd_soc_dai *codec_dai = rtd->codec_dai; 143 struct snd_soc_dai *codec_dai = rtd->codec_dai;
136 int ret = 0; 144 int ret = 0;
137 145
146 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
147
138 if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { 148 if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) {
139 ret = platform->driver->compr_ops->trigger(cstream, cmd); 149 ret = platform->driver->compr_ops->trigger(cstream, cmd);
140 if (ret < 0) 150 if (ret < 0)
141 return ret; 151 goto out;
142 } 152 }
143 153
144 if (cmd == SNDRV_PCM_TRIGGER_START) 154 if (cmd == SNDRV_PCM_TRIGGER_START)
@@ -146,6 +156,8 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
146 else if (cmd == SNDRV_PCM_TRIGGER_STOP) 156 else if (cmd == SNDRV_PCM_TRIGGER_STOP)
147 snd_soc_dai_digital_mute(codec_dai, 1); 157 snd_soc_dai_digital_mute(codec_dai, 1);
148 158
159out:
160 mutex_unlock(&rtd->pcm_mutex);
149 return ret; 161 return ret;
150} 162}
151 163
@@ -156,6 +168,8 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
156 struct snd_soc_platform *platform = rtd->platform; 168 struct snd_soc_platform *platform = rtd->platform;
157 int ret = 0; 169 int ret = 0;
158 170
171 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
172
159 /* first we call set_params for the platform driver 173 /* first we call set_params for the platform driver
160 * this should configure the soc side 174 * this should configure the soc side
161 * if the machine has compressed ops then we call that as well 175 * if the machine has compressed ops then we call that as well
@@ -165,18 +179,20 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream,
165 if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { 179 if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) {
166 ret = platform->driver->compr_ops->set_params(cstream, params); 180 ret = platform->driver->compr_ops->set_params(cstream, params);
167 if (ret < 0) 181 if (ret < 0)
168 return ret; 182 goto out;
169 } 183 }
170 184
171 if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) { 185 if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) {
172 ret = rtd->dai_link->compr_ops->set_params(cstream); 186 ret = rtd->dai_link->compr_ops->set_params(cstream);
173 if (ret < 0) 187 if (ret < 0)
174 return ret; 188 goto out;
175 } 189 }
176 190
177 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK, 191 snd_soc_dapm_stream_event(rtd, SNDRV_PCM_STREAM_PLAYBACK,
178 SND_SOC_DAPM_STREAM_START); 192 SND_SOC_DAPM_STREAM_START);
179 193
194out:
195 mutex_unlock(&rtd->pcm_mutex);
180 return ret; 196 return ret;
181} 197}
182 198
@@ -187,9 +203,12 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream,
187 struct snd_soc_platform *platform = rtd->platform; 203 struct snd_soc_platform *platform = rtd->platform;
188 int ret = 0; 204 int ret = 0;
189 205
206 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
207
190 if (platform->driver->compr_ops && platform->driver->compr_ops->get_params) 208 if (platform->driver->compr_ops && platform->driver->compr_ops->get_params)
191 ret = platform->driver->compr_ops->get_params(cstream, params); 209 ret = platform->driver->compr_ops->get_params(cstream, params);
192 210
211 mutex_unlock(&rtd->pcm_mutex);
193 return ret; 212 return ret;
194} 213}
195 214
@@ -200,9 +219,12 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream,
200 struct snd_soc_platform *platform = rtd->platform; 219 struct snd_soc_platform *platform = rtd->platform;
201 int ret = 0; 220 int ret = 0;
202 221
222 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
223
203 if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps) 224 if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps)
204 ret = platform->driver->compr_ops->get_caps(cstream, caps); 225 ret = platform->driver->compr_ops->get_caps(cstream, caps);
205 226
227 mutex_unlock(&rtd->pcm_mutex);
206 return ret; 228 return ret;
207} 229}
208 230
@@ -213,9 +235,12 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream,
213 struct snd_soc_platform *platform = rtd->platform; 235 struct snd_soc_platform *platform = rtd->platform;
214 int ret = 0; 236 int ret = 0;
215 237
238 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
239
216 if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) 240 if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps)
217 ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); 241 ret = platform->driver->compr_ops->get_codec_caps(cstream, codec);
218 242
243 mutex_unlock(&rtd->pcm_mutex);
219 return ret; 244 return ret;
220} 245}
221 246
@@ -225,9 +250,12 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes)
225 struct snd_soc_platform *platform = rtd->platform; 250 struct snd_soc_platform *platform = rtd->platform;
226 int ret = 0; 251 int ret = 0;
227 252
253 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
254
228 if (platform->driver->compr_ops && platform->driver->compr_ops->ack) 255 if (platform->driver->compr_ops && platform->driver->compr_ops->ack)
229 ret = platform->driver->compr_ops->ack(cstream, bytes); 256 ret = platform->driver->compr_ops->ack(cstream, bytes);
230 257
258 mutex_unlock(&rtd->pcm_mutex);
231 return ret; 259 return ret;
232} 260}
233 261
@@ -237,9 +265,12 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
237 struct snd_soc_pcm_runtime *rtd = cstream->private_data; 265 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
238 struct snd_soc_platform *platform = rtd->platform; 266 struct snd_soc_platform *platform = rtd->platform;
239 267
268 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
269
240 if (platform->driver->compr_ops && platform->driver->compr_ops->pointer) 270 if (platform->driver->compr_ops && platform->driver->compr_ops->pointer)
241 platform->driver->compr_ops->pointer(cstream, tstamp); 271 platform->driver->compr_ops->pointer(cstream, tstamp);
242 272
273 mutex_unlock(&rtd->pcm_mutex);
243 return 0; 274 return 0;
244} 275}
245 276