From: Takashi Iwai Subject: Re: [PATCH] ASoC: dmic: Introduce mode switch delay Date: Fri, 02 Nov 2018 08:37:39 +0100 Message-ID: References: <1541143847-30450-1-git-send-email-jenny.tc@intel.com> <1541143847-30450-2-git-send-email-jenny.tc@intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id D57052678CA for ; Fri, 2 Nov 2018 08:37:40 +0100 (CET) In-Reply-To: <1541143847-30450-2-git-send-email-jenny.tc@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Jenny TC Cc: alsa-devel@alsa-project.org, Jairaj Arava , Kuninori Morimoto , Harshapriya N , Takashi Iwai , Liam Girdwood , Mark Brown , Sathyanarayana Nujella , Matthias Kaehlcke List-Id: alsa-devel@alsa-project.org 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 > Signed-off-by: Jairaj Arava > Signed-off-by: Harsha Priya > --- > 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 > #include > > +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