ASoC: generic-dmaengine-pcm: Add support for half-duplex
Subsystems (4)
Lars-Peter Clausen
maintainerPATCH 1/8 ASoC: generic-dmaengine-pcm: Add support for half-duplex
Some platforms which are half-duplex share the same DMA channel between the playback and capture stream. Add support for this to the generic dmaengine PCM driver.
--- include/sound/dmaengine_pcm.h | 5 ++++ sound/soc/soc-generic-dmaengine-pcm.c | 43 ++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 13 deletions(-)
include/sound/dmaengine_pcm.h +5 -0
@@ -91,6 +91,11 @@ void snd_dmaengine_pcm_set_config_from_dai_data(* bytes that are still left to transfer. */ #define SND_DMAENGINE_PCM_FLAG_NO_RESIDUE BIT(2) +/* +* The PCM is half duplex and the DMA channel is shared between capture and +* playback. +*/ +#define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3)/** * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM
sound/soc/soc-generic-dmaengine-pcm.c +30 -13
87 lines not on this page · raw message
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerPATCH 2/8 ASoC: mxs-pcm: Set SNDRV_PCM_INFO_HALF_DUPLEX
The MXS SAIF is only half-duplex so set the SNDRV_PCM_INFO_HALF_DUPLEX flag for the PCM in order to prevent playback and capture from running at the same time.
--- sound/soc/mxs/mxs-pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/mxs/mxs-pcm.c +2 -1
@@ -43,7 +43,8 @@ static struct snd_pcm_hardware snd_mxs_hardware = {SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_RESUME | - SNDRV_PCM_INFO_INTERLEAVED, +SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_HALF_DUPLEX, .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE,
Signature · 1 line
1.8.0
Re: [PATCH 2/8] ASoC: mxs-pcm: Set SNDRV_PCM_INFO_HALF_DUPLEX
Quoted 2 lines · Lars-Peter Clausen
The MXS SAIF is only half-duplex so set the
SNDRV_PCM_INFO_HALF_DUPLEXflag for the PCM in order to prevent playback and capture from running at the same time.
Applied, thanks.
Lars-Peter Clausen
maintainerPATCH 3/8 ASoC: mxs: Setup dma data in DAI probe
In reply to Lars-Peter ClausenThis allows us to access the DAI DMA data when we create the PCM. We'll use this when converting mxs to generic DMA engine PCM driver.
--- sound/soc/mxs/mxs-saif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/mxs/mxs-saif.c +2 -1
@@ -369,7 +369,6 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) {struct mxs_saif *saif =snd_soc_dai_get_drvdata (cpu_dai); -snd_soc_dai_set_dma_data (cpu_dai, substream, &saif->dma_param);/* clear error status to 0 for each re-open */ saif->fifo_underrun =0 ;
@@ -605,6 +604,8 @@ static int mxs_saif_dai_probe(struct snd_soc_dai *dai)struct mxs_saif *saif =dev_get_drvdata (dai->dev);snd_soc_dai_set_drvdata (dai, saif); + dai->playback_dma_data = &saif->dma_param; + dai->capture_dma_data = &saif->dma_param;return 0 ; }
Signature · 1 line
1.8.0
Re: [PATCH 3/8] ASoC: mxs: Setup dma data in DAI probe
Quoted 2 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting mxs to generic DMA engine PCM driver.
Applied, thanks.
Lars-Peter Clausen
maintainerPATCH 4/8 ASoC: mxs: Use generic dmaengine PCM
In reply to Lars-Peter ClausenUse the generic dmaengine PCM driver instead of a custom implementation.
---
Changes since v1:
Set SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX to reflect that the DMA channel is shared between playback and capture
--- sound/soc/mxs/Kconfig | 2 +- sound/soc/mxs/mxs-pcm.c | 136 ++++-------------------------------------------- 2 files changed, 12 insertions(+), 126 deletions(-)
sound/soc/mxs/Kconfig +1 -1
@@ -1,7 +1,7 @@ menuconfig SND_MXS_SOC tristate "SoC Audio for Freescale MXS CPUs" depends on ARCH_MXS - select SND_SOC_DMAENGINE_PCM + select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y or M if you want to add support for codecs attached to the MXS SAIF interface.
sound/soc/mxs/mxs-pcm.c +11 -125
174 lines not on this page · raw message
Signature · 1 line
1.8.0
Re: [PATCH 4/8] ASoC: mxs: Use generic dmaengine PCM
Quoted 1 line · Lars-Peter Clausen
Use the generic dmaengine PCM driver instead of a custom implementation.
Applied, thanks.
Lars-Peter Clausen
maintainerPATCH 5/8 ASoC: ep93xx: Setup dma data in DAI probe
In reply to Lars-Peter ClausenThis allows us to access the DAI DMA data when we create the PCM. We'll use this when converting ep39xx to generic DMA engine PCM driver.
---
Changes since v1:
* Fix a mis-rebase which mixed up bits from this patch with the next one
--- sound/soc/cirrus/ep93xx-ac97.c | 14 ++++---------- sound/soc/cirrus/ep93xx-i2s.c | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-)
sound/soc/cirrus/ep93xx-ac97.c +4 -10
@@ -314,22 +314,15 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream,return 0 ; } -static int ep93xx_ac97_startup (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int ep93xx_ac97_dai_probe (struct snd_soc_dai *dai) { -struct ep93xx_dma_data *dma_data; + dai->playback_dma_data = &ep93xx_ac97_pcm_out; + dai->capture_dma_data = &ep93xx_ac97_pcm_in; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - dma_data = &ep93xx_ac97_pcm_out; -else - dma_data = &ep93xx_ac97_pcm_in; - -snd_soc_dai_set_dma_data (dai, substream, dma_data);return 0 ; }static const struct snd_soc_dai_ops ep93xx_ac97_dai_ops = { - .startup = ep93xx_ac97_startup, .trigger = ep93xx_ac97_trigger, };
@@ -337,6 +330,7 @@ static struct snd_soc_dai_driver ep93xx_ac97_dai = { .name = "ep93xx-ac97", .id = 0, .ac97_control = 1, + .probe = ep93xx_ac97_dai_probe, .playback = { .stream_name = "AC97 Playback", .channels_min = 2,
sound/soc/cirrus/ep93xx-i2s.c +4 -10
@@ -60,7 +60,6 @@ struct ep93xx_i2s_info {struct clk *mclk;struct clk *sclk;struct clk *lrclk; -struct ep93xx_dma_data *dma_data;void __iomem *regs; };
@@ -139,15 +138,11 @@ static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info, int stream) } } -static int ep93xx_i2s_startup (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int ep93xx_i2s_dai_probe (struct snd_soc_dai *dai) { -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct ep93xx_i2s_info *info =snd_soc_dai_get_drvdata (dai); -struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + dai->playback_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK ]; + dai->capture_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE ]; -snd_soc_dai_set_dma_data (cpu_dai, substream, - &info->dma_data[substream->stream]);return 0 ; }
@@ -338,7 +333,6 @@ static int ep93xx_i2s_resume(struct snd_soc_dai *dai)#endif static const struct snd_soc_dai_ops ep93xx_i2s_dai_ops = { - .startup = ep93xx_i2s_startup, .shutdown = ep93xx_i2s_shutdown, .hw_params = ep93xx_i2s_hw_params, .set_sysclk = ep93xx_i2s_set_sysclk,
@@ -349,6 +343,7 @@ static const struct snd_soc_dai_ops ep93xx_i2s_dai_ops = {static struct snd_soc_dai_driver ep93xx_i2s_dai = { .symmetric_rates=1 , + .probe = ep93xx_i2s_dai_probe, .suspend = ep93xx_i2s_suspend, .resume = ep93xx_i2s_resume, .playback = {
@@ -403,7 +398,6 @@ static int ep93xx_i2s_probe(struct platform_device *pdev) }dev_set_drvdata (&pdev->dev, info); - info->dma_data = ep93xx_i2s_dma_data; err =snd_soc_register_dai (&pdev->dev, &ep93xx_i2s_dai);if (err)
Signature · 1 line
1.8.0
Lars-Peter Clausen
maintainerRe: [PATCH 5/8] ASoC: ep93xx: Setup dma data in DAI probe
Quoted 5 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting ep39xx to generic DMA engine PCM driver.
Signed-off-by Lars-Peter Clausen <[email protected]>
Hi Mark,
it looks like this patch was lost. The next one in this series which has a dependency on this one was applied though. Should I resend the patch?
- Lars
Quoted 101 lines
---
Changes since v1:
* Fix a mis-rebase which mixed up bits from this patch with the next one--- sound/soc/cirrus/ep93xx-ac97.c | 14 ++++---------- sound/soc/cirrus/ep93xx-i2s.c | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-)sound/soc/cirrus/ep93xx-ac97.c +4
-10@@ -314,22 +314,15 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream,return 0 ; } -static int ep93xx_ac97_startup (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int ep93xx_ac97_dai_probe (struct snd_soc_dai *dai) { -struct ep93xx_dma_data *dma_data; + dai->playback_dma_data = &ep93xx_ac97_pcm_out; + dai->capture_dma_data = &ep93xx_ac97_pcm_in; -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - dma_data = &ep93xx_ac97_pcm_out; -else - dma_data = &ep93xx_ac97_pcm_in; - -snd_soc_dai_set_dma_data (dai, substream, dma_data);return 0 ; }static const struct snd_soc_dai_ops ep93xx_ac97_dai_ops = { - .startup = ep93xx_ac97_startup, .trigger = ep93xx_ac97_trigger, };@@ -337,6 +330,7 @@ static struct snd_soc_dai_driver ep93xx_ac97_dai = { .name = "ep93xx-ac97", .id = 0, .ac97_control = 1, + .probe = ep93xx_ac97_dai_probe, .playback = { .stream_name = "AC97 Playback", .channels_min = 2,sound/soc/cirrus/ep93xx-i2s.c +4
-10@@ -60,7 +60,6 @@ struct ep93xx_i2s_info {struct clk *mclk;struct clk *sclk;struct clk *lrclk; -struct ep93xx_dma_data *dma_data;void __iomem *regs; };@@ -139,15 +138,11 @@ static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info, int stream) } } -static int ep93xx_i2s_startup (struct snd_pcm_substream *substream, -struct snd_soc_dai *dai) +static int ep93xx_i2s_dai_probe (struct snd_soc_dai *dai) { -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct ep93xx_i2s_info *info =snd_soc_dai_get_drvdata (dai); -struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + dai->playback_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_PLAYBACK ]; + dai->capture_dma_data = &ep93xx_i2s_dma_data[SNDRV_PCM_STREAM_CAPTURE ]; -snd_soc_dai_set_dma_data (cpu_dai, substream, - &info->dma_data[substream->stream]);return 0 ; }@@ -338,7 +333,6 @@ static int ep93xx_i2s_resume(struct snd_soc_dai *dai)#endif static const struct snd_soc_dai_ops ep93xx_i2s_dai_ops = { - .startup = ep93xx_i2s_startup, .shutdown = ep93xx_i2s_shutdown, .hw_params = ep93xx_i2s_hw_params, .set_sysclk = ep93xx_i2s_set_sysclk,@@ -349,6 +343,7 @@ static const struct snd_soc_dai_ops ep93xx_i2s_dai_ops = {static struct snd_soc_dai_driver ep93xx_i2s_dai = { .symmetric_rates=1 , + .probe = ep93xx_i2s_dai_probe, .suspend = ep93xx_i2s_suspend, .resume = ep93xx_i2s_resume, .playback = {@@ -403,7 +398,6 @@ static int ep93xx_i2s_probe(struct platform_device *pdev) }dev_set_drvdata (&pdev->dev, info); - info->dma_data = ep93xx_i2s_dma_data; err =snd_soc_register_dai (&pdev->dev, &ep93xx_i2s_dai);if (err)
Mark Brown
maintainerRe: [PATCH 5/8] ASoC: ep93xx: Setup dma data in DAI probe
Quoted 6 lines · Lars-Peter Clausen
Quoted 2 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting ep39xx to generic DMA engine PCM driver.
it looks like this patch was lost. The next one in this series which has a dependency on this one was applied though. Should I resend the patch?
You need to rebase it into the current code, if it's been discared it's a result of the rebase into v3.10-rc1 - I didn't have to do any fixups for ep83xx.
Mark Brown
maintainerRe: [PATCH 5/8] ASoC: ep93xx: Setup dma data in DAI probe
In reply to Lars-Peter ClausenQuoted 2 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting ep39xx to generic DMA engine PCM driver.
Hrm, it seems to still apply against the current code so I did that. Hopefully the tooling worked OK but please check.
Lars-Peter Clausen
maintainerRe: [PATCH 5/8] ASoC: ep93xx: Setup dma data in DAI probe
Quoted 6 lines · Mark Brown
Quoted 2 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting ep39xx to generic DMA engine PCM driver.
Hrm, it seems to still apply against the current code so I did that. Hopefully the tooling worked OK but please check.
Looks fine, the only other change was the removal of platform_set_drvdata(..., NULL).
Lars-Peter Clausen
maintainerPATCH 6/8 ASoC: ep93xx: Use generic dmaengine PCM
In reply to Lars-Peter ClausenUse the generic dmaengine PCM driver instead of a custom implementation.
--- sound/soc/cirrus/Kconfig | 2 +- sound/soc/cirrus/ep93xx-pcm.c | 138 ++++-------------------------------------- 2 files changed, 12 insertions(+), 128 deletions(-)
sound/soc/cirrus/Kconfig +1 -1
@@ -1,7 +1,7 @@ config SND_EP93XX_SOC tristate "SoC Audio support for the Cirrus Logic EP93xx series" depends on ARCH_EP93XX && SND_SOC - select SND_SOC_DMAENGINE_PCM + select SND_SOC_GENERIC_DMAENGINE_PCM help Say Y or M if you want to add support for codecs attached to the EP93xx I2S or AC97 interfaces.
sound/soc/cirrus/ep93xx-pcm.c +11 -127
165 lines not on this page · raw message
Signature · 1 line
1.8.0
Re: [PATCH 6/8] ASoC: ep93xx: Use generic dmaengine PCM
Quoted 1 line · Lars-Peter Clausen
Use the generic dmaengine PCM driver instead of a custom implementation.
Applied, thanks.
Lars-Peter Clausen
maintainerPATCH 7/8 ASoC: spear: Setup dma data in DAI probe
In reply to Lars-Peter ClausenThis allows us to access the DAI DMA data when we create the PCM. We'll use this when converting spear to generic DMA engine PCM driver.
--- sound/soc/spear/spdif_in.c | 12 ++++-------- sound/soc/spear/spdif_out.c | 7 ++++--- 2 files changed, 8 insertions(+), 11 deletions(-)
sound/soc/spear/spdif_in.c +4 -8
@@ -49,15 +49,12 @@ static void spdif_in_configure(struct spdif_in_dev *host)writel (0xF , host->io_base +SPDIF_IN_IRQ_MASK ); } -static int spdif_in_startup (struct snd_pcm_substream *substream, -struct snd_soc_dai *cpu_dai) +static int spdif_in_dai_probe (struct snd_soc_dai *dai) { -struct spdif_in_dev *host =snd_soc_dai_get_drvdata (cpu_dai); +struct spdif_in_dev *host =snd_soc_dai_get_drvdata (dai); -if (substream->stream !=SNDRV_PCM_STREAM_CAPTURE ) -return -EINVAL ; + dai->capture_dma_data = &host->dma_params; -snd_soc_dai_set_dma_data (cpu_dai, substream, (void *)&host->dma_params);return 0 ; }
@@ -70,7 +67,6 @@ static void spdif_in_shutdown(struct snd_pcm_substream *substream,return ;writel (0x0 , host->io_base +SPDIF_IN_IRQ_MASK ); -snd_soc_dai_set_dma_data (dai, substream,NULL ); }static void spdif_in_format (struct spdif_in_dev *host,u32 format)
@@ -151,13 +147,13 @@ static int spdif_in_trigger(struct snd_pcm_substream *substream, int cmd, }static struct snd_soc_dai_ops spdif_in_dai_ops = { - .startup = spdif_in_startup, .shutdown = spdif_in_shutdown, .trigger = spdif_in_trigger, .hw_params = spdif_in_hw_params, };struct snd_soc_dai_driver spdif_in_dai = { + .probe = spdif_in_dai_probe, .capture = { .channels_min =2 , .channels_max =2 ,
sound/soc/spear/spdif_out.c +4 -3
@@ -62,8 +62,6 @@ static int spdif_out_startup(struct snd_pcm_substream *substream,if (substream->stream !=SNDRV_PCM_STREAM_PLAYBACK )return -EINVAL ; -snd_soc_dai_set_dma_data (cpu_dai, substream, (void *)&host->dma_params); - ret =clk_enable (host->clk);if (ret)return ret;
@@ -84,7 +82,6 @@ static void spdif_out_shutdown(struct snd_pcm_substream *substream,clk_disable (host->clk); host->running = false; -snd_soc_dai_set_dma_data (dai, substream,NULL ); } static void spdif_out_clock(struct spdif_out_dev *host, u32 core_freq,
@@ -245,6 +242,10 @@ static const struct snd_kcontrol_new spdif_out_controls[] = {int spdif_soc_dai_probe (struct snd_soc_dai *dai) { +struct spdif_out_dev *host =snd_soc_dai_get_drvdata (dai); + + dai->playback_dma_data = &host->dma_params; +return snd_soc_add_dai_controls (dai, spdif_out_controls,ARRAY_SIZE (spdif_out_controls)); }
Signature · 1 line
1.8.0
Re: [PATCH 7/8] ASoC: spear: Setup dma data in DAI probe
Quoted 2 lines · Lars-Peter Clausen
This allows us to access the DAI DMA data when we create the PCM. We'll use this when converting spear to generic DMA engine PCM driver.
Applied, thanks.
Lars-Peter Clausen
maintainerPATCH 8/8 ASoC: spear: Use generic dmaengine PCM
In reply to Lars-Peter ClausenUse the generic dmaengine PCM driver instead of a custom implementation.
--- sound/soc/spear/spear_pcm.c | 152 +++++--------------------------------------- 1 file changed, 15 insertions(+), 137 deletions(-)
sound/soc/spear/spear_pcm.c +15 -137
@@ -13,19 +13,13 @@#include <linux/module.h> #include <linux/dmaengine.h> -#include <linux/dma-mapping.h> -#include <linux/init.h> #include <linux/platform_device.h> -#include <linux/scatterlist.h> -#include <linux/slab.h> -#include <sound/core.h> #include <sound/dmaengine_pcm.h> #include <sound/pcm.h> -#include <sound/pcm_params.h> #include <sound/soc.h> #include <sound/spear_dma.h> -struct snd_pcm_hardware spear_pcm_hardware = { +static const struct snd_pcm_hardware spear_pcm_hardware = { .info = (SNDRV_PCM_INFO_INTERLEAVED |SNDRV_PCM_INFO_BLOCK_TRANSFER |SNDRV_PCM_INFO_MMAP |SNDRV_PCM_INFO_MMAP_VALID |SNDRV_PCM_INFO_PAUSE |SNDRV_PCM_INFO_RESUME ),
@@ -37,149 +31,33 @@ struct snd_pcm_hardware spear_pcm_hardware = { .fifo_size = 0, /* fifo size in bytes */ }; -static int spear_pcm_hw_params (struct snd_pcm_substream *substream, -struct snd_pcm_hw_params *params) +static struct dma_chan *spear_pcm_request_chan (struct snd_soc_pcm_runtime *rtd, +struct snd_pcm_substream *substream) { -snd_pcm_set_runtime_buffer (substream, &substream->dma_buffer); +struct spear_dma_data *dma_data; -return 0 ; -} - -static int spear_pcm_hw_free (struct snd_pcm_substream *substream) -{ -snd_pcm_set_runtime_buffer (substream,NULL ); - -return 0 ; -} - -static int spear_pcm_open (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; - -struct spear_dma_data *dma_data = (struct spear_dma_data *) -snd_soc_dai_get_dma_data (rtd->cpu_dai, substream); -int ret; - - ret =snd_soc_set_runtime_hwparams (substream, &spear_pcm_hardware); -if (ret) -return ret; + dma_data =snd_soc_dai_get_dma_data (rtd->cpu_dai, substream); -return snd_dmaengine_pcm_open_request_chan (substream, dma_data->filter, - dma_data); +return snd_dmaengine_pcm_request_channel (dma_data->filter, dma_data); } -static int spear_pcm_mmap (struct snd_pcm_substream *substream, -struct vm_area_struct *vma) -{ -struct snd_pcm_runtime *runtime = substream->runtime; - -return dma_mmap_writecombine (substream->pcm->card->dev, vma, - runtime->dma_area, runtime->dma_addr, - runtime->dma_bytes); -} - -static struct snd_pcm_ops spear_pcm_ops = { - .open = spear_pcm_open, - .close = snd_dmaengine_pcm_close_release_chan, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = spear_pcm_hw_params, - .hw_free = spear_pcm_hw_free, - .trigger = snd_dmaengine_pcm_trigger, - .pointer = snd_dmaengine_pcm_pointer, - .mmap = spear_pcm_mmap, -}; - -static int -spear_pcm_preallocate_dma_buffer (struct snd_pcm *pcm,int stream, -size_t size) -{ -struct snd_pcm_substream *substream = pcm->streams[stream].substream; -struct snd_dma_buffer *buf = &substream->dma_buffer; - - buf->dev.type =SNDRV_DMA_TYPE_DEV ; - buf->dev.dev = pcm->card->dev; - buf->private_data =NULL ; - - buf->area =dma_alloc_writecombine (pcm->card->dev, size, - &buf->addr,GFP_KERNEL ); -if (!buf->area) -return -ENOMEM ; - -dev_info (buf->dev.dev, -" preallocate_dma_buffer: area=%p, addr=%p, size=%d\n" , - (void *)buf->area, (void *)buf->addr, size); - - buf->bytes = size; -return 0 ; -} - -static void spear_pcm_free (struct snd_pcm *pcm) -{ -struct snd_pcm_substream *substream; -struct snd_dma_buffer *buf; -int stream; - -for (stream =0 ; stream <2 ; stream++) { - substream = pcm->streams[stream].substream; -if (!substream) -continue ; - - buf = &substream->dma_buffer; -if (!buf || !buf->area) -continue ; - -dma_free_writecombine (pcm->card->dev, buf->bytes, - buf->area, buf->addr); - buf->area =NULL ; - } -} - -static u64 spear_pcm_dmamask =DMA_BIT_MASK (32 ); - -static int spear_pcm_new (struct snd_soc_pcm_runtime *rtd) -{ -struct snd_card *card = rtd->card->snd_card; -int ret; - -if (!card->dev->dma_mask) - card->dev->dma_mask = &spear_pcm_dmamask; -if (!card->dev->coherent_dma_mask) - card->dev->coherent_dma_mask =DMA_BIT_MASK (32 ); - -if (rtd->cpu_dai->driver->playback.channels_min) { - ret =spear_pcm_preallocate_dma_buffer (rtd->pcm, -SNDRV_PCM_STREAM_PLAYBACK , - spear_pcm_hardware.buffer_bytes_max); -if (ret) -return ret; - } - -if (rtd->cpu_dai->driver->capture.channels_min) { - ret =spear_pcm_preallocate_dma_buffer (rtd->pcm, -SNDRV_PCM_STREAM_CAPTURE , - spear_pcm_hardware.buffer_bytes_max); -if (ret) -return ret; - } - -return 0 ; -} - -struct snd_soc_platform_driver spear_soc_platform = { - .ops = &spear_pcm_ops, - .pcm_new = spear_pcm_new, - .pcm_free = spear_pcm_free, +static const struct snd_dmaengine_pcm_config spear_dmaengine_pcm_config = { + .pcm_hardware = &spear_pcm_hardware, + .compat_request_channel = spear_pcm_request_chan, + .prealloc_buffer_size =16 *1024 , };static int spear_soc_platform_probe (struct platform_device *pdev) { -return snd_soc_register_platform (&pdev->dev, &spear_soc_platform); +return snd_dmaengine_pcm_register (&pdev->dev, + &spear_dmaengine_pcm_config, +SND_DMAENGINE_PCM_FLAG_NO_DT | +SND_DMAENGINE_PCM_FLAG_COMPAT ); }static int spear_soc_platform_remove (struct platform_device *pdev) { -snd_soc_unregister_platform (&pdev->dev); - +snd_dmaengine_pcm_unregister (&pdev->dev);return 0 ; }
Signature · 1 line
1.8.0
Re: [PATCH 8/8] ASoC: spear: Use generic dmaengine PCM
Quoted 1 line · Lars-Peter Clausen
Use the generic dmaengine PCM driver instead of a custom implementation.
Applied, thanks.
Quoted 5 lines · Lars-Peter Clausen
Some platforms which are half-duplex share the same DMA channel between the playback and capture stream. Add support for this to the generic dmaengine PCM driver.
Signed-off-by Lars-Peter Clausen <[email protected]>
Patch 1 ~ 4,
Quoted 3 lines · Lars-Peter Clausen
Some platforms which are half-duplex share the same DMA channel between the playback and capture stream. Add support for this to the generic dmaengine PCM driver.
Applied, thanks.