From patchwork Thu Oct 2 16:42:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 5019391 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 09733C11AB for ; Thu, 2 Oct 2014 16:43:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE6E920200 for ; Thu, 2 Oct 2014 16:43:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 33F732016C for ; Thu, 2 Oct 2014 16:43:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 45EF6261785; Thu, 2 Oct 2014 18:43:09 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DD8D526168C; Thu, 2 Oct 2014 18:42:58 +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 0F0F42616B9; Thu, 2 Oct 2014 18:42:57 +0200 (CEST) Received: from mail-oi0-f74.google.com (mail-oi0-f74.google.com [209.85.218.74]) by alsa0.perex.cz (Postfix) with ESMTP id CFDE426167D for ; Thu, 2 Oct 2014 18:42:50 +0200 (CEST) Received: by mail-oi0-f74.google.com with SMTP id v63so473048oia.1 for ; Thu, 02 Oct 2014 09:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ogK9gp0GAk+yFPTSWpnadP4sQd2PXZuxiyAIR8rTKwk=; b=MoJSn08656XsZ1RcEYmL8kgnU9JZk4mexKsxwZIbP7xlakt8HyydsETRkfanzhAVYX VSvNSCA6hMSSla4ESXZguKW4lET4hwTy2xVLkI+3+jnAZsaqX9+BgARdbQzxdsHpAbXh lJ41td6OMdyQaBIjBb0V5MAwze4Js5+jWCoi990Nx2WtXBMOOZnNESN1r8s+wrEUgxOY uFxdpOAF0a330q9LlmsYKGZrpwiKDcqJBkeWy+KrxucQM8CdlVGzxWBBMtXYKzF57d1d MizoDVnBYO9E0hPI+Zp6/EJ0kCbBn1/MR0Vz4QiKQ8nh/HSTCmIFE7Fp6IJzUuT8aZMQ l4Bg== X-Gm-Message-State: ALoCoQkVnV0URiOQWxXNh5gCLfrpe5msyxWmH+kCRXkktO15mYZbVq+hRVB/bLRA20+l4JzqxFlHX2fxFkBH1XNUVGzH8oRk7y60gdlAQVErFXsvNy3uFvXTf4A66DN7uRxLDq0AucvfBFPlDBwCoM7lwtSxRS1RUCFbmlU2d3N/wlK+2+tMH/8= X-Received: by 10.50.25.41 with SMTP id z9mr3198913igf.2.1412268169413; Thu, 02 Oct 2014 09:42:49 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id t28si206022yhb.4.2014.10.02.09.42.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Oct 2014 09:42:49 -0700 (PDT) Received: from hojo20.mtv.corp.google.com ([172.22.65.103]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id Zh0MODOk.1; Thu, 02 Oct 2014 09:42:49 -0700 Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id 72F681C082D; Thu, 2 Oct 2014 09:42:48 -0700 (PDT) From: Dylan Reid To: alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org Date: Thu, 2 Oct 2014 09:42:44 -0700 Message-Id: <1412268164-3333-1-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 2.1.2.330.g565301e Cc: Dylan Reid , broonie@kernel.org, thierry.reding@gmail.com, swarren@wwwdotorg.org Subject: [alsa-devel] [PATCH 1/2] ASoC: tegra: add mic detect gpio to tegra_max98090 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 Add an optional mic detect gpio property. If specified in device tree there will be a mic jack created for the given gpio. This will be used by the Tegra-based Chromebooks. Signed-off-by: Dylan Reid Reviewed-by: Stephen Warren --- .../bindings/sound/nvidia,tegra-audio-max98090.txt | 1 + sound/soc/tegra/tegra_max98090.c | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt index 9c7c55c..c949abc 100644 --- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt +++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt @@ -25,6 +25,7 @@ Required properties: Optional properties: - nvidia,hp-det-gpios : The GPIO that detect headphones are plugged in +- nvidia,mic-det-gpios : The GPIO that detect microphones are plugged in Example: diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index b86cd99..01921d7 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -42,6 +42,7 @@ struct tegra_max98090 { struct tegra_asoc_utils_data util_data; int gpio_hp_det; + int gpio_mic_det; }; static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, @@ -112,6 +113,22 @@ static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = { .invert = 1, }; +static struct snd_soc_jack tegra_max98090_mic_jack; + +static struct snd_soc_jack_pin tegra_max98090_mic_jack_pins[] = { + { + .pin = "Mic Jack", + .mask = SND_JACK_MICROPHONE, + }, +}; + +static struct snd_soc_jack_gpio tegra_max98090_mic_jack_gpio = { + .name = "Mic detection", + .report = SND_JACK_MICROPHONE, + .debounce_time = 150, + .invert = 1, +}; + static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_SPK("Speakers", NULL), @@ -141,6 +158,19 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) &tegra_max98090_hp_jack_gpio); } + if (gpio_is_valid(machine->gpio_mic_det)) { + snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, + &tegra_max98090_mic_jack); + snd_soc_jack_add_pins(&tegra_max98090_mic_jack, + ARRAY_SIZE(tegra_max98090_mic_jack_pins), + tegra_max98090_mic_jack_pins); + + tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; + snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, + 1, + &tegra_max98090_mic_jack_gpio); + } + return 0; } @@ -153,6 +183,11 @@ static int tegra_max98090_card_remove(struct snd_soc_card *card) &tegra_max98090_hp_jack_gpio); } + if (gpio_is_valid(machine->gpio_mic_det)) { + snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1, + &tegra_max98090_mic_jack_gpio); + } + return 0; } @@ -201,6 +236,11 @@ static int tegra_max98090_probe(struct platform_device *pdev) if (machine->gpio_hp_det == -EPROBE_DEFER) return -EPROBE_DEFER; + machine->gpio_mic_det = + of_get_named_gpio(np, "nvidia,mic-det-gpios", 0); + if (machine->gpio_mic_det == -EPROBE_DEFER) + return -EPROBE_DEFER; + ret = snd_soc_of_parse_card_name(card, "nvidia,model"); if (ret) goto err;