Skip to contentSkip to conversation

ASoC: Allocate PCM operations dynamically to support multiple DAIs

PATCH In review Sangbeom Kim 3 participants 4 messages Dec 23, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Allocate PCM operations dynamically to support multiple DAIs

The original code does not cover the case that two DAIs(CPU) have different ASoC core PCM operations(like mmap, pointer...). Currently we have only one global soc_pcm_ops for ASoC core PCM operation. When two DAIs have different pointer functions, second DAI's pointer function is set for both first DAI and second DAI in case of original code.

This patch allocates ASoC core PCM operations dynamically for each DAIs. So each DAIs can have different ASoC core PCM operations. This is needed to support multiple DAIs.

---
 sound/core/pcm.c    |    1 +
 sound/soc/soc-pcm.c |   44 ++++++++++++++++++++++++--------------------
 2 files changed, 25 insertions(+), 20 deletions(-)
sound/core/pcm.c +1 -0
index 8928ca8..15cf27a 100644
@@ -769,6 +769,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
 		substream_next = substream->next;
 		snd_pcm_timer_done(substream);
 		snd_pcm_substream_proc_done(substream);
+		kfree(substream->ops);
 		kfree(substream);
 		substream = substream_next;
 	}
sound/soc/soc-pcm.c +24 -20

71 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw
Quoted 10 lines · Sangbeom Kim

The original code does not cover the case that two DAIs(CPU) have different ASoC core PCM operations(like mmap, pointer...). Currently we have only one global soc_pcm_ops for ASoC core PCM operation. When two DAIs have different pointer functions, second DAI's pointer function is set for both first DAI and second DAI in case of original code.

This patch allocates ASoC core PCM operations dynamically for each DAIs. So each DAIs can have different ASoC core PCM operations. This is needed to support multiple DAIs.

I assume that you have two different DMA controllers (with a separate DMA platform drivers) here ?

If so, why can you not specify each DMA platform driver in your machine driver DAI link ?

Thanks

Liam

#2 lore raw
Quoted 5 lines · Liam Girdwood

I assume that you have two different DMA controllers (with a separate DMA platform drivers) here ?

If so, why can you not specify each DMA platform driver in your machine driver DAI link ?

Alan Tull reported the same problem before with a patch that needed respinning. The issue is that we have a static soc_pcm_ops and we don't properly indirect everything, we copy some of the ops into snd_pcm_ops directly. This means that if those ops end up being used then they end up being the same for both drivers.

I was actually intending to fix this over Christmas.

#3 lore raw
In reply to Sangbeom Kim

sound/soc/soc-pcm.c int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) · line 617

Quoted 5 lines · Sangbeom Kim
sound/soc/soc-pcm.c +5 -0
+	soc_pcm_ops = kzalloc(sizeof(*soc_pcm_ops), GFP_KERNEL);
+	if (soc_pcm_ops == NULL) {
+		snd_printk(KERN_ERR "Cannot allocate PCM OPS\n");
+		return -ENOMEM;
+	}

This patch is good and fixes a real problem but can you please change it slightly so that instead of dynamically allocating the soc_pcm_ops we just embed it directly in the runtime structure. Since every runtime needs an ops structure we may as well just have it embedded directly and not write the allocation, freeing and error handling code.