From patchwork Sat May 25 13:28:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13674019 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 DFA9AC25B78 for ; Sat, 25 May 2024 13:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yh/Tr+OnOylBfVsMUqOI7jclNK+eTA9GQZkutnfvsgk=; b=Sc20eVf95psrg1 UH7DiqVY+R+z2gRTahC9tm0NHP3CfXSSKyPA06QmFy2uF6cZiiuHb+V2j5OZZa77f3J0VmAU6jmyS opmqCq/qMfOicOoSFWRX7zvRY941tcYZIUqWTI+bi9iqa/xCx8YRIuk7Ih9hfykgAXdmqaL532xGt yitSTRP/9KYr9CIwkgDH/6RIzdNiphIK5UlwiWBbbH/JAHtGr/baxX1SMVgOTcv9djNv0R6o8pcPU U7EmiGFKolwUODrmFa7JndI2OQelMUWMJ98hgkzdDw4rBq4mLVrN4dA6JuSXhNYdrpy2VPPcf13/Z d/49tyAeEIwfSRqEfXmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sArRi-0000000B4Bn-1K7d; Sat, 25 May 2024 13:28:26 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sArRU-0000000B46H-3GDn for linux-arm-kernel@lists.infradead.org; Sat, 25 May 2024 13:28:14 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a59a609dd3fso726166566b.0 for ; Sat, 25 May 2024 06:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716643691; x=1717248491; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cyhcJDHjI0opVSCgJiHt0Zs5JH59m1ORkw4OcBCxAuU=; b=ONYTh1mA+ilO1ZLnPorktUHq+/dAlKJO/2m1+2eO80RYYEVvys9MdQTQaPVU8bEnVa bx7Zp4RBZjiC2R0helhZRgmSBsLdU5qNpUJZPoJ9R4Yp3pcoDqpSa6ouIbD6/lh9wkth c8GvhbkeUFHvbjuIB/fPt3h6OHLlMuLWsBMuLkZmPsLdEBOiPyn8XQVQKmoMLnqfIlyO TWA/aEFm4Wj/irPEAnTLm5NBDCg0DpFgXiRr42YbAJIg7/I+Mqe13nvityJkIc4fjj+H QlmHUdOnZTg7OEz23j9s2DhgzOoMSRk/zSJhi0bEzWSrorX9tXoefw3ZL5c+hmr9VIy6 rvTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716643691; x=1717248491; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cyhcJDHjI0opVSCgJiHt0Zs5JH59m1ORkw4OcBCxAuU=; b=BMx7CVq9mIF67eKnq0UDkBsHVd5C94JsE6E/xfsJDLAZkATRs8HHs0vsYrRe5Bt5iH lNy5PnG5X7NsINnlAhDN0qJOcFr9ACLoSly9cX5XeAcZk/M4QvzjyWHy4QiclgaBm6Yv jBTbHvKnC/2sUbYKu83oOzi6eBnbthWpEjFE4j6JV+3R4Rnb0XRxUtu9JBI9vZM/zu2f w5xY3HgKM6BGX8LbCSa4MQ09kVh/UJ9bGWmAZJttuwLlydqAukPnJAlR/LhTDzdvQoEn /Rq60bv8wA8BBYWb3a9qM/b8fn83uCU9Xv7WNV60dBbZDphZhabUg9VofrVL9GwiayJB Wisw== X-Forwarded-Encrypted: i=1; AJvYcCWs/tdCGOJ/9B9z4eKm0jHBFeV/ZOjwiSa0p2GqJsXT11w5flRRDVse726+IVWtz6NJ17flSNqUA5bKrfOnJARV66Yx8RK24QBM+A9tKj0RSWSKOVo= X-Gm-Message-State: AOJu0YyqZ9ZFFn1pXvdLdbu2Ux32XSUHeYcZ+2ZxcBgKC1h4L2P/bnbH tx685auROHnNAa2k9loMpFx+o+H+r29YxJ0qbnIC147sm32Tvvj5bU/AMw== X-Google-Smtp-Source: AGHT+IEPpi36yJB2n9ipEwdR4D1zjMs1IzS01+2Vzze66vzbl5+wC4+jiyDQmWyXGxZdTp2Ak5ZhWA== X-Received: by 2002:a17:906:8443:b0:a61:7f85:e31c with SMTP id a640c23a62f3a-a6261f91a42mr367814466b.12.1716643690633; Sat, 25 May 2024 06:28:10 -0700 (PDT) Received: from hex.my.domain (83.8.128.191.ipv4.supernova.orange.pl. [83.8.128.191]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626cda46e1sm251842566b.196.2024.05.25.06.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 06:28:10 -0700 (PDT) From: Artur Weber Date: Sat, 25 May 2024 15:28:07 +0200 Subject: [PATCH v4 3/9] ASoC: samsung: midas_wm1811: Use SND_SOC_DAPM_REGULATOR_SUPPLY for bias regulators MIME-Version: 1.0 Message-Id: <20240525-midas-wm1811-gpio-jack-v4-3-f488e03bd8c7@gmail.com> References: <20240525-midas-wm1811-gpio-jack-v4-0-f488e03bd8c7@gmail.com> In-Reply-To: <20240525-midas-wm1811-gpio-jack-v4-0-f488e03bd8c7@gmail.com> To: Sylwester Nawrocki , Krzysztof Kozlowski Cc: Liam Girdwood , Mark Brown , Rob Herring , Conor Dooley , Jaroslav Kysela , Takashi Iwai , Alim Akhtar , alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716643685; l=4146; i=aweber.kernel@gmail.com; s=20231030; h=from:subject:message-id; bh=2vAqa2DIEcQwtApC4VQYYpht9ERjbrcStYfppA44U0Y=; b=aPD49g9qEDnvFgYpa5MvgqUaV0Ias6Acg1pgU8JR9ggAbockzhyIz4uoEhAXWApuS8Qs+03bm 7D7hw3nfGozDATDmsFZ8F3NJgXmuf/Xt38YOWi7jNvh2bMfPkTYpKDb X-Developer-Key: i=aweber.kernel@gmail.com; a=ed25519; pk=RhDBfWbJEHqDibXbhNEBAnc9FMkyznGxX/hwfhL8bv8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240525_062812_853684_1D3A0D8C X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of using a custom function with the SND_SOC_DAPM_MIC widget, split out the main mic/sub mic bias regulators into a separate widget using SND_SOC_DAPM_REGULATOR_SUPPLY, and connect them via a routing. Signed-off-by: Artur Weber --- Changes in v4: - Added this commit --- sound/soc/samsung/midas_wm1811.c | 62 +++++++++------------------------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1811.c index f31244156ff6..20b274734487 100644 --- a/sound/soc/samsung/midas_wm1811.c +++ b/sound/soc/samsung/midas_wm1811.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -27,8 +26,6 @@ #define DEFAULT_FLL1_RATE 11289600U struct midas_priv { - struct regulator *reg_mic_bias; - struct regulator *reg_submic_bias; struct gpio_desc *gpio_fm_sel; struct gpio_desc *gpio_lineout_sel; unsigned int fll1_rate; @@ -169,38 +166,6 @@ static int midas_ext_spkmode(struct snd_soc_dapm_widget *w, return ret; } -static int midas_mic_bias(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_card *card = w->dapm->card; - struct midas_priv *priv = snd_soc_card_get_drvdata(card); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return regulator_enable(priv->reg_mic_bias); - case SND_SOC_DAPM_POST_PMD: - return regulator_disable(priv->reg_mic_bias); - } - - return 0; -} - -static int midas_submic_bias(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_card *card = w->dapm->card; - struct midas_priv *priv = snd_soc_card_get_drvdata(card); - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - return regulator_enable(priv->reg_submic_bias); - case SND_SOC_DAPM_POST_PMD: - return regulator_disable(priv->reg_submic_bias); - } - - return 0; -} - static int midas_fm_set(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -272,8 +237,17 @@ static const struct snd_soc_dapm_widget midas_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), - SND_SOC_DAPM_MIC("Main Mic", midas_mic_bias), - SND_SOC_DAPM_MIC("Sub Mic", midas_submic_bias), + SND_SOC_DAPM_MIC("Main Mic", NULL), + SND_SOC_DAPM_REGULATOR_SUPPLY("mic-bias", 0, 0), + SND_SOC_DAPM_MIC("Sub Mic", NULL), + SND_SOC_DAPM_REGULATOR_SUPPLY("submic-bias", 0, 0), +}; + +/* Default routing; supplemented by audio-routing DT property */ +static const struct snd_soc_dapm_route midas_dapm_routes[] = { + /* Bind microphones with their respective regulator supplies */ + {"Main Mic", NULL, "mic-bias"}, + {"Sub Mic", NULL, "submic-bias"}, }; static int midas_set_bias_level(struct snd_soc_card *card, @@ -421,6 +395,8 @@ static struct snd_soc_card midas_card = { .num_controls = ARRAY_SIZE(midas_controls), .dapm_widgets = midas_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(midas_dapm_widgets), + .dapm_routes = midas_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(midas_dapm_routes), .set_bias_level = midas_set_bias_level, .late_probe = midas_late_probe, @@ -443,18 +419,6 @@ static int midas_probe(struct platform_device *pdev) snd_soc_card_set_drvdata(card, priv); card->dev = dev; - priv->reg_mic_bias = devm_regulator_get(dev, "mic-bias"); - if (IS_ERR(priv->reg_mic_bias)) { - dev_err(dev, "Failed to get mic bias regulator\n"); - return PTR_ERR(priv->reg_mic_bias); - } - - priv->reg_submic_bias = devm_regulator_get(dev, "submic-bias"); - if (IS_ERR(priv->reg_submic_bias)) { - dev_err(dev, "Failed to get submic bias regulator\n"); - return PTR_ERR(priv->reg_submic_bias); - } - priv->gpio_fm_sel = devm_gpiod_get_optional(dev, "fm-sel", GPIOD_OUT_HIGH); if (IS_ERR(priv->gpio_fm_sel)) { dev_err(dev, "Failed to get FM selection GPIO\n");