* Re: [PATCH] ASoC: dmic: Introduce mode switch delay
2018-11-02 7:30 ` [PATCH] ASoC: dmic: Introduce mode switch delay Jenny TC
@ 2018-11-02 7:37 ` Takashi Iwai
2018-11-02 14:34 ` Pierre-Louis Bossart
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2018-11-02 7:37 UTC (permalink / raw)
To: Jenny TC
Cc: alsa-devel, Jairaj Arava, Kuninori Morimoto, Harshapriya N,
Takashi Iwai, Liam Girdwood, Mark Brown, Sathyanarayana Nujella,
Matthias Kaehlcke
On Fri, 02 Nov 2018 08:30:47 +0100,
Jenny TC wrote:
>
> Some DMICs require a delay as defined in the DMIC data sheet to complete
> DMIC mode transitions. DMIC may enter a bad state if the clock is stopped
> before successful mode transition. To handle this, a delay is introduced
> in the STOP STREAM to ensure the clock is running for the mode switch delay
> duration. A module parameter is introduced to pass the delay as a module
> parameter.
>
> Signed-off-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>
> Signed-off-by: Jairaj Arava <jairaj.arava@intel.com>
> Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
> ---
> sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c
> index 8c4926d..0527bc2 100644
> --- a/sound/soc/codecs/dmic.c
> +++ b/sound/soc/codecs/dmic.c
> @@ -30,9 +30,35 @@
> #include <sound/soc.h>
> #include <sound/soc-dapm.h>
>
> +static int modeswitch_delay_ms;
> +module_param(modeswitch_delay_ms, uint, 0644);
signed or unsigned?
> struct dmic {
> struct gpio_desc *gpio_en;
> int wakeup_delay;
> + /* Delay after DMIC mode switch */
> + int modeswitch_delay_ms;
> +};
> +
> +int dmic_daiops_trigger(struct snd_pcm_substream *substream,
> + int cmd, struct snd_soc_dai *dai)
> +{
> + struct snd_soc_component *component = dai->component;
> + struct dmic *dmic = snd_soc_component_get_drvdata(component);
> +
> + switch (cmd) {
> + case SNDRV_PCM_TRIGGER_STOP:
> + if (dmic->modeswitch_delay_ms)
> + mdelay(dmic->modeswitch_delay_ms);
You need to have a value sanity check either at execution time or at
initialization time. The current code allows user to stall for a
quite long time by passing some bad value via module option.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: dmic: Introduce mode switch delay
2018-11-02 7:30 ` [PATCH] ASoC: dmic: Introduce mode switch delay Jenny TC
2018-11-02 7:37 ` Takashi Iwai
@ 2018-11-02 14:34 ` Pierre-Louis Bossart
1 sibling, 0 replies; 4+ messages in thread
From: Pierre-Louis Bossart @ 2018-11-02 14:34 UTC (permalink / raw)
To: Jenny TC, alsa-devel
Cc: Jairaj Arava, Kuninori Morimoto, Harshapriya N, Takashi Iwai,
Liam Girdwood, Mark Brown, Sathyanarayana Nujella,
Matthias Kaehlcke
On 11/2/18 2:30 AM, Jenny TC wrote:
> Some DMICs require a delay as defined in the DMIC data sheet to complete
> DMIC mode transitions. DMIC may enter a bad state if the clock is stopped
> before successful mode transition. To handle this, a delay is introduced
> in the STOP STREAM to ensure the clock is running for the mode switch delay
> duration. A module parameter is introduced to pass the delay as a module
> parameter.
Sorry, I am still not clear on the effect of the delay on a TRIGGER_STOP
since the clock is managed at a different level - by the DSP firmware to
be precise. In the absence of a command to tell the DMIC a mode switch
is going to happen, the only thing that the dmic observes is the clock,
and whether you delay the stop or not isn't going to result in a
stimulus that can be used to change modes.
There's been multiple emails on this and there is no clear explanation
on the results of the delay..I would suggest describing the requirement
with more information to understand how this delay helps with
conformance, in 'as measured by' terms.
While I am at it, if we use module parameters we might as well use them
for all parameters, including the wakeup_delay, so that the information
can be passed by either of device_property or module parameters in all
cases.
>
> Signed-off-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>
> Signed-off-by: Jairaj Arava <jairaj.arava@intel.com>
> Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
> ---
> sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c
> index 8c4926d..0527bc2 100644
> --- a/sound/soc/codecs/dmic.c
> +++ b/sound/soc/codecs/dmic.c
> @@ -30,9 +30,35 @@
> #include <sound/soc.h>
> #include <sound/soc-dapm.h>
>
> +static int modeswitch_delay_ms;
> +module_param(modeswitch_delay_ms, uint, 0644);
> +
> struct dmic {
> struct gpio_desc *gpio_en;
> int wakeup_delay;
> + /* Delay after DMIC mode switch */
> + int modeswitch_delay_ms;
> +};
> +
> +int dmic_daiops_trigger(struct snd_pcm_substream *substream,
> + int cmd, struct snd_soc_dai *dai)
> +{
> + struct snd_soc_component *component = dai->component;
> + struct dmic *dmic = snd_soc_component_get_drvdata(component);
> +
> + switch (cmd) {
> + case SNDRV_PCM_TRIGGER_STOP:
> + if (dmic->modeswitch_delay_ms)
> + mdelay(dmic->modeswitch_delay_ms);
> +
> + break;
> + }
> +
> + return 0;
> +}
> +
> +static const struct snd_soc_dai_ops dmic_dai_ops = {
> + .trigger = dmic_daiops_trigger,
> };
>
> static int dmic_aif_event(struct snd_soc_dapm_widget *w,
> @@ -68,6 +94,7 @@ static int dmic_aif_event(struct snd_soc_dapm_widget *w,
> | SNDRV_PCM_FMTBIT_S24_LE
> | SNDRV_PCM_FMTBIT_S16_LE,
> },
> + .ops = &dmic_dai_ops,
> };
>
> static int dmic_component_probe(struct snd_soc_component *component)
> @@ -85,6 +112,10 @@ static int dmic_component_probe(struct snd_soc_component *component)
>
> device_property_read_u32(component->dev, "wakeup-delay-ms",
> &dmic->wakeup_delay);
> + device_property_read_u32(component->dev, "modeswitch_delay_ms",
> + &dmic->modeswitch_delay_ms);
> + if (modeswitch_delay_ms)
> + dmic->modeswitch_delay_ms = modeswitch_delay_ms;
>
> snd_soc_component_set_drvdata(component, dmic);
>
^ permalink raw reply [flat|nested] 4+ messages in thread