From patchwork Mon Jun 16 16:13:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 4360681 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3C3FFBEEAA for ; Mon, 16 Jun 2014 16:19:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4ACA220274 for ; Mon, 16 Jun 2014 16:19:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CAA922020A for ; Mon, 16 Jun 2014 16:19:52 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id AA6662655FD; Mon, 16 Jun 2014 18:19:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 2FC6B2654E1; Mon, 16 Jun 2014 18:13:48 +0200 (CEST) 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 E272C26549A; Mon, 16 Jun 2014 18:13:42 +0200 (CEST) Received: from smtp-out-035.synserver.de (smtp-out-035.synserver.de [212.40.185.35]) by alsa0.perex.cz (Postfix) with ESMTP id 7D97726549C for ; Mon, 16 Jun 2014 18:13:28 +0200 (CEST) Received: (qmail 18340 invoked by uid 0); 16 Jun 2014 16:13:28 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 17625 Received: from p4fe602a8.dip0.t-ipconnect.de (HELO lars-adi-laptop.analog.com) [79.230.2.168] by 217.119.54.96 with SMTP; 16 Jun 2014 16:13:27 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Mon, 16 Jun 2014 18:13:09 +0200 Message-Id: <1402935191-18398-10-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1402935191-18398-1-git-send-email-lars@metafoo.de> References: <1402935191-18398-1-git-send-email-lars@metafoo.de> Cc: Vinod Koul , alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH v2 09/11] ASoC: Add component level set_bias_level() support 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 This patch adds a set_bias_level() callback to the snd_soc_component_driver struct similar to that found in the snd_soc_codec_driver struct. This will allow any component type and not just CODECs to implement such a callback. The semantics of the component driver and CODEC driver set_bias_level() callbacks slightly differ. While the CODEC driver callback only takes the target bias level, the component driver callback takes both the current and the target bias level. Also for the component driver callback the current bias level will be automatically updated to the target bias level if the callback does not return an error, whereas with the CODEC bias level callback this has to be done in every callback by hand. The change in semantics was implement because the new semantics more closly match what drivers need. Most drivers are interested in both the current and the target bias level and all drivers update the current to the target bias level in case there is no error. Signed-off-by: Lars-Peter Clausen --- include/sound/soc.h | 4 ++++ sound/soc/soc-core.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 9a5b4f6..e560b6f 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -680,6 +680,10 @@ struct snd_soc_component_driver { void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, int subseq); int (*stream_event)(struct snd_soc_component *, int event); + int (*set_bias_level)(struct snd_soc_component *component, + enum snd_soc_bias_level current_level, + enum snd_soc_bias_level target_level); + bool idle_bias_off; }; struct snd_soc_component { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 5fe732f..a414689 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4011,6 +4011,20 @@ static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, return component->driver->stream_event(component, event); } +static int snd_soc_component_set_bias_level(struct snd_soc_dapm_context *dapm, + enum snd_soc_bias_level target_level) +{ + struct snd_soc_component *component = dapm->component; + int ret; + + ret = component->driver->set_bias_level(component, dapm->bias_level, + target_level); + if (ret == 0) + dapm->bias_level = target_level; + + return ret; +} + static int snd_soc_component_initialize(struct snd_soc_component *component, const struct snd_soc_component_driver *driver, struct device *dev) { @@ -4032,10 +4046,13 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, dapm->dev = dev; dapm->component = component; dapm->bias_level = SND_SOC_BIAS_OFF; + dapm->idle_bias_off = driver->idle_bias_off; if (driver->seq_notifier) dapm->seq_notifier = snd_soc_component_seq_notifier; if (driver->stream_event) dapm->stream_event = snd_soc_component_stream_event; + if (driver->set_bias_level) + dapm->set_bias_level = snd_soc_component_set_bias_level; INIT_LIST_HEAD(&component->dai_list); mutex_init(&component->io_mutex);