Skip to contentSkip to conversation

ASoC DaVinci voicecodec based on copyfromuser

PATCH In review Raffaele Recalcati 3 participants 8 messages Jul 16, 2010 – Aug 3, 2010 2 messages not in the archive

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

In dm365 cpu it is not possible to run CQ93VC Voice Codec together with McBSP I2S peripheral, because they share the same dma event. With this patchset it is possible to run the CQ93VC Voice Codec using copyfromuser.

A message that is not in the archive (sent off-list or not yet received): 1279291619-5081-1-git-send-email-lamiaposta71-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/3 ASoC: soc-core: soc_pcm_ops dynamically allocated

From: Davide Bonfanti <[email protected]>

If soc_pcm_ops is statically allocated, more than one call to soc_new_pcm cause operations overwrite. The problem is overcome usyng dynamic allocation.

---
 sound/soc/soc-core.c |   38 +++++++++++++++++---------------------
 1 files changed, 17 insertions(+), 21 deletions(-)
sound/soc/soc-core.c +17 -21
index ad7f952..6500686 100644
@@ -801,17 +801,6 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 	}
 	return 0;
 }
-
-/* ASoC PCM operations */
-static struct snd_pcm_ops soc_pcm_ops = {
-	.open		= soc_pcm_open,
-	.close		= soc_codec_close,
-	.hw_params	= soc_pcm_hw_params,
-	.hw_free	= soc_pcm_hw_free,
-	.prepare	= soc_pcm_prepare,
-	.trigger	= soc_pcm_trigger,
-};
-
 #ifdef CONFIG_PM
 /* powers down audio subsystem for suspend */
 static int soc_suspend(struct device *dev)
@@ -1306,6 +1295,7 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
 	struct snd_pcm *pcm;
 	char new_name[64];
 	int ret = 0, playback = 0, capture = 0;
+	struct snd_pcm_ops *soc_pcm_ops;
 
 	rtd = kzalloc(sizeof(struct snd_soc_pcm_runtime), GFP_KERNEL);
 	if (rtd == NULL)
@@ -1335,19 +1325,25 @@ static int soc_new_pcm(struct snd_soc_device *socdev,
 
 	dai_link->pcm = pcm;
 	pcm->private_data = rtd;
-	soc_pcm_ops.mmap = platform->pcm_ops->mmap;
-	soc_pcm_ops.pointer = platform->pcm_ops->pointer;
-	soc_pcm_ops.ioctl = platform->pcm_ops->ioctl;
-	soc_pcm_ops.copy = platform->pcm_ops->copy;
-	soc_pcm_ops.silence = platform->pcm_ops->silence;
-	soc_pcm_ops.ack = platform->pcm_ops->ack;
-	soc_pcm_ops.page = platform->pcm_ops->page;
+	soc_pcm_ops = kmalloc(sizeof(struct snd_pcm_ops), GFP_KERNEL);
+	soc_pcm_ops->open		= soc_pcm_open;
+	soc_pcm_ops->close		= soc_codec_close;
+	soc_pcm_ops->hw_params	= soc_pcm_hw_params;
+	soc_pcm_ops->hw_free	= soc_pcm_hw_free;
+	soc_pcm_ops->prepare	= soc_pcm_prepare;
+	soc_pcm_ops->trigger	= soc_pcm_trigger;
+	soc_pcm_ops->mmap = platform->pcm_ops->mmap;
+	soc_pcm_ops->pointer = platform->pcm_ops->pointer;
+	soc_pcm_ops->ioctl = platform->pcm_ops->ioctl;
+	soc_pcm_ops->copy = platform->pcm_ops->copy;
+	soc_pcm_ops->silence = platform->pcm_ops->silence;
+	soc_pcm_ops->ack = platform->pcm_ops->ack;
+	soc_pcm_ops->page = platform->pcm_ops->page;
 
 	if (playback)
-		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
-
+		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, soc_pcm_ops);
 	if (capture)
