From patchwork Tue Dec 19 14:54:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 181037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1994837dyi; Tue, 19 Dec 2023 07:00:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IH19wJNh+Y2bXNp3g8ZWdk3mb1Y+Id5un/TSTAPaRFjTKsvPwtmPRZ8sPz5SEtBTwimw6ji X-Received: by 2002:ac8:5cc4:0:b0:423:852e:8273 with SMTP id s4-20020ac85cc4000000b00423852e8273mr25745154qta.61.1702998008038; Tue, 19 Dec 2023 07:00:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702998008; cv=none; d=google.com; s=arc-20160816; b=DjdZLfby4Y1wlPxhVu0gNmZ/SX714IrP+HBFwCNEihf0sgGkN6Nrd+Ztf/OEh2nUX7 gmxcZsd4rrOSY42Mc/qzeudA5B6y8JmbhN8rCk3xBl3wDO7y4nVlZDGoevf5tgkpQgFg sSCkYjanERNnW6TO+jtRx4Q58nBL7XgM6d8QxYoY2B/JViUYgmDupKNHbV6x+MS+Qg+O HyF6sAb/obBEKEW8PbRl+nfiSEBftGuIaCVcpCdYo7i/xLNXAqS+9KeTfK/pvThPw4sd vsmph0N429PHufCUScLZjf/NqX/UVFcQN3kwUBNJtbtcufOyij3WZBACvlE4XS+BNrM6 Dq7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=PDyTeU9usO3nPa3fs7kQ7qNlzGdPYLhGQTUhd4FhxwY=; fh=YBpXnBz4z5WTNuRpmEjjmJAYZAysFFiStO3A7cE8DhM=; b=0GE4Y7qNe/ocV1EKZDZGU+TCEdCQ4SrkK429VGLVnJ1JxnCT1/CHDPFBfldvKSHIjW qD/13cu+OjprbExtvWBBOwJs9LHCkKeaXu6f5A52pRrqI6bY8e8P3TID9u59s51OuVjD FwuQvdWAT2p87myt/2DNFnAPAtFmV1ps4nrvOwlyXp8mNnU+vxdV2YAdusivMUSRplkC hWskEBHk2q2diW2zAs5MfUUI83OQ7as4Xr3Kfvsf8p0h74/u7U3xiKDWxH6dm6zZ3XlN h941td92GIOFLCSCXwBjXJzn7BhvImjXyodDyrS89EmLDJ0xVbv50kFsGUL5BJ098BXj q6Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=B96wPCLj; spf=pass (google.com: domain of linux-kernel+bounces-5435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ex8-20020a05622a518800b00419642d586esi28892303qtb.450.2023.12.19.07.00.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 07:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=B96wPCLj; spf=pass (google.com: domain of linux-kernel+bounces-5435-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 5BF4E1C2185C for ; Tue, 19 Dec 2023 15:00:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C426C38F99; Tue, 19 Dec 2023 14:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="B96wPCLj" X-Original-To: linux-kernel@vger.kernel.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C0C11CAAC; Tue, 19 Dec 2023 14:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 8B06440013; Tue, 19 Dec 2023 14:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702997689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PDyTeU9usO3nPa3fs7kQ7qNlzGdPYLhGQTUhd4FhxwY=; b=B96wPCLjTmdsJD900DmDDyWBYyQR63QedKxMVIFYAllO8UzR/7+MLZMuQRr1oxPqVHLdmO wqA6h37ijE/3NphaWd+uLSe0Fc9/ntSHfmhnTu/GCJbS0V6ByORZiqZ6hFaDmI6Dq4+DGE 3hM4a98hdzQVVOFTBIwayVOkTrig86/1GbL183VD2Ms6bHkdMvjaJ6fW5U/NOJ5+B697U4 0zV6dplJh/+LM1dQwB0WLOL3A6gpF68bLbPyGYB2O4xiHFeVUFnQYYIZ7fM/if1mt3IVH8 J9k2qbJT/HRTvmrg+pWtqr853UDpnkCQPJB7sdEYHnoabdV5jV7OhBQj06GG1g== From: Luca Ceresoli Date: Tue, 19 Dec 2023 15:54:18 +0100 Subject: [PATCH v2 3/6] ASoC: core: add SOC_DOUBLE_RANGE_TLV() helper macro Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231219-rk3308-audio-codec-v2-3-c70d06021946@bootlin.com> References: <20231219-rk3308-audio-codec-v2-0-c70d06021946@bootlin.com> In-Reply-To: <20231219-rk3308-audio-codec-v2-0-c70d06021946@bootlin.com> To: Nicolas Frattaroli , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel Cc: Thomas Petazzoni , linux-rockchip@lists.infradead.org, linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.12.4 X-GND-Sasl: luca.ceresoli@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785722839227345241 X-GMAIL-MSGID: 1785722839227345241 No macro currently allows handling a stereo control that has left and right in the same register and whose minimum register value is not zero. Add one that does that. Note that even though the snd_soc_*_volsw_range() look more appropriate given the _range suffix, they are not suitable because they don't honor the two shift values. The snd_soc_*_volsw() look more generic and are suitable for the task. Signed-off-by: Luca Ceresoli --- This patch is new in v2. --- include/sound/soc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 7792c393e238..41ba90bdbea9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -149,6 +149,18 @@ {.reg = xreg, .rreg = xreg, \ .shift = shift_left, .rshift = shift_right, \ .max = xmax, .min = xmin} } +#define SOC_DOUBLE_RANGE_TLV(xname, xreg, xshift_left, xshift_right, xmin, xmax, \ + xinvert, tlv_array) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ + SNDRV_CTL_ELEM_ACCESS_READWRITE,\ + .tlv.p = (tlv_array), \ + .info = snd_soc_info_volsw, \ + .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ + .private_value = (unsigned long)&(struct soc_mixer_control) \ + {.reg = xreg, .rreg = xreg, \ + .shift = xshift_left, .rshift = xshift_right, \ + .min = xmin, .max = xmax, .invert = xinvert} } #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\