From patchwork Sat Apr 20 10:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10910195 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 4652417E0 for ; Sat, 20 Apr 2019 10:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3388728905 for ; Sat, 20 Apr 2019 10:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25B7D28C92; Sat, 20 Apr 2019 10:47:17 +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,DKIM_SIGNED, DKIM_VALID,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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0896C28905 for ; Sat, 20 Apr 2019 10:47:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A4B8982A; Sat, 20 Apr 2019 12:46:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A4B8982A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555757233; bh=cpE+7SnGU/b0KGcr7vmVb3YMy6ELnd0nerLqiFIr9wY=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=K6wT3PkK28bJYzJBtzE59QQ32rUz12Ti+73w7V6FyvS1CTq/oahto4xnlQ1Wrrxlo i7AV3+CzB91FdYewd94VX7kdZUEHv7vCJaSIhEKC/vIgFN/C9t5Y8ReBOE+SMyFdRy cw8aZI9Sy0pGcjgpWwefuo/uZIIltmUiRDilnTjM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0E7EAF801D9; Sat, 20 Apr 2019 12:46:23 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 440EAF896F8; Sat, 20 Apr 2019 12:46:21 +0200 (CEST) Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 797C2F896E4 for ; Sat, 20 Apr 2019 12:46:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 797C2F896E4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="LZHodeN6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1555757174; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=t48U9jSkloXavrVWCQ8wexCxy94BEuAxk0yrN4gB0xA=; b=LZHodeN6V1jyf7j9DTzIHUJaq3fCijrMx7lEW0vpeVCry8ec31T+zlQ9yvvIJyehaEAJkb kZhuOwv+AF/IObtd7xf5jzTqtmM878vYJmbnJtqz77UuLhR7lTMVQcqWDa4YsZDjpceHfk UTA81zADTtkHvhgq9kWoBXL3CRIwRlA= From: Paul Cercueil To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland Date: Sat, 20 Apr 2019 12:45:51 +0200 Message-Id: <20190420104553.5071-1-paul@crapouillou.net> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kuninori Morimoto , linux-kernel@vger.kernel.org, Paul Cercueil , od@zcrc.me Subject: [alsa-devel] [PATCH 1/3] ASoC: doc: simple-card: Add pin-switches property X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP The simple-audio-card,pin-switches property can contain the list of widget names for which pin switches must be created. Signed-off-by: Paul Cercueil --- Documentation/devicetree/bindings/sound/simple-card.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 4629c8f8a6b6..79954cd6e37b 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -24,6 +24,8 @@ Optional properties: a microphone is attached. - simple-audio-card,aux-devs : List of phandles pointing to auxiliary devices, such as amplifiers, to be added to the sound card. +- simple-audio-card,pin-switches : List of strings containing the widget names for + which pin switches must be created. Optional subnodes: From patchwork Sat Apr 20 10:45:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10910205 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 D6E8B17E0 for ; Sat, 20 Apr 2019 10:48:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C556728905 for ; Sat, 20 Apr 2019 10:48:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B764528C92; Sat, 20 Apr 2019 10:48:11 +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,DKIM_SIGNED, DKIM_VALID,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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08B2428905 for ; Sat, 20 Apr 2019 10:48:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CC260867; Sat, 20 Apr 2019 12:47:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CC260867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555757288; bh=VW97nqToGNro/JiyZ75fjo6wP7Qzvo22KKmJI0IWTvk=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KsOg7mBZvqZVUUrjfwgX5AEZlx/cJgwnpLxj7v4SOnn8wLbK0/PVH3o9VCFaV0Dwi 8r4VXh1ogV7dAb72aVXLIdwzBOglx4BckvmsNWKxb4FLFNMHaiI71pX56jwxrYTuZ0 AUlHDSWCGJbpAbViC8haQBjEeBBEQ+/mQUXe0dng= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 71BBDF896F7; Sat, 20 Apr 2019 12:46:25 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 66D62F801D9; Sat, 20 Apr 2019 12:46:21 +0200 (CEST) Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 715ECF801D9 for ; Sat, 20 Apr 2019 12:46:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 715ECF801D9 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="pD8+PQaR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1555757176; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+37NYGOkFUpJZTWiZmXk4xAeier065JR0ubSruTb7RA=; b=pD8+PQaRlnKrQFsISssYM1W80w48E1PIO3RieCKubLZBlS6Rt4PV3Arg/DUJHhho5Fy8H5 NKpijMpi+eab38T2+0Jk8GhxYI3DVtzWR2cBoAF6MqwuxoZp+h8t5cdG51aRuwk4R5nb35 KnsBE7BiXNhUniOm47pa+meKeZ4Og2c= From: Paul Cercueil To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland Date: Sat, 20 Apr 2019 12:45:52 +0200 Message-Id: <20190420104553.5071-2-paul@crapouillou.net> In-Reply-To: <20190420104553.5071-1-paul@crapouillou.net> References: <20190420104553.5071-1-paul@crapouillou.net> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kuninori Morimoto , linux-kernel@vger.kernel.org, Paul Cercueil , od@zcrc.me Subject: [alsa-devel] [PATCH 2/3] ASoC: simple-card-utils: add asoc_simple_card_of_parse_pin_switches() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function is a helper that permits to create pin switch controls for a list of widgets whose names are listed in the PREFIX "pin-switches" devicetree property. Signed-off-by: Paul Cercueil --- include/sound/simple_card_utils.h | 2 + sound/soc/generic/simple-card-utils.c | 57 +++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 7afe45389972..8a56c1713952 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -124,6 +124,8 @@ int asoc_simple_card_of_parse_routing(struct snd_soc_card *card, char *prefix); int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, char *prefix); +int asoc_simple_card_of_parse_pin_switches(struct snd_soc_card *card, + char *prefix); int asoc_simple_card_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 5c1424f03620..431002e3e63f 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -469,6 +469,63 @@ int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card, } EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_widgets); +int asoc_simple_card_of_parse_pin_switches(struct snd_soc_card *card, + char *prefix) +{ + const unsigned int nb_controls_max = 16; + const char **strings, *control_name; + struct snd_kcontrol_new *controls; + struct device *dev = card->dev; + unsigned int i, nb_controls; + char prop[128]; + int ret; + + if (!prefix) + prefix = ""; + + snprintf(prop, sizeof(prop), "%s%s", prefix, "pin-switches"); + + if (!of_property_read_bool(dev->of_node, prop)) + return 0; + + strings = devm_kcalloc(dev, nb_controls_max, + sizeof(*strings), GFP_KERNEL); + if (!strings) + return -ENOMEM; + + ret = of_property_read_string_array(dev->of_node, prop, + strings, nb_controls_max); + if (ret < 0) + return ret; + + nb_controls = (unsigned int)ret; + + controls = devm_kcalloc(dev, nb_controls, + sizeof(*controls), GFP_KERNEL); + if (!controls) + return -ENOMEM; + + for (i = 0; i < nb_controls; i++) { + control_name = devm_kasprintf(dev, GFP_KERNEL, + "%s Switch", strings[i]); + if (!control_name) + return -ENOMEM; + + controls[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; + controls[i].name = control_name; + controls[i].info = snd_soc_dapm_info_pin_switch; + controls[i].get = snd_soc_dapm_get_pin_switch; + controls[i].put = snd_soc_dapm_put_pin_switch; + controls[i].private_value = (unsigned long)strings[i]; + } + + card->controls = controls; + card->num_controls = nb_controls; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_of_parse_pin_switches); + int asoc_simple_card_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, int is_hp, char *prefix) From patchwork Sat Apr 20 10:45:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10910207 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 8AE301515 for ; Sat, 20 Apr 2019 10:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78E1D28905 for ; Sat, 20 Apr 2019 10:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A9B928C92; Sat, 20 Apr 2019 10:48:57 +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,DKIM_SIGNED, DKIM_VALID,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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B5BFA28905 for ; Sat, 20 Apr 2019 10:48:56 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 03176853; Sat, 20 Apr 2019 12:48:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 03176853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1555757335; bh=7xOwnUHOypes2KXiuojM3djWyiGurGzjbawsjysBxLs=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Wi4sElmLmRLllg/B4Dmagz/9PlrNxqDwY/04RqmbuZkHkxujGQhPWEitI1B0tC9Go Sk8L+wyZhWzF1HRin8xDHQlZBXGW4QhVGsasD6yc4O7eXQ+VHX7iiABY5XWKOk6oxP OCLg/4iyfcB8UQUp2NnESY/xKSCOVpKtwtLyDOiE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 94D9EF8971F; Sat, 20 Apr 2019 12:46:27 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCDC3F896E8; Sat, 20 Apr 2019 12:46:22 +0200 (CEST) Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 04D7EF896E5 for ; Sat, 20 Apr 2019 12:46:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 04D7EF896E5 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="qRYWagdb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1555757177; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZFNdaIfJj47xCdubjYphhaOdGLseFCSEhtDMHA2MkFo=; b=qRYWagdbYStd7BnfbFN6tceTIudnCdyRo9MizWqVC0GBAWPjL9vnPlYbz6ymY2UleSHwre oJ8rNvj0QXVwd0I23GVUDBIY4btBAzbVfgwIF2BGEdIliQuUZUGCy2S8VyH+KKlzqDnZs6 R+ETEyWJl9ozc6Pj8Vk26r6JGoyo7FU= From: Paul Cercueil To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland Date: Sat, 20 Apr 2019 12:45:53 +0200 Message-Id: <20190420104553.5071-3-paul@crapouillou.net> In-Reply-To: <20190420104553.5071-1-paul@crapouillou.net> References: <20190420104553.5071-1-paul@crapouillou.net> MIME-Version: 1.0 Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kuninori Morimoto , linux-kernel@vger.kernel.org, Paul Cercueil , od@zcrc.me Subject: [alsa-devel] [PATCH 3/3] ASoC: simple-card: Read pin switches conf from devicetree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP When the routing path between a widget (e.g. "Speaker") and the codec goes through an external amplifier, having a pin switch for this widget allows the amplifier to be disabled when the widget is not to be used (e.g. when using headphones). Signed-off-by: Paul Cercueil --- sound/soc/generic/simple-card.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 34de32efc4c4..d34adb1518e7 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -556,6 +556,10 @@ static int simple_parse_of(struct simple_priv *priv) if (ret < 0) return ret; + ret = asoc_simple_card_of_parse_pin_switches(card, PREFIX); + if (ret < 0) + return ret; + /* Single/Muti DAI link(s) & New style of DT node */ memset(&li, 0, sizeof(li)); for (li.cpu = 1; li.cpu >= 0; li.cpu--) {