Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp888022lqg; Sat, 2 Mar 2024 06:03:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+VNizYbXnXOO9M8T179YKHwdMV32G/Q4nrk3PwGMHwHAf6tinDOdOFOe5EURdA2FWzPAMSr5J/AYa6do/rnz9kOyA0V/K8IkYyYedTA== X-Google-Smtp-Source: AGHT+IHB5WiSHNz4IqeMfpzoBH+ct7/5weuB+R7pn9OPDHy9zVpmX46b0ebpaSzIWQBKN6ghFLQy X-Received: by 2002:a05:6a20:9f48:b0:1a0:e89c:38e4 with SMTP id ml8-20020a056a209f4800b001a0e89c38e4mr4336290pzb.48.1709388181012; Sat, 02 Mar 2024 06:03:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709388180; cv=pass; d=google.com; s=arc-20160816; b=vf30Hlrm6aXqi+hZAOx50eP276Y+bL/N0Pk31zWemW/45pz6FnuWX+VFTkDuS32iRv TiKm6RsTT2oeOyWJs2Ih57C+5mTPiSB3YCJc9BuK+wbuf5xAJCTM+q7FApXuqjCYNupO NQZp4AvYB/9NQAPbbCecPzhxS6c5csBSwBboW/WD0HpJByt0b9mZXuOiiJmMqO7YoPBj 6/3aZ4PEUG2zPWxgbPt1u/u7G76nK6YlMkWDKgSF+lxOBy5O236sQeTIbHxSdty8b5PK gWtDBtHuVFDiBeijMBegAeiSiDv6iahvZNhUnl9MlLUaYAJuzsZeOCouB0lFstT9atK1 mftg== 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=1Gcj0qc1u3aUgszUbSu9OoYzvYzXGNKWtNTNN4a6Xt8=; fh=QGdVBqYg4q7jIiN9KcNXeuSkybNfaLt8K5LfUlN67/I=; b=PJzlsx5MpfWgzyb3FKEbHafxTnKgjFdYcjqOC/zOxGxBe2I86NdDOk+P3UJOvO6ArW 3cnmWVPe+OIfO/BW2hWF7ucN2vbkF8870/eQ6VHgL48PSJ/rO//x9V6WbVfxgAJ9pIlO 9xuJs3aqayq4TWkJvLZqYugGUp6sRbuRufeadhpn8Xo7R4x+gJDHMd3Bdk/ZgOI3JNkv Eqe99WWffy1I1V0db+mPLychc7D/yUqBMG2Efc/uBWnRojPtD8Of3Jmh6IvZSPZp56Dn 0Fk5MJMkV3VwwamZ0zda+6ySynLq2P/P5pv3mfh+YGgbKqN47ySq2ZpslNUB3urOTp5h FP9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=wKYf2ij8; 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-89459-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s132-20020a632c8a000000b005dc3d92a492si5233739pgs.39.2024.03.02.06.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 06:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89459-linux.lists.archive=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=wKYf2ij8; 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-89459-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89459-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8CE4FB247A0 for ; Sat, 2 Mar 2024 14:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66A6F1C6AD; Sat, 2 Mar 2024 14:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="wKYf2ij8" 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 7C34417BAB; Sat, 2 Mar 2024 14:00:48 +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=1709388053; cv=none; b=f2NY0Qi3CTBvbJKd8/FM8KZofo9kbuqU+JNJgrKlRZvM+UF3OcnKWc6lnk7PO9yHojaSxSJOgZHyelrb1xPbhqyuEgEZkA210xnJ7r5A5XdoXpTPm27wDD3T5gkakw7LmNmKeLHWPR/A1DrXjExpbR7fqBvYePb4CBZajCSuhCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709388053; c=relaxed/simple; bh=Z28QC5gcB/zs8Hn8IrbI18nN31MND5p/CuLpPPG6++U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RzppvI+sEgZbMV686MDpbeG+4hQlGweYRDN2fO+weZBSOl2MVRByv+5thH+cIZ4Az+k4u/x4Siet/QY8jVqNX0RgEvYw/fRpPJ7G/cRq/qezXDlZHUvijPpGYWnW1dLayKytHyC7SwIUzBEL2pyoKIrqPfo6/9EyB+mKH1f2/e0= 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=wKYf2ij8; 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=1709388045; bh=Z28QC5gcB/zs8Hn8IrbI18nN31MND5p/CuLpPPG6++U=; h=From:To:Cc:Subject:Date:References:From; b=wKYf2ij8vG7DwafJasLhwAaCtBDnoIscdrv85dfXjKfXM+C95rP8MM901ftzykFDb Zx5//2lV7HVji/zlfazVO1zhkhPf6/vN42HqVwuOcmSRZOr+ucGV6UJEzpNsRWDn81 TByo+g2iIcJY4VNimrmv9KdTuJaxorjEvN78NMNw= 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 v3 1/4] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level Date: Sat, 2 Mar 2024 15:00:35 +0100 Message-ID: <20240302140042.1990256-2-megi@xff.cz> In-Reply-To: <20240302140042.1990256-1-megi@xff.cz> References: <20240302140042.1990256-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.44.0