From patchwork Wed Nov 28 16:05:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 152307 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1267891ljp; Wed, 28 Nov 2018 08:05:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/XwrxpQWcomV/JZNfOUXlENy0tfUA6XelxE8xliXY+Tlyz+kLEUBduwMEuXsL4mLcPUpZut X-Received: by 2002:adf:ffca:: with SMTP id x10mr33578199wrs.289.1543421149095; Wed, 28 Nov 2018 08:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543421149; cv=none; d=google.com; s=arc-20160816; b=xyTf3uHFEqJr+uyWVBMLdwnW+UhCZnlOXBKYjxs0/BGILKhePjNgS/0NpjXeyUMvEJ pCb+9NCFdwS3Wz0tj0AAUBYLx9Yny/x74nicIrmsdIaLyQ7APFhCOb82RmhvCbpy/1bA 1f6ybISNbWT6dv6Hn8MWRF9oB1apKioojL1lonAysnIOGZfvBFFoXgHvT2loYd/A6IfM fMPw2mgkyucmM8tCYXGZKBHgFssoK/tLnULuCvo+Em8mCcybXQx9DrhPT0vK6eKkBFxZ TZEv+21iSmrOBO3nOfXaJUL7LlqX9JjV8lOmWNL4IO53giCWpOV3O1XdfekievsML0e9 LF2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to; bh=ncZru2x5jBdeCx4R/DqSWIYVpr1O/nwDuucrkXfR/Pc=; b=bZeR5rOJo2dk/32qv2KiHwv/cVf0b9wObTT0ovU9dNUTLMyiQTEq7WX0ziFEMWQpst cZTEm65mfzOHbHCrLn9evtSi/ardwRZeBenut3R6S/p+X0YWGHpEVozqOqRg0l7Sq3/x 542+0mt2bULXdut421T3pwrOkqWB2YyQGvfkLlc/iF2yTbhhB5FqFlyz/8wrDwIeAx8V qU9z63bVcb+MDvM+BKzS4pzprJ5gm0VaAiQ39TKgnJ3mNhBxmWSkKtmsJyhti2j+6q/0 XOrVNGINH+OXrq0JSDO9KvLPzv6U3VQfexMhyT+lRqyNGysuHl4x8mHfk5igz+BExWNa L2rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=d1rqKesS; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id t8si5354984wrb.394.2018.11.28.08.05.48; Wed, 28 Nov 2018 08:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=d1rqKesS; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 64629267B7A; Wed, 28 Nov 2018 17:05:30 +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 931B5267B6C; Wed, 28 Nov 2018 17:05:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id B34AE267B6B for ; Wed, 28 Nov 2018 17:05:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=NudtIuJkP1uPHdBPgRRivU6HSifIgqLMkkkZZFX0ZcY=; b=d1rqKesSHE9S cGKN+Xmit0N5QG2JrCvjoU6t5vMKU1C3n0vKGjtPqrPk9empDI59vGkTDkQpSbES0sXCIAMlON2h/ gRm92gT0tKYrAwEeQ0buwOansR5677h5pw5V0nz1EYEwBza5qbeKnAv5kfvSOvJe4jR+0L/UFZSHG wB7vQ=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1gS2L3-0005wX-HK; Wed, 28 Nov 2018 16:05:21 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 30EC6112521B; Wed, 28 Nov 2018 16:05:21 +0000 (GMT) From: Mark Brown To: Jenny TC In-Reply-To: <1543387966-2708-2-git-send-email-jenny.tc@intel.com> Message-Id: <20181128160521.30EC6112521B@debutante.sirena.org.uk> Date: Wed, 28 Nov 2018 16:05:21 +0000 (GMT) Cc: alsa-devel@alsa-project.org, Jairaj Arava , Kuninori Morimoto , Harshapriya N , Takashi Iwai , Liam Girdwood , Mark Brown , Sathyanarayana Nujella , Matthias Kaehlcke Subject: [alsa-devel] Applied "ASoC: dmic: introduce mode switch delay" to the asoc tree 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 The patch ASoC: dmic: introduce mode switch delay has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From bc0a7dbc5a54a06b925064adba8b07d65acf8718 Mon Sep 17 00:00:00 2001 From: Jenny TC Date: Wed, 28 Nov 2018 12:22:45 +0530 Subject: [PATCH] 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: Sathyanarayana Nujella Signed-off-by: Jairaj Arava Signed-off-by: Harsha Priya Signed-off-by: Jenny TC Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/dmic.txt | 2 ++ sound/soc/codecs/dmic.c | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) -- 2.19.0.rc2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/Documentation/devicetree/bindings/sound/dmic.txt b/Documentation/devicetree/bindings/sound/dmic.txt index e957b4136716..32e871037269 100644 --- a/Documentation/devicetree/bindings/sound/dmic.txt +++ b/Documentation/devicetree/bindings/sound/dmic.txt @@ -9,6 +9,7 @@ Optional properties: - dmicen-gpios: GPIO specifier for dmic to control start and stop - num-channels: Number of microphones on this DAI - wakeup-delay-ms: Delay (in ms) after enabling the DMIC + - modeswitch-delay-ms: Delay (in ms) to complete DMIC mode switch Example node: @@ -17,4 +18,5 @@ Example node: dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>; num-channels = <1>; wakeup-delay-ms <50>; + modeswitch-delay-ms <35>; }; diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index 71322e0410ee..f4eb0a438a3a 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -30,9 +30,36 @@ #include #include +#define MAX_MODESWITCH_DELAY 70 +static int modeswitch_delay; +module_param(modeswitch_delay, uint, 0644); + struct dmic { struct gpio_desc *gpio_en; 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, @@ -68,6 +95,7 @@ static struct snd_soc_dai_driver dmic_dai = { | 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 +113,13 @@ 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); + 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);