From patchwork Thu Jun 29 13:26:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 106647 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1096753qge; Thu, 29 Jun 2017 06:27:22 -0700 (PDT) X-Received: by 10.84.128.195 with SMTP id a61mr3856814pla.124.1498742842598; Thu, 29 Jun 2017 06:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498742842; cv=none; d=google.com; s=arc-20160816; b=JCQFV1nMWibO90WpAu7XeggUIwqEjIXFOV7Dl0LmXa8xUoCklutXsPOIZKBCEovp5Q MHTdk0AcBV2oIQHZN/5UKP8lamSoX8fyGweNhQCjL1ce9afZMp0DFEmYEMUIsbINy6cu NEUw4HxKR0+iYFB/bLOZFOlSD4hX9jC0M8MUGIxpe68SpR5VN8bOOCklhNIi0EhsPuIh DsyN72+jm6SCqfi+ZvCizy9mrcoy9tFyu5IkHT49DqRAVoxwwV5dUH9hseJKmHknCBzu VJ9yEbFjwSeWNsE/6QQ/vxBzI5FgA61XSMqFHey2xWShHfdjdM2pEyTlSZwpP68ebXL3 h97w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=CZIZ0sgXipAbZAgw2JgMOezg7L+QHxQe1Ko1P5kVNnQ=; b=xRUGYS4cStJcgLvGpB9iZxmFII7u1WARtVz7HWuB8/LkKcpBaXVxC+S+Ts8sRulfBP JU2QaCh/y3bsFdEUsg/+Oj2Ml50gfwXLtoQhYIz8tKwSJiJ529U59ebC3qtwvvNUUaHz g6xoavA8xS6zJj+XmS5L+gzlGzgQSYrQeMY11a7pv2FKie5bJejjjGR6z8lNPQc+vM72 LDqMmhEmYOKYUYy2mq2Q/5yv4ecAKMyDrtgBvTHLLxdjrMkrGHFHGMU+dd4gHjZgA4C3 ZPN60LR50q1wuk4Is4jePbpr1p0lgYurD9T6H5qErmnceTk7wC1Lle4LZMTm9WUJKdQt oQLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si4081756plj.137.2017.06.29.06.27.22; Thu, 29 Jun 2017 06:27:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752787AbdF2N1V (ORCPT + 7 others); Thu, 29 Jun 2017 09:27:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:32882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbdF2N1V (ORCPT ); Thu, 29 Jun 2017 09:27:21 -0400 Received: from localhost.localdomain (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6825122BD8; Thu, 29 Jun 2017 13:27:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6825122BD8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org From: Shawn Guo To: Mark Brown , Rob Herring Cc: Kuninori Morimoto , Baoyou Xie , Xin Zhou , Jun Nie , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Shawn Guo Subject: [PATCH 1/2] ASoC: audio-graph-card: update bindings for amplifier support Date: Thu, 29 Jun 2017 21:26:37 +0800 Message-Id: <1498742798-3128-2-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498742798-3128-1-git-send-email-shawnguo@kernel.org> References: <1498742798-3128-1-git-send-email-shawnguo@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Shawn Guo The audio-graph-card should be able to support widgets and routing in the same way as what simple-audio-card does. The patch adds the properties into audio-graph-card bindings. Then an optional property 'pa-gpios' for controlling external amplifier, which depends on DAPM widgets and routing, is added. Signed-off-by: Shawn Guo --- Documentation/devicetree/bindings/sound/audio-graph-card.txt | 5 +++++ 1 file changed, 5 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.txt b/Documentation/devicetree/bindings/sound/audio-graph-card.txt index bac4b1b1060f..6e6720aa33f1 100644 --- a/Documentation/devicetree/bindings/sound/audio-graph-card.txt +++ b/Documentation/devicetree/bindings/sound/audio-graph-card.txt @@ -10,6 +10,8 @@ see ${LINUX}/Documentation/devicetree/bindings/sound/simple-card.txt Below are same as Simple-Card. - label +- widgets +- routing - dai-format - frame-master - bitclock-master @@ -24,6 +26,9 @@ Required properties: - compatible : "audio-graph-card"; - dais : list of CPU DAI port{s} +Optional properties: +- pa-gpios: GPIO used to control external amplifier. + Example: Single DAI case sound_card { From patchwork Thu Jun 29 13:26:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 106648 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1096836qge; Thu, 29 Jun 2017 06:27:26 -0700 (PDT) X-Received: by 10.84.129.69 with SMTP id 63mr18152215plb.0.1498742846271; Thu, 29 Jun 2017 06:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498742846; cv=none; d=google.com; s=arc-20160816; b=njsNHpya7IcxLsMcc/2sm1MbP99odGcTkRXk/bSroMv6vPhPqJkeA4wFvzGZsts/jf fvAmZZFcjz66e8fOdcXr//aeomZucXSioxQbZAiryT1GxuVRQWjSjwGmPfORPhis0xxv Z8BgJPLgRZwlHGD3kVjBXhZpph/vIiLaYqNS98vzdRh9WbyzCOv5OoJpWsGOLXbzo0N7 r3eJI6sbeJrF2ENSh21wwTUO/o5PU6Ph98e+HrQ6Ntf/ztRLeVv4NA0BHdcSk8fh1SEu 68oro6G47VoT907jiGFHjmrMm6fMEd5PzNv+bxMWLuxmPP5WMnTc/SaR4eWOJaSqux7j okYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=SAGq/wV99S6fxY6N2kUg7CNA7vzmRoFxbFT9SCp7EKI=; b=DkBSrybWFF5d8JtKkhMV9iKQqbpP+LgXoa7xZ7BevJ8o8yi2MgmqvS5oKrHOPnletD 2gKou6ADGqYAkZD9MMgli7pCJPJhpg7V39sTJzaXDQp2YRjK0XLIq8G5ZlssRZXLdK6U sAEr16qbTogsPq8rPXvENJ0TZv8K5IWwSFW7q9KIhaRQfsksVt+6dNBCs+pacRnT//K9 4vW9/OT6FWOR25ibiKYOwVccBOdOMJEo34n6IMJ8sh3ffNMKRPXVn8z/PSiHGAnx5jVB MiC8DhFPw+//PWl7/DhDr/ONwNKzutKmd1NC2MNMkL47l3d0pO865jGWr+kdsHZK2JZ4 Bu9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si4081756plj.137.2017.06.29.06.27.26; Thu, 29 Jun 2017 06:27:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752852AbdF2N1Z (ORCPT + 7 others); Thu, 29 Jun 2017 09:27:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:32912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbdF2N1Y (ORCPT ); Thu, 29 Jun 2017 09:27:24 -0400 Received: from localhost.localdomain (li411-102.members.linode.com [106.187.91.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8201922B62; Thu, 29 Jun 2017 13:27:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8201922B62 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org From: Shawn Guo To: Mark Brown , Rob Herring Cc: Kuninori Morimoto , Baoyou Xie , Xin Zhou , Jun Nie , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Shawn Guo Subject: [PATCH 2/2] ASoC: audio-graph-card: add widgets and routing for external amplifier support Date: Thu, 29 Jun 2017 21:26:38 +0800 Message-Id: <1498742798-3128-3-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498742798-3128-1-git-send-email-shawnguo@kernel.org> References: <1498742798-3128-1-git-send-email-shawnguo@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Shawn Guo 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 --- sound/soc/generic/audio-graph-card.c | 48 +++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Kuninori Morimoto diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 885b405d7844..a0bcebc77e2a 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) @@ -181,8 +210,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 */ @@ -234,6 +271,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; @@ -243,6 +287,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) {