From patchwork Fri Nov 2 07:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jenny TC X-Patchwork-Id: 10665109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 884A217D5 for ; Fri, 2 Nov 2018 07:31:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 632CB2B8D8 for ; Fri, 2 Nov 2018 07:31:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 573862B8F1; Fri, 2 Nov 2018 07:31:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B0A2B8D8 for ; Fri, 2 Nov 2018 07:31:13 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D88222678CA; Fri, 2 Nov 2018 08:31:08 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 54CE8267955; Fri, 2 Nov 2018 08:31:04 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by alsa0.perex.cz (Postfix) with ESMTP id E84762677E4 for ; Fri, 2 Nov 2018 08:31:00 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 00:31:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,454,1534834800"; d="scan'208";a="88041224" Received: from jenny-desktop.iind.intel.com ([10.223.163.92]) by orsmga006.jf.intel.com with ESMTP; 02 Nov 2018 00:30:57 -0700 From: Jenny TC To: alsa-devel@alsa-project.org Date: Fri, 2 Nov 2018 13:00:47 +0530 Message-Id: <1541143847-30450-2-git-send-email-jenny.tc@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1541143847-30450-1-git-send-email-jenny.tc@intel.com> References: <1541143847-30450-1-git-send-email-jenny.tc@intel.com> Cc: Jairaj Arava , Kuninori Morimoto , Harshapriya N , Takashi Iwai , Liam Girdwood , Mark Brown , Sathyanarayana Nujella , Matthias Kaehlcke , Jenny TC Subject: [alsa-devel] [PATCH] ASoC: dmic: Introduce mode switch delay X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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); + 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);