From patchwork Wed Jul 15 14:09:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 235587 Delivered-To: patch@linaro.org Received: by 2002:a54:2c11:0:0:0:0:0 with SMTP id g17csp433476ecp; Wed, 15 Jul 2020 07:13:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVw9fl4Welt+ILscnlbzZ93riJ5DauO5/eg1j4CGQQ5QpAdXybG7A3gvjnAWw5s0bC3vFx X-Received: by 2002:aa7:d2d2:: with SMTP id k18mr9505096edr.16.1594822434069; Wed, 15 Jul 2020 07:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594822434; cv=none; d=google.com; s=arc-20160816; b=vJdssoaP0+zHFG5YsonLiv4Wx1knHxlqGREC3PdRfjCJ4YsWAhgeNTySFxG0tpaUDh EQb0a+vjeaKOrZunxu09yiepKAVENQviGm0nHYsObY4J3JDHQcugaKUX/+5dwQjv5K8V 4QK1y0eMuPEE+S7ZX9EEe2B31d5I/tOim7E1iW+8fzwl3wBGk9iQX/2uBEIu1P+8oyUv uMM31YQN/7OmrgKaEeGdPpoNi/bn8HhazPuxelwimpgnwTz7M2hLAUwzSNVGuhgOPBrx zIIo/fWRkBS28s+2Ulp93c7sYjPBu1r00m5Fup0thxX4XKwegYm7LxMAHJeXez/AOsL3 ZNnA== 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; bh=ewCYzhqS7tj8R2BgCJ+Cm0Ga76eDaM+0kn4tb2JxjQQ=; b=GKm9QRlcJ5ZbNgAQLMCTYeBzBqpvSALu/hufmAxvbryOvSPbmdqhmX1sJ9MbIM2pre wHi7IousAhl1zKn3k90VB9avWRsoJF/JMcpb8xgDx83U9szOxgVv/EoNR7ZySsB/rOrE smm3TpoRAucmYj0jetQeq7bSarIL/hdKhgkjzNRxITDW648drXT3ShuPZEv9pfH7+Ksi Fpmx4Vrq7Zq8/VqTnHT0DW2Szd73VRn37aYKrKNh5ksznGguyrA5SJZyl1v4p1eYzH6z HSslGzRQ/PG/esNL7o5JRJ5c31mN14+CFd+f71ZJu+CEdX/E/I4RaYm6ELYTnn+wF09o ItVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si1306398ejp.600.2020.07.15.07.13.53; Wed, 15 Jul 2020 07:13:54 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbgGOONx (ORCPT + 6 others); Wed, 15 Jul 2020 10:13:53 -0400 Received: from inva020.nxp.com ([92.121.34.13]:49490 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbgGOONw (ORCPT ); Wed, 15 Jul 2020 10:13:52 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3D21A1A01F3; Wed, 15 Jul 2020 16:13:50 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E43AF1A0461; Wed, 15 Jul 2020 16:13:44 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 31265402E4; Wed, 15 Jul 2020 22:13:38 +0800 (SGT) From: Shengjiu Wang To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org, devicetree@vger.kernel.org, timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 1/3] ASoC: simple-card-utils: Support configure pin_name for asoc_simple_init_jack Date: Wed, 15 Jul 2020 22:09:37 +0800 Message-Id: <1594822179-1849-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> References: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Currently the pin_name is fixed in asoc_simple_init_jack, but some driver may use a different pin_name. So add a new parameter in asoc_simple_init_jack for configuring pin_name. If this parameter is NULL, then the default pin_name is used. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- include/sound/simple_card_utils.h | 6 +++--- sound/soc/generic/simple-card-utils.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) -- 2.27.0 diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index bbdd1542d6f1..86a1e956991e 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -12,9 +12,9 @@ #include #define asoc_simple_init_hp(card, sjack, prefix) \ - asoc_simple_init_jack(card, sjack, 1, prefix) + asoc_simple_init_jack(card, sjack, 1, prefix, NULL) #define asoc_simple_init_mic(card, sjack, prefix) \ - asoc_simple_init_jack(card, sjack, 0, prefix) + asoc_simple_init_jack(card, sjack, 0, prefix, NULL) struct asoc_simple_dai { const char *name; @@ -131,7 +131,7 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card, int asoc_simple_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, - int is_hp, char *prefix); + int is_hp, char *prefix, char *pin); int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct link_info *li); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 8c54dc6710fe..b408cb5ed644 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -540,7 +540,8 @@ EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches); int asoc_simple_init_jack(struct snd_soc_card *card, struct asoc_simple_jack *sjack, - int is_hp, char *prefix) + int is_hp, char *prefix, + char *pin) { struct device *dev = card->dev; enum of_gpio_flags flags; @@ -557,12 +558,12 @@ int asoc_simple_init_jack(struct snd_soc_card *card, if (is_hp) { snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix); - pin_name = "Headphones"; + pin_name = pin ? pin : "Headphones"; gpio_name = "Headphone detection"; mask = SND_JACK_HEADPHONE; } else { snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix); - pin_name = "Mic Jack"; + pin_name = pin ? pin : "Mic Jack"; gpio_name = "Mic detection"; mask = SND_JACK_MICROPHONE; } From patchwork Wed Jul 15 14:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 235589 Delivered-To: patch@linaro.org Received: by 2002:a54:2c11:0:0:0:0:0 with SMTP id g17csp433591ecp; Wed, 15 Jul 2020 07:14:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2NRX0tLDPKFhPRxfODcntlPzogvS70dol8HH2Gt/ZC3armwo/ybelTc5N87AXCUGQdvlX X-Received: by 2002:a17:907:7283:: with SMTP id dt3mr9739096ejc.195.1594822441590; Wed, 15 Jul 2020 07:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594822441; cv=none; d=google.com; s=arc-20160816; b=uAxUOI4rig1g/hQsex0W9VPdpIC3EILlPVaG5Y/sCnKoKR0Ieqqzml1j0ThnjTEx5O suBlwG/sykcuiXZLrxQhYXNEqNyA0CQXg/6C3gJxt/ro3CM8HKf0smz545IEX/3OWtIH YEbtc+mQiMc6eSLbZx2Upzkd7HTaGr0P0xDongOvQvP8Yy40cAH4T7gpnDJ+t7B6CEMh C86vte/wR8z5GN61qnyM0SaGHyf/7AP9NJBSlKwwU98X7ptCycDiTwXBsNMGna0fufQg et6/LJz/URDQV8AzACTC++n8ZFxUR3W6KQCJ2jFpXzLKCr2nbJXn82bxb1VCGtHX4cIK fL7A== 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; bh=gaHFeje2qaJUQBEowAzT24KbMnjb1jaWsFn3WmQG1wE=; b=l5qmfN2Ve6IjfH6A5DTE7rnHzAciCykMzJILSzbKfL+mqElTXzIMBsBaH+AIR+x0q+ MBj+9zkEz4BA6msVVy9yAg472ZKPcC6MmFFR3K6zN0eKHrSAB22xUPlG+407cruOLv/4 g2uhOkYbMLE6ZX69jli7fa/a+eyMPqtJH13vAn8lPRqAt5WRR+iUX2FSvkiQErAurcse SI2L8xIjGqISFFrIkH+1VJw7NtXq+TvtcgYonnDt3q3ePt8/mNwJ2Fho3tG/mlCuqlC/ 8C0yh57zl380uruZFZ4yB21Mcua2+R7fMfJnh/TdA8EaNVPprqXVNllb/UIDmtsD5QNk il8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si1284189edn.258.2020.07.15.07.14.01; Wed, 15 Jul 2020 07:14:01 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgGOOOA (ORCPT + 6 others); Wed, 15 Jul 2020 10:14:00 -0400 Received: from inva021.nxp.com ([92.121.34.21]:43420 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbgGOONx (ORCPT ); Wed, 15 Jul 2020 10:13:53 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 800B9200307; Wed, 15 Jul 2020 16:13:51 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2FF932002F8; Wed, 15 Jul 2020 16:13:46 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 6759540305; Wed, 15 Jul 2020 22:13:39 +0800 (SGT) From: Shengjiu Wang To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org, devicetree@vger.kernel.org, timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 2/3] ASoC: bindings: fsl-asoc-card: Support hp-det-gpio and mic-det-gpio Date: Wed, 15 Jul 2020 22:09:38 +0800 Message-Id: <1594822179-1849-3-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> References: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add headphone and microphone detection GPIO support. These properties are optional. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 3 +++ 1 file changed, 3 insertions(+) -- 2.27.0 Acked-by: Rob Herring diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt index 133d7e14a4d0..8a6a3d0fda5e 100644 --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt @@ -69,6 +69,9 @@ Optional properties: coexisting in order to support the old bindings of wm8962 and sgtl5000. + - hp-det-gpio : The GPIO that detect headphones are plugged in + - mic-det-gpio : The GPIO that detect microphones are plugged in + Optional unless SSI is selected as a CPU DAI: - mux-int-port : The internal port of the i.MX audio muxer (AUDMUX) From patchwork Wed Jul 15 14:09:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shengjiu Wang X-Patchwork-Id: 235588 Delivered-To: patch@linaro.org Received: by 2002:a54:2c11:0:0:0:0:0 with SMTP id g17csp433506ecp; Wed, 15 Jul 2020 07:13:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjXT2pg/7KgmZA+g9pWlVQJLpISOLEB4n+bGReS2r5McpE3/4INz9lTHG8UzdQpSDP7EyM X-Received: by 2002:a17:906:4f82:: with SMTP id o2mr9611288eju.424.1594822436386; Wed, 15 Jul 2020 07:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594822436; cv=none; d=google.com; s=arc-20160816; b=nf4Fg5SFLIxrkSdbil1b1ux0qMyQcfy3eDcUUp+heDaPFqYs3hY44n+sbCeUnqTiHj FnFZkmv5SmY4IeJPHUgIEFkpXX8h5i4IkH0V6Yzjd9c4Zkee41eh5b07uye2CaFYy8oS UwTIc8Jm3LAY5zqmVUeEpR6KYdhUtApLTm4GPGv/dePSe9+sGZI0izznU4QqDCUKPJYy WFbFDwY11PuySyPYB5YJSyl0x9apu4O5i/bPnlGlyLeQVDJUc/joWK/QwcYS84evetVC iJWKn2FANZgUkWWae8FpCAgTqSXHR8/X2z3XHtSAqaehrFbd2g5ly+KrO19uRNC9YV8E d80g== 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; bh=0pV1C8URjlHoUqgkLhGeHNqB+k0zo4DI5Hhww1sWfN8=; b=EhmEA64MKE9YNBax1JkW5VpWi87GPeH3efCE7sc/kS/ZY5kECe7EOwhDCWTK0g2Smp Xyf4uKbiK4zw8uT7312OUMLFTpS6e49KT0FbjxRbe+IIsO0BGthFdvaftphUnOz1g+oo KW0gjyqwQ+3J4J6Rva3emfK5Zhr3NBasT0EoC50Gq2ZIZ7BXQBpN9xw/aZr1Rk1My7YY XWW8jivTgUgDx736L6AdUW8VTkyaipLFomWYdIXu+5F/xy1flHPBZBo48m5DtLpZhl/Y TYP+7UrjeMvJ69MWR2r6ukQ6b6rLgojRIn7g/FwkWsbpJJYSudHOH7ndVRvMc110dojr gGLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si1311724eje.434.2020.07.15.07.13.56; Wed, 15 Jul 2020 07:13:56 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgGOONz (ORCPT + 6 others); Wed, 15 Jul 2020 10:13:55 -0400 Received: from inva020.nxp.com ([92.121.34.13]:49520 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727771AbgGOONy (ORCPT ); Wed, 15 Jul 2020 10:13:54 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 9267F1A1442; Wed, 15 Jul 2020 16:13:52 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 0F4A31A0241; Wed, 15 Jul 2020 16:13:47 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id A6A80402C1; Wed, 15 Jul 2020 22:13:40 +0800 (SGT) From: Shengjiu Wang To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org, devicetree@vger.kernel.org, timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 3/3] ASoC: fsl-asoc-card: Support Headphone and Microphone Jack detection Date: Wed, 15 Jul 2020 22:09:39 +0800 Message-Id: <1594822179-1849-4-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> References: <1594822179-1849-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use asoc_simple_init_jack function from simple card to implement the Headphone and Microphone detection. Register notifier to disable Speaker when Headphone is plugged in and enable Speaker when Headphone is unplugged. Register notifier to disable Digital Microphone when Analog Microphone is plugged in and enable DMIC when Analog Microphone is unplugged. Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen --- sound/soc/fsl/Kconfig | 1 + sound/soc/fsl/fsl-asoc-card.c | 77 ++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index ea7b4787a8af..1c4ca5ec8caf 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -315,6 +315,7 @@ config SND_SOC_FSL_ASOC_CARD depends on OF && I2C # enforce SND_SOC_FSL_ASOC_CARD=m if SND_AC97_CODEC=m: depends on SND_AC97_CODEC || SND_AC97_CODEC=n + select SND_SIMPLE_CARD_UTILS select SND_SOC_IMX_AUDMUX select SND_SOC_IMX_PCM_DMA select SND_SOC_FSL_ESAI diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index faac6ce9a82c..f0cde3ecb5b7 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -15,6 +15,8 @@ #endif #include #include +#include +#include #include "fsl_esai.h" #include "fsl_sai.h" @@ -65,6 +67,8 @@ struct cpu_priv { /** * struct fsl_asoc_card_priv - Freescale Generic ASOC card private data * @dai_link: DAI link structure including normal one and DPCM link + * @hp_jack: Headphone Jack structure + * @mic_jack: Microphone Jack structure * @pdev: platform device pointer * @codec_priv: CODEC private data * @cpu_priv: CPU private data @@ -79,6 +83,8 @@ struct cpu_priv { struct fsl_asoc_card_priv { struct snd_soc_dai_link dai_link[3]; + struct asoc_simple_jack hp_jack; + struct asoc_simple_jack mic_jack; struct platform_device *pdev; struct codec_priv codec_priv; struct cpu_priv cpu_priv; @@ -445,6 +451,44 @@ static int fsl_asoc_card_audmux_init(struct device_node *np, return 0; } +static int hp_jack_event(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct snd_soc_jack *jack = (struct snd_soc_jack *)data; + struct snd_soc_dapm_context *dapm = &jack->card->dapm; + + if (event & SND_JACK_HEADPHONE) + /* Disable speaker if headphone is plugged in */ + snd_soc_dapm_disable_pin(dapm, "Ext Spk"); + else + snd_soc_dapm_enable_pin(dapm, "Ext Spk"); + + return 0; +} + +static struct notifier_block hp_jack_nb = { + .notifier_call = hp_jack_event, +}; + +static int mic_jack_event(struct notifier_block *nb, unsigned long event, + void *data) +{ + struct snd_soc_jack *jack = (struct snd_soc_jack *)data; + struct snd_soc_dapm_context *dapm = &jack->card->dapm; + + if (event & SND_JACK_MICROPHONE) + /* Disable dmic if microphone is plugged in */ + snd_soc_dapm_disable_pin(dapm, "DMIC"); + else + snd_soc_dapm_enable_pin(dapm, "DMIC"); + + return 0; +} + +static struct notifier_block mic_jack_nb = { + .notifier_call = mic_jack_event, +}; + static int fsl_asoc_card_late_probe(struct snd_soc_card *card) { struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card); @@ -745,8 +789,37 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(&priv->card, priv); ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); - if (ret && ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); + if (ret) { + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); + goto asrc_fail; + } + + /* + * Properties "hp-det-gpio" and "mic-det-gpio" are optional, and + * asoc_simple_init_jack uses these properties for creating + * Headphone Jack and Microphone Jack. + * + * The notifier is initialized in snd_soc_card_jack_new(), then + * snd_soc_jack_notifier_register can be called. + */ + if (of_property_read_bool(np, "hp-det-gpio")) { + ret = asoc_simple_init_jack(&priv->card, &priv->hp_jack, + 1, NULL, "Headphone Jack"); + if (ret) + goto asrc_fail; + + snd_soc_jack_notifier_register(&priv->hp_jack.jack, &hp_jack_nb); + } + + if (of_property_read_bool(np, "mic-det-gpio")) { + ret = asoc_simple_init_jack(&priv->card, &priv->mic_jack, + 0, NULL, "Mic Jack"); + if (ret) + goto asrc_fail; + + snd_soc_jack_notifier_register(&priv->mic_jack.jack, &mic_jack_nb); + } asrc_fail: of_node_put(asrc_np);