Message ID | 20230523151223.109551-7-herve.codina@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp2202343rwl; Tue, 23 May 2023 08:16:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IbdGa5Zwak93gP7lq445roAjitQq3O4j6lNl5Kj4zMq3pqzo7EVMw5Fa2tGhJTruGy1hJ X-Received: by 2002:a17:90b:3582:b0:255:435e:ceb6 with SMTP id mm2-20020a17090b358200b00255435eceb6mr9502769pjb.17.1684854976815; Tue, 23 May 2023 08:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684854976; cv=none; d=google.com; s=arc-20160816; b=OqSos5nZwEOUJNY4ZCQrJjCFHqPNKI65jMohUmUItvSJ/Nwk2+RANRApcOBoipgoTQ dcUi2MBIdvm6mJnJfhjv4zJlTRDzeHWCJy1SkkxasquwvDG9Dm5sEhzHiwVHVzblUb77 4LNUpEuAWW5brubUXFJrL5z/4iN5AxeJhpxtd5742G5Q9Z3cnUY+VuOGD/OzEkHa7y8O A3p80l5ZLeChzs1FCibKrV5KH/moqLMkojEX+qukVbQSLtewYIYVqkanjIzMYM/WlFCk Tjti3GXqd7MbroEz5wTJWAl07PCD64Pz1JfuQgqPBFyuPafpkbMTVmYqsFCb1AlQe8W5 swag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DrMZ95BLnGjcDr2P+qmpgq0WbufG1vHwF/RueaYJS28=; b=IKHVcC5OZld3YDWmRU4Hc7ODxXXrlqyjiRtP5d4hvJTP+cXUi1Fshd+b9vqp6JGpEM SSzjOc/HsO0MT74epu8Fcgfh+Z71GBqda8f3/ac5t2vdt31iff755VVCewIyRhKFADmi XsNWUY0Ceber+BfrJURp2Lfjd9comyc2ZUi4m5Ca65F2dNjxu41gR9NQroXsR01DovlS hDDlxxYcTKjzf38ID63GZpEzmo9YiMQRy1ydmKu7RQI6etNf8vwc82ppYHNpEuEqFJG7 ZsOnEluza8Lm9NOf9Ipl9aIvHoZwDv63N7f51BrcX4k/J33JGFdUXZNOSKrJnsqQaaTI ++9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OJWTwCnl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a17090ad50a00b0023d22d0f0fdsi2036672pju.19.2023.05.23.08.16.04; Tue, 23 May 2023 08:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OJWTwCnl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237499AbjEWPNP (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 11:13:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjEWPNE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 11:13:04 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A1981B1; Tue, 23 May 2023 08:12:51 -0700 (PDT) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPA id 3D8ECC0008; Tue, 23 May 2023 15:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1684854770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DrMZ95BLnGjcDr2P+qmpgq0WbufG1vHwF/RueaYJS28=; b=OJWTwCnlWn+Xthk0Xfek+s2r5juF2h7SNMSfs+CDSVW51lOc8n36dXjfmK4BGPJBYbTAPt 86JjRd4Mcrd49qLXHvDbArKC/E8hki2QuxdslB+MaEZqxwzDROqTu3G8Z0Oz5C6eQX+enW 1FEIgs2cKR0VhE8GLUYxb3DvhzjllrjjdzEjgxzsfnZWENwkRrwuSFZJ1V6owA63QJX4at E+lI4csyxxNOldCH4gEdjII1NaSjAe/tFPmI74ueGDSpFa0nTIg+UIMmKFywgHxEA6Z5du 0P+mF8ZkTdK3AP4vyWzvlgggQVXF+c6HB2D3ptw9OPIUQUqHT2gaJZ7N9lx2tQ== From: Herve Codina <herve.codina@bootlin.com> To: Herve Codina <herve.codina@bootlin.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Christophe Leroy <christophe.leroy@csgroup.eu>, Thomas Petazzoni <thomas.petazzoni@bootlin.com> Subject: [PATCH v2 6/9] ASoC: soc-dapm.h: Add a helper to build a DAPM widget dynamically Date: Tue, 23 May 2023 17:12:20 +0200 Message-Id: <20230523151223.109551-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230523151223.109551-1-herve.codina@bootlin.com> References: <20230523151223.109551-1-herve.codina@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766698492057690775?= X-GMAIL-MSGID: =?utf-8?q?1766698492057690775?= |
Series |
Add support for IIO devices in ASoC
|
|
Commit Message
Herve Codina
May 23, 2023, 3:12 p.m. UTC
The SND_SOC_DAPM_* helpers family are used to build widgets array in a
static way.
Introduce SND_SOC_DAPM_WIDGET() in order to use the SND_SOC_DAPM_*
helpers family in a dynamic way. The different SND_SOC_DAPM_* parameters
can be computed by the code and the widget can be built based on this
parameter computation.
For instance:
static int create_widget(char *input_name)
{
struct snd_soc_dapm_widget widget;
char name*;
...
name = input_name;
if (!name)
name = "default";
widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(name));
...
}
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
include/sound/soc-dapm.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
Comments
Tue, May 23, 2023 at 05:12:20PM +0200, Herve Codina kirjoitti: > The SND_SOC_DAPM_* helpers family are used to build widgets array in a > static way. > > Introduce SND_SOC_DAPM_WIDGET() in order to use the SND_SOC_DAPM_* > helpers family in a dynamic way. The different SND_SOC_DAPM_* parameters > can be computed by the code and the widget can be built based on this > parameter computation. > For instance: > static int create_widget(char *input_name) > { > struct snd_soc_dapm_widget widget; > char name*; > ... > name = input_name; > if (!name) > name = "default"; > > widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(name)); > ... > } Maybe instead of adding a helper, simply convert those macros to provide a compaund literal? (See, for example, https://elixir.bootlin.com/linux/v6.4-rc4/source/include/linux/pinctrl/pinctrl.h#L42)
On Sat, 3 Jun 2023 17:07:43 +0300 andy.shevchenko@gmail.com wrote: > Tue, May 23, 2023 at 05:12:20PM +0200, Herve Codina kirjoitti: > > The SND_SOC_DAPM_* helpers family are used to build widgets array in a > > static way. > > > > Introduce SND_SOC_DAPM_WIDGET() in order to use the SND_SOC_DAPM_* > > helpers family in a dynamic way. The different SND_SOC_DAPM_* parameters > > can be computed by the code and the widget can be built based on this > > parameter computation. > > For instance: > > static int create_widget(char *input_name) > > { > > struct snd_soc_dapm_widget widget; > > char name*; > > ... > > name = input_name; > > if (!name) > > name = "default"; > > > > widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(name)); > > ... > > } > > Maybe instead of adding a helper, simply convert those macros to provide > a compaund literal? (See, for example, > https://elixir.bootlin.com/linux/v6.4-rc4/source/include/linux/pinctrl/pinctrl.h#L42) > Indeed, I will convert macros and remove the helper in the next iteration. Thanks for the review, Hervé
Hi Andy, On Sat, 3 Jun 2023 17:07:43 +0300 andy.shevchenko@gmail.com wrote: > Tue, May 23, 2023 at 05:12:20PM +0200, Herve Codina kirjoitti: > > The SND_SOC_DAPM_* helpers family are used to build widgets array in a > > static way. > > > > Introduce SND_SOC_DAPM_WIDGET() in order to use the SND_SOC_DAPM_* > > helpers family in a dynamic way. The different SND_SOC_DAPM_* parameters > > can be computed by the code and the widget can be built based on this > > parameter computation. > > For instance: > > static int create_widget(char *input_name) > > { > > struct snd_soc_dapm_widget widget; > > char name*; > > ... > > name = input_name; > > if (!name) > > name = "default"; > > > > widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(name)); > > ... > > } > > Maybe instead of adding a helper, simply convert those macros to provide > a compaund literal? (See, for example, > https://elixir.bootlin.com/linux/v6.4-rc4/source/include/linux/pinctrl/pinctrl.h#L42) > Yes, I will convert them in the next iteration. Thanks for the review, Hervé
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 87f8e1793af1..6b62fe5c779c 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -276,7 +276,17 @@ struct soc_enum; .reg = SND_SOC_NOPM, .event = dapm_pinctrl_event, \ .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD } - +/* + * Helper to create a widget 'dynamically' + * This can be used with any of the SND_SOC_DAPM_* widget helper. + * For instance: + * struct snd_soc_dapm_widget widget; + * ... + * widget = SND_SOC_DAPM_WIDGET(SND_SOC_DAPM_INPUT(input_name)); + */ +#define SND_SOC_DAPM_WIDGET(_widget)({ \ + struct snd_soc_dapm_widget _w[1] = { _widget }; \ + _w[0]; }) /* dapm kcontrol types */ #define SOC_DAPM_DOUBLE(xname, reg, lshift, rshift, max, invert) \