ASoC: samsung: Provide helper for DMA init
Subsystems (5)
Mark Brown
maintainerPATCH 1/3 ASoC: samsung: Provide helper for DMA init
From: Mark Brown <[email protected]>
In preparation for using the dmaengine helpers in ASoC rather than the dmaengine wrappers for the Samsung API wrap the configuration of dma_data. The dmaengine code expects different data to that used by the legacy API.
--- sound/soc/samsung/ac97.c | 51 +++++++++++++++--------------------------------- sound/soc/samsung/dma.c | 8 ++++++++ sound/soc/samsung/dma.h | 3 +++ sound/soc/samsung/i2s.c | 2 +- sound/soc/samsung/pcm.c | 18 +++++++++-------- 5 files changed, 38 insertions(+), 44 deletions(-)
sound/soc/samsung/ac97.c +16 -35
@@ -221,24 +221,6 @@ static struct snd_ac97_bus_ops s3c_ac97_ops = { .reset = s3c_ac97_cold_reset, }; -static int s3c_ac97_hw_params (struct snd_pcm_substream *substream, -struct snd_pcm_hw_params *params, -struct snd_soc_dai *dai) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai; -struct s3c_dma_params *dma_data; - -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - dma_data = &s3c_ac97_pcm_out; -else - dma_data = &s3c_ac97_pcm_in; - -snd_soc_dai_set_dma_data (cpu_dai, substream, dma_data); - -return 0 ; -} -static int s3c_ac97_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai) {
@@ -279,21 +261,6 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd,return 0 ; } -static int s3c_ac97_hw_mic_params (struct snd_pcm_substream *substream, -struct snd_pcm_hw_params *params, -struct snd_soc_dai *dai) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) -return -ENODEV ; -else -snd_soc_dai_set_dma_data (cpu_dai, substream, &s3c_ac97_mic_in); - -return 0 ; -} -static int s3c_ac97_mic_trigger (struct snd_pcm_substream *substream,int cmd,struct snd_soc_dai *dai) {
@@ -329,15 +296,27 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, }static const struct snd_soc_dai_ops s3c_ac97_dai_ops = { - .hw_params = s3c_ac97_hw_params, .trigger = s3c_ac97_trigger, };static const struct snd_soc_dai_ops s3c_ac97_mic_dai_ops = { - .hw_params = s3c_ac97_hw_mic_params, .trigger = s3c_ac97_mic_trigger, }; +static int s3c_ac97_dai_probe (struct snd_soc_dai *dai) +{ +samsung_asoc_init_dma_data (dai, &s3c_ac97_pcm_out, &s3c_ac97_pcm_in); + +return 0 ; +} + +static int s3c_ac97_mic_dai_probe (struct snd_soc_dai *dai) +{ +samsung_asoc_init_dma_data (dai,NULL , &s3c_ac97_mic_in); + +return 0 ; +} +static struct snd_soc_dai_driver s3c_ac97_dai[] = { [S3C_AC97_DAI_PCM ] = { .name ="samsung-ac97" ,
@@ -354,6 +333,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = { .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, + .probe = s3c_ac97_dai_probe, .ops = &s3c_ac97_dai_ops, }, [S3C_AC97_DAI_MIC] = {
@@ -365,6 +345,7 @@ static struct snd_soc_dai_driver s3c_ac97_dai[] = { .channels_max = 1, .rates = SNDRV_PCM_RATE_8000_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE,}, + .probe = s3c_ac97_mic_dai_probe, .ops = &s3c_ac97_mic_dai_ops, }, };
sound/soc/samsung/dma.c +8 -0
@@ -441,6 +441,14 @@ static struct snd_soc_platform_driver samsung_asoc_platform = { .pcm_free = dma_free_dma_buffers, }; +void samsung_asoc_init_dma_data (struct snd_soc_dai *dai, +struct s3c_dma_params *playback, +struct s3c_dma_params *capture) +{ +snd_soc_dai_init_dma_data (dai, playback, capture); +} +EXPORT_SYMBOL_GPL (samsung_asoc_init_dma_data); +int samsung_asoc_dma_platform_register (struct device *dev) {return snd_soc_register_platform (dev, &samsung_asoc_platform);
sound/soc/samsung/dma.h +3 -0
@@ -22,6 +22,9 @@ struct s3c_dma_params {char *ch_name; }; +void samsung_asoc_init_dma_data (struct snd_soc_dai *dai, +struct s3c_dma_params *playback, +struct s3c_dma_params *capture);int samsung_asoc_dma_platform_register (struct device *dev);void samsung_asoc_dma_platform_unregister (struct device *dev);
sound/soc/samsung/i2s.c +1 -1
@@ -963,7 +963,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) }clk_prepare_enable (i2s->clk); -snd_soc_dai_init_dma_data (dai, &i2s->dma_playback, &i2s->dma_capture); +samsung_asoc_init_dma_data (dai, &i2s->dma_playback, &i2s->dma_capture);if (other) { other->addr = i2s->addr;
sound/soc/samsung/pcm.c +10 -8
@@ -275,7 +275,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream, {struct snd_soc_pcm_runtime *rtd = substream->private_data;struct s3c_pcm_info *pcm =snd_soc_dai_get_drvdata (rtd->cpu_dai); -struct s3c_dma_params *dma_data;void __iomem *regs = pcm->regs;struct clk *clk;int sclk_div, sync_div;
@@ -284,13 +283,6 @@ static int s3c_pcm_hw_params(struct snd_pcm_substream *substream,dev_dbg (pcm->dev,"Entered %s\n" , __func__); -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - dma_data = pcm->dma_playback; -else - dma_data = pcm->dma_capture; - -snd_soc_dai_set_dma_data (rtd->cpu_dai, substream, dma_data); -/* Strictly check for sample size */ switch (params_format (params)) {case SNDRV_PCM_FORMAT_S16_LE :
@@ -461,10 +453,20 @@ static const struct snd_soc_dai_ops s3c_pcm_dai_ops = { .set_fmt = s3c_pcm_set_fmt, }; +static int s3c_pcm_dai_probe (struct snd_soc_dai *dai) +{ +struct s3c_pcm_info *pcm =snd_soc_dai_get_drvdata (dai); + +snd_soc_dai_init_dma_data (dai, pcm->dma_playback, pcm->dma_capture); + +return 0 ; +} +#define S3C_PCM_RATES SNDRV_PCM_RATE_8000_96000#define S3C_PCM_DAI_DECLARE \ .symmetric_rates = 1, \ + .probe = s3c_pcm_dai_probe, \ .ops = &s3c_pcm_dai_ops, \ .playback = { \ .channels_min = 2, \
Signature · 1 line
1.8.4.rc3
Mark Brown
maintainerPATCH 2/3 ASoC: dmaengine: Support custom channel names
From: Mark Brown <[email protected]>
Some devices have more than just simple TX and RX DMA channels, for example modern Samsung I2S IPs support a secondary transmit DMA stream which is mixed into the primary stream during playback. Allow such devices to specify the names of the channels to be requested in their dma_data.
--- include/sound/dmaengine_pcm.h | 6 ++++++ sound/soc/soc-generic-dmaengine-pcm.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
include/sound/dmaengine_pcm.h +6 -0
@@ -61,6 +61,7 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream)* @slave_id: Slave requester id for the DMA channel. * @filter_data: Custom DMA channel filter data, this will usually be used when * requesting the DMA channel. +* @chan_name: Custom channel name to use when requesting DMA channel. * @fifo_size: FIFO size of the DAI controller in bytes */ struct snd_dmaengine_dai_dma_data {
@@ -69,6 +70,7 @@ struct snd_dmaengine_dai_dma_data {u32 maxburst;unsigned int slave_id;void *filter_data; +const char *chan_name;unsigned int fifo_size; };
@@ -98,6 +100,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data(* playback. */ #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3) +/* +* The PCM streams have custom channel names specified. +*/ +#define SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME BIT(4)/** * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM
sound/soc/soc-generic-dmaengine-pcm.c +12 -1
@@ -186,6 +186,8 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) {struct dmaengine_pcm *pcm =soc_platform_to_pcm (rtd->platform);const struct snd_dmaengine_pcm_config *config = pcm->config; +struct device *dev = rtd->platform->dev; +struct snd_dmaengine_dai_dma_data *dma_data;struct snd_pcm_substream *substream;size_t prealloc_buffer_size;size_t max_buffer_size;
@@ -206,6 +208,13 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)if (!substream)continue ; + dma_data =snd_soc_dai_get_dma_data (rtd->cpu_dai, substream); + +if (!pcm->chan[i] && + (pcm->flags &SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME )) + pcm->chan[i] =dma_request_slave_channel (dev, + dma_data->chan_name); +if (!pcm->chan[i] && (pcm->flags &SND_DMAENGINE_PCM_FLAG_COMPAT )) { pcm->chan[i] =dmaengine_pcm_compat_request_channel (rtd, substream);
@@ -278,7 +287,9 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, {unsigned int i; -if ((pcm->flags &SND_DMAENGINE_PCM_FLAG_NO_DT ) || !dev->of_node) +if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | +SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME )) || + !dev->of_node)return ;if (pcm->flags &SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX ) {
Signature · 1 line
1.8.4.rc3
Lars-Peter Clausen
maintainerRe: [alsa-devel] [PATCH 2/3] ASoC: dmaengine: Support custom channel names
Quoted 8 lines · Mark Brown
From: Mark Brown <[email protected]>
Some devices have more than just simple TX and RX DMA channels, for example modern Samsung I2S IPs support a secondary transmit DMA stream which is mixed into the primary stream during playback. Allow such devices to specify the names of the channels to be requested in their
dma_data.Signed-off-by Mark Brown <[email protected]>
As shortly discussed yesterday, I think the general idea is fine. But it might be better to have the names available at PCM creation time, since this allows us to e.g. do proper probe referral and will also have the code take the same path in the DT case, no matter if it uses the default names or not.
- Lars
Mark Brown
maintainerRe: [PATCH 2/3] ASoC: dmaengine: Support custom channel names
Quoted 11 lines · Lars-Peter Clausen
Quoted 4 lines · Mark Brown
Some devices have more than just simple TX and RX DMA channels, for example modern Samsung I2S IPs support a secondary transmit DMA stream which is mixed into the primary stream during playback. Allow such devices to specify the names of the channels to be requested in their
dma_data.As shortly discussed yesterday, I think the general idea is fine. But it might be better to have the names available at PCM creation time, since this allows us to e.g. do proper probe referral and will also have the code take the same path in the DT case, no matter if it uses the default names or not.
I agree, but I'm thinking that the way to do this is to get the entire struct provided earlier so that the compat drivers get to use this stuff too. Is there any great reason not to do that?
Lars-Peter Clausen
maintainerRe: [alsa-devel] [PATCH 2/3] ASoC: dmaengine: Support custom channel names
Quoted 8 lines · Mark Brown
Quoted 6 lines · Lars-Peter Clausen
Quoted 4 lines · Mark Brown
Some devices have more than just simple TX and RX DMA channels, for example modern Samsung I2S IPs support a secondary transmit DMA stream which is mixed into the primary stream during playback. Allow such devices to specify the names of the channels to be requested in their
dma_data.
Quoted 8 lines
Quoted 4 lines
As shortly discussed yesterday, I think the general idea is fine. But it might be better to have the names available at PCM creation time, since this allows us to e.g. do proper probe referral and will also have the code take the same path in the DT case, no matter if it uses the default names or not.
I agree, but I'm thinking that the way to do this is to get the entire struct provided earlier so that the compat drivers get to use this stuff too. Is there any great reason not to do that?
No, that should be fine. I've been thinking about this before as well. We probably need something like a snd_soc_register_component_with_dai_data() or similar. That assign the DAI data on creation.
- Lars
Mark Brown
maintainerPATCH 3/3 ASoC: samsung: Use ASoC dmaengine code where possible
In reply to Mark BrownFrom: Mark Brown <[email protected]>
Since all Exynos platforms have been converted to dmaengine and many of the older platforms are in the process of conversion they do not need to use the legacy s3c-dma APIs for DMA but can instead use the standard ASoC dmaengine helpers. This both allows them to benefit from improvements implemented in the generic code and supports multiplatform.
---
This uses the patches I've posted over the weekend and Lars-Peter's changes to support querying DMA capabilities from the driver is currently failing for me on s3c64xx where the DMA controller reports an error immediately and fails to transfer anything, I'm going to investigate that but that shouldn't be an issue for mainline yet since the patches converting to Tomasz haven't landed yet s3c64xx is still using s3c-dma there.
sound/soc/samsung/Kconfig | 9 +++++ sound/soc/samsung/Makefile | 6 ++-- sound/soc/samsung/dma.h | 3 ++ sound/soc/samsung/dmaengine.c | 83 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 sound/soc/samsung/dmaengine.c
sound/soc/samsung/Kconfig +9 -0
@@ -3,11 +3,20 @@ config SND_SOC_SAMSUNG depends on PLAT_SAMSUNG || COMPILE_TEST select S3C64XX_PL080 if ARCH_S3C64XX select S3C2410_DMA if ARCH_S3C24XX + select SND_S3C_DMA if !(ARCH_S3C24XX || ARCH_S3C64XX) + select SND_S3C_DMA_LEGACY if ARCH_S3C24XX || ARCH_S3C64XX + select SND_SOC_GENERIC_DMAENGINE_PCM if !(ARCH_S3C24XX || ARCH_S3C64XX) help Say Y or M if you want to add support for codecs attached to the Samsung SoCs' Audio interfaces. You will also need to select the audio interfaces to support below. +config SND_S3C_DMA + tristate + +config SND_S3C_DMA_LEGACY + tristate + config SND_S3C24XX_I2S tristate select S3C2410_DMA
sound/soc/samsung/Makefile +4 -2
@@ -1,5 +1,6 @@ # S3c24XX Platform Support -snd-soc-s3c24xx-objs := dma.o +snd-soc-s3c-dma-objs := dmaengine.o +snd-soc-s3c-dma-legacy-objs := dma.o snd-soc-idma-objs := idma.o snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o
@@ -9,7 +10,8 @@ snd-soc-samsung-spdif-objs := spdif.o snd-soc-pcm-objs := pcm.o snd-soc-i2s-objs := i2s.o -obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c24xx.o +obj-$(CONFIG_SND_S3C_DMA) += snd-soc-s3c-dma.o +obj-$(CONFIG_SND_S3C_DMA_LEGACY) += snd-soc-s3c-dma-legacy.o obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o
sound/soc/samsung/dma.h +3 -0
@@ -12,6 +12,8 @@ #ifndef _S3C_AUDIO_H #define _S3C_AUDIO_H +#include <sound/dmaengine_pcm.h> + struct s3c_dma_params { struct s3c2410_dma_client *client; /* stream identifier */ int channel; /* Channel ID */
@@ -20,6 +22,7 @@ struct s3c_dma_params {unsigned ch;struct samsung_dma_ops *ops;char *ch_name; +struct snd_dmaengine_dai_dma_data dma_data; }; void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
sound/soc/samsung/dmaengine.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
1.8.4.rc3