From patchwork Sat Feb 24 13:54:55 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: 205890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1157194dyb; Sat, 24 Feb 2024 05:57:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWhH+ezQl4+17lgkAeZRLERKVo6qROwCvTH8MA0a/aKKPlrTi6KuxZ/n1IDW4/EmPwLbugu/4YqtnpNfujPUEmvc8jb+w== X-Google-Smtp-Source: AGHT+IEB3xzBp512blCmG3vgipGeQmYnF/pRmEIGDiOI34qJi2YpaOjlsDPNYPUrOiojdGojkZIQ X-Received: by 2002:a17:906:3397:b0:a3f:33b5:64dd with SMTP id v23-20020a170906339700b00a3f33b564ddmr1597909eja.49.1708783079195; Sat, 24 Feb 2024 05:57:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708783079; cv=pass; d=google.com; s=arc-20160816; b=nvkPwlqAC2XUSTD3kuJ9ljbk+vzaUxBv69pcDUgHbe+38nuqyQlF8drwY2WfpU4Hvr YoJNGCu7nM+3BMDE/Sl4yoNbSpt7mybCR6TkUcfuahb+5JleSXPhup4gxpM2GtMH0HXF bkKZfz6D5R56icObpssEnnvUIE+fPrybqUZ+YJrWFJo0L+XaVPO5AqxkrBJQjlrbIm4J qEqCTPE6vh/zhsk4Cq7x5bCS6qE8k6InUfytxaRX54+Ico4jswI58lvjfhb/3lvTE6gs /JxWU8fzM1axtAelB+h7QRW4VXlsFOMHgwIScfw4br0XRy1NcIGV2/ITLBP7QILBWFds jRwQ== 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=c0ByhCenn9n2/Gg3f79DXng527omIiP5Cr8W9F+Rrb8=; b=EdvJ4oarevPVQsS5TI1Tq9zoCIq5DQCo/EOj8j1ZdaPlIOI5+abBe3uxst8KoaJ3Wm niynMWOUcouLCmLTfbX0LSeM+in+DGGXG3/Pt+Q+AUOxLUzCJrkJotXfbvom44smePTG RCfJljpjbc7iu59B/fym0g1iQHmIylRVoZAdODGzeFF2cFZXV4V4jH2Rt9L/FqeyWnhJ 5nUClldtmuP88MqGacN7AoXnxzIvPcpha/ULHBh0TXrurRliY90jbVzfbRcTCaCZ1oHR cDAIUxAdF3Rqu9t9tTee1CO98QzdDa3ZmyOVj88Pp9MhyrBJqnpEsNpGsiUvcLS1pkQg d10Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=wd9DTMKD; 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-79694-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79694-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id o24-20020a1709064f9800b00a3e256e95d2si551605eju.205.2024.02.24.05.57.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 05:57:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79694-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=wd9DTMKD; 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-79694-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79694-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C34111F210DA for ; Sat, 24 Feb 2024 13:57:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 244704DA16; Sat, 24 Feb 2024 13:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="wd9DTMKD" 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 62012405F4; Sat, 24 Feb 2024 13:55:11 +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=1708782913; cv=none; b=N2hYg0hImVK2Dv3sXI+tY3nx7J9M4dBCRHj/7qMM34dMRbpwBqhUqHp5go1E/P8yY8zXQNZv0JqShnVwubNVsNUf0h7alZevmV2Hrap/cuIGC3buVwoMm+FglIhBM4oAMebOVQQRRvpMCaR0s2heTxbG7W3L/l7urq3uXYdjWfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708782913; c=relaxed/simple; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fw1JAOlwjd7mrE7A7g1j5KRrnybkSEIyPpEoZtU3eucTZLM33C+BmRYvt/dG0K5t/RpCN+iPh3M0CjepkpGF0bYnFCKO31pVWcwUdfX9LKPF95ycw8gfkeUczdiD52GLzDCs2TAs9j3jJOdXOmyMrBCtMY4H3fdTdWaCPTuETEU= 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=wd9DTMKD; 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=1708782909; bh=0xAlq3FKxyKOFVzLVHdJfOKR9ZGZX8El43JyE9dp5i8=; h=From:To:Cc:Subject:Date:References:From; b=wd9DTMKDUrorPP8TJV46+jKHCZLJxBaZKFYdOT9ySCSrdDNgeVRe44ufvZ/epRk8O 7Wx0XcEuPsXh5o060cK8SisRCJKlxtBEpBJG2SSB5O9aaRf9gWaGV+J1YnPS42qJur gKMLqqOIX/3IhKx93KD01QgunTwePGaSkocxW5RM= From: =?utf-8?q?Ond=C5=99ej_Jirman?= To: linux-kernel@vger.kernel.org, Liam Girdwood , Rob Herring , Conor Dooley , 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, devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: [RESEND PATCH v2 2/5] ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level Date: Sat, 24 Feb 2024 14:54:55 +0100 Message-ID: <20240224135501.3822390-3-megi@xff.cz> In-Reply-To: <20240224135501.3822390-1-megi@xff.cz> References: <20240224135501.3822390-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: 1791788925853273922 X-GMAIL-MSGID: 1791788925853273922 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[] = {