Initial stab at converting OMAP ASoC support to DMA engine
cover Initial stab at converting OMAP ASoC support to DMA engine
The following series of three patches is an attempt to convert the OMAP ASoC backend to use the DMA engine support.
I'll bring your attention to the comments in patch 3 which highlight some of the features lost in this process. Some questions need answering there (in particular the one concerning pause/resume) especially as it seems the present driver could well be buggy wrt comments recently on the mailing list about ALSA pause/resume requirements.
This works for me, given the wind is in the right direction and if it's sunny outside. I find the audio support on OMAP to be rather flakey at best, requiring reboots if it doesn't work first time.
RFC 1/3 ASoC: dmaengine: Don't use runtime private data for dmaengine data
Use a dedicated member to store dmaengine data so that drivers can use private data for their own purposes.
--- include/sound/pcm.h | 2 ++ sound/soc/soc-dmaengine-pcm.c | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-)
include/sound/pcm.h +2 -0
@@ -269,6 +269,7 @@ struct snd_pcm_hw_constraint_list { };struct snd_pcm_hwptr_log ; +struct dmaengine_pcm_runtime_data ;struct snd_pcm_runtime {/* -- Status -- */
@@ -345,6 +346,7 @@ struct snd_pcm_runtime {unsigned char *dma_area;/* DMA area */ dma_addr_t dma_addr;/* physical bus address (not accessible from main CPU) */ size_t dma_bytes;/* size of DMA area */ +struct dmaengine_pcm_runtime_data *dmaengine_data;struct snd_dma_buffer *dma_buffer_p;/* allocated buffer */
sound/soc/soc-dmaengine-pcm.c +1 -1
@@ -40,7 +40,7 @@ struct dmaengine_pcm_runtime_data {static inline struct dmaengine_pcm_runtime_data *substream_to_prtd (const struct snd_pcm_substream *substream) { -return substream->runtime->private_data; +return substream->runtime->dmaengine_data; }/**
Signature · 1 line
1.7.4.4
Re: [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
Quoted 3 lines · Liam Girdwood
Use a dedicated member to store dmaengine data so that drivers can use private data for their own purposes.
The idea was that we'll eventually get to a point where we won't need private data for the drivers using the generic dmaengine code. But for the transitional period there is snd_dmaengine_pcm_{set,get}_data which allows to attach driver private data to the dmaengine pcm. For an example see how the other users of dmaengine pcm handle this.
Quoted 40 lines
Signed-off-by Liam Girdwood <[email protected]>Signed-off-by Russell King <[email protected]>--- include/sound/pcm.h | 2 ++ sound/soc/soc-dmaengine-pcm.c | 2 +- 2 files changed, 3 insertions(+), 1 deletions(-)include/sound/pcm.h +2
-0@@ -269,6 +269,7 @@ struct snd_pcm_hw_constraint_list { };struct snd_pcm_hwptr_log ; +struct dmaengine_pcm_runtime_data ;struct snd_pcm_runtime {/* -- Status -- */ @@ -345,6 +346,7 @@ struct snd_pcm_runtime {unsigned char *dma_area;/* DMA area */ dma_addr_t dma_addr;/* physical bus address (not accessible from main CPU) */ size_t dma_bytes;/* size of DMA area */ +struct dmaengine_pcm_runtime_data *dmaengine_data;struct snd_dma_buffer *dma_buffer_p;/* allocated buffer */ sound/soc/soc-dmaengine-pcm.c +1
-1@@ -40,7 +40,7 @@ struct dmaengine_pcm_runtime_data {static inline struct dmaengine_pcm_runtime_data *substream_to_prtd (const struct snd_pcm_substream *substream) { -return substream->runtime->private_data; +return substream->runtime->dmaengine_data; }/**
Re: [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
Quoted 10 lines · Lars-Peter Clausen
Quoted 3 lines · Liam Girdwood
Use a dedicated member to store dmaengine data so that drivers can use private data for their own purposes.
The idea was that we'll eventually get to a point where we won't need private data for the drivers using the generic dmaengine code. But for the transitional period there is snd_dmaengine_pcm_{set,get}_data which allows to attach driver private data to the dmaengine pcm. For an example see how the other users of dmaengine pcm handle this.
That's fine if you are writing new drivers from scatch, or know the driver you're converting inside-out. Neither applies here (I've struggled to do anything with the OMAP audio stuff for many many reasons.)
I rather wish that people who did know the OMAP ASoC driver had stepped up to this conversion, but alas they haven't.
In any case, if you want people to use the this soc-dmaengine helper then you have to make the conversion to it simple, and requiring everyone to totally restructure their drivers to use it does not make that process simple.
What you have here is the result of several transformations to the driver, which would _not_ have been possible without this first patch from Liam.
Re: [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
Quoted 20 lines · Russell King - ARM Linux
Quoted 10 lines · Lars-Peter Clausen
Quoted 3 lines · Liam Girdwood
Use a dedicated member to store dmaengine data so that drivers can use private data for their own purposes.
The idea was that we'll eventually get to a point where we won't need private data for the drivers using the generic dmaengine code. But for the transitional period there is snd_dmaengine_pcm_{set,get}_data which allows to attach driver private data to the dmaengine pcm. For an example see how the other users of dmaengine pcm handle this.
That's fine if you are writing new drivers from scatch, or know the driver you're converting inside-out. Neither applies here (I've struggled to do anything with the OMAP audio stuff for many many reasons.)
I rather wish that people who did know the OMAP ASoC driver had stepped up to this conversion, but alas they haven't.
Quoted 8 lines
In any case, if you want people to use the this soc-dmaengine helper then you have to make the conversion to it simple, and requiring everyone to totally restructure their drivers to use it does not make that process simple.
What you have here is the result of several transformations to the driver, which would _not_ have been possible without this first patch from Liam.
Ok, it might have been helpful in the conversion process, but for the final patch it would be nice if you could replace
struct snd_pcm_runtime *runtime = substream->runtime;
struct omap_runtime_data *prtd = runtime->private_data;
struct omap_pcm_dma_data *dma_data = prtd->dma_data;
with
struct omap_pcm_dma_data *dma_data = snd_dmaengine_pcm_get_data(substream);
and in the hwparams callback use
snd_dmaengine_pcm_set_data(substream, dma_data);
and then drop patch 1 and 2 from the series.
Re: [alsa-devel] [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
At Mon, 03 Sep 2012 22:59:54 +0200,
Quoted 40 lines · Lars-Peter Clausen
Quoted 20 lines · Russell King - ARM Linux
Quoted 10 lines · Lars-Peter Clausen
Quoted 3 lines · Liam Girdwood
Use a dedicated member to store dmaengine data so that drivers can use private data for their own purposes.
The idea was that we'll eventually get to a point where we won't need private data for the drivers using the generic dmaengine code. But for the transitional period there is snd_dmaengine_pcm_{set,get}_data which allows to attach driver private data to the dmaengine pcm. For an example see how the other users of dmaengine pcm handle this.
That's fine if you are writing new drivers from scatch, or know the driver you're converting inside-out. Neither applies here (I've struggled to do anything with the OMAP audio stuff for many many reasons.)
I rather wish that people who did know the OMAP ASoC driver had stepped up to this conversion, but alas they haven't.
Quoted 8 lines
In any case, if you want people to use the this soc-dmaengine helper then you have to make the conversion to it simple, and requiring everyone to totally restructure their drivers to use it does not make that process simple.
What you have here is the result of several transformations to the driver, which would _not_ have been possible without this first patch from Liam.
Ok, it might have been helpful in the conversion process, but for the final patch it would be nice if you could replace
struct
snd_pcm_runtime*runtime =substream->runtime;
structomap_runtime_data*prtd =runtime->private_data;
structomap_pcm_dma_data*dma_data=prtd->dma_data;
with
structomap_pcm_dma_data*dma_data=snd_dmaengine_pcm_get_data(substream);
Quoted 5 lines
and in the hwparams callback use
snd_dmaengine_pcm_set_data(substream, dma_data);and then drop patch 1 and 2 from the series.
We discussed with Liam about the addition of new field in ALSA core, and concluded that a bit different approach, at least, more generic name is preferred, even if a new field is inevitably needed.
So, eventually some change may happen in near future in ALSA core side, but still it'd be really helpful if the callers have been standardized beforehand with a helper function like above.
thanks,
Takashi
Re: [alsa-devel] [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
Hi Takashi,
Quoted 15 lines · Takashi Iwai
Quoted 9 lines
Ok, it might have been helpful in the conversion process, but for the final patch it would be nice if you could replace
struct
snd_pcm_runtime*runtime =substream->runtime;
structomap_runtime_data*prtd =runtime->private_data;
structomap_pcm_dma_data*dma_data=prtd->dma_data;
with
structomap_pcm_dma_data*dma_data=snd_dmaengine_pcm_get_data(substream);Quoted 5 lines
and in the hwparams callback use
snd_dmaengine_pcm_set_data(substream, dma_data);and then drop patch 1 and 2 from the series.
Quoted 7 lines
We discussed with Liam about the addition of new field in ALSA core, and concluded that a bit different approach, at least, more generic name is preferred, even if a new field is inevitably needed.
So, eventually some change may happen in near future in ALSA core side, but still it'd be really helpful if the callers have been standardized beforehand with a helper function like above.
If the omap-pcm dmaengine conversion works on all OMAP versions (from OMAP1 to OMAP5) it is possible to avoid the additional field.
My main concern at the moment is if we will need two sets of drivers to support OMAP1 and OMAP2/3/4/5.
In all case we use the same omap-mcbsp driver which would need deal with two different type of ASoC platform driver (dmaengine and non-dmaengine). I hope we get confirmation from Janusz soon regarding to OMAP1 with dmaengine so we can plan on how to move forward.
Signature · 5 lines
Péter -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [alsa-devel] [RFC 1/3] ASoC: dmaengine: Don't use runtime private data for dmaengine data
Quoted 26 lines · Peter Ujfalusi
Hi Takashi,
Quoted 15 lines · Takashi Iwai
Quoted 9 lines
Ok, it might have been helpful in the conversion process, but for the final patch it would be nice if you could replace
struct
snd_pcm_runtime*runtime =substream->runtime;
structomap_runtime_data*prtd =runtime->private_data;
structomap_pcm_dma_data*dma_data=prtd->dma_data;
with
structomap_pcm_dma_data*dma_data=snd_dmaengine_pcm_get_data(substream);Quoted 5 lines
and in the hwparams callback use
snd_dmaengine_pcm_set_data(substream, dma_data);and then drop patch 1 and 2 from the series.
Quoted 7 lines
We discussed with Liam about the addition of new field in ALSA core, and concluded that a bit different approach, at least, more generic name is preferred, even if a new field is inevitably needed.
So, eventually some change may happen in near future in ALSA core side, but still it'd be really helpful if the callers have been standardized beforehand with a helper function like above.
Quoted 8 lines
If the omap-pcm dmaengine conversion works on all OMAP versions (from OMAP1 to OMAP5) it is possible to avoid the additional field.
My main concern at the moment is if we will need two sets of drivers to support OMAP1 and OMAP2/3/4/5.
In all case we use the same omap-mcbsp driver which would need deal with two different type of ASoC platform driver (dmaengine and non-dmaengine). I hope we get confirmation from Janusz soon regarding to OMAP1 with dmaengine so we can plan on how to move forward.
As the target for the DMA engine work is to kill off the OMAP private DMA APIs, then if OMAP1 doesn't work with the OMAP DMA engine driver, that's what needs fixing, rather than having two ASoC platform drivers.
Note that time is ticking for the removal of the OMAP private DMA APIs (see feature-removal-schedule.txt) and it has to happen so that the next stage of the OMAP DMA engine conversion can happen - that is, to make the OMAP DMA engine support be a proper driver rather than just a DMA Engine to OMAP private DMA API conversion shim.
RFC 2/3 Fix "ASoC: dmaengine: Don't use runtime private data for dmaengine data"
In reply to Russell King - ARM LinuxThe above commit was not initializing the correct substream runtime member with the ASoC DMA engine runtime data. Fix that.
--- sound/soc/soc-dmaengine-pcm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-dmaengine-pcm.c +1 -1
@@ -293,7 +293,7 @@ int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,return ret; } - substream->runtime->private_data = prtd; + substream->runtime->dmaengine_data = prtd;return 0 ; }
Signature · 1 line
1.7.4.4
RFC 3/3 ASoC: first stab at converting OMAP PCM driver to use dmaengine
In reply to Russell King - ARM LinuxNote that certain features of the original driver are not supported:
1. Non-packet mode sync
2. No period wakeup mode
DMA engine has no way to communicate this information through standard channels.
3. Pause
4. Resume
OMAP DMA engine backend does not support pausing and resuming an in-progress transfer. It is unclear from the specs what effect clearing the enable bit has on the DMA position of a destination synchronized transfer, and whether the transfer can be restarted from the exact point that it was paused (or whether the data in the FIFO read from memory is simply discarded.)
--- sound/soc/omap/Kconfig | 1 + sound/soc/omap/omap-pcm.c | 173 ++++++++++++-------------------------------- 2 files changed, 48 insertions(+), 126 deletions(-)
sound/soc/omap/Kconfig +1 -0
@@ -1,6 +1,7 @@ config SND_OMAP_SOC tristate "SoC Audio for the Texas Instruments OMAP chips" depends on ARCH_OMAP + select SND_SOC_DMAENGINE_PCM config SND_OMAP_SOC_DMIC tristate
sound/soc/omap/omap-pcm.c +47 -126
282 lines not on this page · raw message
Signature · 1 line
1.7.4.4
cover dmaengine/ASoC: omap: Enable element mode in cyclic DMA
Hi Russell,
Enable the element mode (thus allowing mono playback and probably unblocking OMAP1, OMAP2420) in OMAP dmaengine and omap-pcm.
Janusz: would it be possible for you to test Russell's series plus this on OMAP1 to make sure that we do not broke it?
Russell: we should wait for Janusz to test this on OMAP1. Based on the feedback we can plan on how to proceed with the dmaengine for OMAP audio.
Regards,
Peter
---
Peter Ujfalusi (2):
dmaengine: omap: Support for element mode in cyclic DMA
ASoC: omap-pcm: Do not check DMA sync_mode
drivers/dma/omap-dma.c | 5 ++++- sound/soc/omap/omap-pcm.c | 10 ---------- 2 files changed, 4 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.12
RFC 1/2 dmaengine: omap: Support for element mode in cyclic DMA
When src_maxburst/dst_maxburst is set to 0 by the users of cyclic DMA (mostly audio) indicates that we should configure the omap DMA to element sync mode instead of packet mode.
--- drivers/dma/omap-dma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/omap-dma.c +4 -1
@@ -413,7 +413,10 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_cyclic( d->dev_addr = dev_addr; d->fi = burst; d->es = es; - d->sync_mode =OMAP_DMA_SYNC_PACKET ; +if (burst) + d->sync_mode =OMAP_DMA_SYNC_PACKET ; +else + d->sync_mode =OMAP_DMA_SYNC_ELEMENT ; d->sync_type = sync_type; d->periph_port =OMAP_DMA_PORT_MPUI ; d->sg[0 ].addr = buf_addr;
Signature · 1 line
1.7.12
RFC 2/2 ASoC: omap-pcm: Do not check DMA sync_mode
In reply to Peter UjfalusiOMAP dmaengine now supports element mode also in cyclic DMA so we do not need to block non PACKET modes.
--- sound/soc/omap/omap-pcm.c | 10 ---------- 1 file changed, 10 deletions(-)
sound/soc/omap/omap-pcm.c +0 -10
@@ -32,7 +32,6 @@#include <sound/pcm_params.h> #include <sound/soc.h> -#include <plat/dma.h> /* needed just for OMAP_DMA_SYNC_PACKET */ #include "omap-pcm.h" static const struct snd_pcm_hardware omap_pcm_hardware = {
@@ -83,15 +82,6 @@ static int omap_pcm_hw_params(struct snd_pcm_substream *substream,return 0 ; prtd->dma_data = dma_data; -/* -* This is the only parameter we don't handle with DMA -* engine - so we insist on OMAP_DMA_SYNC_PACKET here. -*/ -if (dma_data->sync_mode !=OMAP_DMA_SYNC_PACKET ) { -pr_warn ("ALSA: omap-dma: DMA using non-packet mode?\n" ); -return -EINVAL ; - } - req = dma_data->dma_req; err =snd_dmaengine_pcm_open (substream, omap_dma_filter_fn, &req);if (err)
Signature · 1 line
1.7.12
Re: [RFC update 0/2] dmaengine/ASoC: omap: Enable element mode in cyclic DMA
In reply to Peter UjfalusiQuoted 7 lines · On Tue, 4 Sep 2012 15:08:00 Peter Ujfalusi wrote:
Hi Russell,
Enable the element mode (thus allowing mono playback and probably unblocking OMAP1, OMAP2420) in OMAP dmaengine and omap-pcm.
Janusz: would it be possible for you to test Russell's series plus this on OMAP1 to make sure that we do not broke it?
Hi Peter, Russell,
I'll be happy to make this test for you. This will take some time (I work away from home), but I expect to have it done by Monday.
BTW, I haven't been following OMAP development very closely last weeks, and I didn't even know about the OMAP DMA engine availability. Which Linux version should I base my test on? Would 3.6-rc be OK? Or l-o master?
Thanks,
Janusz
Re: [RFC update 0/2] dmaengine/ASoC: omap: Enable element mode in cyclic DMA
In reply to Peter UjfalusiQuoted 2 lines · On Tue, 4 Sep 2012 15:08:00 Peter Ujfalusi wrote:
Enable the element mode (thus allowing mono playback and probably
unblocking
Quoted 3 lines
OMAP1, OMAP2420) in OMAP dmaengine and omap-pcm.
Janusz: would it be possible for you to test Russell's series plus
this on
Quoted 1 line
OMAP1 to make sure that we do not broke it?
Hi,
I can confirm that sound works for me as before, both capture and playback, on my OMAP1 Amstrad Delta with Russell's and Peter's patches applied on top of linux-3.6-rc3, with the OMAP DMA engine driver built in. I was not able make audible tests with applications other than a soft phone as I didn't get back home for this weekend, but I think that the asterisk soft phone is quite a demanding use case.
The only thing I'm not sure about is why the sysfs provided bytes_transferred values never change from their initial zeros.
For OMAP1:
Thanks,
Janusz
Re: [RFC update 0/2] dmaengine/ASoC: omap: Enable element mode in cyclic DMA
Hi Janusz,
Quoted 10 lines · Janusz Krzysztofik
Quoted 2 lines · On Tue, 4 Sep 2012 15:08:00 Peter Ujfalusi wrote:
Enable the element mode (thus allowing mono playback and probably
unblocking
Quoted 3 lines
OMAP1, OMAP2420) in OMAP dmaengine and omap-pcm.
Janusz: would it be possible for you to test Russell's series plus
this on
Quoted 1 line
OMAP1 to make sure that we do not broke it?
Quoted 7 lines
Hi,
I can confirm that sound works for me as before, both capture and playback, on my OMAP1 Amstrad Delta with Russell's and Peter's patches applied on top of linux-3.6-rc3, with the OMAP DMA engine driver built in. I was not able make audible tests with applications other than a soft phone as I didn't get back home for this weekend, but I think that the asterisk soft phone is quite a demanding use case.
Thank you very much for taking time to test this! This is indeed a good news.
Quoted 2 lines
The only thing I'm not sure about is why the sysfs provided
bytes_transferredvalues never change from their initial zeros.
I have not looked at those files in sysfs, but if the same applies for OMAP3/4/5 I can look at it and fix it which should correct OMAP1 at the same time.
Quoted 3 lines
For OMAP1:
Tested-by Janusz Krzysztofik <[email protected]>
Again, thanks for the testing,
Péter
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel