From patchwork Fri Jun 30 11:58:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9819463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A1B26035F for ; Fri, 30 Jun 2017 12:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B98E2867B for ; Fri, 30 Jun 2017 12:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC3728665; Fri, 30 Jun 2017 12:10:28 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 70A6D28658 for ; Fri, 30 Jun 2017 12:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Date: Message-Id:In-Reply-To:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=kH1snS7QBMLYHQ6XDD5H5xIvtpvdeLZlphFHGo4SKlY=; b=n34 9W8nqqJuWTEkY6nvzzvc7ojx7793HYl7Um21F4nlFfwXQZFEpQHn81ixUGY6rfRYb8sxmWObGIKu1 17LJ9txIbjt9LzdAAaIZMEr+7cE08/dBVJ7TPNrWgG4bxqgY+GUCvwuA+KBTOCfk5qY2oahGMAg5c 0HmTJxXXMA0P4A+5DSsz0N+BK1SdGk9gZD9SLhUj6DWD2X+TbiGSUErX5xCoa67npZewyGW+WerbQ VX3UEozvO8jSnULbggIlrQq28K5BTCEAqVb5/+qnmzg3XqtshBa4HlayYHS7ATq/G7KjXBN95mBZx hEpZJkWbKIMT5QiZPslfmw7zo3t4mkg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQukl-0004Fo-1n; Fri, 30 Jun 2017 12:10:27 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQuaY-0004RL-KT for linux-arm-kernel@bombadil.infradead.org; Fri, 30 Jun 2017 11:59:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Subject:Date:Message-Id:In-Reply-To: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=724RE2+jHb6awOx1Mb10JDqOUgdX1SbQHt93nCsplNQ=; b=OdeGdehXnEgbBwY+Y86JhfMpTp iAMd54pXcqgu37Zj7OWKurZyLoP4hjINA7P3fdXSZMddha403qGhCOAQ+B/KaEDzv2riokr5ZsD0p z01OlqxOP9+1KF/vy5/qB51gwtye9p9E6I+A2nRBgAGsSOHmTkH66/JiHa5gMRtSkpz9gxGLi0cIb 2Xp1POCvoMh+ZskEkMV1D94KCQHyCGEJCpu0BX0tlAPirwqmvCaq3nTcUshHjxKTMJ8AL3ZVfUi52 t+CoyxfGgmVe3XwqgQb6esLlvulzp7R8zERQ5i/2uHVhrcSfFPjn3VjuvpGtlwh7y5yxZSL6dvEV2 +krzwANw==; Received: from mezzanine.sirena.org.uk ([2400:8900::f03c:91ff:fedb:4f4]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQuaU-0002B4-M9 for linux-arm-kernel@lists.infradead.org; Fri, 30 Jun 2017 11:59:53 +0000 Received: from [176.12.107.140] (helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1dQuZc-0001KW-Q3; Fri, 30 Jun 2017 11:58:59 +0000 Received: from broonie by finisterre with local (Exim 4.89) (envelope-from ) id 1dQuZY-0007xM-6Q; Fri, 30 Jun 2017 12:58:52 +0100 From: Mark Brown To: Shawn Guo In-Reply-To: <1498742798-3128-3-git-send-email-shawnguo@kernel.org> Message-Id: Date: Fri, 30 Jun 2017 12:58:52 +0100 X-SA-Exim-Connect-IP: 176.12.107.140 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Applied "ASoC: audio-graph-card: add widgets and routing for external amplifier support" to the asoc tree X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure X-Bad-Reply: In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170630_125950_966021_7BD86620 X-CRM114-Status: GOOD ( 23.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kuninori Morimoto , Mark Brown , Baoyou Xie , Rob Herring , Xin Zhou , Jun Nie , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The patch ASoC: audio-graph-card: add widgets and routing for external amplifier support has been applied to the asoc tree at git://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 f986907c9225cf48e9a55233b086039152bb5b99 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Thu, 29 Jun 2017 21:26:38 +0800 Subject: [PATCH] ASoC: audio-graph-card: add widgets and routing for external amplifier support It's very common that audio card has a machine level amplifier which is controlled by GPIO. The patch adds DAPM widgets and routing support into audio-graph-card driver, and creates an output driver widget with event to control the amplifier via GPIO. Signed-off-by: Shawn Guo Acked-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/generic/audio-graph-card.c | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index ee752f62d89d..105ec3a6e30d 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,34 @@ struct graph_card_data { struct asoc_simple_dai codec_dai; } *dai_props; struct snd_soc_dai_link *dai_link; + struct gpio_desc *pa_gpio; +}; + +static int asoc_graph_card_outdrv_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, + int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct graph_card_data *priv = snd_soc_card_get_drvdata(dapm->card); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + gpiod_set_value_cansleep(priv->pa_gpio, 1); + break; + case SND_SOC_DAPM_PRE_PMD: + gpiod_set_value_cansleep(priv->pa_gpio, 0); + break; + default: + return -EINVAL; + } + + return 0; +} + +static const struct snd_soc_dapm_widget asoc_graph_card_dapm_widgets[] = { + SND_SOC_DAPM_OUT_DRV_E("Amplifier", SND_SOC_NOPM, + 0, 0, NULL, 0, asoc_graph_card_outdrv_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), }; #define graph_priv_to_card(priv) (&(priv)->snd_card) @@ -180,8 +209,16 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) int rc, idx = 0; int ret; + ret = asoc_simple_card_of_parse_widgets(card, NULL); + if (ret < 0) + return ret; + + ret = asoc_simple_card_of_parse_routing(card, NULL, 1); + if (ret < 0) + return ret; + /* - * we need to consider "widgets", "routing", "mclk-fs" around here + * we need to consider "mclk-fs" around here * see simple-card */ @@ -233,6 +270,13 @@ static int asoc_graph_card_probe(struct platform_device *pdev) if (!dai_props || !dai_link) return -ENOMEM; + priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW); + if (IS_ERR(priv->pa_gpio)) { + ret = PTR_ERR(priv->pa_gpio); + dev_err(dev, "failed to get amplifier gpio: %d\n", ret); + return ret; + } + priv->dai_props = dai_props; priv->dai_link = dai_link; @@ -242,6 +286,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) card->dev = dev; card->dai_link = dai_link; card->num_links = num; + card->dapm_widgets = asoc_graph_card_dapm_widgets; + card->num_dapm_widgets = ARRAY_SIZE(asoc_graph_card_dapm_widgets); ret = asoc_graph_card_parse_of(priv); if (ret < 0) {