[alsa-devel] [PATCH 1/2] ASoC: samsung: Provide helper for DMA init
From: Mark Brown broonie@linaro.org
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.
Signed-off-by: Mark Brown broonie@linaro.org --- 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(-)
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c index 350ba23..4a88e36 100644 --- a/sound/soc/samsung/ac97.c +++ b/sound/soc/samsung/ac97.c @@ -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, }, }; diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index fe2748b..ee23194 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -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); diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h index 0e86315..fb09a1c 100644 --- a/sound/soc/samsung/dma.h +++ b/sound/soc/samsung/dma.h @@ -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);
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index a5cbdb4..67d9fa9 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -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; diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index e54256f..6a5e4bf 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c @@ -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, \
From: Mark Brown broonie@linaro.org
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.
Signed-off-by: Mark Brown broonie@linaro.org ---
This depends on Tomasz's s3c64xx dmaengine conversion since that is how I've tested it - if possible I'd like to get that merged into ASoC and SPI early after -rc1, since I maintian both trees it's possibly easiest if I go ahead any apply it?
sound/soc/samsung/Kconfig | 13 +++++-- sound/soc/samsung/Makefile | 6 ++-- sound/soc/samsung/dma.h | 3 ++ sound/soc/samsung/dmaengine.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 sound/soc/samsung/dmaengine.c
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 6afcf9d..cd21a8e 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -1,13 +1,22 @@ config SND_SOC_SAMSUNG tristate "ASoC support for Samsung" depends on PLAT_SAMSUNG || COMPILE_TEST - select S3C64XX_DMA if ARCH_S3C64XX - select S3C24XX_DMA if ARCH_S3C24XX + select S3C2410_DMA if ARCH_S3C24XX + select S3C64XX_PL080 if ARCH_S3C64XX + select SND_S3C_DMA if !ARCH_S3C24XX + select SND_S3C_DMA_LEGACY if ARCH_S3C24XX + select SND_SOC_GENERIC_DMAENGINE_PCM if !ARCH_S3C24XX 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 diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 709f605..86715d8 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -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 diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h index fb09a1c..225e537 100644 --- a/sound/soc/samsung/dma.h +++ b/sound/soc/samsung/dma.h @@ -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, diff --git a/sound/soc/samsung/dmaengine.c b/sound/soc/samsung/dmaengine.c new file mode 100644 index 0000000..ad0a371 --- /dev/null +++ b/sound/soc/samsung/dmaengine.c @@ -0,0 +1,82 @@ +/* + * dmaengine.c - Samsung dmaengine wrapper + * + * Author: Mark Brown broonie@linaro.org + * Copyright 2013 Linaro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#include <linux/module.h> +#include <linux/amba/pl08x.h> + +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/dmaengine_pcm.h> +#include <sound/soc.h> +#include <sound/soc-dai.h> + +#include "dma.h" + +#ifdef CONFIG_ARCH_S3C64XX +#define filter_fn pl08x_filter_id +#else +#define filter_fn NULL +#endif + +static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = { + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .compat_filter_fn = filter_fn, +}; + +void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, + struct s3c_dma_params *playback, + struct s3c_dma_params *capture) +{ + struct snd_dmaengine_dai_dma_data *playback_data = NULL; + struct snd_dmaengine_dai_dma_data *capture_data = NULL; + + if (playback) { + playback_data = &playback->dma_data; + playback_data->filter_data = (void *)playback->channel; + playback_data->chan_name = playback->ch_name; + playback_data->addr = playback->dma_addr; + playback_data->addr_width = playback->dma_size; + } + if (capture) { + capture_data = &capture->dma_data; + capture_data->filter_data = (void *)capture->channel; + capture_data->chan_name = capture->ch_name; + capture_data->addr = capture->dma_addr; + capture_data->addr_width = capture->dma_size; + } + + snd_soc_dai_init_dma_data(dai, playback_data, capture_data); +} +EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); + +int samsung_asoc_dma_platform_register(struct device *dev) +{ + return snd_dmaengine_pcm_register(dev, &samsung_dmaengine_pcm_config, + SND_DMAENGINE_PCM_FLAG_COMPAT); +} +EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register); + +void samsung_asoc_dma_platform_unregister(struct device *dev) +{ + return snd_dmaengine_pcm_unregister(dev); +} +EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_unregister); + +MODULE_AUTHOR("Mark Brown broonie@linaro.org"); +MODULE_DESCRIPTION("Samsung dmaengine ASoC driver"); +MODULE_LICENSE("GPL");
Hi Mark,
On Tue, Nov 12, 2013 at 7:18 PM, Mark Brown broonie@kernel.org wrote:
From: Mark Brown broonie@linaro.org
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.
Signed-off-by: Mark Brown broonie@linaro.org
This depends on Tomasz's s3c64xx dmaengine conversion since that is how I've tested it - if possible I'd like to get that merged into ASoC and SPI early after -rc1, since I maintian both trees it's possibly easiest if I go ahead any apply it?
sound/soc/samsung/Kconfig | 13 +++++-- sound/soc/samsung/Makefile | 6 ++-- sound/soc/samsung/dma.h | 3 ++ sound/soc/samsung/dmaengine.c | 82 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 sound/soc/samsung/dmaengine.c
[snip]
void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, diff --git a/sound/soc/samsung/dmaengine.c b/sound/soc/samsung/dmaengine.c new file mode 100644 index 0000000..ad0a371 --- /dev/null +++ b/sound/soc/samsung/dmaengine.c @@ -0,0 +1,82 @@ +/*
- dmaengine.c - Samsung dmaengine wrapper
- Author: Mark Brown broonie@linaro.org
- Copyright 2013 Linaro
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
- */
+#include <linux/module.h> +#include <linux/amba/pl08x.h>
+#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/dmaengine_pcm.h> +#include <sound/soc.h> +#include <sound/soc-dai.h>
+#include "dma.h"
+#ifdef CONFIG_ARCH_S3C64XX +#define filter_fn pl08x_filter_id +#else +#define filter_fn NULL +#endif
+static const struct snd_dmaengine_pcm_config samsung_dmaengine_pcm_config = {
.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
.compat_filter_fn = filter_fn,
+};
+void samsung_asoc_init_dma_data(struct snd_soc_dai *dai,
struct s3c_dma_params *playback,
struct s3c_dma_params *capture)
+{
struct snd_dmaengine_dai_dma_data *playback_data = NULL;
struct snd_dmaengine_dai_dma_data *capture_data = NULL;
if (playback) {
playback_data = &playback->dma_data;
playback_data->filter_data = (void *)playback->channel;
playback_data->chan_name = playback->ch_name;
playback_data->addr = playback->dma_addr;
playback_data->addr_width = playback->dma_size;
}
if (capture) {
capture_data = &capture->dma_data;
capture_data->filter_data = (void *)capture->channel;
capture_data->chan_name = capture->ch_name;
capture_data->addr = capture->dma_addr;
capture_data->addr_width = capture->dma_size;
}
snd_soc_dai_init_dma_data(dai, playback_data, capture_data);
+} +EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data);
+int samsung_asoc_dma_platform_register(struct device *dev) +{
return snd_dmaengine_pcm_register(dev, &samsung_dmaengine_pcm_config,
SND_DMAENGINE_PCM_FLAG_COMPAT);
also need to pass flag SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME here?
I tested this patch set on smdk5420 i2s. During playback audio playing fast and there is underrun error like below. underrun!!! (at least 0.061 ms long) underrun!!! (at least 0.043 ms long)
Thanks Padma
On Tue, Nov 26, 2013 at 10:55:17AM +0530, Padma Venkat wrote:
I tested this patch set on smdk5420 i2s. During playback audio playing fast and there is underrun error like below. underrun!!! (at least 0.061 ms long) underrun!!! (at least 0.043 ms long)
This sounds like it's setting the transfer width incorrectly, though I can't immediately see how that's changed unless the DMA driver is not working correctly. What exactly did you do to test?
Hi Mark,
On Tue, Nov 26, 2013 at 3:53 PM, Mark Brown broonie@kernel.org wrote:
On Tue, Nov 26, 2013 at 10:55:17AM +0530, Padma Venkat wrote:
I tested this patch set on smdk5420 i2s. During playback audio playing fast and there is underrun error like below. underrun!!! (at least 0.061 ms long) underrun!!! (at least 0.043 ms long)
This sounds like it's setting the transfer width incorrectly, though I can't immediately see how that's changed unless the DMA driver is not working correctly. What exactly did you do to test?
I tried this on linux-samsung tree by applying all the patches from you and Lars. I initialised the dma_data for secondary dai as there is a crash with out that. Then I used aplay after running the mixer settings. ./aplay /mars/share/sounds/alsa/Front_Center.wav
Thanks Padma
On Tue, Nov 26, 2013 at 04:18:41PM +0530, Padma Venkat wrote:
I tried this on linux-samsung tree by applying all the patches from you and Lars.
Can you use -next plus the posted patches please in case there's something been misplaced, it'll help if we're working from the same code base?
I initialised the dma_data for secondary dai as there is a crash with out that.
Can you please send a patch for that if you find it's needed? Like I said in reply to your earlier mail it looks like this doesn't work anyway so mainline ought to be fixed.
Then I used aplay after running the mixer settings. ./aplay /mars/share/sounds/alsa/Front_Center.wav
So this is 16 bit stereo or something, and did it work beforehand? Like I say I suspect the DMA is ending up being configured with the wrong transfer size, can you check what actually happens there please - what's different about the configuration that the DMA controller gets? I don't have any Exynos systems with mainline audio support so I can't test anything myself.
Hi Mark,
On Tue, Nov 26, 2013 at 5:50 PM, Mark Brown broonie@kernel.org wrote:
On Tue, Nov 26, 2013 at 04:18:41PM +0530, Padma Venkat wrote:
I tried this on linux-samsung tree by applying all the patches from you and Lars.
Can you use -next plus the posted patches please in case there's something been misplaced, it'll help if we're working from the same code base?
Sound tree has some booting issue on smdk5420 so I tried this on linux-samsung tree.
I initialised the dma_data for secondary dai as there is a crash with out that.
Can you please send a patch for that if you find it's needed? Like I said in reply to your earlier mail it looks like this doesn't work anyway so mainline ought to be fixed.
Okay. I will send a patch.
Then I used aplay after running the mixer settings. ./aplay /mars/share/sounds/alsa/Front_Center.wav
So this is 16 bit stereo or something, and did it work beforehand? Like I say I suspect the DMA is ending up being configured with the wrong transfer size, can you check what actually happens there please - what's different about the configuration that the DMA controller gets? I don't have any Exynos systems with mainline audio support so I can't test anything myself.
This stream was working before. dma_size in i2s_hw_params not getting effected as dma_data is getting initialized only at dai probe time. So by default the dma_size is always 4 which is initialized at driver probe time. The fifo_size of dai is also always 0. It is not getting passed from dai driver. I just hard coded the dma_size to 2 and fifo_size to 32 then I can hear the audio only on right ear phone. Still underrun error message appears.
Thanks Padma
On Wed, Nov 27, 2013 at 06:08:47PM +0530, Padma Venkat wrote:
On Tue, Nov 26, 2013 at 5:50 PM, Mark Brown broonie@kernel.org wrote:
So this is 16 bit stereo or something, and did it work beforehand? Like I say I suspect the DMA is ending up being configured with the wrong transfer size, can you check what actually happens there please - what's different about the configuration that the DMA controller gets? I don't have any Exynos systems with mainline audio support so I can't test anything myself.
This stream was working before. dma_size in i2s_hw_params not getting effected as dma_data is getting initialized only at dai probe time. So by default the dma_size is always 4 which is initialized at driver probe time. The fifo_size of dai is also always 0. It is not getting passed from dai driver. I just hard coded the dma_size to 2 and
But if it's initialised at probe time then when is it getting overwritten? This must be something triggered by DT which unfortunately I can't test. It's a bit of a shame that the flows are different between the DT and non-DT cases.
The FIFO size looks like a difference between the pl330 and pl080, it doesn't seem to matter for pl080. We just need to set it though.
fifo_size to 32 then I can hear the audio only on right ear phone. Still underrun error message appears.
Are you sure that dma_size should be 2? The i2s DAI driver seems to be hard coding it to 4.
Hi Mark,
On Wed, Nov 27, 2013 at 8:35 PM, Mark Brown broonie@kernel.org wrote:
On Wed, Nov 27, 2013 at 06:08:47PM +0530, Padma Venkat wrote:
On Tue, Nov 26, 2013 at 5:50 PM, Mark Brown broonie@kernel.org wrote:
So this is 16 bit stereo or something, and did it work beforehand? Like I say I suspect the DMA is ending up being configured with the wrong transfer size, can you check what actually happens there please - what's different about the configuration that the DMA controller gets? I don't have any Exynos systems with mainline audio support so I can't test anything myself.
This stream was working before. dma_size in i2s_hw_params not getting effected as dma_data is getting initialized only at dai probe time. So by default the dma_size is always 4 which is initialized at driver probe time. The fifo_size of dai is also always 0. It is not getting passed from dai driver. I just hard coded the dma_size to 2 and
But if it's initialised at probe time then when is it getting overwritten? This must be something triggered by DT which unfortunately I can't test. It's a bit of a shame that the flows are different between the DT and non-DT cases.
it's getting overwritten in i2s_hw_params which is happening after dma_data got initialized in dai probe. Based on mono or stereo channel this value getting initialized to 2 or 4 respectively in i2s_hw_params. This value is not triggered by DT now.
The FIFO size looks like a difference between the pl330 and pl080, it doesn't seem to matter for pl080. We just need to set it though.
fifo_size seems doesn't have any effect even in this case.
fifo_size to 32 then I can hear the audio only on right ear phone. Still underrun error message appears.
Are you sure that dma_size should be 2? The i2s DAI driver seems to be hard coding it to 4.
I think for mono files the dma_size should be 2 only. Right now based on mono or stereo this value getting overwritten in i2s_hw_params. Initially it is hardcoded to 4. Due to this commit "ASoC: samsung: Allow mono in i2s driver" which was not there earlier, I got confused. Now it seems clear except that underrun message which I am still debugging.
Thanks Padma
On Thu, Nov 28, 2013 at 03:29:31PM +0530, Padma Venkat wrote:
On Wed, Nov 27, 2013 at 8:35 PM, Mark Brown broonie@kernel.org wrote:
But if it's initialised at probe time then when is it getting overwritten? This must be something triggered by DT which unfortunately I can't test. It's a bit of a shame that the flows are different between the DT and non-DT cases.
it's getting overwritten in i2s_hw_params which is happening after dma_data got initialized in dai probe. Based on mono or stereo channel this value getting initialized to 2 or 4 respectively in i2s_hw_params. This value is not triggered by DT now.
OK, so we can probably just reinitialise the dmaengine data after we reset it? Like below
Are you sure that dma_size should be 2? The i2s DAI driver seems to be hard coding it to 4.
I think for mono files the dma_size should be 2 only. Right now based on mono or stereo this value getting overwritten in i2s_hw_params. Initially it is hardcoded to 4. Due to this commit "ASoC: samsung: Allow mono in i2s driver" which was not there earlier, I got confused. Now it seems clear except that underrun message which I am still debugging.
Yeah, that's now confusing - I'll send a patch to remove the initialisation on probe() since it's getting overwritten later.
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 67d9fa91fdb9..ba24a954b9e4 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -702,6 +702,8 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, } writel(mod, i2s->addr + I2SMOD);
+ samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); + i2s->frmclk = params_rate(params);
return 0;
Hi Mark,
On Thu, Nov 28, 2013 at 5:23 PM, Mark Brown broonie@kernel.org wrote:
On Thu, Nov 28, 2013 at 03:29:31PM +0530, Padma Venkat wrote:
On Wed, Nov 27, 2013 at 8:35 PM, Mark Brown broonie@kernel.org wrote:
But if it's initialised at probe time then when is it getting overwritten? This must be something triggered by DT which unfortunately I can't test. It's a bit of a shame that the flows are different between the DT and non-DT cases.
it's getting overwritten in i2s_hw_params which is happening after dma_data got initialized in dai probe. Based on mono or stereo channel this value getting initialized to 2 or 4 respectively in i2s_hw_params. This value is not triggered by DT now.
OK, so we can probably just reinitialise the dmaengine data after we reset it? Like below
Yes. That works well.
Are you sure that dma_size should be 2? The i2s DAI driver seems to be hard coding it to 4.
I think for mono files the dma_size should be 2 only. Right now based on mono or stereo this value getting overwritten in i2s_hw_params. Initially it is hardcoded to 4. Due to this commit "ASoC: samsung: Allow mono in i2s driver" which was not there earlier, I got confused. Now it seems clear except that underrun message which I am still debugging.
As I forgot to add SND_DMAENGINE_PCM_FLAG_NO_RESIDUE flag, I was getting underrun error. After adding this flag audio playback is working fine for smaller files on smdk5420 with pl330 dma driver.
Except for the crash due to NULL pointer dereference in secondary dai(I posted a patch for the same (ASoC: samsung: Initialize the dma_data for secondary dai)) you can add my
Tested By: Padmavathi Venna padma.v@samsung.com
Yeah, that's now confusing - I'll send a patch to remove the initialisation on probe() since it's getting overwritten later.
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 67d9fa91fdb9..ba24a954b9e4 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -702,6 +702,8 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, } writel(mod, i2s->addr + I2SMOD);
samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
i2s->frmclk = params_rate(params); return 0;
Thanks Padma
On Thu, Dec 05, 2013 at 04:20:03PM +0530, Padma Venkat wrote:
On Thu, Nov 28, 2013 at 5:23 PM, Mark Brown broonie@kernel.org wrote:
OK, so we can probably just reinitialise the dmaengine data after we reset it? Like below
Yes. That works well.
Great.
As I forgot to add SND_DMAENGINE_PCM_FLAG_NO_RESIDUE flag, I was getting underrun error. After adding this flag audio playback is working fine for smaller files on smdk5420 with pl330 dma driver.
OK, there were some patches on the thread adding residue support to the PL330 driver yesterday - hopefully those can get merged at some point
Except for the crash due to NULL pointer dereference in secondary dai(I posted a patch for the same (ASoC: samsung: Initialize the dma_data for secondary dai)) you can add my
Tested By: Padmavathi Venna padma.v@samsung.com
Excellent, thanks - I'd squashed in your change already. Like I say I'm still concerned that we might need a fix for v3.13 since I can't entirely see why the code works as-is.
Hi Mark,
On Thu, Dec 5, 2013 at 5:15 PM, Mark Brown broonie@kernel.org wrote:
On Thu, Dec 05, 2013 at 04:20:03PM +0530, Padma Venkat wrote:
On Thu, Nov 28, 2013 at 5:23 PM, Mark Brown broonie@kernel.org wrote:
OK, so we can probably just reinitialise the dmaengine data after we reset it? Like below
Yes. That works well.
Great.
As I forgot to add SND_DMAENGINE_PCM_FLAG_NO_RESIDUE flag, I was getting underrun error. After adding this flag audio playback is working fine for smaller files on smdk5420 with pl330 dma driver.
OK, there were some patches on the thread adding residue support to the PL330 driver yesterday - hopefully those can get merged at some point
Except for the crash due to NULL pointer dereference in secondary dai(I posted a patch for the same (ASoC: samsung: Initialize the dma_data for secondary dai)) you can add my
Tested By: Padmavathi Venna padma.v@samsung.com
Excellent, thanks - I'd squashed in your change already. Like I say I'm still concerned that we might need a fix for v3.13 since I can't entirely see why the code works as-is.
Here two things 1)crash due to null pointer reference during boot which got fixed by initializing the secondary dai. This crash was not there in mainline because the channel request happening at runtime and with dmaengine the channel request happening at boot time. But if some one try to play audio with secondary device then at run time this crash might happen. 2) overwritting of dma_size during hw_params This is not required in mainline because pointer to the whole s3c_dma_params were being passed as dma_data which has dma_size init. But with dmaengine we are just passing the pointer to snd_dmaengine_dai_dma_data which is embedded in s3c_dma_params and dma_size is outside.
I think this is what you are concern about why it is not working as-is.
Thanks Padma
Hi Mark,
On Tue, Nov 12, 2013 at 7:18 PM, Mark Brown broonie@kernel.org wrote:
From: Mark Brown broonie@linaro.org
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.
Signed-off-by: Mark Brown broonie@linaro.org
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(-)
[snip]
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index a5cbdb4..67d9fa9 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -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);
we have to initialize the dma data for i2s secondary dai also otherwise there is a crash in dmaengine_pcm_new during probe.
Thanks Padma
On Tue, Nov 26, 2013 at 10:54:57AM +0530, Padma Venkat wrote:
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);
we have to initialize the dma data for i2s secondary dai also otherwise there is a crash in dmaengine_pcm_new during probe.
This should be called when both DAIs are probed... in any case, if this is broken presumably the driver is already broken given that this is just a substitution? I've no systems capable of actually running audio with the later DAIs.
participants (2)
-
Mark Brown
-
Padma Venkat