Commit bc0a7dbc authored by Jenny TC's avatar Jenny TC Committed by Mark Brown

ASoC: dmic: introduce mode switch delay

On startup, applications such as PulseAudio or CRAS enable playback or
capture on all PCM devices to verify that configurations are correct,
and close them immediately. For DMICs, this can result in the clock
being turned off very quickly, which may not compatible with internal
state machine transition requirements.

This patch add a mode-switch delay which will prevent the clock from
being turned off without complying with manufacturer timing
specifications. While the DMIC clock may be controlled at a lower level,
be it with hardware or firmware, applying the delay during the
STOP_TRIGGER phase ensures that there is no race condition, e.g. with
the hardware/firmware turning off the clock earlier
Signed-off-by: default avatarSathyanarayana Nujella <sathyanarayana.nujella@intel.com>
Signed-off-by: default avatarJairaj Arava <jairaj.arava@intel.com>
Signed-off-by: default avatarHarsha Priya <harshapriya.n@intel.com>
Signed-off-by: default avatarJenny TC <jenny.tc@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 22cc062c
...@@ -9,6 +9,7 @@ Optional properties: ...@@ -9,6 +9,7 @@ Optional properties:
- dmicen-gpios: GPIO specifier for dmic to control start and stop - dmicen-gpios: GPIO specifier for dmic to control start and stop
- num-channels: Number of microphones on this DAI - num-channels: Number of microphones on this DAI
- wakeup-delay-ms: Delay (in ms) after enabling the DMIC - wakeup-delay-ms: Delay (in ms) after enabling the DMIC
- modeswitch-delay-ms: Delay (in ms) to complete DMIC mode switch
Example node: Example node:
...@@ -17,4 +18,5 @@ Example node: ...@@ -17,4 +18,5 @@ Example node:
dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>; dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>;
num-channels = <1>; num-channels = <1>;
wakeup-delay-ms <50>; wakeup-delay-ms <50>;
modeswitch-delay-ms <35>;
}; };
...@@ -30,9 +30,36 @@ ...@@ -30,9 +30,36 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-dapm.h> #include <sound/soc-dapm.h>
#define MAX_MODESWITCH_DELAY 70
static int modeswitch_delay;
module_param(modeswitch_delay, uint, 0644);
struct dmic { struct dmic {
struct gpio_desc *gpio_en; struct gpio_desc *gpio_en;
int wakeup_delay; int wakeup_delay;
/* Delay after DMIC mode switch */
int modeswitch_delay;
};
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)
mdelay(dmic->modeswitch_delay);
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, static int dmic_aif_event(struct snd_soc_dapm_widget *w,
...@@ -68,6 +95,7 @@ static struct snd_soc_dai_driver dmic_dai = { ...@@ -68,6 +95,7 @@ static struct snd_soc_dai_driver dmic_dai = {
| SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_LE
| SNDRV_PCM_FMTBIT_S16_LE, | SNDRV_PCM_FMTBIT_S16_LE,
}, },
.ops = &dmic_dai_ops,
}; };
static int dmic_component_probe(struct snd_soc_component *component) static int dmic_component_probe(struct snd_soc_component *component)
...@@ -85,6 +113,13 @@ static int dmic_component_probe(struct snd_soc_component *component) ...@@ -85,6 +113,13 @@ static int dmic_component_probe(struct snd_soc_component *component)
device_property_read_u32(component->dev, "wakeup-delay-ms", device_property_read_u32(component->dev, "wakeup-delay-ms",
&dmic->wakeup_delay); &dmic->wakeup_delay);
device_property_read_u32(component->dev, "modeswitch-delay-ms",
&dmic->modeswitch_delay);
if (modeswitch_delay)
dmic->modeswitch_delay = modeswitch_delay;
if (dmic->modeswitch_delay > MAX_MODESWITCH_DELAY)
dmic->modeswitch_delay = MAX_MODESWITCH_DELAY;
snd_soc_component_set_drvdata(component, dmic); snd_soc_component_set_drvdata(component, dmic);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment