From patchwork Thu Feb 22 18:18:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 204999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp141393dyb; Thu, 22 Feb 2024 10:51:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXksVUjiaEYFyAnXRpdl4MygvK68N5GJuvPBvF+czChl++DQDg0cGHjkuEVqHAX7qo5wAy2D0AnMqcXVqOZC753fmFqeg== X-Google-Smtp-Source: AGHT+IET2G9RJEvUjNvBDfGlvV+Q+3OsiTu67djYwyDXP9NGSa6hfgC3PcLekPksgdKlqpWmoKlE X-Received: by 2002:a05:6a21:3489:b0:1a0:d8be:55d3 with SMTP id yo9-20020a056a21348900b001a0d8be55d3mr1961913pzb.16.1708627874433; Thu, 22 Feb 2024 10:51:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708627874; cv=pass; d=google.com; s=arc-20160816; b=K7jvmqKeo787GYcAZQLuZmO7tC5PFFyFGZ1TQpyp17np8PvUSUUIehTkhQ+eo8Q/iT fh2E6HVRjhqYwW+EdLPmNeB1Ewxykk1LqxfOjfbrQ1uDlOYXazhkpzRUSjB16EX6HVv8 2tzFo/a6jE3ozIk8XWfFnnwnSGFBvwQnAXgeP92oJnqz3wrrgUcqstw4LWmlvEaY7zh/ FgFGknymVfRJPvM521fqIyIjxssYSW25jQpGQc4FwvLk27TQYOr1ebMJjInMWOTpaOv+ J8Ryg7hIwbPlk1+LC95uJ1d4eUR7zbvnekAP7uHJnA3YVxX6RIkyF81YOML91bkALiDe 5LSQ== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77122-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b8-20020a056a000cc800b006e4c0eb955bsi2848344pfv.168.2024.02.22.10.51.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77122-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 32C62B261DD for ; Thu, 22 Feb 2024 18:34:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99D4A15DBA9; Thu, 22 Feb 2024 18:19:02 +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_Jirman?= 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791626182023414366 X-GMAIL-MSGID: 1791626182023414366 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[] = {