From patchwork Fri Oct 28 10:24:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajye Huang X-Patchwork-Id: 13023371 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4510ECAAA1 for ; Fri, 28 Oct 2022 10:26:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EC5A72252; Fri, 28 Oct 2022 12:26:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EC5A72252 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666952814; bh=OeWPc7oWMGPiGIdKZqwxDwL7JCnzTIddLOwR0TQE0VQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vBWXqTg0NSoK+NFZjyQd5FhKlsMbZ986InoyBGTkw+g5dZOUk2JNRONslf5+M9IGd lmVlAYNstUehWDRAJAKwO0zyDtnQxp8+LAYT/48aJhBEyazEucD7grZAW76oVSYtLA 2kDSqztEYo13Gr/Y2D7L/UQAwD0VJnyyQNr+Fjqk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4C4C7F8054A; Fri, 28 Oct 2022 12:25:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6730AF80557; Fri, 28 Oct 2022 12:25:35 +0200 (CEST) Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3E116F80558 for ; Fri, 28 Oct 2022 12:25:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3E116F80558 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=compal-corp-partner-google-com.20210112.gappssmtp.com header.i=@compal-corp-partner-google-com.20210112.gappssmtp.com header.b="vOC/xKdM" Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-13b103a3e5dso5804270fac.2 for ; Fri, 28 Oct 2022 03:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compal-corp-partner-google-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4ci1NI4rEDngdiIs8klmEEe/VgSVPTbSHjvB1KeT7kI=; b=vOC/xKdMUo642qaKQH78hZIqPpTZUPYnjK3EGVr+0Op2zSKxXyp6TtAf2S3VcbZrba tINVIqD6zWtjOgefgvzhYrG+wmguFT/XM1Tu91Ra4H+kCzYaSWaZWNMHYXXwSxm5AmoJ 4S3b4Q2XUvNUxmtYEmDYVEJ1FmFRAfbPPrD7hfslyblh+6CAgZ5/alZ2pTuRmnfNNg7y xYRShGLqziBYo4JFrwSaF+luHyYRtif7mzPZPc1S5QZ4Yt32W8i1mFzm22+thOC9xI5/ Rk4ZII8CiN5me5xRrH+OoKtbqMnfO5+XayqbfeXAZYRiAoPq2/bT/zECUOzsYNblxX4y 2P7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ci1NI4rEDngdiIs8klmEEe/VgSVPTbSHjvB1KeT7kI=; b=w4dFr06sPVNV1fMEUN5sHg9Bky6vVNsYt+RZWzXK75n+0dGIt2mWSdYImQ4OHd/FRp yx3MQ5/lGGf4ZLWaBD8vuUbaRU9oiV7LShiwtI+j8eGSn8dPG3TyuqYf6IcANxeVeGl/ fFhrvcXtg7f+ES811DhuaKTDvgurMPGzBgS3ZOLnM1tqoAiUlmMvkEGBf6+oECBTItvL 97COhBksEZTBM+VZ52pIZLUpXcHpgubMXf3LbFv2rX0vmXUKqN+EdA8GMsL6v9M/2VIX lDC7FnjBmkL9hsd5rCtTNR7vdcfGdBCwau1gVmx9oPuTvcrlf9QImC2ZZ12S1/QE1Sh4 6DWg== X-Gm-Message-State: ACrzQf0ffZWYX+0qazCnnlOfwWy8ub74enlNSEFL598YaY6Epdl7rqW4 touDkkKxT8qTeqZx6OV/EE2Jd89DCDVtgA== X-Google-Smtp-Source: AMsMyM5p59DDqaMCPQtyBwckPVjxO8rqbMGhs0bxJed+3GQ/ycCvWR71cW2eMf0VHFL+RSgqFw2M1Q== X-Received: by 2002:a17:90b:254c:b0:20a:8a92:ea5b with SMTP id nw12-20020a17090b254c00b0020a8a92ea5bmr15151822pjb.81.1666952710834; Fri, 28 Oct 2022 03:25:10 -0700 (PDT) Received: from localhost.localdomain (118-167-210-30.dynamic-ip.hinet.net. [118.167.210.30]) by smtp.gmail.com with ESMTPSA id o1-20020aa79781000000b0056b6a22d6c9sm2565236pfp.212.2022.10.28.03.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 03:25:10 -0700 (PDT) From: Ajye Huang To: linux-kernel@vger.kernel.org Subject: [PATCH v1 1/2] ASoC: dt-bindings: Document dmic_sel-gpios optional prop for two DMICs case Date: Fri, 28 Oct 2022 18:24:49 +0800 Message-Id: <20221028102450.1161382-2-ajye_huang@compal.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221028102450.1161382-1-ajye_huang@compal.corp-partner.google.com> References: <20221028102450.1161382-1-ajye_huang@compal.corp-partner.google.com> MIME-Version: 1.0 Cc: robh@kernel.org, alsa-devel@alsa-project.org, Ajye Huang , Charles Keepax , devicetree@vger.kernel.org, angelogioacchino.delregno@collabora.corp-partner.google.com, Shengjiu Wang , Liam Girdwood , Takashi Iwai , Rob Herring , Mark Brown , Krzysztof Kozlowski , Arnaud Pouliquen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Document dmic_sel-gpios optional prop for switching between two DMICs. Ex, the GPIO can control a MUX to select Front or Rear dmic. Signed-off-by: Ajye Huang --- Documentation/devicetree/bindings/sound/dmic-codec.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/dmic-codec.yaml b/Documentation/devicetree/bindings/sound/dmic-codec.yaml index bba27c985996..4013af65f3e7 100644 --- a/Documentation/devicetree/bindings/sound/dmic-codec.yaml +++ b/Documentation/devicetree/bindings/sound/dmic-codec.yaml @@ -36,6 +36,10 @@ properties: wakeup-delay-ms: description: Delay (in ms) after enabling the DMIC + dmic_sel-gpios: + maxItems: 1 + description: GPIO for switching between DMICs, ex Front/Rear dmic + required: - compatible @@ -48,6 +52,7 @@ examples: dmic { compatible = "dmic-codec"; dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>; + dmic_sel-gpios = <&pio 23 GPIO_ACTIVE_HIGH>; num-channels = <1>; wakeup-delay-ms = <50>; modeswitch-delay-ms = <35>; From patchwork Fri Oct 28 10:24:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajye Huang X-Patchwork-Id: 13023370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65D3AECAAA1 for ; Fri, 28 Oct 2022 10:26:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4475B2253; Fri, 28 Oct 2022 12:25:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4475B2253 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1666952786; bh=ZKc8ylDd3p8WZSF4jRHV2mMBbH7shNx0jCao1ROSkgk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sRzmv4Ufpbe1Dcb2N3aQUc9KhYW1vU+O5QLJzHHjV1XjFa2UGJBeEmie6xryGAIK/ 278oMsK55/8Zkb7sgK7O+ScwvPpUDNHG3OZRZESrwI2vnWyo5XS3VGe6ac5arEtdav CMwS/nFh5qr3LO1DvIDWKlVzkI1ndEylE/iWA/GA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 81111F804C1; Fri, 28 Oct 2022 12:25:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2FBBDF804D0; Fri, 28 Oct 2022 12:25:20 +0200 (CEST) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 792CDF80095 for ; Fri, 28 Oct 2022 12:25:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 792CDF80095 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=compal-corp-partner-google-com.20210112.gappssmtp.com header.i=@compal-corp-partner-google-com.20210112.gappssmtp.com header.b="m/UP4fu4" Received: by mail-pl1-x62d.google.com with SMTP id f23so4481135plr.6 for ; Fri, 28 Oct 2022 03:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compal-corp-partner-google-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mUsj9+u75ZiURBRDbzjBcZDwYbW7xC+xuux1Bvrvp1o=; b=m/UP4fu4PKx43aYhlz2Rp68oxaguB66SWgjhBVhkhTHKdqmEwNzyWVWP/JjKj9e9MR Y9NbqLdrh6vosMJkx4/BbPjlDdoTGOSbLf9YlskUdi2tRYgX1g1CvzAuVyoCi0VkzXRC YiJikNgpdC5EnHKpbrhHNkk119Nj3DFsGsE6w+TjxTdDz+6HVs67iFL9qP8jyjb/AORE f3P+EGHaIc/diGpmmYEz4CycVYZSvEao+8SdiHCuSm9vC6VKyCeNUY/bjUA93jagvckf 3An73/Dpsb6QM8WHQVPgptVGjG3555ilgw6nCH2As9aTzF5lO+bKWqXlNOhd+iiecq/a GB6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mUsj9+u75ZiURBRDbzjBcZDwYbW7xC+xuux1Bvrvp1o=; b=auatM9MGwR+f08vMEt78V9agU676OQYOi+1ycbMii6wJ56ht3blTduxuYjKNXlhXki 3zrnINxg/S/WmYeWs3kFKq4jnyltUo6kYQsDPP3rfPUeW6HKU8ZR34b0bJqlbMfb9kyV tRV/IvaKaY5WqAUeZu3XsD/rjEpAmRqcyc6pzmaJv/Jz8ijzpKc1yMHImvklRifVL877 ngftS5BC3HQkgZWpwWeIyUmMd+EiMFdx5Rm2XyinZhUW6AQsNL52ZV9sdpNwAXeob73P eQAtjq+eO43xmXl8hNUvfHKgYISlqETIfhpTzHz3ACl50CskqXa7AATXqafDKX7pg39+ JcAg== X-Gm-Message-State: ACrzQf3TJt+dTMb6s0Q3GQQEcVz89aBrRGctuheWzVk7BmcHyVAydgNo dwR7lF5jBwq4TGDo8/Vvd5z3MA== X-Google-Smtp-Source: AMsMyM5PF+mfGpOT7qE4MUpscnGJjWoxwCDcOj+0J2CfXJVc05btTeWq4lG3ZKUCtFYAksnUSFF5Nw== X-Received: by 2002:a17:902:bd8e:b0:178:25ab:56cc with SMTP id q14-20020a170902bd8e00b0017825ab56ccmr53514796pls.86.1666952715118; Fri, 28 Oct 2022 03:25:15 -0700 (PDT) Received: from localhost.localdomain (118-167-210-30.dynamic-ip.hinet.net. [118.167.210.30]) by smtp.gmail.com with ESMTPSA id o1-20020aa79781000000b0056b6a22d6c9sm2565236pfp.212.2022.10.28.03.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 03:25:14 -0700 (PDT) From: Ajye Huang To: linux-kernel@vger.kernel.org Subject: [PATCH v1 2/2] ASoC: dmic: Add optional dmic selection Date: Fri, 28 Oct 2022 18:24:50 +0800 Message-Id: <20221028102450.1161382-3-ajye_huang@compal.corp-partner.google.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221028102450.1161382-1-ajye_huang@compal.corp-partner.google.com> References: <20221028102450.1161382-1-ajye_huang@compal.corp-partner.google.com> MIME-Version: 1.0 Cc: robh@kernel.org, alsa-devel@alsa-project.org, Ajye Huang , Charles Keepax , devicetree@vger.kernel.org, angelogioacchino.delregno@collabora.corp-partner.google.com, Shengjiu Wang , Liam Girdwood , Takashi Iwai , Rob Herring , Mark Brown , Krzysztof Kozlowski , Arnaud Pouliquen X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Having two DMICs, a front DMIC and a rear DMIC, but only host audio input AUX port0 is used for these two Dmics. A "dmic_sel-gpios" property is used for a mixer control to switch the dmic signal source between the Front and Rear Dmic. usage: amixer -c0 cset name='Dmic Mux' 'FrontMic' usage: amixer -c0 cset name='Dmic Mux' 'RearMic' Refer to this one as an example, commit 3cfbf07c6d27 ("ASoC: qcom: sc7180: Modify machine driver for 2mic") Signed-off-by: Ajye Huang --- sound/soc/codecs/dmic.c | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index 4fd6f97e5a49..5c56fbcdb3e6 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -28,8 +28,50 @@ struct dmic { int wakeup_delay; /* Delay after DMIC mode switch */ int modeswitch_delay; + struct gpio_desc *dmic_sel; + int dmic_switch; }; +static int dmic_sel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct dmic *dmic = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = dmic->dmic_switch; + return 0; +} + +static int dmic_sel_set(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct dmic *dmic = snd_soc_component_get_drvdata(component); + + dmic->dmic_switch = ucontrol->value.integer.value[0]; + if (dmic->dmic_sel) { + gpiod_set_value(dmic->dmic_sel, dmic->dmic_switch); + dev_info(dapm->dev, "%s value %d\n", __func__, dmic->dmic_switch); + } else + dev_info(dapm->dev, "%s without dmic_sel-gpios\n", __func__); + + return 0; +} + +static const char * const dmic_mux_text[] = { + "FrontMic", + "RearMic", +}; + +static SOC_ENUM_SINGLE_DECL(dmic_enum, + SND_SOC_NOPM, 0, dmic_mux_text); + +static const struct snd_kcontrol_new dmic_mux_control = + SOC_DAPM_ENUM_EXT("DMIC Select Mux", dmic_enum, + dmic_sel_get, dmic_sel_set); + static int dmic_daiops_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { @@ -115,6 +157,11 @@ static int dmic_component_probe(struct snd_soc_component *component) if (dmic->modeswitch_delay > MAX_MODESWITCH_DELAY) dmic->modeswitch_delay = MAX_MODESWITCH_DELAY; + dmic->dmic_sel = devm_gpiod_get_optional(component->dev, + "dmic_sel", GPIOD_OUT_LOW); + if (IS_ERR(dmic->dmic_sel)) + return PTR_ERR(dmic->dmic_sel); + snd_soc_component_set_drvdata(component, dmic); return 0; @@ -125,10 +172,15 @@ static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { SND_SOC_NOPM, 0, 0, dmic_aif_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_INPUT("DMic"), + SND_SOC_DAPM_MIC("DMIC", NULL), + SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &dmic_mux_control), }; static const struct snd_soc_dapm_route intercon[] = { {"DMIC AIF", NULL, "DMic"}, + /* digital mics */ + {"Dmic Mux", "FrontMic", "DMIC"}, + {"Dmic Mux", "RearMic", "DMIC"}, }; static const struct snd_soc_component_driver soc_dmic = {