Introduce dmic mode switch delay parameter
v2 cover Introduce dmic mode switch delay parameter
Some DMICs need clock to be running for a specified duration as per the DMIC spec to complete the mode transition like sleep to normal, off to normal etc.
v1: First patch set
v2:
1). Removed ACPI device entry since a) The DMIC vendor doesn't have an ACPI vendor ID b) The ACPI enumeration creates one more device and conflicts with the existing skl.c dmic platform device registration.
2). Updated commit message
Jenny TC (1):
ASoC: dmic: Introduce mode switch delay
sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Signature · 1 line
1.9.1
PATCH 1/1 ASoC: dmic: Introduce mode switch delay
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.
--- sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
sound/soc/codecs/dmic.c +31 -0
@@ -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);
Signature · 1 line
1.9.1
Re: [PATCH] ASoC: dmic: Introduce mode switch delay
Quoted 20 lines · Jenny TC
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 <[email protected]>Signed-off-by Jairaj Arava <[email protected]>Signed-off-by Harsha Priya <[email protected]>--- sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)sound/soc/codecs/dmic.c +0
-0
sound/soc/codecs/dmic.c line 34
Quoted 5 lines
sound/soc/codecs/dmic.c +2
-0@@ -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?
Quoted 7 lines
sound/soc/codecs/dmic.c +4
-0struct dmic {struct gpio_desc *gpio_en;int wakeup_delay; +/* Delay after DMIC mode switch */ +int modeswitch_delay_ms; +}; +
sound/soc/codecs/dmic.c line 52
Quoted 10 lines
sound/soc/codecs/dmic.c +10
-0+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
Re: [PATCH] ASoC: dmic: Introduce mode switch delay
In reply to Jenny TCQuoted 6 lines · Jenny TC
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.
Quoted 67 lines
Signed-off-by Sathyanarayana Nujella <[email protected]>Signed-off-by Jairaj Arava <[email protected]>Signed-off-by Harsha Priya <[email protected]>--- sound/soc/codecs/dmic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)sound/soc/codecs/dmic.c +31
-0@@ -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);