From patchwork Mon Sep 28 06:37:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ajye huang X-Patchwork-Id: 11802967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5404C6CA for ; Mon, 28 Sep 2020 06:38:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E58122262 for ; Mon, 28 Sep 2020 06:38:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EvW1auze" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726565AbgI1GiH (ORCPT ); Mon, 28 Sep 2020 02:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726559AbgI1GiH (ORCPT ); Mon, 28 Sep 2020 02:38:07 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 246BDC0613CE; Sun, 27 Sep 2020 23:38:07 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id f18so9320pfa.10; Sun, 27 Sep 2020 23:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J9fPNn2hkvUvRS1FoBqTdwdl0ikK+0K/8i5MIze2SS4=; b=EvW1auzeaeX+5P91nfpAeNz3iU3z6CXl1gD1XAWygHj/x0evv/YLyspd75P/ksoy33 3nVjlPmZjT6ZnNetqaqDPlAPzuuy6rlHXgFEa0nOSDqhBn7HfjEcCRSj5cEYx6Ny2yRo +Ki+TDRfUpNA4phWyuxqaKjCnEL8Mh4HyT3elj7VQONpzdS+h/UiwvMfUKMu9hGlZqqB lOQtoGiDYfWb4OEfRjemFbIstZy/a5gWi+rASC9MguiWr/Z2kWRVSWmZVN2XsSZsGjNO gPoyDRbBnwcvIwk8TAUAxBN9hBkDqXEq+xBy2Kaqk8zyzFsObQTMfGmorhlDJEd4vVYn se2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J9fPNn2hkvUvRS1FoBqTdwdl0ikK+0K/8i5MIze2SS4=; b=IWafYUutdvx/AcSLk2vnxm4sTdLF03LSTNf+Q3gWfcNeItByhdTxYWmy4BkcqXmfno C724hgtIPcYgAzs365BEwUJoPIX//5/IimR5iWK3/h4QQYjV46+kCug0rCLvpKBgcCg6 mtPhFcy6UYf3P//7883LTY6pbNmwZ6MXD1OefL+a8rRvXmjAEHdZrs6FJPGbyrW6Wrzu +COevxUYQZwhL00BR7pHsunUA2ex089ttH0BEVuYJSwzySfJahDSuuj1Qys0etJnhHCt nwTeSJpiCSoWGe0h+Zi1uQAy/pvnWZ2ja2oeVrVk8OI1fZSSr3rVAHtpN9jFuFgO4YmY WcAg== X-Gm-Message-State: AOAM5323BM/uf/o7zXewUsT0ROqRms+ByUmDZKeCZiyAHtqlnfPs7BC1 zBP6/rUd7MY9ogzNju8+e5N/afHkWZdSwjr3 X-Google-Smtp-Source: ABdhPJxG7BOD2ezBdXdfZEH8XstwCs/b4Bb6Xk3lDpQvpYBcSTLCgVvLyhndkIczw2+7IlEErCpQpQ== X-Received: by 2002:a17:902:9007:b029:d2:8cdd:d8cd with SMTP id a7-20020a1709029007b02900d28cddd8cdmr206114plp.85.1601275086370; Sun, 27 Sep 2020 23:38:06 -0700 (PDT) Received: from localhost (114-34-18-97.HINET-IP.hinet.net. [114.34.18.97]) by smtp.gmail.com with ESMTPSA id c7sm189527pfj.100.2020.09.27.23.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 23:38:05 -0700 (PDT) From: Ajye Huang X-Google-Original-From: Ajye Huang To: linux-kernel@vger.kernel.org Cc: Mark Brown , Rohit kumar , Banajit Goswami , Patrick Lai , Srinivasa Rao Mandadapu , Andy Gross , Bjorn Andersson , Liam Girdwood , Rob Herring , Jaroslav Kysela , cychiang@chromium.org, tzungbi@chromium.org, dianders@chromium.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Ajye Huang Subject: [PATCH v1 1/2] ASoC: qcom: dt-bindings: Modify sc7180 machine bindings Date: Mon, 28 Sep 2020 14:37:43 +0800 Message-Id: <20200928063744.525700-2-ajye_huang@compal.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928063744.525700-1-ajye_huang@compal.corp-partner.google.com> References: <20200928063744.525700-1-ajye_huang@compal.corp-partner.google.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add compatible "qcom,sc7180-sndcard-rt5682-m98357-2mic" for 2mic case. Signed-off-by: Ajye Huang Reviewed-by: Rob Herring --- This patch depends on this patch series https://patchwork.kernel.org/patch/11773221/ . .../bindings/sound/qcom,sc7180.yaml | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,sc7180.yaml b/Documentation/devicetree/bindings/sound/qcom,sc7180.yaml index b77311bb5190..ec84dbfc1bc9 100644 --- a/Documentation/devicetree/bindings/sound/qcom,sc7180.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,sc7180.yaml @@ -15,7 +15,9 @@ description: properties: compatible: - const: qcom,sc7180-sndcard-rt5682-m98357-1mic + enum: + - qcom,sc7180-sndcard-rt5682-m98357-1mic + - qcom,sc7180-sndcard-rt5682-m98357-2mic audio-routing: $ref: /schemas/types.yaml#/definitions/non-unique-string-array @@ -34,6 +36,11 @@ properties: "#size-cells": const: 0 + dmic-gpios: + description: + GPIO for switching between DMICs, it is required when + compatible is "qcom,sc7180-sndcard-rt5682-m98357-2mic". + patternProperties: "^dai-link(@[0-9])?$": description: @@ -81,6 +88,7 @@ additionalProperties: false examples: - | + //Example 1 sound { compatible = "qcom,sc7180-sndcard-rt5682-m98357-1mic"; model = "sc7180-snd-card"; @@ -128,3 +136,57 @@ examples: }; }; }; + + - | + //Example 2 (2mic case) + sound { + compatible = "qcom,sc7180-sndcard-rt5682-m98357-2mic"; + model = "sc7180-snd-card"; + + audio-routing = + "Headphone Jack", "HPOL", + "Headphone Jack", "HPOR"; + + #address-cells = <1>; + #size-cells = <0>; + + dmic-gpios = <&tlmm 86 0>; + + dai-link@0 { + link-name = "MultiMedia0"; + reg = <0>; + cpu { + sound-dai = <&lpass_cpu 0>; + }; + + codec { + sound-dai = <&alc5682 0>; + }; + }; + + dai-link@1 { + link-name = "MultiMedia1"; + reg = <1>; + cpu { + sound-dai = <&lpass_cpu 1>; + }; + + codec { + sound-dai = <&max98357a>; + }; + }; + + dai-link@2 { + link-name = "MultiMedia2"; + reg = <2>; + cpu { + sound-dai = <&lpass_hdmi 0>; + }; + + codec { + sound-dai = <&msm_dp>; + }; + }; + }; + +... From patchwork Mon Sep 28 06:37:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ajye huang X-Patchwork-Id: 11802969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F76D6CA for ; Mon, 28 Sep 2020 06:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0B9123444 for ; Mon, 28 Sep 2020 06:38:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G3rybhcS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbgI1GiV (ORCPT ); Mon, 28 Sep 2020 02:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgI1GiV (ORCPT ); Mon, 28 Sep 2020 02:38:21 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 140C1C0613CE; Sun, 27 Sep 2020 23:38:21 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id o20so5933pfp.11; Sun, 27 Sep 2020 23:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4BsT30it0uqVB1WMYTnRzRInhOP9DiMllB30Hf1GBMc=; b=G3rybhcS1SH9bwJ4tVWLrGwn2MQphTWU1S5C/QyTbUk+mAEcCpKN8EbP7LQZ9Rp8No s5G54j/6KtPNuy8C/Ex3NwfyiJr1A+nbBepFRf++TNBBeD9PXEoM6UGz9R7H5VvR4xY1 t5irZFrjhe5NYkswtb+p/hg77pWYfgwBvs5noUNtw2AW0ac3G0x9NokpNaXFVm5CDMi5 4mH7yzJZvV+lsYdE7ucVBCTkVlFIt8tsvp9oKtbGxN6frqqBRLrAEez88EBC2BahjInf l83hpmKJhAd0zQJ4Sx8q9aSYVcpNkpyDzYcCYsyP0/xOdnPN9Zle/RdqxZoDTFZsMatf GalQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4BsT30it0uqVB1WMYTnRzRInhOP9DiMllB30Hf1GBMc=; b=YGkU8OjgKwDJtB/Se466GCdPHEDquvtBh2kumEyixVNj0Jd+w5biKMm35gCaBXwFn5 mckmXzAukINi3I2Vf7kNga3srOoPRaXCy5b1OxD2iPPFKMKYZ9VMrmeFRg7XcXOXs7KT Qa6ctO5Ogs6yo09J5N3f9RYa9puIxTqxx+kI831qbLfGdeWawRYJBWYvvE7alWTYI68W rYvehclPV1tqXFOE9YDXSa+5I2NQHUKT5ZWPM9xml6QyI3q/XCrCXOBqjy29+5rE8j9r pOtKxCjfDXVq53zJZV/RiwJ81dR7Wh25jo5NLAIJRN+sdd+TB1MrKTS6PcyRl7bJfqtX uOmg== X-Gm-Message-State: AOAM5335JqZ7hN9y3zAadaywVWWC2+QtxlzdVN2/zoTdcaKDQ2pH2Xy5 59rkTq41dO4BQX1jGcOzmQOYgk0qY+VG3543 X-Google-Smtp-Source: ABdhPJyxgmFyFSLKz/iCCPDLGbVs1DgwaczFEGBnOyQJvl6b2b0LZG0bNsqw01cruin/PlcQ+T2gBw== X-Received: by 2002:a62:dd01:0:b029:13c:f607:5fff with SMTP id w1-20020a62dd010000b029013cf6075fffmr203229pff.3.1601275100351; Sun, 27 Sep 2020 23:38:20 -0700 (PDT) Received: from localhost (114-34-18-97.HINET-IP.hinet.net. [114.34.18.97]) by smtp.gmail.com with ESMTPSA id x3sm67652pgg.54.2020.09.27.23.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Sep 2020 23:38:19 -0700 (PDT) From: Ajye Huang X-Google-Original-From: Ajye Huang To: linux-kernel@vger.kernel.org Cc: Mark Brown , Rohit kumar , Banajit Goswami , Patrick Lai , Srinivasa Rao Mandadapu , Andy Gross , Bjorn Andersson , Liam Girdwood , Rob Herring , Jaroslav Kysela , cychiang@chromium.org, tzungbi@chromium.org, dianders@chromium.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Ajye Huang Subject: [PATCH v1 2/2] ASoC: qcom: sc7180: Modify machine driver for 2mic Date: Mon, 28 Sep 2020 14:37:44 +0800 Message-Id: <20200928063744.525700-3-ajye_huang@compal.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928063744.525700-1-ajye_huang@compal.corp-partner.google.com> References: <20200928063744.525700-1-ajye_huang@compal.corp-partner.google.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In addition, having mixer control to switch between DMICs for "qcom,sc7180-sndcard-rt5682-m98357-2mic" 2mic case. Refer to this one as an example, commit b7a742cff3f6 ("ASoC: AMD: Use mixer control to switch between DMICs") Signed-off-by: Ajye Huang --- This patch depends on this patch series https://patchwork.kernel.org/patch/11773223/ . sound/soc/qcom/sc7180.c | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sound/soc/qcom/sc7180.c b/sound/soc/qcom/sc7180.c index 0e90448523b0..c8751fb9f9bf 100644 --- a/sound/soc/qcom/sc7180.c +++ b/sound/soc/qcom/sc7180.c @@ -5,6 +5,8 @@ // sc7180.c -- ALSA SoC Machine driver for SC7180 #include +#include +#include #include #include #include @@ -24,6 +26,9 @@ // This will be defined in include/dt-bindings/sound/sc7180-lpass.h #define LPASS_DP_RX 2 +static struct gpio_desc *dmic_sel; +static int dmic_switch; + struct sc7180_snd_data { struct snd_soc_card card; u32 pri_mi2s_clk_count; @@ -170,6 +175,23 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) return 0; } +static int dmic_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = dmic_switch; + return 0; +} + +static int dmic_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + if (dmic_sel) { + dmic_switch = ucontrol->value.integer.value[0]; + gpiod_set_value(dmic_sel, dmic_switch); + } + return 0; +} + static void sc7180_snd_shutdown(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; @@ -207,6 +229,30 @@ static const struct snd_soc_dapm_widget sc7180_snd_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), }; +static const char * const dmic_mux_text[] = { + "Front Mic", + "Rear Mic", +}; + +static SOC_ENUM_SINGLE_DECL(sc7180_dmic_enum, + SND_SOC_NOPM, 0, dmic_mux_text); + +static const struct snd_kcontrol_new sc7180_dmic_mux_control = + SOC_DAPM_ENUM_EXT("DMIC Select Mux", sc7180_dmic_enum, + dmic_get, dmic_set); + +static const struct snd_soc_dapm_widget sc7180_snd_dual_mic_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("DMIC", NULL), + SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &sc7180_dmic_mux_control), +}; + +static const struct snd_soc_dapm_route sc7180_snd_dual_mic_audio_route[] = { + {"Dmic Mux", "Front Mic", "DMIC"}, + {"Dmic Mux", "Rear Mic", "DMIC"}, +}; + static void sc7180_add_ops(struct snd_soc_card *card) { struct snd_soc_dai_link *link; @@ -238,6 +284,19 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) card->dapm_widgets = sc7180_snd_widgets; card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_widgets); + if (of_device_is_compatible(dev->of_node, "qcom,sc7180-sndcard-rt5682-m98357-2mic")) { + card->dapm_widgets = sc7180_snd_dual_mic_widgets, + card->num_dapm_widgets = ARRAY_SIZE(sc7180_snd_dual_mic_widgets), + card->dapm_routes = sc7180_snd_dual_mic_audio_route, + card->num_dapm_routes = ARRAY_SIZE(sc7180_snd_dual_mic_audio_route), + dmic_sel = devm_gpiod_get(&pdev->dev, "dmic", GPIOD_OUT_LOW); + if (IS_ERR(dmic_sel)) { + dev_err(&pdev->dev, "DMIC gpio failed err=%d\n", + PTR_ERR(dmic_sel)); + return PTR_ERR(dmic_sel); + } + } + ret = qcom_snd_parse_of(card); if (ret) return ret; @@ -249,6 +308,7 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) static const struct of_device_id sc7180_snd_device_id[] = { { .compatible = "qcom,sc7180-sndcard-rt5682-m98357-1mic" }, + { .compatible = "qcom,sc7180-sndcard-rt5682-m98357-2mic" }, {}, }; MODULE_DEVICE_TABLE(of, sc7180_snd_device_id);