From patchwork Fri May 22 22:09:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Reid X-Patchwork-Id: 6469141 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EAAA6C0020 for ; Fri, 22 May 2015 22:13:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAB5420531 for ; Fri, 22 May 2015 22:13:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7A314204D1 for ; Fri, 22 May 2015 22:13:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 72A562614C8; Sat, 23 May 2015 00:13:11 +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 102D3260593; Sat, 23 May 2015 00:11:13 +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 33136260563; Sat, 23 May 2015 00:11:09 +0200 (CEST) Received: from mail-pd0-f202.google.com (mail-pd0-f202.google.com [209.85.192.202]) by alsa0.perex.cz (Postfix) with ESMTP id 3139226043C for ; Sat, 23 May 2015 00:10:56 +0200 (CEST) Received: by pdbht2 with SMTP id ht2so2375793pdb.0 for ; Fri, 22 May 2015 15:10:55 -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:in-reply-to :references; bh=pAg0tP4bLcrD5FdMoGWdkx3WJaJj/73oQI96IQ7h3UY=; b=PLmxrIuVTlMnJT0Ds2gRSH1lRoafWm6sEzD4w8DQRQ7cSqZmkptdqdu538tVLIedPZ T9tYjVbatEAP4a47f4m+aLe+ahO4vLa3sLL6kF62UU7mCBuFEhzgeAtL/WAi0v9Hxx3N EUI3GmIgTxffu/z0rTseYGrK7uOErMpaDGaTwU/jhz//XyhbWBw/c1+e7t2a3MWc9eRA lA5e34UlhKDLe3KTDYJ0F7aMGM1BkDzFvUcfBj9AjdKqg4FbSoD9TNNR/BG3cHF8V2oe LW7/uC5zezOiOVR5bh24OTAZpzekSZYZlQNm1NaRW+LtVn82FOSHbfKESsbMjfpDiUJL 9iAA== X-Gm-Message-State: ALoCoQl7eD5LHvzS8b9ErZE/UBXIzaDXIBZ8CURI/HhLqcGvGUtqXlpMkxVPXU8DuFndfYy4KjCzT8YoHBD/KpG5DKQm17jMldHs8aAacwLI76GIeTGWhiw0jnkuDENkYX2g8e80pkxfpqk9+SZeaiMItgk1qe4GDYkgT7WtytUzMBNb+WRL0smC5WZYRZMvVwzds7UgFfae X-Received: by 10.66.160.234 with SMTP id xn10mr11980343pab.43.1432332654621; Fri, 22 May 2015 15:10:54 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id x25si182231yha.2.2015.05.22.15.10.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 15:10:54 -0700 (PDT) Received: from hojo20.mtv.corp.google.com ([172.22.65.103]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id I2n9zqR5.1; Fri, 22 May 2015 15:10:54 -0700 Received: by hojo20.mtv.corp.google.com (Postfix, from userid 123195) id 8FC9C1C3C07; Fri, 22 May 2015 15:10:53 -0700 (PDT) From: Dylan Reid To: alsa-devel@alsa-project.org Date: Fri, 22 May 2015 15:09:22 -0700 Message-Id: <1432332563-15447-5-git-send-email-dgreid@chromium.org> X-Mailer: git-send-email 2.2.1.62.g3f15098 In-Reply-To: <1432332563-15447-1-git-send-email-dgreid@chromium.org> References: <1432332563-15447-1-git-send-email-dgreid@chromium.org> Cc: lars@metafoo.de, zhengxing@rock-chips.com, tiwai@suse.de, lgirdwood@gmail.com, broonie@kernel.org, Dylan Reid Subject: [alsa-devel] [RFC 4/5] ASoC: tegra_max98090: Change nyan to use gpio-jack 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 Use the new gpio jack device instead of handling the gpios in the machine driver. Signed-off-by: Dylan Reid --- sound/soc/tegra/Kconfig | 1 + sound/soc/tegra/tegra_max98090.c | 107 ++++++++------------------------------- 2 files changed, 22 insertions(+), 86 deletions(-) diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index a6768f8..de42bfb 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -125,6 +125,7 @@ config SND_SOC_TEGRA_MAX98090 select SND_SOC_TEGRA20_I2S if ARCH_TEGRA_2x_SOC select SND_SOC_TEGRA30_I2S if ARCH_TEGRA_3x_SOC select SND_SOC_MAX98090 + select SND_SOC_GPIO_AUDIO_JACK help Say Y or M here if you want to add support for SoC audio on Tegra boards using the MAX98090 codec, such as Venice2. diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index 902da36..a8d77ff 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c @@ -41,8 +41,6 @@ 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, @@ -97,38 +95,6 @@ static struct snd_soc_ops tegra_max98090_ops = { .hw_params = tegra_max98090_asoc_hw_params, }; -static struct snd_soc_jack tegra_max98090_hp_jack; - -static struct snd_soc_jack_pin tegra_max98090_hp_jack_pins[] = { - { - .pin = "Headphones", - .mask = SND_JACK_HEADPHONE, - }, -}; - -static struct snd_soc_jack_gpio tegra_max98090_hp_jack_gpio = { - .name = "Headphone detection", - .report = SND_JACK_HEADPHONE, - .debounce_time = 150, - .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), @@ -145,50 +111,14 @@ static const struct snd_kcontrol_new tegra_max98090_controls[] = { static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) { - struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); - - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_card_jack_new(rtd->card, "Headphones", - SND_JACK_HEADPHONE, - &tegra_max98090_hp_jack, - tegra_max98090_hp_jack_pins, - ARRAY_SIZE(tegra_max98090_hp_jack_pins)); - - tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; - snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, - 1, - &tegra_max98090_hp_jack_gpio); - } - - if (gpio_is_valid(machine->gpio_mic_det)) { - snd_soc_card_jack_new(rtd->card, "Mic Jack", - SND_JACK_MICROPHONE, - &tegra_max98090_mic_jack, - tegra_max98090_mic_jack_pins, - ARRAY_SIZE(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; -} - -static int tegra_max98090_card_remove(struct snd_soc_card *card) -{ - struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); + struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; - if (gpio_is_valid(machine->gpio_hp_det)) { - snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1, - &tegra_max98090_hp_jack_gpio); - } + /* Force MICBIAS on because it is needed for mic detection. */ + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); - if (gpio_is_valid(machine->gpio_mic_det)) { - snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1, - &tegra_max98090_mic_jack_gpio); - } + snd_soc_dapm_sync(dapm); return 0; } @@ -203,12 +133,17 @@ static struct snd_soc_dai_link tegra_max98090_dai = { SND_SOC_DAIFMT_CBS_CFS, }; +static struct snd_soc_aux_dev gpio_headset_jack_dev = { + .name = "gpio-headset-jack", +}; + static struct snd_soc_card snd_soc_tegra_max98090 = { .name = "tegra-max98090", .owner = THIS_MODULE, - .remove = tegra_max98090_card_remove, .dai_link = &tegra_max98090_dai, .num_links = 1, + .aux_dev = &gpio_headset_jack_dev, + .num_aux_devs = 1, .controls = tegra_max98090_controls, .num_controls = ARRAY_SIZE(tegra_max98090_controls), .dapm_widgets = tegra_max98090_dapm_widgets, @@ -234,15 +169,6 @@ static int tegra_max98090_probe(struct platform_device *pdev) platform_set_drvdata(pdev, card); snd_soc_card_set_drvdata(card, machine); - machine->gpio_hp_det = of_get_named_gpio(np, "nvidia,hp-det-gpios", 0); - 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; @@ -269,6 +195,15 @@ static int tegra_max98090_probe(struct platform_device *pdev) goto err; } + gpio_headset_jack_dev.codec_of_node = of_parse_phandle(np, + "nvidia,headset-dev", 0); + if (!gpio_headset_jack_dev.codec_of_node) { + dev_err(&pdev->dev, + "Property 'nvidia,headset-dev' missing or invalid\n"); + ret = -EINVAL; + goto err; + } + tegra_max98090_dai.platform_of_node = tegra_max98090_dai.cpu_of_node; ret = tegra_asoc_utils_init(&machine->util_data, &pdev->dev);