ASoC: atmel-pcm: align with generic dmaengine framwork
Subsystems (6)
v2 cover ASoC: atmel-pcm: align with generic dmaengine framwork
This patch set is based on linux next-20130701
mainly implement
- move set dma data from hw_params to startup callback to avoid memory leak
- align atmel pcm with generic dmaenigne framwork
Bo Shen (5):
ASoC: atmel_ssc_dai: move set dma data to startup callback
ASoC: atmel_ssc_dai: add error mask define
ASoC: atmel-pcm-dma: move prepare for dma to dai prepare
ARM: atmel-ssc: change phybase type to dma_addr_t
ASoC: atmel-pcm: use generic dmaengine framework
include/linux/atmel-ssc.h | 2 +- sound/soc/atmel/Kconfig | 1 + sound/soc/atmel/atmel-pcm-dma.c | 118 ++++++--------------------------------- sound/soc/atmel/atmel_ssc_dai.c | 36 ++++++------ 4 files changed, 37 insertions(+), 120 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/5 ASoC: atmel_ssc_dai: move set dma data to startup callback
move set dma data to startup callback function, if the set dma data exist in hw_params callback, so the dma data only usable when call hw_params, if want use it before hw_params callback, it will cause NULL pointer access oops
---
Change in v2:
- no change
--- sound/soc/atmel/atmel_ssc_dai.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
sound/soc/atmel/atmel_ssc_dai.c +16 -17
@@ -196,15 +196,27 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; -int dir_mask; +struct atmel_pcm_dma_params *dma_params; +int dir, dir_mask;pr_debug ("atmel_ssc_startup: SSC_SR=0x%u\n" ,ssc_readl (ssc_p->ssc->regs,SR )); -if (substream->stream =SNDRV_PCM_STREAM_PLAYBACK ) +if (substream->stream =SNDRV_PCM_STREAM_PLAYBACK ) { + dir =0 ; dir_mask =SSC_DIR_MASK_PLAYBACK ; -else + }else { + dir =1 ; dir_mask =SSC_DIR_MASK_CAPTURE ; + } + + dma_params = &ssc_dma_params[dai->id][dir]; + dma_params->ssc = ssc_p->ssc; + dma_params->substream = substream; + + ssc_p->dma_params[dir] = dma_params; + +snd_soc_dai_set_dma_data (dai, substream, dma_params);spin_lock_irq (&ssc_p->lock);if (ssc_p->dir_mask & dir_mask) {
@@ -325,7 +337,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); int id = dai->id;struct atmel_ssc_info *ssc_p = &ssc_info[id];struct atmel_pcm_dma_params *dma_params;
@@ -344,19 +355,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream,else dir =1 ; - dma_params = &ssc_dma_params[id][dir]; - dma_params->ssc = ssc_p->ssc; - dma_params->substream = substream; - - ssc_p->dma_params[dir] = dma_params; - -/* -* The snd_soc_pcm_stream->dma_data field is only used to communicate -* the appropriate DMA parameters to the pcm driver hw_params() -* function. It should not be used for other purposes -* as it is common to all substreams. -*/ -snd_soc_dai_set_dma_data (rtd->cpu_dai, substream, dma_params); + dma_params = ssc_p->dma_params[dir]; channels =params_channels (params);
Signature · 1 line
1.7.9.5
PATCH v2 2/5 ASoC: atmel_ssc_dai: add error mask define
In reply to Bo Shenadd error mask define, which will be used when execute DMA transfer
---
Change in v2:
- new patch
--- sound/soc/atmel/atmel_ssc_dai.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/atmel_ssc_dai.c +2 -0
@@ -73,6 +73,7 @@ static struct atmel_ssc_mask ssc_tx_mask = { .ssc_disable = SSC_BIT(CR_TXDIS), .ssc_endx = SSC_BIT(SR_ENDTX), .ssc_endbuf = SSC_BIT(SR_TXBUFE), + .ssc_error = SSC_BIT(SR_OVRUN), .pdc_enable = ATMEL_PDC_TXTEN, .pdc_disable = ATMEL_PDC_TXTDIS, };
@@ -82,6 +83,7 @@ static struct atmel_ssc_mask ssc_rx_mask = { .ssc_disable = SSC_BIT(CR_RXDIS), .ssc_endx = SSC_BIT(SR_ENDRX), .ssc_endbuf = SSC_BIT(SR_RXBUFF), + .ssc_error = SSC_BIT(SR_OVRUN), .pdc_enable = ATMEL_PDC_RXTEN, .pdc_disable = ATMEL_PDC_RXTDIS, };
Signature · 1 line
1.7.9.5
PATCH v2 3/5 ASoC: atmel-pcm-dma: move prepare for dma to dai prepare
In reply to Bo Shenas prepare callback for dma is acctually access ssc register which better done in dai driver, so move it to dai prepare callback function
---
Change in v2:
- split as a new patch
--- sound/soc/atmel/atmel-pcm-dma.c | 14 -------------- sound/soc/atmel/atmel_ssc_dai.c | 1 + 2 files changed, 1 insertion(+), 14 deletions(-)
sound/soc/atmel/atmel-pcm-dma.c +0 -14
@@ -175,19 +175,6 @@ err:return ret; } -static int atmel_pcm_dma_prepare (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct atmel_pcm_dma_params *prtd; - - prtd =snd_soc_dai_get_dma_data (rtd->cpu_dai, substream); - -ssc_writex (prtd->ssc->regs,SSC_IER , prtd->mask->ssc_error); -ssc_writex (prtd->ssc->regs,SSC_CR , prtd->mask->ssc_enable); - -return 0 ; -} -static int atmel_pcm_open (struct snd_pcm_substream *substream) {snd_soc_set_runtime_hwparams (substream, &atmel_pcm_dma_hardware);
@@ -200,7 +187,6 @@ static struct snd_pcm_ops atmel_pcm_ops = { .close = snd_dmaengine_pcm_close_release_chan, .ioctl = snd_pcm_lib_ioctl, .hw_params = atmel_pcm_hw_params, - .prepare = atmel_pcm_dma_prepare, .trigger = snd_dmaengine_pcm_trigger, .pointer = snd_dmaengine_pcm_pointer_no_residue, .mmap = atmel_pcm_mmap,
sound/soc/atmel/atmel_ssc_dai.c +1 -0
@@ -649,6 +649,7 @@ static int atmel_ssc_prepare(struct snd_pcm_substream *substream, dma_params = ssc_p->dma_params[dir];ssc_writel (ssc_p->ssc->regs,CR , dma_params->mask->ssc_enable); +ssc_writel (ssc_p->ssc->regs,IER , dma_params->mask->ssc_error); pr_debug("%s enabled SSC_SR=0x%08x\n", dir ? "receive" : "transmit",
Signature · 1 line
1.7.9.5
PATCH v2 4/5 ARM: atmel-ssc: change phybase type to dma_addr_t
In reply to Bo Shenas the phybase paramter only used for DMA operation, change it's type from resource_size_t to dma_addr_t
---
Change in v2:
- new patch
--- include/linux/atmel-ssc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/atmel-ssc.h +1 -1
@@ -11,7 +11,7 @@ struct atmel_ssc_platform_data {struct ssc_device {struct list_head list; -resource_size_t phybase; +dma_addr_t phybase;void __iomem *regs;struct platform_device *pdev;struct atmel_ssc_platform_data *pdata;
Signature · 1 line
1.7.9.5
PATCH v2 5/5 ASoC: atmel-pcm: use generic dmaengine framework
In reply to Bo ShenAlign atmel pcm to use ASoC generic dmaengine framework
DMA is fully device tree based
---
Change in v2:
- slipt the prepare function as a seperate patch
- remove phybase convert as the type change to dma_addr_t
--- sound/soc/atmel/Kconfig | 1 + sound/soc/atmel/atmel-pcm-dma.c | 104 ++++++--------------------------------- 2 files changed, 17 insertions(+), 88 deletions(-)
sound/soc/atmel/Kconfig +1 -0
@@ -13,6 +13,7 @@ config SND_ATMEL_SOC_PDC config SND_ATMEL_SOC_DMA tristate depends on SND_ATMEL_SOC + select SND_SOC_GENERIC_DMAENGINE_PCM config SND_ATMEL_SOC_SSC tristate
sound/soc/atmel/atmel-pcm-dma.c +16 -88
140 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 6 lines · Bo Shen
This patch set is based on linux next-20130701
mainly implement
- move set dma data fromhw_paramsto startup callback to avoid memory leak
- align atmel pcm with generic dmaenigne framwork
Whole series looks good to me. Although the DMA driver still references the ssc struct, but that can be fixed later.
FWIW, Reviewed-by: Lars-Peter Clausen <[email protected]>
Quoted 13 lines
Bo Shen (5):
ASoC:atmel_ssc_dai: move set dma data to startup callback
ASoC:atmel_ssc_dai: add error mask define
ASoC: atmel-pcm-dma: move prepare for dma to dai prepare
ARM: atmel-ssc: change phybase type todma_addr_t
ASoC: atmel-pcm: use generic dmaengine frameworkinclude/linux/atmel-ssc.h | 2 +- sound/soc/atmel/Kconfig | 1 + sound/soc/atmel/atmel-pcm-dma.c | 118 ++++++--------------------------------- sound/soc/atmel/atmel_ssc_dai.c | 36 ++++++------ 4 files changed, 37 insertions(+), 120 deletions(-)
Quoted 5 lines · Bo Shen
This patch set is based on linux next-20130701
mainly implement
- move set dma data fromhw_paramsto startup callback to avoid memory leak
- align atmel pcm with generic dmaenigne framwork
Applied all, thanks.