Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 353360
b: refs/heads/master
c: 1f88eb0
h: refs/heads/master
v: v3
  • Loading branch information
Charles Keepax authored and Mark Brown committed Feb 5, 2013
1 parent a84d006 commit 3e6fd18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 202c8f7082e87e09f861d06b1a03501047c017b5
refs/heads/master: 1f88eb0f0660f8b58a1fe9011f3d3a350c7dd194
38 changes: 35 additions & 3 deletions trunk/sound/soc/soc-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,22 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream,
return 0;
}

static int soc_compr_copy(struct snd_compr_stream *cstream,
const char __user *buf, size_t count)
{
struct snd_soc_pcm_runtime *rtd = cstream->private_data;
struct snd_soc_platform *platform = rtd->platform;
int ret = 0;

mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);

if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
ret = platform->driver->compr_ops->copy(cstream, buf, count);

mutex_unlock(&rtd->pcm_mutex);
return ret;
}

/* ASoC Compress operations */
static struct snd_compr_ops soc_compr_ops = {
.open = soc_compr_open,
Expand All @@ -319,6 +335,7 @@ static struct snd_compr_ops soc_compr_ops = {
int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
{
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_compr *compr;
Expand All @@ -335,14 +352,25 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
return -ENOMEM;
}

compr->ops = &soc_compr_ops;
compr->ops = devm_kzalloc(rtd->card->dev, sizeof(soc_compr_ops),
GFP_KERNEL);
if (compr->ops == NULL) {
dev_err(rtd->card->dev, "Cannot allocate compressed ops\n");
ret = -ENOMEM;
goto compr_err;
}
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));

/* Add copy callback for not memory mapped DSPs */
if (platform->driver->compr_ops && platform->driver->compr_ops->copy)
compr->ops->copy = soc_compr_copy;

mutex_init(&compr->lock);
ret = snd_compress_new(rtd->card->snd_card, num, direction, compr);
if (ret < 0) {
pr_err("compress asoc: can't create compress for codec %s\n",
codec->name);
kfree(compr);
return ret;
goto compr_err;
}

/* DAPM dai link stream work */
Expand All @@ -354,4 +382,8 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n", codec_dai->name,
cpu_dai->name);
return ret;

compr_err:
kfree(compr);
return ret;
}

0 comments on commit 3e6fd18

Please sign in to comment.