aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-02-05 05:41:47 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-02-05 08:55:52 -0500
commit1f88eb0f0660f8b58a1fe9011f3d3a350c7dd194 (patch)
tree64682db83e8a9450c6e3b41dde9d615c74f2145f
parent202c8f7082e87e09f861d06b1a03501047c017b5 (diff)
ASoC: soc-compress: Add support for not memory mapped DSPs
The ASoC compressed API did not implement the copy callback in its compressed ops which is required for DSPs that are not memory mapped. This patch creates a local copy of the compress ops for each runtime and modifies them with a copy callback as appropriate. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/soc-compress.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index 3ea79564a993..c81aeecec936 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -302,6 +302,22 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
302 return 0; 302 return 0;
303} 303}
304 304
305static int soc_compr_copy(struct snd_compr_stream *cstream,
306 const char __user *buf, size_t count)
307{
308 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
309 struct snd_soc_platform *platform = rtd->platform;
310 int ret = 0;
311
312 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
313
314 if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
315 ret = platform->driver->compr_ops->copy(cstream, buf, count);
316
317 mutex_unlock(&rtd->pcm_mutex);
318 return ret;
319}
320
305/* ASoC Compress operations */ 321/* ASoC Compress operations */
306static struct snd_compr_ops soc_compr_ops = { 322static struct snd_compr_ops soc_compr_ops = {
307 .open = soc_compr_open, 323 .open = soc_compr_open,
@@ -319,6 +335,7 @@ static struct snd_compr_ops soc_compr_ops = {
319int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) 335int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
320{ 336{
321 struct snd_soc_codec *codec = rtd->codec; 337 struct snd_soc_codec *codec = rtd->codec;
338 struct snd_soc_platform *platform = rtd->platform;
322 struct snd_soc_dai *codec_dai = rtd->codec_dai; 339 struct snd_soc_dai *codec_dai = rtd->codec_dai;
323 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 340 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
324 struct snd_compr *compr; 341 struct snd_compr *compr;
@@ -335,14 +352,25 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
335 return -ENOMEM; 352 return -ENOMEM;
336 } 353 }
337 354
338 compr->ops = &soc_compr_ops; 355 compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
356 GFP_KERNEL);
357 if (compr->ops == NULL) {
358 dev_err(rtd->card->dev, "Cannot allocate compressed ops\n");
359 ret = -ENOMEM;
360 goto compr_err;
361 }
362 memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));
363
364 /* Add copy callback for not memory mapped DSPs */
365 if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
366 compr->ops->copy = soc_compr_copy;
367
339 mutex_init(&compr->lock); 368 mutex_init(&compr->lock);
340 ret = snd_compress_new(rtd->card->snd_card, num, direction, compr); 369 ret = snd_compress_new(rtd->card->snd_card, num, direction, compr);
341 if (ret < 0) { 370 if (ret < 0) {
342 pr_err("compress asoc: can't create compress for codec %s\n", 371 pr_err("compress asoc: can't create compress for codec %s\n",
343 codec->name); 372 codec->name);
344 kfree(compr); 373 goto compr_err;
345 return ret;
346 } 374 }
347 375
348 /* DAPM dai link stream work */ 376 /* DAPM dai link stream work */
@@ -354,4 +382,8 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
354 printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n", codec_dai->name, 382 printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n", codec_dai->name,
355 cpu_dai->name); 383 cpu_dai->name);
356 return ret; 384 return ret;
385
386compr_err:
387 kfree(compr);
388 return ret;
357} 389}