From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 2A83D306757; Wed, 13 May 2026 08:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660246; cv=none; b=bwxNxwXZtUpXKZhI6Q1IU8aWkgHWb6D2reTXad23I0AOls3+5MTPzZlG3eRvt2ev7/YibbcQFth9Uep/E5PztP4Qa9voTDbjh6lQERSqm2IoIqvNdqqST8DZn/NaLvoszfTyhZFabJ6ykCwshA/6VpgtW+ZYE4ZYPK6Ujr87fUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660246; c=relaxed/simple; bh=aQKpuKeLWGzs0rc2yJxJsWgIw5xsY6mHoRbEI75011I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iFDM40Jkofju5gmZv7oJtC0Fof9/lU62e4Fry8EHnlzdn2LtZLUOgUFViYldsZJTnznbDpa5cJAep+REbTfeGqVGkZpAKFGCLMF550sH0j2jaV/iT2Spabqjc+V1clqumq1LkJg17SVqYFWBfvrQe9OonNznCGvjUhY4GObwGFY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=2ofK1yqG; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="2ofK1yqG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id A9BC2C5E175; Wed, 13 May 2026 08:18:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5233B606CE; Wed, 13 May 2026 08:17:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7F69E11AF8790; Wed, 13 May 2026 10:17:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660241; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=hL78oEbudOSFeol+ORqqQXKroRRxjS7rg6+ZdehjJvI=; b=2ofK1yqGhUwRj/frLcXVD4KQryIOeXSH/I75l5cLQEb0EZQfPJsp2TVt3LWdbfwBza+rym /HP7m+0ID6Q8FUDy4UFf2kO1h1DMvPsfRTju6ALQZ1fuGnGCsf301+eKqpbvKlwY30Yclh IRjIToaBG7CsF7IFvxSArSPPpDGCgvzQqbZ6Mt+H9mUM606RVstQPltMKiDUcgHTszdGNr Q6kLCNfv5MH5aAf4gFczka/Os7zr6snePj++N7MsYvPStGPBn43NNCY4suyVETugoNXJWE T0nC/VAaWw8kQD6BI9llRzJ6Vyy5ZUrQz0fzutCYvecFbdkMQQaAnMpzAu8SKw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 01/17] of: Introduce of_property_read_s32_index() Date: Wed, 13 May 2026 10:16:45 +0200 Message-ID: <20260513081702.317117-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Signed integers can be read from single value properties using of_property_read_s32() but nothing exist to read signed integers from multi-value properties. Fix this lack adding of_property_read_s32_index(). Signed-off-by: Herve Codina Acked-by: Rob Herring (Arm) --- include/linux/of.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 959786f8f196..28153616e616 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1476,6 +1476,13 @@ static inline int of_property_read_s32(const struct = device_node *np, return of_property_read_u32(np, propname, (u32*) out_value); } =20 +static inline int of_property_read_s32_index(const struct device_node *np, + const char *propname, u32 index, + s32 *out_value) +{ + return of_property_read_u32_index(np, propname, index, (u32 *)out_value); +} + #define of_for_each_phandle(it, err, np, ln, cn, cc) \ for (of_phandle_iterator_init((it), (np), (ln), (cn), (cc)), \ err =3D of_phandle_iterator_next(it); \ --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 EB50F388896; Wed, 13 May 2026 08:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660252; cv=none; b=DyPiQltMwbna3uE7mXBAgxIshhkV2yjO40OfeRma1ZeDH9yQCLxZZRR/8z0D+XUXR0tOacpuKiM8lYr97jGz0sNmq8r1bC+WEVA+0Srl/MjupYCzO5PtIPFKUX5HRA048y5ach7Uy73QOxI2pp1I9LQaefXCs+GaXmM0uHfkFGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660252; c=relaxed/simple; bh=TQjKByRvsX9lIZ+Og9tNG7DVpm+mvyrZqEFZnCV7BB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Iw1vUSpca0U8OsFpL58xJJmW1SMMsLjNOcXkI2Ci1iEvFdHnk84Rqr+QWOyFOss1HzJpjiJp/1B1bddPwzdwvyVHJtFT/3w2KfBHnh0kv48tchKSUx+otRshPl3SetsQhvmIwFbyDKobTm/lJDTWSxpwzj7FbTRKUeKwOc6SGJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=E++l5Nm8; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="E++l5Nm8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 1409C1A3598; Wed, 13 May 2026 08:17:24 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D9EDB606CE; Wed, 13 May 2026 08:17:23 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7CE0E11AF8CAA; Wed, 13 May 2026 10:17:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660242; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=0zinHiBM3fEpTYt8/+O7+fe/fqCVMjUqGdXgb4Vs4F4=; b=E++l5Nm84tHMnnHoGSHtOPjzuSO49vCd5EUe6m1+H6YefdVWFIgEGFX5NlvgT+KpBuK0YX 1IoTQ9eWWpfTPMi5wkoVTVN1CPesbpXEXuaiLfXBoDjJpc9TDBQN9sxl8hrPbfCrGr3aFx 3/X9mbZlac/UEQqgcX+n/SlnlExMvxxlEa81kG539O+PciB34cmM4Y/UqP7U7VmR6RP+b6 nNZwnQ5bUTNxt8KZjlAZDLKTwX6ee5KSx9Ydtf1b0SnNmYAlIsqzK7/jovwkSkEnjh4K2A zeYwMozrDT9O2FmtLlwBSbC3M+A+sAFI6mQ0vA1/dqS8f4qFCGgiqMWhahuuiw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 02/17] ASoC: dt-bindings: Add support for the GPIOs driven amplifier Date: Wed, 13 May 2026 10:16:46 +0200 Message-ID: <20260513081702.317117-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Some amplifiers based on analog switches and op-amps can be present in the audio path and can be driven by GPIOs in order to control their gain value, their mute and/or bypass functions. Those components needs to be viewed as audio components in order to be fully integrated in the audio path. gpio-audio-amp allows to consider these GPIO driven amplifiers as auxiliary audio devices. Signed-off-by: Herve Codina Reviewed-by: Rob Herring (Arm) --- .../bindings/sound/gpio-audio-amp.yaml | 270 ++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/gpio-audio-amp.= yaml diff --git a/Documentation/devicetree/bindings/sound/gpio-audio-amp.yaml b/= Documentation/devicetree/bindings/sound/gpio-audio-amp.yaml new file mode 100644 index 000000000000..3690f3d1628c --- /dev/null +++ b/Documentation/devicetree/bindings/sound/gpio-audio-amp.yaml @@ -0,0 +1,270 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/gpio-audio-amp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Audio amplifier driven by GPIOs + +maintainers: + - Herve Codina + +description: | + Audio GPIO amplifiers are driven by GPIO in order to control the gain va= lue + of the amplifier, its mute function and/or its bypass function. + + Those amplifiers are based on discrete components (analog switches, op-a= mps + and more) where some of them, mostly analog switches, are controlled by = GPIOs + to adjust the gain value of the whole amplifier and/or to control + the mute and/or bypass function. + + For instance, the following piece of hardware is a GPIO amplifier + + +5VA + ^ + |\ | + | \ + Vin >---------------------------|+ \ + | +-------+-----> Vout + .--\/\/\/--+------------|- / | + | | | / | + v | |/ | | + GND o v | + \ GND | + gpio >-----------> \ | + o o | + | | | + | '--\/\/\/--. | + | +--\/\/\/--' + '---------------' + +properties: + compatible: + oneOf: + - const: gpio-audio-amp-mono + description: + A single channel amplifier. All features apply to this sole chan= nel. + + - const: gpio-audio-amp-stereo + description: + A dual channel amplifier (left and right). All features apply to= both + channels producing the same effect on both channels at the same = time. + + vdd-supply: + description: Main power supply of the amplifier + + vddio-supply: + description: Power supply related to the control path + + vdda1-supply: + description: Analog power supply + + vdda2-supply: + description: Additional analog power supply + + mute-gpios: + description: GPIO to control the mute function + maxItems: 1 + + bypass-gpios: + description: GPIO to control the bypass function + maxItems: 1 + + gain-gpios: + description: | + GPIOs to control the amplifier gain + + The gain value is computed from GPIOs value from 0 to 2^N-1 with N t= he + number of GPIO described. The first GPIO described is the lsb of the= gain + value. + + For instance assuming 2 gpios + gain-gpios =3D <&gpio1 GPIO_ACTIVE_HIGH> <&gpio2 GPIO_ACTIVE_HIGH= >; + The gain value will be the following: + + gpio1 | gpio2 | gain + ------+-------+----- + 0 | 0 | 0b00 -> 0 + 1 | 0 | 0b01 -> 1 + 0 | 1 | 0b10 -> 2 + 1 | 1 | 0b11 -> 3 + ------+-------+----- + + Note: The gain value, bits set to 1 or 0, indicate the state active = (bit + set) or the state inactive (bit unset) of the related GPIO. The + physical voltage corresponding to this active/inactive state is + given by the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags. + + minItems: 1 + maxItems: 16 + + gain-ranges: + $ref: /schemas/types.yaml#/definitions/int32-matrix + description: | + A list of one or more ranges of possible values. Each range is defin= ed by + the first and last point in the range. Each point is defined by the = pair + (GPIOs value, Gain in 0.01 dB unit). + + Ranges can be contiguous or holes can be present between ranges if s= ome + gpios value should not be used. Also in a range the first point and = the + last point can be identical. In that case, the range contains only o= ne + item, the given point. + + items: + items: + - description: GPIOs value of the first point in the range + - description: Gain in 0.01 dB unit of the first point in the range + - description: GPIOs value of the last point in the range + - description: Gain in 0.01 dB unit of the last point in the range + description: | + A range defines a linear function (linear in dB) from the first po= int + to the last point, both included. The number of items in the range= is + N =3D abs(first_point.gpio_value - last_point.gpio_value) + 1 + + It allows to define the gain range from the first_point.gain to + the last_point.gain, both points included. + + Gain (0.01 dB unit) + ^ + | last + +- - - - - - - - - - + point + | + . + | + . + | + . + +- - - - + . + | first . . + | point . . + | . . + +--------+-----------+---> gpios + value + + Note: Even if first_point.gpio_value is lower than last_point.gpio= _value + and first_point.gain is lower than last_point.gain in the ab= ove + graphic, all combination of values are supported leading to = an + increasing or a decreasing linear segment. + + minItems: 1 + maxItems: 65536 + + gain-labels: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 2 + maxItems: 65536 + description: | + List of the gain labels attached to the combination of GPIOs control= ling + the gain. The first label is related to the gain value 0, the second= label + is related to the gain value 1 and so on. + + With 2 GPIOs controlling the gain, GPIOs value can be 0, 1, 2 and 3. + Assuming that gain value set the hardware according to the following + table: + + GPIOs | Hardware + value | amplification + ------+-------------- + 0 | Low + 1 | Middle + 2 | High + 3 | Max + ------+-------------- + + The description using gain labels can be: + gain-labels =3D "Low", "Middle", "High", "Max"; + +dependencies: + gain-ranges: [ gain-gpios ] + gain-labels: [ gain-gpios ] + +required: + - compatible + - vdd-supply + +anyOf: + - required: + - gain-gpios + - required: + - mute-gpios + - required: + - bypass-gpios + +allOf: + - $ref: component-common.yaml# + - if: + required: + - gain-ranges + then: + properties: + gain-labels: false + - if: + required: + - gain-labels + then: + properties: + gain-ranges: false + +unevaluatedProperties: false + +examples: + - | + #include + + /* Gain controlled by gpios */ + amplifier-0 { + compatible =3D "gpio-audio-amp-mono"; + vdd-supply =3D <®ulator>; + gain-gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>, <&gpio 1 GPIO_ACTIVE_HI= GH>; + }; + + /* Gain controlled by gpio using a simple range on a stereo amplifier = */ + amplifier-1 { + compatible =3D "gpio-audio-amp-stereo"; + vdd-supply =3D <®ulator>; + gain-gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>, <&gpio 1 GPIO_ACTIVE_HI= GH>; + gain-ranges =3D <0 (-300) 3 600>; + }; + + /* Gain controlled by gpio with labels */ + amplifier-3 { + compatible =3D "gpio-audio-amp-mono"; + vdd-supply =3D <®ulator>; + gain-gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>; + gain-labels =3D "Low", "High"; + }; + + /* A mutable stereo amplifier without any gain control */ + amplifier-4 { + compatible =3D "gpio-audio-amp-stereo"; + vdd-supply =3D <®ulator>; + mute-gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>; + }; + + /* + * Several supplies, gain controlled using more complex ranges, mute a= nd + * bypass. + * + * Assuming 3 gpios for controlling the gain with the following table + * gpios value Gain + * 0b000 Do not use (gpios value not allowed) + * 0b001 - 3dB + * 0b010 + 3dB + * 0b011 + 10dB + * 0b100 Do not use (gpios value not allowed) + * 0b101 + 6dB + * 0b110 + 7dB + * 0b111 + 8dB + */ + amplifier-5 { + compatible =3D "gpio-audio-amp-mono"; + vdd-supply =3D <®ulator>; + vddio-supply =3D <®ulator1>; + vdda1-supply =3D <®ulator2>; + gain-gpios =3D <&gpio 0 GPIO_ACTIVE_HIGH>, + <&gpio 1 GPIO_ACTIVE_HIGH>, + <&gpio 2 GPIO_ACTIVE_HIGH>; + gain-ranges =3D <1 (-300) 2 300>, + <3 1000 3 1000>, + <5 600 7 800>; + mute-gpios =3D <&gpio 3 GPIO_ACTIVE_HIGH>; + bypass-gpios =3D <&gpio 4 GPIO_ACTIVE_HIGH>; + }; +... --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 0B0EF385D64 for ; Wed, 13 May 2026 08:17:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660254; cv=none; b=T6y9Nw8ceC4VraiTV+DnhyM4HV5J0RR1uYP5cKcqd1XxDtcWlpWkjmK7WaTMuAQ9bfJteN42LIxgR2kEaHDJjyshky6dSYLvF4JAuqVRHOmo7llnNY9OB/NnQwJquEkZC/6GMc8rzHbHIigPmTJW3wuDVicbU4+2sC+1IP5V3JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660254; c=relaxed/simple; bh=T1w65KOywt6Aem2GhCbJmOJlyoLknLOfFIhNHMwkQ2s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NSytjZfxchopp68du0gN0L1s8HiqPccDlcmWsMi+ccZf/AF7wUsDF0fZeL6JAUuu5XdUi6CsyylSNLgVGCf1q+c/CMrApfZywNZopKwfrGwY9vE77xonnRCLjdeS2C3xuvW4e5ycue3ct1ibwYGgiSpXLaSSOCCgvbxMY5PErXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=K8B+4nQY; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="K8B+4nQY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id D08411A3599; Wed, 13 May 2026 08:17:25 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A15AD606CE; Wed, 13 May 2026 08:17:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5185411AF874F; Wed, 13 May 2026 10:17:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660244; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=sKypgypZ6D+IKIIZxzDHFHASGVM/SOc1W5Wd/depBrA=; b=K8B+4nQYAYF+KrlYvqdWE/8FTHLd9XoG5JgN4zB/XWzA2PXG542ZnBv5Ooe4GPXMpakqJe 7LI0rmY0BlxP9QtbnnbkX5M5LzBDo3FQc7E7q8GD8xEPflZBvmB8ulzAjKHXJpRucq3tBa Kjig4OPsHaPq32Cp2YnK0L1ejY29LgKsN/HNeeVIEh9Fly58/PxJjwV4V9siGkKCoW3K9e k8/nsmStQpEyaHehYiVmzuvAUW3504cvXQiuzpg/rphqQet+KsuaOzCOhF0U6zqwYdkoOw 2Mujj6/IvKN2MmwuBTbau5bde/EAGXDSY6S7P+ImNeGpqU1IppRREAuxKpqO/w== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 03/17] ASoC: simple-amplifier: Remove DRV_NAME defined value Date: Wed, 13 May 2026 10:16:47 +0200 Message-ID: <20260513081702.317117-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" DRV_NAME is defined and used only in the simple-amplifier driver declaration. Remove the useless defined and use directly the value in the driver declaration itself. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index d306c585b52b..41485445727d 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -9,8 +9,6 @@ #include #include =20 -#define DRV_NAME "simple-amplifier" - struct simple_amp { struct gpio_desc *gpiod_enable; }; @@ -97,7 +95,7 @@ MODULE_DEVICE_TABLE(of, simple_amp_ids); =20 static struct platform_driver simple_amp_driver =3D { .driver =3D { - .name =3D DRV_NAME, + .name =3D "simple-amplifier", .of_match_table =3D of_match_ptr(simple_amp_ids), }, .probe =3D simple_amp_probe, --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 B2AEF385D64; Wed, 13 May 2026 08:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660250; cv=none; b=hEw4z6OgvNO8PrD/fM+Oo7dcAR5cUnjvct/nGH9OZ3ealmSe4pkM9uFtI05AGbvhiDEdYBJYT9idf0xq1GOgnGunoPfN8gvFYfoKRE4HnS7vJmV8bYe+xeHXFl9sBcidCBu7hAT4dt3qdqMR7R9dLQUub3OZ9oka0IF+rYVKuKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660250; c=relaxed/simple; bh=GItI68PveC34KXEaGotOESlp/XqQHAJQV5gB8+kI5QY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PN3kNwq7L5ZNnxOJtQUKkfUhTJ10bwEf0j5yH6r0sqmy96uSK18eG/FH7wcu3Prou3yLCQjEsp6AMWrHr9onlEfubbN2sQY9uJkACuhFj74TU97/5gWljhUmynq3pxYtIeJIWqXcb8TezfwzjFg8KTv1ntT/UizVpuHFUH+qxeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eG0duiJS; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eG0duiJS" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id E4043C5DC48; Wed, 13 May 2026 08:18:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8DD31606CE; Wed, 13 May 2026 08:17:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2ADAD11AF8790; Wed, 13 May 2026 10:17:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660246; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=2wgXoEE23jW8P9I06trxVet/K0Ld7403TpqPZ+ivRA8=; b=eG0duiJSz7o8D6LRakUS/GtdCzdVyOS48mwfSzTo8KaS+mU7araV3tCMypBdc9xikIR1VP QGIGzVZGvV1dNsreDAIpca1rl9Pz7EWmmVUPY2ANA/FNllS3O8QQ928OPSqfxxqGhoWdh2 lO5X5Pr6IUT6s9DVuLUpx8MFOyuyIo3Lb9ac/vDa1Wli2RxgGMnq2WAztDbbWSdO7tCzh3 wXq7kDtsp8ZSLpRJjAjOysgWozpDl6+eV+HEAoOKrkQl7WNwD5/LWFK91ovK5hnjv4iFh3 dFbom/djneNJLO3L4vGqJ5dGIR6RJx9wkN8ycvHF8xuZPTykNcc8QYvoEbT7Ug== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 04/17] ASoC: simple-amplifier: Add missing headers Date: Wed, 13 May 2026 10:16:48 +0200 Message-ID: <20260513081702.317117-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The simple-amplifier driver is a platform device driver. Add missing include files related to this kind of driver. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 41485445727d..5b44bcfef49e 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -5,7 +5,9 @@ */ =20 #include +#include #include +#include #include #include =20 --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 480F838889C; Wed, 13 May 2026 08:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660254; cv=none; b=EkGhhZgQBQViQ8JwdCVhMKvUxGB/R3AaBerraOdOzA3cXfGD3lO5f0kDSY5edtrRcUwF1ClXjn8jzerzyE/pjR/8CsUJmMQgh7Kj1rxxnK0Uiw1pLV43fEO76YL8rpQUifXkg2oOuVcGyQSZzf4MUdwO6T3/Smqlln7xnLXBJX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660254; c=relaxed/simple; bh=PLXtGH7zPLXfkkIe9EqBxWu/O4wtMDgIlemph7UUw4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B3z0ycuTyUctrQtRyDWCoasMof72TAkVT+bHrELiyGCPXu1nNA2byVd+QJeP4uCXEAUAezvPWYdkMzDBfiUPPub8KTOvYyIr/+5Q6brvE/jCQk0EWAOHNPv97NbGN56FJANdHUN0yH0Pce8zD4mWWu5QMTAe2x9FmZhzL6+u0io= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=b+km4s4u; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="b+km4s4u" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 060A71A3596; Wed, 13 May 2026 08:17:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CA55F606CE; Wed, 13 May 2026 08:17:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 02E4A11AF8CB9; Wed, 13 May 2026 10:17:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660248; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=qARIMrMbrBENAM5Goh6MMU9ZT8eSkmiHwLsrsbigu1A=; b=b+km4s4uGR4r/QDMDdfIbHqae4X7QuYmJL1QzfahNN25I/JvBWGeDsvWRwHZjEUZ02Wfsg jqGwAP3+kq/oWp1baXj2+YfjLmqVjIMfWijl/9Qa8GQK81AKVeBYcgSS0bjKqrq5GZoUna jV5MU5NC42imaVx9SWqHHtgn21hxy8359wp0VRw6Sjq6cK09Wyx7/zECZFWV5CWl5jf2ZH qkP+gFgGSNq3wcsZWXP+5/k4F9f7g3KSVFpdXLtI/Dp3hd9LbsCK9nB8/OqYK9uJNHZ8Q8 DjKkeelTschpnr0xB00dQ5wBwbQVrGAXHgNdVqd5mSR+F7oq7esLEvnuW37TWA== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 05/17] ASoC: simple-amplifier: Remove CONFIG_OF flag and of_match_ptr() Date: Wed, 13 May 2026 10:16:49 +0200 Message-ID: <20260513081702.317117-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The simple-amplifier Use CONFIG_OF flag for its of_device_id table and of_match_ptr() when it assigns the table in the driver declaration. This is no more needed. Drop them. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 5b44bcfef49e..215318ff62fc 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -86,19 +86,17 @@ static int simple_amp_probe(struct platform_device *pde= v) NULL, 0); } =20 -#ifdef CONFIG_OF static const struct of_device_id simple_amp_ids[] =3D { { .compatible =3D "dioo,dio2125", }, { .compatible =3D "simple-audio-amplifier", }, { } }; MODULE_DEVICE_TABLE(of, simple_amp_ids); -#endif =20 static struct platform_driver simple_amp_driver =3D { .driver =3D { .name =3D "simple-amplifier", - .of_match_table =3D of_match_ptr(simple_amp_ids), + .of_match_table =3D simple_amp_ids, }, .probe =3D simple_amp_probe, }; --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 2111638E8A6; Wed, 13 May 2026 08:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660256; cv=none; b=M1EotUZ7n3/XVyZR+n02s5m/NatPOcHi6m01JEbUeyjIuIDtwZJIkIXrjj47Qcq5UbK0Mgx/aYm3Gs4xeq1CfKgyA3cj76fHS0WwT2wwiJZ3TOQx/SUg+EBU36lWMdnStsHtvR0R4dCLRmbT8q1GW0Bk/L0Fnptp6a0LvyImVVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660256; c=relaxed/simple; bh=Lwq3DdX2999OTe9NASug9TPsGMnNPStpw4g9+ZvNMLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XnslH/OCvN/aX9/d+bvTof5f/ZikjHYsLRXX1KLYsd/6gsy58YBhjDjTASeR8RtdGfP0WWUP5UassPI/bx8lMLcVEqh7wihAO56tftWp1FUBLuORqfjzD/SHOsmX63KcHjVxpv6gDLWJIAS3XYrto5S9SnDZifm53kbPSluEs7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=t167YbH6; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="t167YbH6" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 1B7091A3597; Wed, 13 May 2026 08:17:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E0D83606CE; Wed, 13 May 2026 08:17:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 35CA011AF8D81; Wed, 13 May 2026 10:17:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660251; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=tPcax1vVmMn+WekSyZVMY/Gpp1bnyfBe+9QFN7TIpB8=; b=t167YbH6Og001Ar5pWqH1/eKIN/9tWfa6cPVuCZ7Q9mfbN1I52VvdII8cFQGpiFj2ZMv8D XCwUlpBUCZc6avYhk9qjf2UEvNTIor2FhL8dSqE62rc9+acO7SvJvHrJWzagilSX44ivbz Ss7hiKzl6TWxnUPLNT2mVQRaE0cd1g26LAH+j5anQhTWAw3QkGiDDMpPyw5MKEDLQdzcZZ s2fSoJDAXTF6Q2gxvQA9myQbucxjPdyif7qAKrSUMvp06bElNIgKoMIW9DTT9OaCqrW5sZ SQEeclEsjTaELNKm1ZxR82wrXTvyjjGLj0Xi519LdGymTqqJzcuiKIqG0yj75A== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 06/17] ASoC: simple-amplifier: Rename drv_event() function Date: Wed, 13 May 2026 10:16:50 +0200 Message-ID: <20260513081702.317117-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The drv_event() is used to handle power events related to the DRV item. Later, with the support for gpio-audio-amp, this function will be also used to handle power events related to the PGA item. Also, more functions will be added in the driver and it is a common usage to prefix functions based on the driver name. Rename the drv_event() function to simple_amp_power_event() to follow common usage and get rid of the 'drv' term. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 215318ff62fc..8f2daec55134 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -15,8 +15,8 @@ struct simple_amp { struct gpio_desc *gpiod_enable; }; =20 -static int drv_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *control, int event) +static int simple_amp_power_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *control, int event) { struct snd_soc_component *c =3D snd_soc_dapm_to_component(w->dapm); struct simple_amp *priv =3D snd_soc_component_get_drvdata(c); @@ -42,7 +42,7 @@ static int drv_event(struct snd_soc_dapm_widget *w, static const struct snd_soc_dapm_widget simple_amp_dapm_widgets[] =3D { SND_SOC_DAPM_INPUT("INL"), SND_SOC_DAPM_INPUT("INR"), - SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_NOPM, 0, 0, NULL, 0, drv_event, + SND_SOC_DAPM_OUT_DRV_E("DRV", SND_SOC_NOPM, 0, 0, NULL, 0, simple_amp_pow= er_event, (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)), SND_SOC_DAPM_OUTPUT("OUTL"), SND_SOC_DAPM_OUTPUT("OUTR"), --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 3C52B388899; Wed, 13 May 2026 08:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660256; cv=none; b=UoyUtv7OCm0SyyGEtereIMR8MjvEo3/DVulGfkBiBc3nwAuiq3i0Yoo+As+SmdzCPc7ztPSatTp81TAal74mtlq84O02gCedRrDuZLKps7uIYn1mn3ecU21NzjEG5gpR7vz9Uo+0KPjGiN1o11aPTF4ftf2pBBVYgLFZ31GI0Is= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660256; c=relaxed/simple; bh=YKp7OBRR05YAOgw0NaKqcd+xnlnxMjqbyZDXgrXpp/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GXAsnw+vAE0y7u6QhEnmQDQJ3sWp6gpNXIY9M7hVssKUURfdfGRBsU/dSGa1qjjJKiwXyrXbLie0m9p1cF+nHp7SLBhj/d2c90Ee7r4shavWlQmvRjj1PkqWcqI9E48/Z1VB7fFQYY21jHaXBt0X6QtX4iuD96uGh/+QM606iwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=MCWaenBw; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="MCWaenBw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id E4D6C4E42C90; Wed, 13 May 2026 08:17:33 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B6E08606CE; Wed, 13 May 2026 08:17:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6BACB11AF8D2A; Wed, 13 May 2026 10:17:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660252; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=xLMaxXxsn8Xohc8EB+ep57JXHfwWkV62o7p206lPqDI=; b=MCWaenBwzoMKYn9k8O7CK2wQirk6CPq4/qvGI/MvxfN+qY9IALqgGEEb4VP2EoGxd8I9a7 BVP1OJuUbaTtK+9c/nBJd54xSByeWzq3KI8hjdbuYo7Td3qBXiBPyZeIhlqCoW7nwHwNfQ 0t1bLiHfKYi68dvckBNFN5iLslhOqhfWOWvO80zFLFSqmKniT97QE8PM9QKKO6fBHXmDU5 Yqxv1TQ8lvb2qEigBvT+GYrEQuu3gSpqNWmj2QNNEMONaOHWBcQLVt/haPzEHgt0v9ezfO yMIsqNSPGB1ot4dG57hP0K0FI5pk5MhztpVIMrs1/t2/QzMgKc6rrQXYzWSrUQ== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 07/17] ASoC: simple-amplifier: Use 'simple_amp' variable name instead of 'priv' Date: Wed, 13 May 2026 10:16:51 +0200 Message-ID: <20260513081702.317117-8-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The simple-amplifier driver use 'priv' as variable name for its private data (struct simple_amp). With the support for gpio-audio-amp, more functions and data structures will be added. Those future additions will add more complexity in data manipulation and will make the 'priv' term error prone. In order to clearly identify the struct simple_amp private data, use 'simple_amp' as variable name when this structure is involved. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 8f2daec55134..231e84ab4c0e 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -19,7 +19,7 @@ static int simple_amp_power_event(struct snd_soc_dapm_wid= get *w, struct snd_kcontrol *control, int event) { struct snd_soc_component *c =3D snd_soc_dapm_to_component(w->dapm); - struct simple_amp *priv =3D snd_soc_component_get_drvdata(c); + struct simple_amp *simple_amp =3D snd_soc_component_get_drvdata(c); int val; =20 switch (event) { @@ -34,7 +34,7 @@ static int simple_amp_power_event(struct snd_soc_dapm_wid= get *w, return -EINVAL; } =20 - gpiod_set_value_cansleep(priv->gpiod_enable, val); + gpiod_set_value_cansleep(simple_amp->gpiod_enable, val); =20 return 0; } @@ -68,17 +68,17 @@ static const struct snd_soc_component_driver simple_amp= _component_driver =3D { static int simple_amp_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct simple_amp *priv; + struct simple_amp *simple_amp; =20 - priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (priv =3D=3D NULL) + simple_amp =3D devm_kzalloc(dev, sizeof(*simple_amp), GFP_KERNEL); + if (!simple_amp) return -ENOMEM; - platform_set_drvdata(pdev, priv); + platform_set_drvdata(pdev, simple_amp); =20 - priv->gpiod_enable =3D devm_gpiod_get_optional(dev, "enable", - GPIOD_OUT_LOW); - if (IS_ERR(priv->gpiod_enable)) - return dev_err_probe(dev, PTR_ERR(priv->gpiod_enable), + simple_amp->gpiod_enable =3D devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(simple_amp->gpiod_enable)) + return dev_err_probe(dev, PTR_ERR(simple_amp->gpiod_enable), "Failed to get 'enable' gpio"); =20 return devm_snd_soc_register_component(dev, --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 8DBD939A4BA; Wed, 13 May 2026 08:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660259; cv=none; b=fTowVCZ3jcwbdXjH5YKe1VZaTA8g6KJnOUeou4jrkZI2BUu2xtsT593jl6pNFczGQmim51AMnlbrNlh2KwC+3vSmgaqjagdcp2NtNQUHaA1D4pGDo0v97EABaNtgrqCwy/HxRoUFhjwOBVDRBxxfgsHb/tMjBk6WR0ak/xk5hlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660259; c=relaxed/simple; bh=8GJOpBRFIR3Q6Jjms4aMWKWm4vNAmFqwrHNEBT1DlaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BTzVGvAS73wKuAHTqhJvxGTlHmBHyNjOFB0rpc+bABe+cepXg8FyWYB61T5dFcXVXy4rJELfLwHQwl8m6sK/oNG1Tua3GpCtKU8+JmVdLl/Y2GjLml3urlMJvGj6upJbwr/JDKKEVEO2coVaZXm090HKYfsYbz8b5d2m/Akil90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BvzfyxZ4; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BvzfyxZ4" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 4D49F1A3596; Wed, 13 May 2026 08:17:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 13BE2606CE; Wed, 13 May 2026 08:17:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 27BD711AF8D79; Wed, 13 May 2026 10:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660255; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=QmhmB5OxdeBRRp/GKwqgGtcFFCxGWD8fFdPxKo0LR/k=; b=BvzfyxZ4zhZ6i7aocXLH/mstS1SMrL6IncXvSE5RZG2OrVswroUNyemGDy+qGZqmNCrh34 vODMbENFXZZPtJFdv4C6FzWrPUuF5GPjzeFWKXyQoYDogkpp2G7hy0ozx15SXy1NwvH3FB 2NvpZA5dcv+oi+zjYHY3f09xBeOouRCcYzMB6BNQgF8NPCxV48Dzc2TQ7XldTSuLFkPanY v8uLw4JnzUt1czsOWD91xbuTjTPYrZ98g8hMKz5hmzBehmstHC/l+u0c2vkFM8tzTdvOsB CfqX7caeNO02bL6QswKiF0mHa9p69xTOxA7NhsQAdZxopVZ4fRYIAY4VE8B0Pg== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 08/17] ASoC: simple-amplifier: Remove DAPM widgets and routes from the ASoC component driver Date: Wed, 13 May 2026 10:16:52 +0200 Message-ID: <20260513081702.317117-9-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The simple-amplifier set the DAPM wigets and routes table in the ASoC component driver. This is perfectly fine when the component has well known DAPM tables. The simple-amplifier is going to handle several kind of components based on the driver compatible string. The DAPM table will not be the same for all components supported by the driver. In order to have different DAPM table based on matching compatible strings, move those tables from the ASoC component driver to the device compatible string matching data. Add those DAPM widgets and routes dynamically during the ASoC component probe operation. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 59 ++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 231e84ab4c0e..3e644c1c2696 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -11,7 +11,15 @@ #include #include =20 +struct simple_amp_data { + const struct snd_soc_dapm_widget *dapm_widgets; + unsigned int num_dapm_widgets; + const struct snd_soc_dapm_route *dapm_routes; + unsigned int num_dapm_routes; +}; + struct simple_amp { + const struct simple_amp_data *data; struct gpio_desc *gpiod_enable; }; =20 @@ -58,11 +66,39 @@ static const struct snd_soc_dapm_route simple_amp_dapm_= routes[] =3D { { "OUTR", NULL, "DRV" }, }; =20 +static int simple_amp_add_basic_dapm(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm =3D snd_soc_component_to_dapm(component= ); + struct simple_amp *simple_amp =3D snd_soc_component_get_drvdata(component= ); + struct device *dev =3D component->dev; + int ret; + + /* Add basic dapm widgets and routes */ + ret =3D snd_soc_dapm_new_controls(dapm, simple_amp->data->dapm_widgets, + simple_amp->data->num_dapm_widgets); + if (ret) { + dev_err(dev, "Failed to add basic dapm widgets (%d)\n", ret); + return ret; + } + + ret =3D snd_soc_dapm_add_routes(dapm, simple_amp->data->dapm_routes, + simple_amp->data->num_dapm_routes); + if (ret) { + dev_err(dev, "Failed to add basic dapm routes (%d)\n", ret); + return ret; + } + + return 0; +} + +static int simple_amp_component_probe(struct snd_soc_component *component) +{ + /* Add basic dapm widgets and routes */ + return simple_amp_add_basic_dapm(component); +} + static const struct snd_soc_component_driver simple_amp_component_driver = =3D { - .dapm_widgets =3D simple_amp_dapm_widgets, - .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_dapm_widgets), - .dapm_routes =3D simple_amp_dapm_routes, - .num_dapm_routes =3D ARRAY_SIZE(simple_amp_dapm_routes), + .probe =3D simple_amp_component_probe, }; =20 static int simple_amp_probe(struct platform_device *pdev) @@ -75,6 +111,10 @@ static int simple_amp_probe(struct platform_device *pde= v) return -ENOMEM; platform_set_drvdata(pdev, simple_amp); =20 + simple_amp->data =3D of_device_get_match_data(dev); + if (!simple_amp->data) + return -EINVAL; + simple_amp->gpiod_enable =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(simple_amp->gpiod_enable)) @@ -86,9 +126,16 @@ static int simple_amp_probe(struct platform_device *pde= v) NULL, 0); } =20 +static const struct simple_amp_data simple_audio_amplifier_data =3D { + .dapm_widgets =3D simple_amp_dapm_widgets, + .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_dapm_widgets), + .dapm_routes =3D simple_amp_dapm_routes, + .num_dapm_routes =3D ARRAY_SIZE(simple_amp_dapm_routes), +}; + static const struct of_device_id simple_amp_ids[] =3D { - { .compatible =3D "dioo,dio2125", }, - { .compatible =3D "simple-audio-amplifier", }, + { .compatible =3D "dioo,dio2125", .data =3D &simple_audio_amplifier_da= ta}, + { .compatible =3D "simple-audio-amplifier", .data =3D &simple_audio_ampli= fier_data}, { } }; MODULE_DEVICE_TABLE(of, simple_amp_ids); --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 4CD0C3A168A; Wed, 13 May 2026 08:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660261; cv=none; b=E+Tv/NjDoX7frWbROsxlEvEbbZvME7hdN0AND9ivINZd2iM5joPHDpomSqOt4odrV58pH8pmc+VFl7OpHSQkjiud+OR8T3q6fSy+oG3cGuBelSNOXW9ETwhtbAn2Le6XfVVC5pgGa2i10mnkm8G+Nf0DvUAL/ZvqxFDGpgQDyzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660261; c=relaxed/simple; bh=i5JorZ/lhqcxy2K+Vji8D73jYUGJBcGuhuNT0DAMVeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mxor/DYKLR1MlGPM0s5QgMJBvcsws/6dfJKhYrmWUIrInBcIYd2Ek0EfWM8unBX5L4p/mr4Oafp/Xs6TPFrRJA4lcUPfU/Qpb+dlSBXhIDRDVgtDwgdhig7MBd5IpYmOpVNZ+nIjE16VVS2/AJ9DGlhuJZqqq1wMInaF0Hm1Z+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pwGcduH2; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pwGcduH2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id E653C1A3597; Wed, 13 May 2026 08:17:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AFFD2606CE; Wed, 13 May 2026 08:17:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 79E4B11AF8D89; Wed, 13 May 2026 10:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660257; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=CSGSnJ0G/eUMJQf9bcxpqWU0L91cpF0UV0XwaJOSqw8=; b=pwGcduH2bAXhWT3TXmfSrSsWXwhVHPnA/dFeO1Y4TKLpdSbRtt9aRNnd9n0236HHMeVByw QMri6ufMHX9m6l8IhICB90+wG+UQjm70A+goCui2DoU0yDSCD3lqeJX8Rbiq0XzAqHiyl3 pIUEzgDi34MyPXHTqqva7AF20mRVszhX9LDgn3aObi2JJkuQFHiU9vPKGqgcY3Xjorb7iD b6l94LzeLDeezZ6e7S920lvraJx1q2bC0B6xwTtWpxQM/Y0XXAEtAqRn2behiGmic8yjuJ 4eeL9CQvjJcCTwqwqO94R1RXiYQ+thcVSoleypqEWEkuQ/9PrpPuMCbrI3MGTA== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 09/17] ASoC: simple-amplifier: Introduce support for gpio-audio-amp Date: Wed, 13 May 2026 10:16:53 +0200 Message-ID: <20260513081702.317117-10-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Improve the simple-amplifier introducing preliminary support for gpio-audio-amp. Those amplifiers are amplifiers driven by gpios. This support introduction doesn't handle any GPIO yet but introduces the compatible strings and the related DAPM table. Two gpio-audio-amp are available: A mono and a stereo version. The mono version has only one audio channel and gpio settings impact features such as the gain or mute of this sole channel. The stereo version has two channels (left and right). Gpio settings impact both channels in the same manner and at the same time. For instance, the gain setting set the gain of both channels as well as the mute setting mutes both channels. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 3e644c1c2696..1704cdbb7de5 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -4,6 +4,7 @@ * Author: Jerome Brunet */ =20 +#include #include #include #include @@ -12,6 +13,9 @@ #include =20 struct simple_amp_data { + unsigned int supports; +#define SIMPLE_AUDIO_SUPPORT_PGA BIT(0) + const struct snd_soc_dapm_widget *dapm_widgets; unsigned int num_dapm_widgets; const struct snd_soc_dapm_route *dapm_routes; @@ -66,6 +70,38 @@ static const struct snd_soc_dapm_route simple_amp_dapm_r= outes[] =3D { { "OUTR", NULL, "DRV" }, }; =20 +static const struct snd_soc_dapm_widget simple_amp_mono_pga_dapm_widgets[]= =3D { + SND_SOC_DAPM_INPUT("IN"), + SND_SOC_DAPM_OUTPUT("OUT"), + SND_SOC_DAPM_PGA_E("PGA", SND_SOC_NOPM, 0, 0, NULL, 0, simple_amp_power_e= vent, + (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)), + SND_SOC_DAPM_REGULATOR_SUPPLY("vdd", 0, 0), +}; + +static const struct snd_soc_dapm_route simple_amp_mono_pga_dapm_routes[] = =3D { + { "PGA", NULL, "IN" }, + { "PGA", NULL, "vdd" }, + { "OUT", NULL, "PGA" }, +}; + +static const struct snd_soc_dapm_widget simple_amp_stereo_pga_dapm_widgets= [] =3D { + SND_SOC_DAPM_INPUT("INL"), + SND_SOC_DAPM_INPUT("INR"), + SND_SOC_DAPM_OUTPUT("OUTL"), + SND_SOC_DAPM_OUTPUT("OUTR"), + SND_SOC_DAPM_PGA_E("PGA", SND_SOC_NOPM, 0, 0, NULL, 0, simple_amp_power_e= vent, + (SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD)), + SND_SOC_DAPM_REGULATOR_SUPPLY("vdd", 0, 0), +}; + +static const struct snd_soc_dapm_route simple_amp_stereo_pga_dapm_routes[]= =3D { + { "PGA", NULL, "INL" }, + { "PGA", NULL, "INR" }, + { "PGA", NULL, "vdd" }, + { "OUTL", NULL, "PGA" }, + { "OUTR", NULL, "PGA" }, +}; + static int simple_amp_add_basic_dapm(struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm =3D snd_soc_component_to_dapm(component= ); @@ -133,9 +169,27 @@ static const struct simple_amp_data simple_audio_ampli= fier_data =3D { .num_dapm_routes =3D ARRAY_SIZE(simple_amp_dapm_routes), }; =20 +static const struct simple_amp_data simple_audio_mono_pga_data =3D { + .supports =3D SIMPLE_AUDIO_SUPPORT_PGA, + .dapm_widgets =3D simple_amp_mono_pga_dapm_widgets, + .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_mono_pga_dapm_widgets), + .dapm_routes =3D simple_amp_mono_pga_dapm_routes, + .num_dapm_routes =3D ARRAY_SIZE(simple_amp_mono_pga_dapm_routes), +}; + +static const struct simple_amp_data simple_audio_stereo_pga_data =3D { + .supports =3D SIMPLE_AUDIO_SUPPORT_PGA, + .dapm_widgets =3D simple_amp_stereo_pga_dapm_widgets, + .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_stereo_pga_dapm_widgets), + .dapm_routes =3D simple_amp_stereo_pga_dapm_routes, + .num_dapm_routes =3D ARRAY_SIZE(simple_amp_stereo_pga_dapm_routes), +}; + static const struct of_device_id simple_amp_ids[] =3D { { .compatible =3D "dioo,dio2125", .data =3D &simple_audio_amplifier_da= ta}, { .compatible =3D "simple-audio-amplifier", .data =3D &simple_audio_ampli= fier_data}, + { .compatible =3D "gpio-audio-amp-mono", .data =3D &simple_audio_mono_p= ga_data}, + { .compatible =3D "gpio-audio-amp-stereo", .data =3D &simple_audio_stere= o_pga_data}, { } }; MODULE_DEVICE_TABLE(of, simple_amp_ids); --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 A4D5D3A3E7A for ; Wed, 13 May 2026 08:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660264; cv=none; b=q6Le0pjYDPyXJIKOxjFo83ulHqygFRX30pYBCJ/wddX2c2g67he5+kH7fq6U/OAtQ7Dlswio9GVseGCzPF2jPo6Evs0iG7vBjwoFCZ6s7e1Q3ODtm1/byTZUm1mi8Drpe2HzduTZrWCQdauv/tELRJWVre6X/pET83LLjCi0WVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660264; c=relaxed/simple; bh=i2mY3MVN5dt/ry+r1WOFBuy2erA+7+Hf6qqrifEXYvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fELYmwV2WKvdIOWG51xe+B6DWj6LPgchzEAF6cHW2YluVLfa0RpuDTPXHdE9V/0usOyzBAT1pme9TaMJD/+PjowDhbtJRJ4C3/QrgUGztLdbC9bNF5Ll2KdRdtX2dMVHfyqE+HDElddO1g/fvVib8lAn6zQPbbZQOQcQN/9Ib1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=csEIykZ7; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="csEIykZ7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 309584E42C8F; Wed, 13 May 2026 08:17:41 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id F06FB606CE; Wed, 13 May 2026 08:17:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1076B11AF8D8C; Wed, 13 May 2026 10:17:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660259; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Mm7BvWADy+ZPIcjANv5OqdK0/9vQmIIVPvkzVzXD3us=; b=csEIykZ7leuo8SndF+3k/zs0OSnI8K/cMIu7rSS9bCGbxvM8ELKDZrEv0MpI7esQuWiDKI ez/wjpu3MX4A51+w0Q/MdILKTGHqGB6OwVTLLvMTGtj/3WU/1QwoNbcNztLTuOhvUZ2rMg PyfA16r7uP4lNkKuBtPrGm8zPfzh0iX8foFJ6gVoCbaM8MpKrPcw0g+RJ+FdbVyM9Dn0cZ my8NXVThjJo14YMG96yd4a8tHXR6QcrPqKzWYtvgF125ddmiDDIQ4DOEuDzn3i2F3FafbD eViaDQosRgMrQLtiqFS2UnsGNIsqcLEMGdTIOG2YoTj02leSoHtl4Wqu/sKw1g== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 10/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for extra power supplies Date: Wed, 13 May 2026 10:16:54 +0200 Message-ID: <20260513081702.317117-11-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The gpio-audio-amp devices can use additional power supplies: - vddio, - vdda1, - vdda2 Add support for those additional power supplies. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 85 ++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 1704cdbb7de5..89e7e9e53b03 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -15,6 +15,7 @@ struct simple_amp_data { unsigned int supports; #define SIMPLE_AUDIO_SUPPORT_PGA BIT(0) +#define SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES BIT(1) =20 const struct snd_soc_dapm_widget *dapm_widgets; unsigned int num_dapm_widgets; @@ -127,10 +128,86 @@ static int simple_amp_add_basic_dapm(struct snd_soc_c= omponent *component) return 0; } =20 +struct simple_amp_supply { + const char *prop_name; + const struct snd_soc_dapm_widget dapm_widget; + const struct snd_soc_dapm_route dapm_route; +}; + +static const struct simple_amp_supply simple_amp_supplies[] =3D { + { + .prop_name =3D "vddio-supply", + .dapm_widget =3D SND_SOC_DAPM_REGULATOR_SUPPLY("vddio", 0, 0), + .dapm_route =3D { "PGA", NULL, "vddio" }, + }, { + .prop_name =3D "vdda1-supply", + .dapm_widget =3D SND_SOC_DAPM_REGULATOR_SUPPLY("vdda1", 0, 0), + .dapm_route =3D { "PGA", NULL, "vdda1" }, + }, { + .prop_name =3D "vdda2-supply", + .dapm_widget =3D SND_SOC_DAPM_REGULATOR_SUPPLY("vdda2", 0, 0), + .dapm_route =3D { "PGA", NULL, "vdda2" }, + }, + { /* End of list */} +}; + +static int simple_amp_add_power_supplies(struct snd_soc_component *compone= nt) +{ + struct snd_soc_dapm_context *dapm =3D snd_soc_component_to_dapm(component= ); + struct simple_amp *simple_amp =3D snd_soc_component_get_drvdata(component= ); + const struct simple_amp_supply *supply; + struct device *dev =3D component->dev; + int ret; + + /* + * Those additional power supplies are attached to the PGA. + * If PGA is not supported, simply skipped them. + */ + if (!(simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_PGA)) { + dev_err(dev, "Extra power supplied need PGA\n"); + return -EINVAL; + } + + supply =3D simple_amp_supplies; + do { + if (!of_property_present(dev->of_node, supply->prop_name)) + continue; + + ret =3D snd_soc_dapm_new_controls(dapm, &supply->dapm_widget, 1); + if (ret) { + dev_err(dev, "Failed to add control for '%s' (%d)\n", + supply->prop_name, ret); + return ret; + } + ret =3D snd_soc_dapm_add_routes(dapm, &supply->dapm_route, 1); + if (ret) { + dev_err(dev, "Failed to add route for '%s' (%d)\n", + supply->prop_name, ret); + return ret; + } + } while ((++supply)->prop_name); + + return 0; +} + static int simple_amp_component_probe(struct snd_soc_component *component) { + struct simple_amp *simple_amp =3D snd_soc_component_get_drvdata(component= ); + int ret; + /* Add basic dapm widgets and routes */ - return simple_amp_add_basic_dapm(component); + ret =3D simple_amp_add_basic_dapm(component); + if (ret) + return ret; + + /* Add additional power supplies */ + if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES) { + ret =3D simple_amp_add_power_supplies(component); + if (ret) + return ret; + } + + return 0; } =20 static const struct snd_soc_component_driver simple_amp_component_driver = =3D { @@ -170,7 +247,8 @@ static const struct simple_amp_data simple_audio_amplif= ier_data =3D { }; =20 static const struct simple_amp_data simple_audio_mono_pga_data =3D { - .supports =3D SIMPLE_AUDIO_SUPPORT_PGA, + .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | + SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES, .dapm_widgets =3D simple_amp_mono_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_mono_pga_dapm_widgets), .dapm_routes =3D simple_amp_mono_pga_dapm_routes, @@ -178,7 +256,8 @@ static const struct simple_amp_data simple_audio_mono_p= ga_data =3D { }; =20 static const struct simple_amp_data simple_audio_stereo_pga_data =3D { - .supports =3D SIMPLE_AUDIO_SUPPORT_PGA, + .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | + SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES, .dapm_widgets =3D simple_amp_stereo_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_stereo_pga_dapm_widgets), .dapm_routes =3D simple_amp_stereo_pga_dapm_routes, --=20 2.54.0 From nobody Fri Jun 12 18:33:14 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 7D4E73A5430 for ; Wed, 13 May 2026 08:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660266; cv=none; b=Hm1kjqffIqf0Ya/vUBkHmZSEAvsEsnqvjSOFkAhMdRtOamS1YfWgGzukubBz5/G0E8aAuBjKwFgYi6xmwUW7CU9rQcRwpCcWIuDhrDYX04/5tqtXCGigrxKhqSbU+VjYIabdsrYInV7vvjJLWAZloLU6U+wU4TuH42/q9qeO6rA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660266; c=relaxed/simple; bh=SfKTvet7I9Yd49AwQ0fendbCDIXL4cK54A5ucMc0lbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VEZ6Cr7HimAY+YnGyLFQGZq3es3J/2xR3L4rI9poy8B3qE4YQ7CRksr6AUyefnguIFhbMMO7fRc7E6pIeeMGLNUzbng93yTmTZNnBwq1nWCMtyJ7RYD9LvMuDnDPt2omQ73nDvyT6sHrLeWcccy9nTQoBXGcwx88rwUlvgOsqKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iggvSsA9; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iggvSsA9" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 35BE54E42C90; Wed, 13 May 2026 08:17:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 071B2606CE; Wed, 13 May 2026 08:17:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 474DE11AF8D8E; Wed, 13 May 2026 10:17:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660262; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=8T3355NEiGiFMMQ+Gq+ntvtR7OJGdhXwgC2fxHQznpk=; b=iggvSsA9fRr4v/shwsrgMcpPud3l/43uVVoO4XnLUcYNWR2r87jhrPXwH2I8gTKMfVIkFv DZ6VRFMTspEVZw7Z+Qemcr9aC4orae+ShNLsUeM3tkLdiSUgjvsyTpRsm9fHLuRmisqmxk V5Iw5FYnk9RA773vSKm1nXktUMN2o0WkAHF/1K/9G4KHqMERMN/oHs43qVwKCk/rAJDcdl KssQ5xM7vzEEnatzA3WlDEF21T/wM77pfZhOfRlNIBb5BaqUyGkKoqXQ9sagDA5Yy7q/Zt mMpcm4XkhVx2/iEI98xpbxl0iB/MqtiK9Z9zBZzq+LfkJiimTWcNaP+UdBCOFw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 11/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for mute gpio Date: Wed, 13 May 2026 10:16:55 +0200 Message-ID: <20260513081702.317117-12-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" A gpio can be used to control the amplifier mute feature. Add support for this mute gpio. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 127 +++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 89e7e9e53b03..c8991e340def 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -12,10 +12,18 @@ #include #include =20 +struct simple_amp_single { + struct gpio_desc *gpio; + bool is_inverted; + int kctrl_val; + const char *control_name; +}; + struct simple_amp_data { unsigned int supports; #define SIMPLE_AUDIO_SUPPORT_PGA BIT(0) #define SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES BIT(1) +#define SIMPLE_AUDIO_SUPPORT_MUTE BIT(2) =20 const struct snd_soc_dapm_widget *dapm_widgets; unsigned int num_dapm_widgets; @@ -26,6 +34,7 @@ struct simple_amp_data { struct simple_amp { const struct simple_amp_data *data; struct gpio_desc *gpiod_enable; + struct simple_amp_single mute; }; =20 static int simple_amp_power_event(struct snd_soc_dapm_widget *w, @@ -103,6 +112,78 @@ static const struct snd_soc_dapm_route simple_amp_ster= eo_pga_dapm_routes[] =3D { { "OUTR", NULL, "PGA" }, }; =20 +static int simple_amp_single_kctrl_write_gpio(struct simple_amp_single *si= ngle, + int kctrl_val) +{ + int gpio_val; + + gpio_val =3D single->is_inverted ? !kctrl_val : kctrl_val; + + return gpiod_set_value_cansleep(single->gpio, gpio_val); +} + +static int simple_amp_single_kctrl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->count =3D 1; + uinfo->value.integer.min =3D 0; + uinfo->value.integer.max =3D 1; + uinfo->type =3D SNDRV_CTL_ELEM_TYPE_BOOLEAN; + return 0; +} + +static int simple_amp_single_kctrl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_single *single =3D (struct simple_amp_single *)kcontrol= ->private_value; + + ucontrol->value.integer.value[0] =3D single->kctrl_val; + + return 0; +} + +static int simple_amp_single_kctrl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_single *single =3D (struct simple_amp_single *)kcontrol= ->private_value; + int kctrl_val; + int err; + + kctrl_val =3D ucontrol->value.integer.value[0] ? 1 : 0; + + if (kctrl_val =3D=3D single->kctrl_val) + return 0; + + err =3D simple_amp_single_kctrl_write_gpio(single, kctrl_val); + if (err) + return err; + + single->kctrl_val =3D kctrl_val; + + return 1; /* The value changed */ +} + +static int simple_amp_single_add_kcontrol(struct snd_soc_component *compon= ent, + struct simple_amp_single *single) +{ + struct snd_kcontrol_new control =3D { + .iface =3D SNDRV_CTL_ELEM_IFACE_MIXER, + .name =3D single->control_name, + .info =3D simple_amp_single_kctrl_info, + .get =3D simple_amp_single_kctrl_get, + .put =3D simple_amp_single_kctrl_put, + .private_value =3D (unsigned long)single, + }; + int ret; + + /* Be consistent between single->kctrl_val value and the GPIO value */ + ret =3D simple_amp_single_kctrl_write_gpio(single, single->kctrl_val); + if (ret) + return ret; + + return snd_soc_add_component_controls(component, &control, 1); +} + static int simple_amp_add_basic_dapm(struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm =3D snd_soc_component_to_dapm(component= ); @@ -207,6 +288,21 @@ static int simple_amp_component_probe(struct snd_soc_c= omponent *component) return ret; } =20 + if (simple_amp->mute.gpio) { + /* + * The name of the GPIO used is mute. According to this name, 1 + * means muted and 0 means un-muted. + * + * An inversion is expected by ALSA. Indeed from ALSA point of + * view, 1 means 'on' (un-muted) and 0 means 'off' (muted). + */ + simple_amp->mute.is_inverted =3D true; + simple_amp->mute.kctrl_val =3D 1; /* Un-muted */ + ret =3D simple_amp_single_add_kcontrol(component, &simple_amp->mute); + if (ret) + return ret; + } + return 0; } =20 @@ -214,10 +310,26 @@ static const struct snd_soc_component_driver simple_a= mp_component_driver =3D { .probe =3D simple_amp_component_probe, }; =20 +static int simple_amp_parse_single_gpio(struct device *dev, + struct simple_amp_single *single, + const char *gpio_property) +{ + /* Start with the inactive value */ + single->is_inverted =3D false; + single->kctrl_val =3D 0; + single->gpio =3D devm_gpiod_get_optional(dev, gpio_property, GPIOD_OUT_LO= W); + if (IS_ERR(single->gpio)) + return dev_err_probe(dev, PTR_ERR(single->gpio), + "Failed to get '%s' gpio\n", + gpio_property); + return 0; +} + static int simple_amp_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; struct simple_amp *simple_amp; + int ret; =20 simple_amp =3D devm_kzalloc(dev, sizeof(*simple_amp), GFP_KERNEL); if (!simple_amp) @@ -234,6 +346,15 @@ static int simple_amp_probe(struct platform_device *pd= ev) return dev_err_probe(dev, PTR_ERR(simple_amp->gpiod_enable), "Failed to get 'enable' gpio"); =20 + if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_MUTE) { + ret =3D simple_amp_parse_single_gpio(dev, &simple_amp->mute, "mute"); + if (ret) + return ret; + } + + /* Set controls name */ + simple_amp->mute.control_name =3D "Switch"; + return devm_snd_soc_register_component(dev, &simple_amp_component_driver, NULL, 0); @@ -248,7 +369,8 @@ static const struct simple_amp_data simple_audio_amplif= ier_data =3D { =20 static const struct simple_amp_data simple_audio_mono_pga_data =3D { .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | - SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES, + SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES | + SIMPLE_AUDIO_SUPPORT_MUTE, .dapm_widgets =3D simple_amp_mono_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_mono_pga_dapm_widgets), .dapm_routes =3D simple_amp_mono_pga_dapm_routes, @@ -257,7 +379,8 @@ static const struct simple_amp_data simple_audio_mono_p= ga_data =3D { =20 static const struct simple_amp_data simple_audio_stereo_pga_data =3D { .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | - SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES, + SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES | + SIMPLE_AUDIO_SUPPORT_MUTE, .dapm_widgets =3D simple_amp_stereo_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_stereo_pga_dapm_widgets), .dapm_routes =3D simple_amp_stereo_pga_dapm_routes, --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 730F6388396; Wed, 13 May 2026 08:17:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660268; cv=none; b=b/kqpINGidoUVJA09QcgOueOzd1NXVtz3uP2Ny5/jQAo/FyyUeEAu5P6NfMAQx0+z7eufYJYpCHnSKNDBtReImcOWBcYW3ePjFpCHIF1oQECwqxUhENoHk8scfH8ySIc6CvoHhOfDszSbuxF76Y4492qs1/SoFg/eNN5dT08Xas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660268; c=relaxed/simple; bh=gUxrwcBNZzbsrKxXV7sZfku4ej4L/dvnA/UNMB1jT2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I7oE7USfWCaLqvaC4TJdAtoAQBT6WZ8H+crBIqnjilP5n7mfa1SlPeUGxECvtK/UelraYgkb0dFOXADH/YYaDKOe9iesJBVMTX+h7ibaVDMBEGcXVnRtkqkazozw1Nn7lT7NH2qIkqGiVaB4gpWmwnfvUs5HAZUJg1CkB4tITsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=vWgZWCbE; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="vWgZWCbE" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 851F5C5DC40; Wed, 13 May 2026 08:18:35 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2D3AD606CE; Wed, 13 May 2026 08:17:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 788CE11AF8D8D; Wed, 13 May 2026 10:17:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660264; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Gphw8W9dqzPoUZJg+3tlhGLKbJUVUowdC9hHr7obwMA=; b=vWgZWCbEUgyy9fnd3ngUralRKNQe19iVijkRrK8eM4fRDpMLUvGFsZjgSa+hfFd1xE6nYb EiPBzjZYXBXynAhNt7xAuxooh3+zDW+BJ203VC/9zmKafI8CuomdcbOW+fiBQL27vHuicj Hve14lXA+XKZyE3AEFZDOJ5H7Snize2fg0FSdVkARxF6X0oKunGJuYjzp3WTwtXYZOMHSD Vx/M80n1QB7WIoPSW4A8MdJMr2YD+kLLIkJkScDK+fNel2oBplDB2sYg7fLX2OO4bhhyQR ZYXogSq6y0xZMENq9WBKyz5BJvFpjnYtZYymsS8TeCK3j49nm4VXuyimHdBuFw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 12/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for bypass gpio Date: Wed, 13 May 2026 10:16:56 +0200 Message-ID: <20260513081702.317117-13-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" A gpio can be used to control the amplifier bypass feature. Add support for this bypass gpio in the same way as it has been done for the mute gpio. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index c8991e340def..b9c09a04832a 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -24,6 +24,7 @@ struct simple_amp_data { #define SIMPLE_AUDIO_SUPPORT_PGA BIT(0) #define SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES BIT(1) #define SIMPLE_AUDIO_SUPPORT_MUTE BIT(2) +#define SIMPLE_AUDIO_SUPPORT_BYPASS BIT(3) =20 const struct snd_soc_dapm_widget *dapm_widgets; unsigned int num_dapm_widgets; @@ -35,6 +36,7 @@ struct simple_amp { const struct simple_amp_data *data; struct gpio_desc *gpiod_enable; struct simple_amp_single mute; + struct simple_amp_single bypass; }; =20 static int simple_amp_power_event(struct snd_soc_dapm_widget *w, @@ -303,6 +305,12 @@ static int simple_amp_component_probe(struct snd_soc_c= omponent *component) return ret; } =20 + if (simple_amp->bypass.gpio) { + ret =3D simple_amp_single_add_kcontrol(component, &simple_amp->bypass); + if (ret) + return ret; + } + return 0; } =20 @@ -352,8 +360,15 @@ static int simple_amp_probe(struct platform_device *pd= ev) return ret; } =20 + if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_BYPASS) { + ret =3D simple_amp_parse_single_gpio(dev, &simple_amp->bypass, "bypass"); + if (ret) + return ret; + } + /* Set controls name */ simple_amp->mute.control_name =3D "Switch"; + simple_amp->bypass.control_name =3D "Bypass Switch"; =20 return devm_snd_soc_register_component(dev, &simple_amp_component_driver, @@ -370,7 +385,8 @@ static const struct simple_amp_data simple_audio_amplif= ier_data =3D { static const struct simple_amp_data simple_audio_mono_pga_data =3D { .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES | - SIMPLE_AUDIO_SUPPORT_MUTE, + SIMPLE_AUDIO_SUPPORT_MUTE | + SIMPLE_AUDIO_SUPPORT_BYPASS, .dapm_widgets =3D simple_amp_mono_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_mono_pga_dapm_widgets), .dapm_routes =3D simple_amp_mono_pga_dapm_routes, @@ -380,7 +396,8 @@ static const struct simple_amp_data simple_audio_mono_p= ga_data =3D { static const struct simple_amp_data simple_audio_stereo_pga_data =3D { .supports =3D SIMPLE_AUDIO_SUPPORT_PGA | SIMPLE_AUDIO_SUPPORT_POWER_SUPPLIES | - SIMPLE_AUDIO_SUPPORT_MUTE, + SIMPLE_AUDIO_SUPPORT_MUTE | + SIMPLE_AUDIO_SUPPORT_BYPASS, .dapm_widgets =3D simple_amp_stereo_pga_dapm_widgets, .num_dapm_widgets =3D ARRAY_SIZE(simple_amp_stereo_pga_dapm_widgets), .dapm_routes =3D simple_amp_stereo_pga_dapm_routes, --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 0460138D3FF; Wed, 13 May 2026 08:17:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660269; cv=none; b=RHcMwNsvreNdtM+1nlSrehKqS2G3Pp8CzOCCUB6tDasMH5eg6kNDKAHhCDq5yQnpQkgPwywI5dmKZAbF4Ps9ZK2i6qTMzPc1q+3HObY6YQzutanpVvs0Xah4ge9FrtpMkRLvRO3bHRAOMMhje6jqhQ5hS4GzVMmSEJ3eX/x/QNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660269; c=relaxed/simple; bh=coNR5/Jbbqx4IcynozWQzsdlswDqEUvwsKZ26kLK5ek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EqIaTxDlXYvuPclgcvXAwYfudMayRmOVmnUPf6Lz3dIO5275h3ksG2zdk2bz2HMKFZXeBbQRSQYOtHe3U5u5UipdyRR8W7qiXIV/AuN17lZQARu6OG20fICrNkMcsuryXr/ieYwvyEtppdA19Vibp0t5aitym9wrrBgm3xSa3Xg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=q52HTojc; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="q52HTojc" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 36F27C5DC43; Wed, 13 May 2026 08:18:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D3600606CE; Wed, 13 May 2026 08:17:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8F42911AF8D92; Wed, 13 May 2026 10:17:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660266; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=rLl6sxdapIDMoZ3QKJ3tkcg6Um6vqswgpyatkMA06D4=; b=q52HTojclKQYpXRKVuBMdKffaTPGA8NtYoy2FIvCUI3fwozAGYS8v7gx7S3Ch/JkREi+0N aNYZKSRGqRTnAhOhDSPM29LiOV0JtkRqX+3An+nbcmgi15PMLO9e+CILXj8HBtaVLO8SFT R+ZOt7phb/FoaV7/ZWn1oP3hykBxN9NOX4cctqm+V3fQ7Oe1qorl23Fr4llxX56wQgaS0p 50rDfbNpnSVL+4v9vlkfR++yIAq2CxGJjuYMTmsM4cO6E9zbw5ldvGgnnqznOIe1o1y7ZN Vf6pc+y+DsoN24jVOWSWBKdZfeCBrKKZigtGRi4pWX05maRdrtoG/L1iUilmAg== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 13/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for basic gain Date: Wed, 13 May 2026 10:16:57 +0200 Message-ID: <20260513081702.317117-14-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Several gpios can be used to control the amplifier gain. Add basic support for those gpios. This basic support doesn't include any mapping between the GPIOs value and the physical gain value (dB). The support for this kind of mapping will be added later on. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 125 ++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index b9c09a04832a..5b172e520dcd 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -4,6 +4,7 @@ * Author: Jerome Brunet */ =20 +#include #include #include #include @@ -19,6 +20,13 @@ struct simple_amp_single { const char *control_name; }; =20 +struct simple_amp_multi { + struct gpio_descs *gpios; + u32 kctrl_val; + u32 kctrl_max; + const char *control_name; +}; + struct simple_amp_data { unsigned int supports; #define SIMPLE_AUDIO_SUPPORT_PGA BIT(0) @@ -37,6 +45,7 @@ struct simple_amp { struct gpio_desc *gpiod_enable; struct simple_amp_single mute; struct simple_amp_single bypass; + struct simple_amp_multi gain; }; =20 static int simple_amp_power_event(struct snd_soc_dapm_widget *w, @@ -186,6 +195,84 @@ static int simple_amp_single_add_kcontrol(struct snd_s= oc_component *component, return snd_soc_add_component_controls(component, &control, 1); } =20 +static int simple_amp_multi_kctrl_write_gpios(struct simple_amp_multi *mul= ti, + u32 kctrl_val) +{ + DECLARE_BITMAP(bm, 32); + u32 gpio_val; + + if (kctrl_val > multi->kctrl_max) + return -EINVAL; + + gpio_val =3D kctrl_val; + bitmap_from_arr32(bm, &gpio_val, multi->gpios->ndescs); + + return gpiod_multi_set_value_cansleep(multi->gpios, bm); +} + +static int simple_amp_multi_kctrl_int_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + + uinfo->count =3D 1; + uinfo->value.integer.min =3D 0; + uinfo->value.integer.max =3D multi->kctrl_max; + uinfo->type =3D SNDRV_CTL_ELEM_TYPE_INTEGER; + return 0; +} + +static int simple_amp_multi_kctrl_int_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + + ucontrol->value.integer.value[0] =3D multi->kctrl_val; + return 0; +} + +static int simple_amp_multi_kctrl_int_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + u32 kctrl_val; + int ret; + + kctrl_val =3D ucontrol->value.integer.value[0]; + + if (kctrl_val =3D=3D multi->kctrl_val) + return 0; + + ret =3D simple_amp_multi_kctrl_write_gpios(multi, kctrl_val); + if (ret) + return ret; + + multi->kctrl_val =3D kctrl_val; + + return 1; /* The value changed */ +} + +static int simple_amp_multi_add_kcontrol(struct snd_soc_component *compone= nt, + struct simple_amp_multi *multi) +{ + struct snd_kcontrol_new control =3D { + .iface =3D SNDRV_CTL_ELEM_IFACE_MIXER, + .name =3D multi->control_name, + .info =3D simple_amp_multi_kctrl_int_info, + .get =3D simple_amp_multi_kctrl_int_get, + .put =3D simple_amp_multi_kctrl_int_put, + .private_value =3D (unsigned long)multi, + }; + int ret; + + /* Be consistent between multi->kctrl_val value and the GPIOs value */ + ret =3D simple_amp_multi_kctrl_write_gpios(multi, multi->kctrl_val); + if (ret) + return ret; + + return snd_soc_add_component_controls(component, &control, 1); +} + static int simple_amp_add_basic_dapm(struct snd_soc_component *component) { struct snd_soc_dapm_context *dapm =3D snd_soc_component_to_dapm(component= ); @@ -311,6 +398,12 @@ static int simple_amp_component_probe(struct snd_soc_c= omponent *component) return ret; } =20 + if (simple_amp->gain.gpios) { + ret =3D simple_amp_multi_add_kcontrol(component, &simple_amp->gain); + if (ret) + return ret; + } + return 0; } =20 @@ -333,6 +426,31 @@ static int simple_amp_parse_single_gpio(struct device = *dev, return 0; } =20 +static int simple_amp_parse_multi_gpio(struct device *dev, + struct simple_amp_multi *multi, + const char *gpios_property) +{ + /* Start with the value 0 (GPIO inactive). Can be changed later */ + multi->kctrl_val =3D 0; + multi->gpios =3D devm_gpiod_get_array_optional(dev, gpios_property, GPIOD= _OUT_LOW); + if (IS_ERR(multi->gpios)) + return dev_err_probe(dev, PTR_ERR(multi->gpios), + "Failed to get '%s' gpios\n", + gpios_property); + if (!multi->gpios) + return 0; + + if (multi->gpios->ndescs > 16) + return dev_err_probe(dev, -EINVAL, + "Number of '%s' gpios limited to 16\n", + gpios_property); + + /* Set default value for the kctrl_max. Can be changed later */ + multi->kctrl_max =3D (1 << multi->gpios->ndescs) - 1; + + return 0; +} + static int simple_amp_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -366,7 +484,14 @@ static int simple_amp_probe(struct platform_device *pd= ev) return ret; } =20 + if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_PGA) { + ret =3D simple_amp_parse_multi_gpio(dev, &simple_amp->gain, "gain"); + if (ret) + return ret; + } + /* Set controls name */ + simple_amp->gain.control_name =3D "Volume"; simple_amp->mute.control_name =3D "Switch"; simple_amp->bypass.control_name =3D "Bypass Switch"; =20 --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 3E74C3AE1A9; Wed, 13 May 2026 08:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660274; cv=none; b=a9pbhzhJo0ds7hF9NUqZbG8Ki9zEvjOrDykitx589Hida6wBOzZJCLYqikNwCvi/hXvGu6JOHhtMDQDY+N0qmtJUE0+W709syrmyMdVZg9YBci7fw0+4oTThBpPYnO3A5z0+/g/jVpx0vUhhjGJ6XrXJ+DkcdgWIdEzXbyORaOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660274; c=relaxed/simple; bh=Sv6+N5Zt1O8orZuQwpvNBNZT5Z1+RinlN6oUfSIb6F4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ScJNtHh9OR7kFZK0cObvlhvWaIYlOJQODKiB3Mwexfmdy4uDPUIEUNaZR3eO57B+OawT/2jHjXVqiKFg9GCuQ2eAtSzn+liAO7/3131qw2vFiPyB6sOhWZkGh4KQy19W7Db7xkejdCNiZSNdul0fjrvWy7H51weFQOMwsiTjuBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iT8MTGpv; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iT8MTGpv" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id E56814E42C8F; Wed, 13 May 2026 08:17:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B5D58606CE; Wed, 13 May 2026 08:17:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4B10611AF874F; Wed, 13 May 2026 10:17:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660268; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=l1y3fIm4ahJOfHQ1HJkg+g3roaTNfBGJSD2gCPJQfgk=; b=iT8MTGpv2VXou8NJWCDaocrF8d8oP26S+MkN0t+2kciDn0wXSALu8Xu8lEnG7EoqtVusn5 eaqSxBJpZAZwnCyM9/IIUoJEFi5KK1biHdK0mbfJMBj4YsL4GFNKJctmKUlovWUx7OFS4g IYbUp3L9iib/Gth4Yhp008pQdMXPuhHfxQeYky4X8mTLsWs0Kjsi0mtZLRQ3RJRIF1VMOt ht1/kv+9J+7taZ1BGhr6owHf1Vwpkqo6IMmgjAtkqQOSddwf+0XylmXVS2v7PRYyjWdVW9 wD7t6HyISIuzwoITK2r1HBeZZtFu/ktADc7C9Gh52OAfTVDnIvYK8HWwTyIKUQ== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 14/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-ranges Date: Wed, 13 May 2026 10:16:58 +0200 Message-ID: <20260513081702.317117-15-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The mapping between physical gain values and gpio values can be expressed using ranges described in the gain-ranges property. This gain-ranges property is an array of ranges. Each range in the array is defined by the first point and last point in the range. Those points are a pair of values, the gpios value and the related gain (dB) value. With that, a given range defines N possible items (from the first point gpios value to the last point gpios value) in order to set a gain from the first point gain value to the last point gain value. Handle this description and the related kcontrol. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 317 +++++++++++++++++++++++++++- 1 file changed, 312 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 5b172e520dcd..5759f9bc2f4f 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -7,11 +7,16 @@ #include #include #include +#include +#include #include #include #include #include +#include #include +#include +#include =20 struct simple_amp_single { struct gpio_desc *gpio; @@ -20,11 +25,35 @@ struct simple_amp_single { const char *control_name; }; =20 +struct simple_amp_point { + u32 gpio_val; + int gain_db; +}; + +struct simple_amp_range { + unsigned int nb_points; + struct simple_amp_point min; + struct simple_amp_point max; +}; + +struct simple_amp_ranges { + unsigned int nb_ranges; + struct simple_amp_range *tab_ranges; +}; + +enum simple_amp_mode { + SIMPLE_AMP_MODE_NONE, + SIMPLE_AMP_MODE_RANGES, +}; + struct simple_amp_multi { struct gpio_descs *gpios; u32 kctrl_val; u32 kctrl_max; const char *control_name; + unsigned int *tlv_array; + enum simple_amp_mode mode; + struct simple_amp_ranges ranges; }; =20 struct simple_amp_data { @@ -195,6 +224,32 @@ static int simple_amp_single_add_kcontrol(struct snd_s= oc_component *component, return snd_soc_add_component_controls(component, &control, 1); } =20 +static u32 simple_amp_multi_ranges_kctrl_to_gpio(u32 kctrl_val, + struct simple_amp_ranges *ranges) +{ + struct simple_amp_range *range; + u32 index =3D kctrl_val; + unsigned int i; + + for (i =3D 0; i < ranges->nb_ranges; i++) { + range =3D &ranges->tab_ranges[i]; + + if (index < range->nb_points) + return (range->max.gpio_val >=3D range->min.gpio_val) ? + range->min.gpio_val + index : + range->min.gpio_val - index; + + index -=3D range->nb_points; + } + + /* + * Given index out of possible ranges. This is shouldn't happen. + * Signal the issue and return the maximum value + */ + WARN(1, "kctrl_val %u out of ranges\n", kctrl_val); + return ranges->tab_ranges[ranges->nb_ranges - 1].max.gpio_val; +} + static int simple_amp_multi_kctrl_write_gpios(struct simple_amp_multi *mul= ti, u32 kctrl_val) { @@ -204,7 +259,12 @@ static int simple_amp_multi_kctrl_write_gpios(struct s= imple_amp_multi *multi, if (kctrl_val > multi->kctrl_max) return -EINVAL; =20 - gpio_val =3D kctrl_val; + if (multi->mode =3D=3D SIMPLE_AMP_MODE_RANGES) + gpio_val =3D simple_amp_multi_ranges_kctrl_to_gpio(kctrl_val, + &multi->ranges); + else + gpio_val =3D kctrl_val; + bitmap_from_arr32(bm, &gpio_val, multi->gpios->ndescs); =20 return gpiod_multi_set_value_cansleep(multi->gpios, bm); @@ -252,6 +312,38 @@ static int simple_amp_multi_kctrl_int_put(struct snd_k= control *kcontrol, return 1; /* The value changed */ } =20 +static unsigned int *simple_amp_alloc_tlv_ranges(const struct simple_amp_r= anges *ranges) +{ + unsigned int index; + unsigned int *tlv; + unsigned int *t; + unsigned int i; + + tlv =3D kzalloc_objs(*tlv, 2 + ranges->nb_ranges * 6, GFP_KERNEL); + if (!tlv) + return NULL; + + t =3D tlv; + + /* Fill first TLV */ + *t++ =3D SNDRV_CTL_TLVT_DB_RANGE; /* Tag */ + *t++ =3D ranges->nb_ranges * 6 * sizeof(*tlv); /* Len */ + /* Ranges are sorted from lower to higher value */ + index =3D 0; + for (i =3D 0; i < ranges->nb_ranges; i++) { + /* Fill range item i */ + *t++ =3D index; /* min */ + index +=3D ranges->tab_ranges[i].nb_points; + *t++ =3D index - 1; /* max */ + *t++ =3D SNDRV_CTL_TLVT_DB_MINMAX; /* Tag */ + *t++ =3D 2 * sizeof(*tlv); /* Len */ + *t++ =3D ranges->tab_ranges[i].min.gain_db; /* min_dB */ + *t++ =3D ranges->tab_ranges[i].max.gain_db; /* max_dB */ + } + + return tlv; +} + static int simple_amp_multi_add_kcontrol(struct snd_soc_component *compone= nt, struct simple_amp_multi *multi) { @@ -265,12 +357,39 @@ static int simple_amp_multi_add_kcontrol(struct snd_s= oc_component *component, }; int ret; =20 + switch (multi->mode) { + case SIMPLE_AMP_MODE_RANGES: + multi->tlv_array =3D simple_amp_alloc_tlv_ranges(&multi->ranges); + if (!multi->tlv_array) + return -ENOMEM; + + control.access =3D SNDRV_CTL_ELEM_ACCESS_TLV_READ | + SNDRV_CTL_ELEM_ACCESS_READWRITE; + control.tlv.p =3D multi->tlv_array; + break; + + case SIMPLE_AMP_MODE_NONE: + /* Already set control configuration is enough */ + break; + + default: + return -EINVAL; + } + /* Be consistent between multi->kctrl_val value and the GPIOs value */ ret =3D simple_amp_multi_kctrl_write_gpios(multi, multi->kctrl_val); if (ret) - return ret; + goto err_free_tlv_array; =20 - return snd_soc_add_component_controls(component, &control, 1); + ret =3D snd_soc_add_component_controls(component, &control, 1); + if (ret) + goto err_free_tlv_array; + + return 0; + +err_free_tlv_array: + kfree(multi->tlv_array); + return ret; } =20 static int simple_amp_add_basic_dapm(struct snd_soc_component *component) @@ -407,8 +526,17 @@ static int simple_amp_component_probe(struct snd_soc_c= omponent *component) return 0; } =20 +static void simple_amp_component_remove(struct snd_soc_component *componen= t) +{ + struct simple_amp *simple_amp =3D snd_soc_component_get_drvdata(component= ); + + kfree(simple_amp->gain.tlv_array); + simple_amp->gain.tlv_array =3D NULL; +} + static const struct snd_soc_component_driver simple_amp_component_driver = =3D { .probe =3D simple_amp_component_probe, + .remove =3D simple_amp_component_remove, }; =20 static int simple_amp_parse_single_gpio(struct device *dev, @@ -426,10 +554,179 @@ static int simple_amp_parse_single_gpio(struct devic= e *dev, return 0; } =20 +static int simple_amp_cmp_ranges(const void *a, const void *b) +{ + const struct simple_amp_range *a_range =3D a; + const struct simple_amp_range *b_range =3D b; + + /* Ranges a and b don't overlap. This has been already checked */ + + return a_range->min.gain_db - b_range->max.gain_db; +} + +static int simple_amp_check_new_range(const struct simple_amp_range *new_r= ange, + const struct simple_amp_range *tab_ranges, + unsigned int nb_ranges) +{ + unsigned int i; + + for (i =3D 0; i < nb_ranges; i++) { + /* Check for range overlaps */ + if (new_range->min.gain_db >=3D tab_ranges[i].min.gain_db && + new_range->min.gain_db <=3D tab_ranges[i].max.gain_db) + return -EINVAL; + + if (new_range->max.gain_db >=3D tab_ranges[i].min.gain_db && + new_range->max.gain_db <=3D tab_ranges[i].max.gain_db) + return -EINVAL; + + if (new_range->min.gain_db <=3D tab_ranges[i].min.gain_db && + new_range->max.gain_db >=3D tab_ranges[i].max.gain_db) + return -EINVAL; + } + return 0; +} + +static int simple_amp_parse_ranges(struct device *dev, + struct simple_amp_multi *multi, + const char *ranges_property) +{ + struct simple_amp_ranges *ranges =3D &multi->ranges; + struct simple_amp_range *range; + struct device_node *np =3D dev->of_node; + struct simple_amp_point first_point; + unsigned int max_gpio_val; + unsigned int i; + int ret; + u32 u; + s32 s; + + max_gpio_val =3D (1 << multi->gpios->ndescs) - 1; + + ret =3D of_property_count_u32_elems(np, ranges_property); + if (ret < 0) + return ret; + + /* The ranges array cannot be empty */ + if (ret =3D=3D 0) + return -EINVAL; + /* + * One range item is composed of 2 points and each point is composed of + * 2 values. + */ + if (ret % 4) + return -EINVAL; + + ranges->nb_ranges =3D ret / 4; + + /* The worst case is one range per possible gpio value */ + if (ranges->nb_ranges > max_gpio_val + 1) + return -EINVAL; + + ranges->tab_ranges =3D devm_kcalloc(dev, ranges->nb_ranges, + sizeof(*ranges->tab_ranges), + GFP_KERNEL); + if (!ranges->tab_ranges) + return -ENOMEM; + + multi->kctrl_max =3D 0; + for (i =3D 0; i < ranges->nb_ranges; i++) { + range =3D &ranges->tab_ranges[i]; + + /* First gpios value */ + ret =3D of_property_read_u32_index(np, ranges_property, i * 4, &u); + if (ret) + return ret; + if (u > max_gpio_val) + return -EINVAL; + + range->min.gpio_val =3D u; + + /* First Gain value */ + ret =3D of_property_read_s32_index(np, ranges_property, i * 4 + 1, &s); + if (ret) + return ret; + + range->min.gain_db =3D s; + + /* Second gpios value */ + ret =3D of_property_read_u32_index(np, ranges_property, i * 4 + 2, &u); + if (ret) + return ret; + if (u > max_gpio_val) + return -EINVAL; + + range->max.gpio_val =3D u; + + /* Second Gain value */ + ret =3D of_property_read_s32_index(np, ranges_property, i * 4 + 3, &s); + if (ret) + return ret; + + range->max.gain_db =3D s; + + /* Save the first point for later usage */ + if (i =3D=3D 0) + first_point =3D range->min; + + /* Fix min and max if needed */ + if (range->min.gain_db > range->max.gain_db) + swap(range->min, range->max); + + ret =3D simple_amp_check_new_range(range, ranges->tab_ranges, i); + if (ret) + return ret; + + range->nb_points =3D abs_diff(range->min.gpio_val, + range->max.gpio_val) + 1; + + multi->kctrl_max +=3D range->nb_points; + } + + multi->kctrl_max -=3D 1; + + /* Sort the tab_range array by gain_db value */ + sort(ranges->tab_ranges, ranges->nb_ranges, sizeof(*ranges->tab_ranges), + simple_amp_cmp_ranges, NULL); + + /* + * multi->kctrl_val is the index in tab_ranges. + * + * Choose to have the initial amplification value set to the first point + * available in the first range available in the tab_ranges array before + * sorting. + * + * This first point has been identified before sorting. Search for it in + * the sorted array in order to set the multi->kctrl_val initial value. + */ + multi->kctrl_val =3D 0; + for (i =3D 0; i < ranges->nb_ranges; i++) { + range =3D &ranges->tab_ranges[i]; + + if (range->min.gpio_val =3D=3D first_point.gpio_val && + range->min.gain_db =3D=3D first_point.gain_db) + break; + + multi->kctrl_val +=3D range->nb_points; + + if (range->max.gpio_val =3D=3D first_point.gpio_val && + range->max.gain_db =3D=3D first_point.gain_db) { + multi->kctrl_val--; + break; + } + } + + return 0; +} + static int simple_amp_parse_multi_gpio(struct device *dev, struct simple_amp_multi *multi, - const char *gpios_property) + const char *gpios_property, + const char *ranges_property) { + struct device_node *np =3D dev->of_node; + int ret; + /* Start with the value 0 (GPIO inactive). Can be changed later */ multi->kctrl_val =3D 0; multi->gpios =3D devm_gpiod_get_array_optional(dev, gpios_property, GPIOD= _OUT_LOW); @@ -448,6 +745,15 @@ static int simple_amp_parse_multi_gpio(struct device *= dev, /* Set default value for the kctrl_max. Can be changed later */ multi->kctrl_max =3D (1 << multi->gpios->ndescs) - 1; =20 + multi->mode =3D SIMPLE_AMP_MODE_NONE; + if (of_property_present(np, ranges_property)) { + ret =3D simple_amp_parse_ranges(dev, multi, ranges_property); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to parse '%s'\n", + ranges_property); + multi->mode =3D SIMPLE_AMP_MODE_RANGES; + } + return 0; } =20 @@ -485,7 +791,8 @@ static int simple_amp_probe(struct platform_device *pde= v) } =20 if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_PGA) { - ret =3D simple_amp_parse_multi_gpio(dev, &simple_amp->gain, "gain"); + ret =3D simple_amp_parse_multi_gpio(dev, &simple_amp->gain, "gain", + "gain-ranges"); if (ret) return ret; } --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 B4C503AE6F4 for ; Wed, 13 May 2026 08:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660276; cv=none; b=KMcDxRiTGvw8f4saewmMhgl1o/87dt8YKeuTx5rOpDrMgmKYuaCR0rwNbHXC+A9PZT8VvWBnHdVY5TdPMNhhUFANcitXcGNKmgUioNSnXV4/Waagl3iQDOT+RbUJ5jUiRUIYmDdsyyJUMmWr0h6yuBKmYgNEEyoE0r/mjkJ4XuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660276; c=relaxed/simple; bh=7RnBr5TLsLGnsDGF92yOn/AlHrJ9hozDSpHcJJP9i+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j8I0Fm7PQiKFqHF36XeADEHfXQF/a8UAVZnrTpgV5J9URy4vg4AgsWmKr8GyIJKkKcRcQJJu6pFE3aicUWqM95N43hAcy71Fxkbs79MAbYrun2/e1GyWQivo5DhrbrQ6BiQTFLWs2AiycdrDGRsGES4epOjvc/vY4Dy/WXSWXW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=s+FAjwqD; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="s+FAjwqD" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 3CECEC5DC40; Wed, 13 May 2026 08:18:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D925F606CE; Wed, 13 May 2026 08:17:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1FA3F11AF86C3; Wed, 13 May 2026 10:17:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660270; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=2s4uqu7uODiMgTxxo91RPScrysYHw7RONpKtbJ5dveQ=; b=s+FAjwqDahx7SByBckcKrCrU8RJr3S6+/w/qja0C0F9jkZksPbyBo3gQuaZdCnS7l1X9++ hbuT0CIDhbO41+gTg/Vi2WqIfZfKG/ynKMfW7kKQKo8OVmVODjQ+pX27KqV2fA3Ia8Xu0V 1pZeJBK9xyf/9iWmb1vrobUaBavqvZ98bGPXy/h+jlBjLR0PFZcUnKhhNuwvSxrM/70Bm5 8wCvjSeocdJIiKtdx5SmaMDp8CQwGXfUWAJaBskwz6Fia+ToTe525wsSbR5FaiWXzOHkSR LkAMKo+k7VFrTf0PTgZ49OBpDtyTT1mo7J3fe/05eT3C7B3gPgw6LiJfUxoqkw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 15/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-labels Date: Wed, 13 May 2026 10:16:59 +0200 Message-ID: <20260513081702.317117-16-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The possible gain values can be described using labels instead of gain values in dB. Those different labels are attached to a gpio values using the gain-labels property. Using the gain-labels description is mutually exclusive with gain-ranges description used to describe the relationship between gpios values and gain values. Handle the gain-labels description and the related kcontrol. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 116 +++++++++++++++++++++++++++- 1 file changed, 113 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 5759f9bc2f4f..3785044235bb 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -41,9 +41,15 @@ struct simple_amp_ranges { struct simple_amp_range *tab_ranges; }; =20 +struct simple_amp_labels { + unsigned int nb_labels; + const char **tab_labels; +}; + enum simple_amp_mode { SIMPLE_AMP_MODE_NONE, SIMPLE_AMP_MODE_RANGES, + SIMPLE_AMP_MODE_LABELS, }; =20 struct simple_amp_multi { @@ -53,7 +59,10 @@ struct simple_amp_multi { const char *control_name; unsigned int *tlv_array; enum simple_amp_mode mode; - struct simple_amp_ranges ranges; + union { + struct simple_amp_ranges ranges; + struct simple_amp_labels labels; + }; }; =20 struct simple_amp_data { @@ -312,6 +321,45 @@ static int simple_amp_multi_kctrl_int_put(struct snd_k= control *kcontrol, return 1; /* The value changed */ } =20 +static int simple_amp_multi_kctrl_enum_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + + return snd_ctl_enum_info(uinfo, 1, multi->labels.nb_labels, + multi->labels.tab_labels); +} + +static int simple_amp_multi_kctrl_enum_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + + ucontrol->value.enumerated.item[0] =3D multi->kctrl_val; + return 0; +} + +static int simple_amp_multi_kctrl_enum_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct simple_amp_multi *multi =3D (struct simple_amp_multi *)kcontrol->p= rivate_value; + u32 kctrl_val; + int ret; + + kctrl_val =3D ucontrol->value.enumerated.item[0]; + + if (kctrl_val =3D=3D multi->kctrl_val) + return 0; + + ret =3D simple_amp_multi_kctrl_write_gpios(multi, kctrl_val); + if (ret) + return ret; + + multi->kctrl_val =3D kctrl_val; + + return 1; /* The value changed */ +} + static unsigned int *simple_amp_alloc_tlv_ranges(const struct simple_amp_r= anges *ranges) { unsigned int index; @@ -368,6 +416,13 @@ static int simple_amp_multi_add_kcontrol(struct snd_so= c_component *component, control.tlv.p =3D multi->tlv_array; break; =20 + case SIMPLE_AMP_MODE_LABELS: + /* Use enumerated values */ + control.info =3D simple_amp_multi_kctrl_enum_info; + control.get =3D simple_amp_multi_kctrl_enum_get; + control.put =3D simple_amp_multi_kctrl_enum_put; + break; + case SIMPLE_AMP_MODE_NONE: /* Already set control configuration is enough */ break; @@ -719,10 +774,44 @@ static int simple_amp_parse_ranges(struct device *dev, return 0; } =20 +static int simple_amp_parse_labels(struct device *dev, + struct simple_amp_multi *multi, + const char *labels_property) +{ + struct simple_amp_labels *labels =3D &multi->labels; + struct device_node *np =3D dev->of_node; + int ret; + + ret =3D of_property_count_strings(np, labels_property); + if (ret < 0) + return ret; + + /* The labels array cannot be empty */ + if (ret =3D=3D 0) + return -EINVAL; + + labels->nb_labels =3D ret; + if (labels->nb_labels > (1 << multi->gpios->ndescs)) + return -EINVAL; + + labels->tab_labels =3D devm_kcalloc(dev, labels->nb_labels, + sizeof(*labels->tab_labels), + GFP_KERNEL); + if (!labels->tab_labels) + return -ENOMEM; + + multi->kctrl_max =3D labels->nb_labels - 1; + multi->kctrl_val =3D 0; + + return of_property_read_string_array(np, labels_property, labels->tab_lab= els, + labels->nb_labels); +} + static int simple_amp_parse_multi_gpio(struct device *dev, struct simple_amp_multi *multi, const char *gpios_property, - const char *ranges_property) + const char *ranges_property, + const char *labels_property) { struct device_node *np =3D dev->of_node; int ret; @@ -752,6 +841,13 @@ static int simple_amp_parse_multi_gpio(struct device *= dev, return dev_err_probe(dev, ret, "Failed to parse '%s'\n", ranges_property); multi->mode =3D SIMPLE_AMP_MODE_RANGES; + } else if (of_property_present(np, labels_property)) { + ret =3D simple_amp_parse_labels(dev, multi, labels_property); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to parse '%s'\n", + labels_property); + + multi->mode =3D SIMPLE_AMP_MODE_LABELS; } =20 return 0; @@ -792,7 +888,7 @@ static int simple_amp_probe(struct platform_device *pde= v) =20 if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_PGA) { ret =3D simple_amp_parse_multi_gpio(dev, &simple_amp->gain, "gain", - "gain-ranges"); + "gain-ranges", "gain-labels"); if (ret) return ret; } @@ -802,6 +898,20 @@ static int simple_amp_probe(struct platform_device *pd= ev) simple_amp->mute.control_name =3D "Switch"; simple_amp->bypass.control_name =3D "Bypass Switch"; =20 + if (simple_amp->gain.mode =3D=3D SIMPLE_AMP_MODE_LABELS) { + /* + * The gain widget control will use enumerated values. + * + * Having just "Voltage" and "Switch" widget names with + * enumerated values and boolean value can confuse ALSA in terms + * of possible values (strings). + * + * Make things clear and avoid the just "Switch" name in that + * case. + */ + simple_amp->mute.control_name =3D "Out Switch"; + } + return devm_snd_soc_register_component(dev, &simple_amp_component_driver, NULL, 0); --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 8A4053AEB4E; Wed, 13 May 2026 08:17:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660278; cv=none; b=n2gTfVVdncn5IrBEmdhujQEYBcesWQDLq5cwbh5hH92E4hCbOlNV5givmH0GCLAtpCpMjRN+6+zULjU36iBiOrtNn7d7eUBI68Sdk1jQ7Y+FXiEPcsB/e8vgD84WJkkrrjW8Wyky1lPd7S7kskzTnUJFgPdqko+YrOBVjOjL4Ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660278; c=relaxed/simple; bh=ckDu0VjPC19YRESbBrFMF6uiYeAqa2EVWTd7bagjIX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zw/kUSw34SA0G6a+31fLArYs4MO2ENpnwOvoiUJ+t/vafwm1HswmwEexqcj6yhfbSNqQCEIwtBAqHrMd9rbCawET8SjY9WX6lKY7pcPWAa24gCvTpMSwgUoO2gm3KcG0fxdvX09oyhDk0gV42hUrTCePeI9Uc5Z2GyTDBuhnyhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KuM3Cftb; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KuM3Cftb" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 073C71A3596; Wed, 13 May 2026 08:17:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CC58E606CE; Wed, 13 May 2026 08:17:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1996611AF8CAA; Wed, 13 May 2026 10:17:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660272; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=w6LvO0+ZHRHkRwAR/Nbky+/YGsSj01EgGbCdFr5Zd7g=; b=KuM3CftbB+9QllsT+Qb+M+yR/OQ/6reaVZOR/7ojmsRkaAkKChRoAVuJWCENbN++V4MYY6 rCw/DOJozJHABerqQPSo8R3iu/bLV6ryJG+GBzsfDYCFmQAYvlEGTYElXl5Aro1F21yn2u Bz4ez02PPFCrC9DxlA2K8TiLWA09okA3CMcEj4T/RPwKxRae97xnA24L8CffLU9ng5Uv4E 0SgRW9ZXoRCMuE9nYNlVeVM4Kh653m00BQRdo+KiIXJyQH1q4QdeJMnVauGk/u3/xM9w7F k+ErLz5qzVzAPGzXPSyiXhJEsumZ32sZxTWedcNPeT6/HEk5X6h23zD28ToAfw== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 16/17] ASoC: simple-amplifier: Update author and copyright Date: Wed, 13 May 2026 10:17:00 +0200 Message-ID: <20260513081702.317117-17-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" After reworking the simple-amplifier driver and adding support for gpio-audio-amp in the driver, add myself as the author of the gpio-audio-amp part of the driver and add a related copyright. Signed-off-by: Herve Codina --- sound/soc/codecs/simple-amplifier.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 3785044235bb..ca0e6ce8cc37 100644 --- a/sound/soc/codecs/simple-amplifier.c +++ b/sound/soc/codecs/simple-amplifier.c @@ -1,7 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017 BayLibre, SAS. - * Author: Jerome Brunet + * Support for gpio amplifier + * Copyright 2026 CS GROUP France + * Author: Herve Codina + * + * Basic simple amplifier driver + * Copyright (c) 2017 BayLibre, SAS. + * Author: Jerome Brunet */ =20 #include @@ -967,4 +972,5 @@ module_platform_driver(simple_amp_driver); =20 MODULE_DESCRIPTION("ASoC Simple Audio Amplifier driver"); MODULE_AUTHOR("Jerome Brunet "); +MODULE_AUTHOR("Herve Codina "); MODULE_LICENSE("GPL"); --=20 2.54.0 From nobody Fri Jun 12 18:33:15 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 5939A3D34BC; Wed, 13 May 2026 08:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660280; cv=none; b=uv8AbejX0+8VUO2co6QGcDvE+EhFmMiB/u3u/3SaENw/Pq6oVfcImwLLQknvtd50t0ihAg9kBAFAk3+62QfifAeGawyAIk/ckpSmk2qaWLqU7/JqGGDf/AF9VpArmhTIAFmwjsVk7Yj5j/bAXwxwrL97skBYVTlAkS0wOk3lmog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660280; c=relaxed/simple; bh=Btr4nQmLXXWnsSVlpqZj6eOGRhJwONNf5L78xXaL/CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aUHuKW+iLJgtrnDR9HpA9y+MJ6yOMXaNREGNc/0pBCmjUqzniYFqXt5Tk9ZV1D1R1hTUxClLwLH848qtNRGBcnwraNb5T7wxyfcocss+IYd/XgWK3faQOmCpkz7IAlLinj1+JcZ8+6PrvunLdcWL8Inp5BHXpVfh/pNiy0LeyBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=keLpunt2; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="keLpunt2" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 3540EC5DC43; Wed, 13 May 2026 08:18:46 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D3303606CE; Wed, 13 May 2026 08:17:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2D56A11AF8D79; Wed, 13 May 2026 10:17:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778660274; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=9DkunmCE8iFG8EgIMG24p8g3IiipYmtACWmSbuVG/BA=; b=keLpunt2nAo+4qdG+waAPwoq30jcXf4oghMW1X2czGpTHHYzhm1WmXHSgsTQP9H58d1Fx/ MSFjkQKcA/pvxSM3jO7BAzE5UtmqNldsiYXedesaaRTqTkr56neO5KRDhGbrU2k4z3vWci IzpltGHttRSAPB5Ac/VdaURqVssw0rGvLzGmPZWeKsZfLLb89OYTF/o6H+43pFTZT0oFZc R02HAEM5BuJplXXt+HTn7/JX4eBgxZABDsQLBeqPT6+4im1nq7/o3N2l9QqHfZuLF5op41 e2OP993LCEX6R2D9PcjC9YhnmXkrsJLKKb0GHJiQI4srE1RcKWYXxl5Y7dqc6w== From: Herve Codina To: Herve Codina , Bartosz Golaszewski , Linus Walleij , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe Leroy , Thomas Petazzoni Subject: [PATCH v3 17/17] MAINTAINERS: Add the ASoC gpio audio amplifier entry Date: Wed, 13 May 2026 10:17:01 +0200 Message-ID: <20260513081702.317117-18-herve.codina@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513081702.317117-1-herve.codina@bootlin.com> References: <20260513081702.317117-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" After contributing the component, add myself as the maintainer for the ASoC gpio audio amplifier component. Signed-off-by: Herve Codina --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2fb1c75afd16..4bd360f7aa80 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -24985,6 +24985,13 @@ F: include/sound/dmaengine_pcm.h F: sound/core/pcm_dmaengine.c F: sound/soc/soc-generic-dmaengine-pcm.c =20 +SOUND - SOC LAYER / GPIO AUDIO AMPLIFIER +M: Herve Codina +L: linux-sound@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/sound/gpio-audio-amp.yaml +F: sound/soc/codecs/simple-amplifier.c + SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT (ASoC) M: Liam Girdwood M: Mark Brown --=20 2.54.0