From patchwork Thu Jan 12 12:01:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shrirang Bagul X-Patchwork-Id: 9513329 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 1AB5660476 for ; Thu, 12 Jan 2017 14:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03701286D3 for ; Thu, 12 Jan 2017 14:23:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7563286E2; Thu, 12 Jan 2017 14:23:26 +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, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF02286D3 for ; Thu, 12 Jan 2017 14:23:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id C1D2A2671F4; Thu, 12 Jan 2017 15:22:56 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 166C5266AFF; Thu, 12 Jan 2017 15:20:38 +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 5E7E3266ABE; Thu, 12 Jan 2017 13:01:33 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id AFCEA2669BD for ; Thu, 12 Jan 2017 13:01:31 +0100 (CET) Received: from [175.41.48.77] (helo=snb-ubuntu.taipei) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1cRe4R-0007ZA-2A; Thu, 12 Jan 2017 12:01:31 +0000 From: Shrirang Bagul To: alsa-devel@alsa-project.org Date: Thu, 12 Jan 2017 20:01:01 +0800 Message-Id: <20170112120101.16933-5-shrirang.bagul@canonical.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170112120101.16933-1-shrirang.bagul@canonical.com> References: <20170112120101.16933-1-shrirang.bagul@canonical.com> Cc: Liam Girdwood , Shrirang Bagul , linux-kernel@vger.kernel.org, Takashi Iwai , Pierre-Louis Bossart , Irina Tirdea , Mark Brown Subject: [alsa-devel] [PATCH v2 4/4] ASoC: Intel: bytcr_rt5640: Support line-out mute gpio 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 support to toggle mute on 'line-out' pin on Dell Edge IoT Gateways. A dedicated GPIO on the SoC is used to control the amplifier. This GPIO is described in the BIOS DSD table. Signed-off-by: Shrirang Bagul --- sound/soc/intel/boards/bytcr_rt5640.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index e8c9a01..ae53a29 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,7 @@ struct byt_acpi_card { struct byt_rt5640_private { struct byt_acpi_card *acpi_card; + struct gpio_desc *gpio_lo_mute; struct clk *mclk; char codec_name[16]; int *clks; @@ -198,6 +200,19 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, return 0; } +static int byt_rt5660_event_lineout(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); + + gpiod_set_value_cansleep(priv->gpio_lo_mute, + !(SND_SOC_DAPM_EVENT_ON(event))); + + return 0; +} + static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), @@ -296,7 +311,7 @@ static const struct snd_kcontrol_new byt_rt5640_controls[] = { static const struct snd_soc_dapm_widget byt_rt5660_widgets[] = { SND_SOC_DAPM_MIC("Line In", NULL), - SND_SOC_DAPM_LINE("Line Out", NULL), + SND_SOC_DAPM_LINE("Line Out", byt_rt5660_event_lineout), SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, platform_clock_control, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), @@ -562,7 +577,18 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) static int byt_rt5660_init(struct snd_soc_pcm_runtime *runtime) { int ret; + struct snd_soc_codec *codec = runtime->codec; struct snd_soc_card *card = runtime->card; + struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); + + /* Request rt5660 GPIO for lineout mute control */ + priv->gpio_lo_mute = devm_gpiod_get_index(codec->dev, + "lineout-mute", 0, 0); + if (IS_ERR(priv->gpio_lo_mute)) { + dev_err(card->dev, "Can't find GPIO_MUTE# gpio\n"); + return PTR_ERR(priv->gpio_lo_mute); + } + gpiod_direction_output(priv->gpio_lo_mute, 1); ret = snd_soc_dapm_add_routes(&card->dapm, byt_rt5640_ssp2_aif1_map,