Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp519230rdb; Thu, 22 Feb 2024 10:33:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX00fs+s0+QHPqlF3qdU7yLLxin3ATVLKfZ7ZS1UAR86pOgbmpR6Py+6ONKOxbHHjQpLCB1NcBXx+XSdEsQx0GyDw4MeFdS4LI/56JN1Q== X-Google-Smtp-Source: AGHT+IFHg+MSxT+S5d9mL3+zKan832DOLWDK76qv9TX8JusNmYEfkEGThrfJRhPrdNEIfU/afkvX X-Received: by 2002:a05:6102:6c6:b0:471:5dc1:66a2 with SMTP id m6-20020a05610206c600b004715dc166a2mr6270594vsg.13.1708626817303; Thu, 22 Feb 2024 10:33:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708626817; cv=pass; d=google.com; s=arc-20160816; b=JSngFjCYkSnnmDVnsv/cwPTxv9q+7TTxPpwdV7dMOso3eBqjlPiyoYH9sO37WgeUyw jPX9EmgzzRFvOgP1241wbMxOifVmbWVWW37NfvwGoiM8n2ZXC1ROHRcaov4by9tb2feW X3/1S5gVHdo7MNgV0smfA6R8kdQe4u9E/mXNN2jUsv1UAmr/RFhR+gUEAeZFbp7DcsVH 43xswk70Cn7W74z4OsfIWZ9/5i1ye2KgtucYywxULpvODBI/nZXB8NtGGOVSZQPFC0eQ I5EJGiwMbclnR8PrmQ2GmhtMSirwWsqWUNIH+ax+L6ul9LkipBbCYTL05+MfSISbzKJq /WVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JGVtLGJoNrifEQCr1YZ3zkxMW3g5EFoYp9uHA+YPkVo=; fh=QGdVBqYg4q7jIiN9KcNXeuSkybNfaLt8K5LfUlN67/I=; b=l+XeD7TGKIsOkI6pO9Dl4CGDm+Nh1Gi2l4xC8swlCUVYEfHNXEW6b1GoLJG2wW1MoW Y6sGk4txqRQaC4vnG1i6h748HVKfDhngm//Jfm2q9gGuv4BaqKSUJWAUfRv9jSvz0nrR ZQ95eXXoONg2KBqYPGKyl3qX0M2dPo9SLA+3uBjxHsjkV285qf8utTAhLA4nuYeOmEwk g3Yqe5uUgMXTQarJNw4Q+a67Ar8+kxPUMYyWtb6Qxjpgu+jyu6RBSKHlZYmUk4nMakw1 vTvlKgmLsWBkfa2ALIbpbokrdhdzfutr/qChip23SEJuXTpCI8BBhFRsGFYuuw07rAMD YC6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="psPTDIu/"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-77122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77122-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dh6-20020a056102578600b0046d191258e1si2332744vsb.365.2024.02.22.10.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:33:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b="psPTDIu/"; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-77122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77122-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E6BE1C242E7 for ; Thu, 22 Feb 2024 18:33:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A41AD15CD7E; Thu, 22 Feb 2024 18:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="psPTDIu/" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8507F15CD4C; Thu, 22 Feb 2024 18:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708625939; cv=none; b=qhC02mKSCsbB7ZKpXDxBCWpBZhBYUK7iryLfjwtGoIbOdZBNcsI3kPgsiw4JTsHyAcpyEbsT+k0L5953zV0TPk9pIy0xPW+u8/+8QGt/AEhHiRGxOb8imWcAhkXtiWdqYBxxi2+98lqLWRt8Mm5ldrnvqs0l/ipULI5O/SgTd7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708625939; c=relaxed/simple; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jYn44iveC69v6U0n5s4srt1dNcwxFmlSZOP1tOqcWIqAf9CMrcfYeeyVLi682Dyd5KwFQbe61h7DG+CNdiHDfPbSrlsSCeLE5TMuzh/kYaI+gDdGTW6cnxt7kneqVJBPDeTe9pMdR9mst6XTBU2UVf3BSl7uhYvX7KjGH0IqLSY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=psPTDIu/; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1708625934; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:References:From; b=psPTDIu/ElVGuGT/SH5gHUemooCcfaafxJ5DKSHWm5j36mhLy6PGAgnbTW9LbJsmJ 7P7SnwrFWG6Xu6m0uq0vqFGUu/kqndVN9HVGlDpp0omgKN1avsYvoNVGQhxKn2xo4T nnCeBqBiGQLcF+7OZdJ/PobIc1RkmZpFHSaF7SMQ= From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= To: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Samuel Holland , Chen-Yu Tsai , Jernej Skrabec , Ondrej Jirman , Arnaud Ferraris , linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 1/4] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level Date: Thu, 22 Feb 2024 19:18:44 +0100 Message-ID: <20240222181851.3398254-2-megi@xff.cz> In-Reply-To: <20240222181851.3398254-1-megi@xff.cz> References: <20240222181851.3398254-1-megi@xff.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Samuel Holland With idle_bias_on and suspend_bias_off, there are bias level transitions that match the suspend/resume callbacks. However, there are also transitions during probe (OFF => STANDBY) and removal (STANDBY => OFF). By using the set_bias_level hook, the driver can have one copy of code that would otherwise be duplicated between the probe/resume and suspend/remove hooks. Signed-off-by: Samuel Holland Signed-off-by: Ondřej Jirman --- sound/soc/sunxi/sun50i-codec-analog.c | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c index 8a32d05e23e1..cedd4de42d1a 100644 --- a/sound/soc/sunxi/sun50i-codec-analog.c +++ b/sound/soc/sunxi/sun50i-codec-analog.c @@ -471,17 +471,23 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = { { "EARPIECE", NULL, "Earpiece Amp" }, }; -static int sun50i_a64_codec_suspend(struct snd_soc_component *component) +static int sun50i_a64_codec_set_bias_level(struct snd_soc_component *component, + enum snd_soc_bias_level level) { - return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL, - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); -} + switch (level) { + case SND_SOC_BIAS_OFF: + regmap_set_bits(component->regmap, SUN50I_ADDA_HP_CTRL, + BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); + break; + case SND_SOC_BIAS_STANDBY: + regmap_clear_bits(component->regmap, SUN50I_ADDA_HP_CTRL, + BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); + break; + default: + break; + } -static int sun50i_a64_codec_resume(struct snd_soc_component *component) -{ - return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL, - BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), 0); + return 0; } static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { @@ -491,8 +497,9 @@ static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { .num_dapm_widgets = ARRAY_SIZE(sun50i_a64_codec_widgets), .dapm_routes = sun50i_a64_codec_routes, .num_dapm_routes = ARRAY_SIZE(sun50i_a64_codec_routes), - .suspend = sun50i_a64_codec_suspend, - .resume = sun50i_a64_codec_resume, + .set_bias_level = sun50i_a64_codec_set_bias_level, + .idle_bias_on = true, + .suspend_bias_off = true, }; static const struct of_device_id sun50i_codec_analog_of_match[] = { -- 2.43.0