Re: [alsa-devel] [PATCH 20/30] ASoC: samsung: convert to dmaengine API
On 04/11/2013 04:47 PM, Arnd Bergmann wrote: On Thursday 11 April 2013, Mark Brown wrote: On Thu, Apr 11, 2013 at 02:05:02AM +0200, Arnd Bergmann wrote: In order to build the exynos kernel with CONFIG_ARCH_MULTIPLATFORM, we must convert all users of the Samsung private DMA interface to the generic dmaengine API. This version of the patch adds the generic dmaengine API as an alternative to the existing samsung specific one. Once all the older platforms provide support for the common dmaengine interfaces, we can remove the old code. There's generic ASoC dmaengine code which should be used instead of open coding this. Lars-Peter Clausen and Lee Jones have been working on making this a totally generic driver, right now it's a library. Ok, I see. I'll drop this patch from my series then and will let someone else handle this driver in 3.11. We can probably live without sound support in 3.10 when running a multiplatform kernel, and it will keep working for exynos-only kernels without the patch. I actually had a look at how the Samsung PCM driver a couple of days back, but I didn't fully grasp how things work with the secondary TX channel for the i2s driver and to make it work with the generic dmaengine PCM driver. The code handling this in the i2s driver seems to be rather messy with lots of ifs and elses. Also things would have would be a lot easier if the dt bindings had used two subnodes each with their own 'dmas' property. - Lars -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 20/30] ASoC: samsung: convert to dmaengine API
On Thu, Apr 11, 2013 at 02:05:02AM +0200, Arnd Bergmann wrote: In order to build the exynos kernel with CONFIG_ARCH_MULTIPLATFORM, we must convert all users of the Samsung private DMA interface to the generic dmaengine API. This version of the patch adds the generic dmaengine API as an alternative to the existing samsung specific one. Once all the older platforms provide support for the common dmaengine interfaces, we can remove the old code. There's generic ASoC dmaengine code which should be used instead of open coding this. Lars-Peter Clausen and Lee Jones have been working on making this a totally generic driver, right now it's a library. -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 20/30] ASoC: samsung: convert to dmaengine API
On Thursday 11 April 2013, Mark Brown wrote: On Thu, Apr 11, 2013 at 02:05:02AM +0200, Arnd Bergmann wrote: In order to build the exynos kernel with CONFIG_ARCH_MULTIPLATFORM, we must convert all users of the Samsung private DMA interface to the generic dmaengine API. This version of the patch adds the generic dmaengine API as an alternative to the existing samsung specific one. Once all the older platforms provide support for the common dmaengine interfaces, we can remove the old code. There's generic ASoC dmaengine code which should be used instead of open coding this. Lars-Peter Clausen and Lee Jones have been working on making this a totally generic driver, right now it's a library. Ok, I see. I'll drop this patch from my series then and will let someone else handle this driver in 3.11. We can probably live without sound support in 3.10 when running a multiplatform kernel, and it will keep working for exynos-only kernels without the patch. Can you have a look at the other three ASoC patches in the series? I think it would still be useful to merge them. Arnd -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 20/30] ASoC: samsung: convert to dmaengine API
On Thu, Apr 11, 2013 at 04:47:17PM +0200, Arnd Bergmann wrote: Can you have a look at the other three ASoC patches in the series? I think it would still be useful to merge them. Yeah, they looked fine - just waiting for me to do a patch run. Should get to it shortly. signature.asc Description: Digital signature
[PATCH 20/30] ASoC: samsung: convert to dmaengine API
In order to build the exynos kernel with CONFIG_ARCH_MULTIPLATFORM, we must convert all users of the Samsung private DMA interface to the generic dmaengine API. This version of the patch adds the generic dmaengine API as an alternative to the existing samsung specific one. Once all the older platforms provide support for the common dmaengine interfaces, we can remove the old code. Signed-off-by: Arnd Bergmann a...@arndb.de Cc: alsa-de...@alsa-project.org Cc: Mark Brown broo...@opensource.wolfsonmicro.com Cc: Liam Girdwood lgirdw...@gmail.com --- sound/soc/samsung/dma.c | 219 ++ sound/soc/samsung/dma.h | 15 +++- sound/soc/samsung/i2s.c | 2 - sound/soc/samsung/pcm.c | 1 - sound/soc/samsung/spdif.c | 1 - 5 files changed, 232 insertions(+), 6 deletions(-) diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index 21b7926..9fd53df 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -22,8 +22,14 @@ #include sound/pcm_params.h #include asm/dma.h + +#ifdef CONFIG_SAMSUNG_DMADEV #include mach/hardware.h #include mach/dma.h +#else +#include linux/dmaengine.h +#include linux/amba/pl330.h +#endif #include dma.h @@ -62,11 +68,13 @@ struct runtime_data { static void audio_buffdone(void *data); +#ifdef CONFIG_SAMSUNG_DMADEV /* dma_enqueue * * place a dma buffer onto the queue for the dma system * to handle. */ + static void dma_enqueue(struct snd_pcm_substream *substream) { struct runtime_data *prtd = substream-runtime-private_data; @@ -265,6 +273,217 @@ static int dma_trigger(struct snd_pcm_substream *substream, int cmd) return ret; } +#else +/* dma_enqueue + * + * place a dma buffer onto the queue for the dma system + * to handle. + */ + +static void dma_enqueue(struct snd_pcm_substream *substream) +{ + struct runtime_data *prtd = substream-runtime-private_data; + dma_addr_t pos = prtd-dma_pos; + unsigned long period = prtd-dma_period; + unsigned int limit; + enum dma_transfer_direction direction; + struct dma_chan *chan = prtd-params-ch; + struct dma_async_tx_descriptor *desc; + + pr_debug(Entered %s\n, __func__); + + limit = (prtd-dma_end - prtd-dma_start) / prtd-dma_period; + + pr_debug(%s: loaded %d, limit %d\n, + __func__, prtd-dma_loaded, limit); + + direction = (substream-stream == SNDRV_PCM_STREAM_PLAYBACK +? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); + + while (prtd-dma_loaded limit) { + pr_debug(dma_loaded: %d\n, prtd-dma_loaded); + + if ((pos + period) prtd-dma_end) { + period = prtd-dma_end - pos; + pr_debug(%s: corrected dma len %ld\n, + __func__, period); + } + + desc = dmaengine_prep_dma_cyclic(chan, pos, +prtd-dma_period*limit, period, direction, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + + if (desc) { + desc-callback = audio_buffdone; + desc-callback_param = substream; + dmaengine_submit(desc); + } + + prtd-dma_loaded++; + pos += period; + if (pos = prtd-dma_end) + pos = prtd-dma_start; + } + + prtd-dma_pos = pos; +} + +static void audio_buffdone(void *data) +{ + struct snd_pcm_substream *substream = data; + struct runtime_data *prtd = substream-runtime-private_data; + + pr_debug(Entered %s\n, __func__); + + if (prtd-state ST_RUNNING) { + prtd-dma_pos += prtd-dma_period; + if (prtd-dma_pos = prtd-dma_end) + prtd-dma_pos = prtd-dma_start; + + if (substream) + snd_pcm_period_elapsed(substream); + } +} + +static int dma_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_pcm_runtime *runtime = substream-runtime; + struct runtime_data *prtd = runtime-private_data; + struct snd_soc_pcm_runtime *rtd = substream-private_data; + unsigned long totbytes = params_buffer_bytes(params); + struct s3c_dma_params *dma = + snd_soc_dai_get_dma_data(rtd-cpu_dai, substream); + + pr_debug(Entered %s\n, __func__); + + /* return if this is a bufferless transfer e.g. +* codec -- BT codec or GSM modem -- lg FIXME */ + if (!dma) + return 0; + + /* this may get called several times by oss emulation +* with different params -HW */ + if (prtd-params == NULL) { + struct dma_slave_config config; + dma_cap_mask_t mask; + + /* prepare DMA */ + prtd-params = dma; + + pr_debug(params %p, channel %d\n,