-		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
+		snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, soc_pcm_ops);
 
 	ret = platform->pcm_new(codec->card, codec_dai, pcm);
 	if (ret < 0) {
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH 1/3] ASoC: soc-core: soc_pcm_ops dynamically allocated

Quoted 3 lines · Raffaele Recalcati

If soc_pcm_ops is statically allocated, more than one call to soc_new_pcm cause operations overwrite. The problem is overcome usyng dynamic allocation.

As I said previously you're looking for Liam's multi-component work here rather than this (or at least should be basing your work off his).

A message that is not in the archive (sent off-list or not yet received): 20100716150948.GA23183-HF5t3jzXg/6ND3a5+9QAFujbO/[email protected]

#5 lore raw

Re: [PATCH 1/3] ASoC: soc-core: soc_pcm_ops dynamically allocated

2010/7/16 Mark Brown <broonie-yzvPICuk2AATkU/[email protected]>

Quoted 10 lines · Raffaele Recalcati
Quoted 2 lines

If soc_pcm_ops is statically allocated, more than one call to

soc_new_pcm

Quoted 2 lines

cause operations overwrite. The problem is overcome usyng dynamic allocation.

As I said previously you're looking for Liam's multi-component work here rather than this (or at least should be basing your work off his).

ok.
For us it is better to have also more feedback from you about the other two patches.
So the next patchset we'll submit shall be more complete.

Thx

#6 lore raw

Re: [PATCH 1/3] ASoC: soc-core: soc_pcm_ops dynamically allocated

Quoted 3 lines · Raffaele Recalcati

For us it is better to have also more feedback from you about the other two patches.
So the next patchset we'll submit shall be more complete.

Sure - those are bigger and take longer to read, should get to them by the end of the weekend at least.

#7 lore raw

PATCH 2/3 ASoC: DaVinci: Added support based on copy_from_user instead of DMA

In reply to a message not in the archive

From: Davide Bonfanti <[email protected]>

This driver implements a pcm interface without the use of a DMA but with a copy_from_user.
There's a buffer in the driver that is filled with davinci_pcm_copy. When pcm is running, a TIMER interrupt is activated in order to fill HW FIFO.
BUG: It happens sometimes that the peripheral stops working so there's a trap.

This patch has been developed against the
http://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-davinci.git
git tree and tested on bmx board.

---
 sound/soc/davinci/Makefile                   |    1 +
 sound/soc/davinci/davinci-pcm-copy.h         |   52 +++++
 sound/soc/davinci/davinci-pcm-copyfromuser.c |  278 ++++++++++++++++++++++++++
 sound/soc/davinci/davinci-pcm.h              |    1 +
 4 files changed, 332 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/davinci/davinci-pcm-copy.h
 create mode 100644 sound/soc/davinci/davinci-pcm-copyfromuser.c
sound/soc/davinci/Makefile +1 -0
index a93679d..7d6a9a1 100644
@@ -1,5 +1,6 @@
 # DAVINCI Platform Support
 snd-soc-davinci-objs := davinci-pcm.o
+snd-soc-davinci-objs += davinci-pcm-copyfromuser.o
 snd-soc-davinci-i2s-objs := davinci-i2s.o
 snd-soc-davinci-mcasp-objs:= davinci-mcasp.o
 snd-soc-davinci-vcif-objs:= davinci-vcif.o
sound/soc/davinci/davinci-pcm-copy.h new file +52 -0

52 lines not on this page · raw message

sound/soc/davinci/davinci-pcm-copyfromuser.c new file +278 -0

278 lines not on this page · raw message

sound/soc/davinci/davinci-pcm.h +1 -0
index 0764944..cb7c2aa 100644
@@ -29,5 +29,6 @@ struct davinci_pcm_dma_params {
 
 
 extern struct snd_soc_platform davinci_soc_platform;
+extern struct snd_soc_platform davinci_soc_platform_copy;
 
 #endif
Signature · 1 line
1.7.0.4
#8 lore raw

Re: [PATCH 2/3] ASoC: DaVinci: Added support based on copy_from_user instead of DMA

Quoted 9 lines · Raffaele Recalcati

From: Davide Bonfanti <[email protected]>

This driver implements a pcm interface without the use of a DMA but with a copy_from_user.
There's a buffer in the driver that is filled with davinci_pcm_copy. When pcm is running, a TIMER interrupt is activated in order to fill HW FIFO.
BUG: It happens sometimes that the peripheral stops working so there's a trap.

Looking at this code the main thing that jumps out at me is that it doesn't look at all DaVinci specific - all the interaction with the hardware is hidden behind the ops structure you've defined, though the ops structure doesn't define things like the maximum number of channels and sample rate which I'd expect it to. This suggests that either the patch shouldn't be DaVinci specific or the splitting out of the ops structure isn't adding anything.

Quoted 1 line

+int pointer_sub;

These should all be static.

sound/soc/davinci/davinci-pcm-copyfromuser.c line 47

Quoted 5 lines
sound/soc/davinci/davinci-pcm-copyfromuser.c new file +5 -0
+int hw_fifo_size;
+u16 *local_buffer;
+static struct hrtimer hrtimer;
+struct snd_pcm_substream *substream_loc;
+int ns_for_interrupt = 1500000;

Magic number?

Quoted 1 line

+ gpio_set_value(69, 0);

Magic number again, and nothing requests this GPIO either. Looks like another thing for the ops structure.

#9 lore raw

PATCH 3/3 ASoC: DaVinci: Voicecodec: Added support based on davinci-pcm-copyfromuser

In reply to a message not in the archive

From: Davide Bonfanti <[email protected]>

The driver uses the pcm implementation without the use of DMA in order to support Voicecodec (cq93vc).

---
 sound/soc/davinci/Makefile      |    3 +
 sound/soc/davinci/cq93vc_copy.c |  130 +++++++++++++++++++++++++++++++++++++++
 sound/soc/davinci/cq93vc_copy.h |   26 ++++++++
 3 files changed, 159 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/davinci/cq93vc_copy.c
 create mode 100644 sound/soc/davinci/cq93vc_copy.h
sound/soc/davinci/Makefile +3 -0
index 7d6a9a1..44c17ad 100644
@@ -1,6 +1,7 @@
 # DAVINCI Platform Support
 snd-soc-davinci-objs := davinci-pcm.o
 snd-soc-davinci-objs += davinci-pcm-copyfromuser.o
+snd-soc-davinci-objs += cq93vc_copy.o
 snd-soc-davinci-i2s-objs := davinci-i2s.o
 snd-soc-davinci-mcasp-objs:= davinci-mcasp.o
 snd-soc-davinci-vcif-objs:= davinci-vcif.o
@@ -13,9 +14,11 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o
 # DAVINCI Machine Support
 snd-soc-evm-objs := davinci-evm.o
 snd-soc-sffsdr-objs := davinci-sffsdr.o
+snd-soc-bmx-objs := davinci-bmx.o
 
 obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o
 obj-$(CONFIG_SND_DAVINCI_SOC_SFFSDR) += snd-soc-sffsdr.o
+obj-$(CONFIG_SND_DAVINCI_SOC_BMX) += snd-soc-bmx.o
sound/soc/davinci/cq93vc_copy.c new file +130 -0

130 lines not on this page · raw message

sound/soc/davinci/cq93vc_copy.h new file +26 -0
new file mode 100644
index 0000000..bcc4458
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2010 Bticino S.p.a
+ * Author: Davide Bonfanti <[email protected]>
+ *
+ * Contributors:
+ *     Raffaele Recalcati <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef _DAVINCI_CQ93VC_COPY_H
+#define _DAVINCI_CQ93VC_COPY_H
+#include "davinci-pcm-copy.h"
+
+extern struct davinci_pcm_copy_ops cq93vc_pcm_copy_ops;
+
+#endif /* _DAVINCI_CQ93VC_COPY_H */
Signature · 1 line
1.7.0.4