From nobody Tue Jun 16 20:35:36 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 1BAB73A5E84; Wed, 29 Apr 2026 07:44:12 +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=1777448655; cv=none; b=IWC4Qred7C1RaQ3JzRxyUlZr1Se9zAKKyx5xZs9AEMFZp3FysAJh1ZhTvmLgI2v38DvxkmwmBWzyzfl8PB5QzF85jHq7clhmVnYB/cDSuaF+Z1EkWLqiRhjy5ACMeoWzrGMYoLE6qVPHEePopyfCjL3XxBsXqCyHSVP82hMDLWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448655; c=relaxed/simple; bh=Rec6tKdlrPie2YlW6IezIVTsdvPBR7mcFyVSswWMX0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5JmYF1MctMOwOoIhpkryuv8++Wo2/StJMrL6vddh2++FeI0G/GOT9JaQvq2oZa9vTkzdMsEMijE+3Y3WlodOo2GFz/Fc9AxH2yQ3dWSfqZSXM8RtwVNveIm1Nur7nAo12EPrYG6m6StEu+RKKUrC7svJZDw+ofA6y1BfH1EvKA= 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=PIJvxGis; 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="PIJvxGis" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id B92961A347C; Wed, 29 Apr 2026 07:44:11 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8D29A601DF; Wed, 29 Apr 2026 07:44:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5F4C6107294F3; Wed, 29 Apr 2026 09:44:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448650; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=bwLke4Yv7KiuA2B/0DRghtp6oBFzx2igNOWj+w+dOh0=; b=PIJvxGisdsGvAzSxK2T43Bmz8JUXirJtXhy7qRFGf6maQ8Kj2NLVxMwQ3xvjoGjHgZGFiB MrWY/QzEGDVqBcCDazRX1pA5blLqwEakIYLgOfcpq6i3Zz+y1YuPIqc3jsGG43RPHo7v5M Q0bdSIrHLkzQtxPN/uTJfS6lV8U7/0pDf/Z30w2kMHBjYtGTeruZVjUGloJ3TROn/1kSQ0 zCqWggh31i/fHtzeIXhtGEXAJW5rYluUuUW1+USNnRa4IxCTUYGiqOQqiMSVX3AEKwhtA6 J507UAVZBa2f2EdtoYlvXgWAtOAN03mspjS/f4o9XKC2l7gwmfiRf9BmqviZGA== 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 v2 01/17] of: Introduce of_property_read_s32_index() Date: Wed, 29 Apr 2026 09:43:37 +0200 Message-ID: <20260429074356.118420-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 1EEC93A6EF1; Wed, 29 Apr 2026 07:44:15 +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=1777448664; cv=none; b=aoDwQQvgB8dcy5A9LqwC4tPGbu+IU+2MSFygvp4Q4OVtLHryNei00NBsEDzi9qU2sDbW1xkAuJr5iqpk0BRHjNb0eShlGndPmJLVvHKGiMAcZresw+GWBdUxIY12avIbMcdwqbsaBbW7PzD2p6Vxh6UpqnGvBDRmkDwNvLESni0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448664; c=relaxed/simple; bh=p66r+zCwkOwB1S0QW0mE5+VDJePu1ZvrY2w3dA98YBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oUWK3Jg3QspK5ezVUbQWpKj1N1rZMwl+lYoJSuPCoH88mHFsgkLk1+0C9WuD/067A4Ym6hnEM52xNGLtxGubdKqJZ0DtJQApB+ubs5X/BURWZaqCEBD64EaU84T7Gv6WduqF7SeFHFn2pReRUGk6eq2x7rvA8tLmBx0FIhxiUpg= 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=fBvQl4xC; 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="fBvQl4xC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9F9A71A347B; Wed, 29 Apr 2026 07:44:14 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 746E4601DF; Wed, 29 Apr 2026 07:44:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3248010729898; Wed, 29 Apr 2026 09:44:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448653; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=IxcuUJb+ByJPJw8uSLEtbL63MS3PIf1zV8Q9uCPz0+s=; b=fBvQl4xCao0eGGnMmPG2s1DuPaxy2W8fEM20BESEF93T/oo5E8tSoEmE3jZ3gbhYXk5DCP X5D56yJQMOvAbm+wQbTZFDHXGglNqq1DRQWeLjDfXodjgu8PTBMlrSVFYdlc4WwcR1jC2f zwp7o7O+Cj6d1rnQvRX3K6Hbomzi/KQcuarx8Zid8lQn8p8CPseWlU7V1GIo6bMczV3rkn hBE2K6YtF5rzxMRoh1vyrw1vqlDznRdci6PR3TxjPTGWQlXva5ERKzHmERzBOVFOizPdBG WzyKSiB2YUVac0EjVjR+p17J/fh1M76Mev/T7lohOgh5H7jCadPyvYcITGZ+JQ== 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 v2 02/17] ASoC: dt-bindings: Add support for the GPIOs driven amplifier Date: Wed, 29 Apr 2026 09:43:38 +0200 Message-ID: <20260429074356.118420-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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..46f99cdd2a97 --- /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 rignt). 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/uint32-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.53.0 From nobody Tue Jun 16 20:35:36 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 3D37A3A75A0 for ; Wed, 29 Apr 2026 07:44:18 +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=1777448664; cv=none; b=d6reHnSVdONWz4jnrWtAmj/fpPjgM6sexf5Jb7B36ICCHTpyzEbJwZgZmlHZGOpkAJEqmacxcK1y2ZqfG52cY+3TV/aO25dMznclucyDgJaivIT0BxLW/RSjakN/ef4K0YAq8Vty4NNRf+Iov1G5AHbaj8awnSacIFbIkZ4EMSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448664; c=relaxed/simple; bh=ReWwt6iaMYqdtIPhdkJViA/sCiJQgZnX+BqD9iMnbMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gp5ui5jlnGaF18tQCUY0lu7LXnsn18WY49zXg1q00/MdbECb3P92LSWxtHhDcP2lQeUHGUh8SZ0z4yjhIgeMM652gQGHOCAtZSPL3kD6H6+UykJqPF8ZAFpEp6AMrMDb151AZnxdMpKEpiGFmDrLMsTquAADubz6x6pJ8nZgVy0= 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=PIFscuU1; 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="PIFscuU1" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 09529C5CD5A; Wed, 29 Apr 2026 07:45:01 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 08258601DF; Wed, 29 Apr 2026 07:44:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0246E10728FEB; Wed, 29 Apr 2026 09:44:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448655; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=6b9GO4bt3gqfGSPPpPA2FX9bro+DbzrPQkDmfCWkm78=; b=PIFscuU1858CKMRFpyR3RpLpfM/ZbZx2g+q4gAhNF8lcixKRASq1/ZFF4ziBv2caVTSE7R pdspwggAeFXbPoq4KyIczhQuW1zVZYmnkT8n9aAJe+vT00Tj6/x1Yw8BOLwodqT+dfGbR4 bvF7xNjtMdRi5w7FWuQcrv3g1l8meYVmrQGL1up2snoF2DGN64Z+iuhonlfOPC/j+4o0/U 8qjn8g1MpPF6i3327C9fxX+YVSsjLIEnYfzhDaDEFWPu4cKQyOHgsUHOshPeQQDvRmF1j+ mBMGeD9rW4SCfOlnd1YBMzB4QunW2oAiowdfgkQlVzZcksrTdKaLxhLzmU/k2w== 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 v2 03/17] ASoC: simple-amplifier: Remove DRV_NAME defined value Date: Wed, 29 Apr 2026 09:43:39 +0200 Message-ID: <20260429074356.118420-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 922233A6EE1; Wed, 29 Apr 2026 07:44:21 +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=1777448663; cv=none; b=Jy7yozETjWCN8utynEcK2kPO+5SDaQGdbMVmJTu2NR5fe88QuMgaD1R3TMufyBAZYePIn8hEinCuljoByuWcAjMjTwiV91Uy2HBn050erG6CsE37cn5H61yvxBcMlX2NvLzeaxl9QRyy0AO3dIT709J2uNAeV30VIMpOrxU66lA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448663; c=relaxed/simple; bh=/7MK0+7D2zQ9okqF45iERYyWi2zb50kZTdI6f1eNHhA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ji8AYHpMHH9GlyU5OsTbXD8Bbku3AD17CUtSdfTAUPAhv/JTxreYzBvKHrsFptn2Bj7WouRg+dQllZe5DxdrU7DsVlVG3vQOoz3unBEhc5OpToNXyomA+Vy23zuHRPAoqp7SvBw4vqpC37lsJemNi0VyQe3J8MHRhH1pmpnnvJc= 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=rIY51K/E; 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="rIY51K/E" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 0ABF0C5CD5B; Wed, 29 Apr 2026 07:45:04 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0A030601DF; Wed, 29 Apr 2026 07:44:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 715D8107294F3; Wed, 29 Apr 2026 09:44:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448658; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=UpX1RydAe9Wy6x8sEQ6RoP1Wnj4DBzp1DQXcqrkR8BM=; b=rIY51K/ELMp4p01WgmvPG8AmU93dnznt1mattjfCZwSjFIFGGtKqs5QJ+9fvC8sPoPMFCb FC1szJqbK1VMyhGteLyw1fqHeDwohQllqI3tEGwC6GZeV3dhB8YH98vOWZFzKJ00XM51Bu pCP+l9WBAS7Fivhu9OWTQ/G4Ebq+uOORYjW8eLD1mjKJsmo9m6RQPV8cJhTNoig4xizvNV Fqcl44z6ZNjTLo3cjfvWqQOoqQk41+c0ZFQ28KsUBR59y6W2UOOZ6NJ9SrwvxhKzYk0kbU hXeToX+7Ghonvr/V/c1nGX88jvN9sYKOtZn/beHroehUE7/K3dTRIhVPlZ+PVA== 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 v2 04/17] ASoC: simple-amplifier: Add missing headers Date: Wed, 29 Apr 2026 09:43:40 +0200 Message-ID: <20260429074356.118420-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 3869B3A6EE0 for ; Wed, 29 Apr 2026 07:44:25 +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=1777448667; cv=none; b=j/3GY1jgpbhZwuEwA4NBKIXWuHId8cUb6nHuisFT9p7sQ0F+E6mRPGY5dyVQq9YlzSQ3ofctzRAgheooU/etmt96u6+bLrv57Mz5+NoEHqUXDzeop/790SZe9CfFxLYzStYnlG/a/vxlhMzru9qU2IuFTfYsHhjXYX+nx5+4/wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448667; c=relaxed/simple; bh=XB4PAC9+Xt1SlGkK8fa2uT700JX99DgEJP/N4cZVx6I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ai1Up+hlRA2/1X8P0mMeAXApaSpyk1/XUBMO6r8vGo7K8+Fm3tPzAWDdY47Jx6hnLxmVqO1XvLhdSzGw527pIrRuC0p1TWcngRM0HbKx9HFeaDd1vaXdOmVQzeti4XTMWlWrsi16CPqasN1bpuLlBQWp26ig6Hk9mgPishZ+dp8= 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=1X0M2PKq; 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="1X0M2PKq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id DAAB24E42B69; Wed, 29 Apr 2026 07:44:23 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AFF7E601DF; Wed, 29 Apr 2026 07:44:23 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8490B1072988A; Wed, 29 Apr 2026 09:44:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448662; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Ao/Ge/7pzeYgeQwu1DzSFkfa9mVgrNeq6YT9C0YLJQ0=; b=1X0M2PKqVM0WS0MleB02urqi7GBYeGMCv8SJ5CPt7amRZfcFD4QlAP5AAXCfjV0lqjvig4 1A+ju3PTz7wr52GBXbUnkg4h8/rqBdUgUWgp9DKvbU464x6iXf7NMy/ETWsFaMJBMcVNOy IA8Y3RVL76ZNeGp3aItjB0mJ5Gw87jMYgngLbHBzaq7kbr768lnm39unfmEWbja9lQdTdQ 89PTgGUwhzmZH/S1/lH3pf5E7M6AFj7cH73aXUM41yGxxempLqTGC5+Ogsnr363aujRXG8 gOQaNrf5CpUgka9fFEZtD0EwGZVd/lWjJ3BX/Wg3Dhvwr3IK8Z2uocA1YhF6pw== 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 v2 05/17] ASoC: simple-amplifier: Remove CONFIG_OF flag and of_match_ptr() Date: Wed, 29 Apr 2026 09:43:41 +0200 Message-ID: <20260429074356.118420-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 C857A3A7855; Wed, 29 Apr 2026 07:44:27 +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=1777448671; cv=none; b=bUygwhcB09PBCqexKZs03fTpXkJMT0OsN+bm2WJ8mcN+KBD3roJstXRqbgICxGwpKTXfg17KXAgXBIS8WI47Iq+IiiUeb3OTgJ+O/KCt1KB6YvLEA4+k8GPpIJMt9fvtEINz+NZmPMhRj3Sh7yP18pMU01TszwHOl7grIGMh67o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448671; c=relaxed/simple; bh=Hgc2uiWzscD7t/E3wgC9iKLt80BoqxNLjQKgfvNVCIU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AP/eQv85hlcdlDwsHOtqwAanVW/jjrkOIcXt9cnKYaq/9qi5VcxbTVJ09Z7lug0nM9ZxqTLssHfWAazWUhCL/rRFEunLjGS5JVuPlHjF8fIwMKbv+5trO2+wEqwXsqSdV+hF88ztUddESA2UpaHKVGfKza1ZjU2t+fmwKqlwRdY= 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=Ex7TX76q; 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="Ex7TX76q" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 490F3C5CD5A; Wed, 29 Apr 2026 07:45:10 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 46DD7601DF; Wed, 29 Apr 2026 07:44:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 05BCE1072989B; Wed, 29 Apr 2026 09:44:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448665; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=MDWbndD0MDPCeru1OfQ7pxS5JaPa/gaaif8SAMi6MO8=; b=Ex7TX76q53iLj9ujUT51zN0Qh4luveldr+SCzvFBKzPk0pxUbJ9tym8dYPN0eLkpls5l+5 tvgvDGj0Mw1A7GKs22CJkYamdYqC7uqJoQmKId9yQnUbIeUy0btJaVAj71NGfsLGAyabVR +86P6V2c7klbQK5bhCSPVs5wRhmF8JX+lr3xHQHqrQyLS7gcR3QFvzWlEigfPCz3+UXxV6 xpdsSf3Q6rba7izjZypcAh39pyxZnmVR59QWACIxj8jCx5MH4uMczTOtnf0greIesTtPZ/ ynFrdhvZkwW3U/Oa3h2Wm09cSUBWK0wEzKc8mSq7jgcvc2x4mbm2+GUrH9Tjfw== 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 v2 06/17] ASoC: simple-amplifier: Rename drv_event() function Date: Wed, 29 Apr 2026 09:43:42 +0200 Message-ID: <20260429074356.118420-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 DEC3C3A6EFA for ; Wed, 29 Apr 2026 07:44:29 +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=1777448672; cv=none; b=aO/zdcsnWskE7Rx62YKlLX+0b7LBFhPGT7NQlebiocrVjaXSihMrCRNkDfQYALCtbWtQAFSAOcTEwIAZAXgxS87KvIvyDu1VNVRMaXm2WbNbnrugyhap/q1UA68pwDZEz1N1sxFjcS309uUxtkQELFlhztHAYR5wEySKV3AiwN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448672; c=relaxed/simple; bh=ocoaZh1cfN3aM3Ass44A1Z0c1a33deHhsbOrm3iYaRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j7LJhjTm8YaLNydw44Gy/2QisGaPZS+G79/R0KYrxSGZ94g4SDVmfvIMmI4Lm83Lc8Qw2mC8CNzQyigKvD4fcB6FHn0nqahTfeC61sw46BdD7x9rLT3kkx/SNPcswgoM/Sf0Xb8OqizBPaEuOFaPcQMQejRWkkf3BG+w8LR0roY= 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=OMPRdntW; 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="OMPRdntW" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id A0321C5CD50; Wed, 29 Apr 2026 07:45:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 9F346601DF; Wed, 29 Apr 2026 07:44:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D7E0C1072989C; Wed, 29 Apr 2026 09:44:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448667; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=ZItBdljHzkyosd2r0ODxJgNw6WPrkERIedKn/xuhEJA=; b=OMPRdntWiyAyoWbGzCBhPmxo+OOwTGzKBUAHyCLhOfiG4Z9hiZOOmcGfYIv0spjdLyfxl8 wBUaQeDTKsQGblyVw46Q9hs2H3xsQtCcGoDxjvh/xJTDWJn6Tx2/H2++eo5pRq096mDqJ6 pPPALyVi6nxjsl+DApW4K5TLbACqLlQUcbbzyH1E0Y+srlTnbuV/sTlsDEAmyodbHFtNna ttLkvVbsETBtME7+1i9Ez7DR899CfNi8tti1I1mRp5Uk3PuAU1Qllzxt0mZFXPQmsvZ7aU k3Zql/ut6gHhsg3TzLRtnoFAlRXce1nq5Xj4yd6+KpOz/j1crUxqreBdbGzOHA== 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 v2 07/17] ASoC: simple-amplifier: Use 'simple_amp' variable name instead of 'priv' Date: Wed, 29 Apr 2026 09:43:43 +0200 Message-ID: <20260429074356.118420-8-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0 From nobody Tue Jun 16 20:35:36 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 9CA233AD500 for ; Wed, 29 Apr 2026 07:44:32 +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=1777448674; cv=none; b=Rv+iFm8Mc2jT0/xuf4PKC6Op9GCOX0mVzqeLR9KSGIqV5fCZcjh9YkcNTftnKbiPSJe0oDzu4hnYFC3GBAjlZf1ECo5Xijtj4FKEYxPfmYEloeW2wKWKOVH5vD58Rtu/hpuXi6foxUmGuyqzV7lWQO1c9dAmrev1NWf+nPVvLtA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448674; c=relaxed/simple; bh=vVKKVyKp/qwA8AdVso5ibgvuvR7GBzwqC4CkNXDx9wg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vo15faFGJyRnS64W6/l9oSgA8U0q6ffBld/z9cM/h6wTHjroSTxzqDd9ehPzinqmDl+scZKxxiiTc49VsWM8HGO3Ldq1+LJOy++2yddzn38LkNrcBacKyLfJqp6VX4dorv3vXDw02b0cPqpm4byrlGShVm3dCHRsKRZl50zsWoI= 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=AT29UGus; 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="AT29UGus" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 167F3C5CD5B; Wed, 29 Apr 2026 07:45:15 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 15C14601DF; Wed, 29 Apr 2026 07:44:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 22AB51072989D; Wed, 29 Apr 2026 09:44:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448670; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=IImuxyRt4AUe1c5zMGGQ7zAe+xjD+QDQeQvNd5COxME=; b=AT29UGusHqPwkfJDaIZCZYwes3PUpu85Q+HtryPhqc4Gl4PSZR7+J9xvkUG18/JbzKPXp+ vKioYCc0VghPxQd9SGYXucl7ULQusW0q49O9BUmRiqq36sJS7wPvs48fgZws+A8RZiEyr+ UgevavtRFab0NWneW2W6jxkBs8mcPKyizBvrmGU7EUpKZyUvRp4NZ2Qo9PQuyubIhp8I/a krSCDxNXSn8wJm6j+t4xfrNknz68ESSg55WAC+mtljrreuDmdyZrMiFmexl36hpPJveguq u1aW7vs2GFxPcJfsjaLGbea7kpbzEfMd9hIlnJcIsSc9JIBqcjHf6SFNd4SgDA== 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 v2 08/17] ASoC: simple-amplifier: Remove DAPM widgets and routes from the ASoC component driver Date: Wed, 29 Apr 2026 09:43:44 +0200 Message-ID: <20260429074356.118420-9-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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..a70f70566340 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 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.53.0 From nobody Tue Jun 16 20:35:36 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 760803A784D; Wed, 29 Apr 2026 07:44: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=1777448677; cv=none; b=UHYfG6ev/EwexPKmgei4NS6lWzYIPFbRoknCuDT4FJYmJ2RGy+Lc8HIajx7XABjp6O7LaVY32wJkovP1JQivdrsOYwxW1G6bxXnJ4wPOc+rJelcM33m+Af0FmX8pUZbYWPTx56HOpjiy9Ch+T1FffuPp3ejBJBJ+LEF7YriMWsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448677; c=relaxed/simple; bh=qG4JoL193VppkbzCeHx7J7tia7prNvgEynGydiAdJB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fD0fumzQp0iLYdVzYs8FNtYhePkKl0CZX9TUszfkD9nYr09hzOXgMQWMevhpE5gSbVc0KzKICAV8JAq+FDLamDkjJL5TWMX3k6In3NGxHs7uCwQ7MVnhc8vJpa0qCtrvjSbxijuGfkc0iGXjzaVUuYzKJGLYCHvBRZFxKQkwRnw= 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=XLEEuTe/; 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="XLEEuTe/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 2D4781A347C; Wed, 29 Apr 2026 07:44:34 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 023DF601DF; Wed, 29 Apr 2026 07:44:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 9BEA7107298A1; Wed, 29 Apr 2026 09:44:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448672; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=luaVjD7OW5gT2xj48rg1oNvZJhOyOblcokl5JE/AWQY=; b=XLEEuTe/IjF0b/Y4jPrtn+/VwYvruqQ5l8nZg4Dqe2tQSgkChhlw3CCC+7JWa2yQkiRbiA Fgt8RtLTOpDklcO4DGI4+pm6K8py9EFbjvNIxanizBpSmU28ptVMKx1Ae2fHuBzKqXMFT2 Zd0HfrRJRF7eGr0OISC9JwSHFbGV76G5q1gpiRqxtDLZ/GrmQ0Ehc2a5scJ/UygQ7kK/rO Kpgg0vPKZEQ42z4dIt4MSoMeM3B+F7tEkhxO3RbOeCPxzZ1C56Gu46RBgl52WxyzBTvItQ NKQ67oKSsrToRNhOHBuAjX9GBnM6vVs+TlUikVd1+sXskZf1JMXSP5+8Fn27gA== 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 v2 09/17] ASoC: simple-amplifier: Introduce support for gpio-audio-amp Date: Wed, 29 Apr 2026 09:43:45 +0200 Message-ID: <20260429074356.118420-10-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 a70f70566340..ab4fa074603e 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.53.0 From nobody Tue Jun 16 20:35:36 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 529863B3888 for ; Wed, 29 Apr 2026 07:44:38 +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=1777448680; cv=none; b=uhe8ScW5GKzZpi1SsCekKaaAZkyCBjS8mil91y7Dfn2zuIkGfTQzoXTIAv462uxJw4O4H+lcFN6R+546v8Nwk9Q1Nkq4wHEqPFKIwJHjr9wkAiPGPDdM0q2lzvpxfL/3YpJ6YBpZ+hEIl1TvGBD1e5RbH3R6tOsjkXQMKn2hWbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448680; c=relaxed/simple; bh=Tq9Zm5cc8QAyn6CoesgnMmrTCJ/2c3DE+Za8nxun/8U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VsmAm5ibC+K+x4++2afxwyayxiKW3R7VudIXylZ2UneUDkWkC4GF96hY1XvMoMbKtKFEvqEX9N0NOBRlhLFkhuiiIacBiFtej6mMFR9liuiK1k9jbnpQRP5XivlxTPtkfVF0Bmv24tp/HC6OdBGuFn758KR5oQxDCYZ7mxG3Fus= 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=c2e5JnIE; 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="c2e5JnIE" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id CF2731A347E; Wed, 29 Apr 2026 07:44:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 92AB3601DF; Wed, 29 Apr 2026 07:44:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 95089107298A3; Wed, 29 Apr 2026 09:44:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448675; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=zPHbeqWn73H0ZvBSUfxN/4jGBDJpeb4A0vDFShhp6ms=; b=c2e5JnIE2JY6xEja9UFUxU6quTMyEyqNo9/zfoufj5HupML1SsqzN5qsmpRrxEhH4X0FPs T8hw5uuF52aikZWOzkrgWYFqbJPoMGl8/B1Ua5hmdllzS0U3+5DDutsI8tmIj7W1kj2r9D Lwsi6PHU18jOzUHPusAsVmcAvd2ztkG58RrPAh441Sd1OWjCO+L4N2m7s3F7SgNJLidA80 rUkmp6RfXxUco8E/D2+qRGSwGZq4RYz0+1lUfGCJRwb+H+VJwF0jC72rka+DPNT0f5h1sQ swPdmNdrKXsBZPHSKQDUk80ox5OgH20WBAu77N4kUH8EQ3St4FCYIr9anZ9GUw== 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 v2 10/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for extra power supplies Date: Wed, 29 Apr 2026 09:43:46 +0200 Message-ID: <20260429074356.118420-11-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 ab4fa074603e..537731996544 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.53.0 From nobody Tue Jun 16 20:35:36 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 C92A23B4EB4; Wed, 29 Apr 2026 07:44:40 +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=1777448682; cv=none; b=XVU5GcUgHHKYwCYjaDOGjD2ToJdTaxV8i+JSMART6iOiBqLOzbRhiQJtOnm8cuBuIJSyZuHe18QEnpsUNxeah9meoeA5LpLGZOno0N7aUOk8yQ7riOxUGbZjjcs8SdjMi46xawnaBWb9+JbnkXQKCo0a+vNGnM0eJHTGE/EfqL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448682; c=relaxed/simple; bh=96M87psX4P0J4QLuFDJoFjKutTQlszkl0O3PgUCYtyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0N/HLYvJ0ACWTCMu3/LK+jEve5eWh/ZdQdlp8oMsLvax7FoTq9kp2/Jbo0y80/ffxNtsoxZowhD0RfE9+QXNwACgISO6UoNVTIwWXcK86m532++zZLTiwZ77KXrxJ5gVVZQboOErU6M5de0aCYzAeF34LnNdQB59n6O68xy51o= 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=CUoqdaC1; 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="CUoqdaC1" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 7986A4E42ADE; Wed, 29 Apr 2026 07:44:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4E56E601DF; Wed, 29 Apr 2026 07:44:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2D5E010728FEB; Wed, 29 Apr 2026 09:44:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448678; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Jz4TmAue/ulWA5im5r6RM8s61tPN0+iCOmjz7hw7KII=; b=CUoqdaC1C93P3tXLbPL81TS0GBQi9Y1Cv+o6vkza+W8oVDgX09+WgOG2elPRf/3rnSM94Z q/x3N/7IHeDMq/b7/y7Ls04/kB2JRN9kvUcyHD0/q1WmR5SJc6C417ZnVWuWnk7jM6NwCn B2HLkYpFRMeDjUJb8LowW9C7Wmo/JYwHwr9621AJB3uHvEMVkgfx5+6XgLgyWwHo481rBo X+ELBYUUG8cOlEhCEOMg+VJLPSs//F8Bt/BVWMctrCTQVBhwsegyhYmvXuTMJfAiCdGv8R 1+oAOQFkuiF9QKRG440TU09pqxsG813fctAfTxnnXHQiXTzh9pDeQK/dttlpcw== 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 v2 11/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for mute gpio Date: Wed, 29 Apr 2026 09:43:47 +0200 Message-ID: <20260429074356.118420-12-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 537731996544..61d1cbb0661d 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]; + + 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.53.0 From nobody Tue Jun 16 20:35:36 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 AFF773B6C01 for ; Wed, 29 Apr 2026 07:44:43 +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=1777448685; cv=none; b=LtzNbj13O1yAF1B8o/KUWtKN8h6wrnbaecwm52I0C2GGIeKE4j7SICDB+Tc3SJmZwlOxvSpTQ3rm9JNXvT3boAcygoE7gv+XXxoXxgeuz/M4v5gXwWKdRo6Pwp3vb6QgPmFFxIZ/iOjAfDd88KFUIKrnc/2x+6aWuY0SpiI7LCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448685; c=relaxed/simple; bh=VUvxQjxqrGJ95aqwSTD02nv/W6p6NukiI/tlT9PyKbo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eInkt3wjyoDzKgMTmCfO3Ia1DxDOgpNKXYPWcF8qxj7xzPq+lnQbO8PJprr5/hgu2po0II+Ipu+qQ0isCHXWD0xCxS5RtDzJvW7AKKUwo+Y0SA2SV1IpgZVkUdp8DmBDhGD3eRODj9qLcE0YKa4lj3VKioGFZw15tv+8eqTK8rw= 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=wf5qZ9pC; 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="wf5qZ9pC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5AF654E42B68; Wed, 29 Apr 2026 07:44:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2F2E4601DF; Wed, 29 Apr 2026 07:44:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C0B561072826C; Wed, 29 Apr 2026 09:44:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448681; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=wV/IA5SaUiFJcnHQD1RBlfYGOPSCgkC9o3PWpTHKxJ0=; b=wf5qZ9pCbJ38pZseUphuRMMR9ZhDO4lBBZxGjajsrdXiY2aErET8Tvb+v5W8vH3JE68dkV 5bWNx6vG+/Qz23V4tWxRP4704TqnNPqOnpAQRhF4fI8/O4CcA9jdkmgAe1vjPzmUI7aSNo KVKF9vP0foP6krwFDf2g/x+hCuIksKRBPneMjPPWRSUFRBl6FfZOPpvEq9bz2e8ndcQN21 MzkAyqUP2MpeBlyzIepbYe7rmydAM0qLx1jCx622JH/8zB7Ka9Q33XysxZJgbWNJlg8E4/ AzFe3zA96w13kln1F6Hn1yWINGPuFQAQk5so6xBylDQZNFk3C8KPEi3aVn+uZg== 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 v2 12/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for bypass gpio Date: Wed, 29 Apr 2026 09:43:48 +0200 Message-ID: <20260429074356.118420-13-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 61d1cbb0661d..1c845272509c 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.53.0 From nobody Tue Jun 16 20:35:36 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 D3A8E3AC0F9 for ; Wed, 29 Apr 2026 07:44: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=1777448688; cv=none; b=ReCCc4+qoGLBwVn06/qvt06nPKJugE9NCznn9tqitD50NblLeJHvdu4RAnDxEvPOWaevp0vfaZpHiQNuq0Ce5pRK2b55503wAnW72ejFnq6VB41FEWKft7I6SfjsDiSx/SHpDoc3fQtVqJ36WQoyA2XwALKAlfFtL0WhpuXwHcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448688; c=relaxed/simple; bh=9ZeNAqe2K1RpT29ZlmLoNX7+/TuYhbpdbTQk6+W5xGk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PoXvWMkQZzku9SV0BPqPmFEZWXkxTdUdb0FxPaVH41YBfGKuXhh0hNsVj0nu8wbV9/y2BwmQSG0LryFTho9KHF1atuyhySV+lmMDFZGvNIj4gfu99jJMD5RJGZY4LyUmdJiRIuIJYNg51XDDKztVnWVEmAi/WgwVw4fI1W5Wh5k= 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=C2knB5ao; 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="C2knB5ao" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 91999C5CD50; Wed, 29 Apr 2026 07:45:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8FDFF601DF; Wed, 29 Apr 2026 07:44:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id F34481072989B; Wed, 29 Apr 2026 09:44:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448684; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=oYgKZIs1o6j/WKLi22VenrpXpjZYinvex25VuhaxODI=; b=C2knB5aoU2HGI6GQi0DSqDKLIbs5sWvP0mGPd7Y/3l6GHLWzehXq+zLLBBnRjkFcPvWxSp s0BkRPKYaRmsi81QKmwWITuPmwJ9YtYX7PY91P4C22LZx0h394PfPuY09gfa+PFBwpDrlz YVtQahmvvDjHZJljPpGZeoC/CADGHWnkn/orkn7/kqo3sHh60Pk0rmgTJFVxVXtVwaR6wl rJ9kxbtHCmJR7RnMbkqpM8jRsRgemrDnM2pJPfZhchCxNvJvlj1Ve+IdOaG1zNSH8GYcT7 mDPkZtgXeDetD0r0RausFTzhGSs2cLUzALWDbekYhfRJItad9LSvdal3xogSIw== 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 v2 13/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for basic gain Date: Wed, 29 Apr 2026 09:43:49 +0200 Message-ID: <20260429074356.118420-14-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 1c845272509c..4f4a3c10f883 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.53.0 From nobody Tue Jun 16 20:35:36 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 AA31D3BAD88; Wed, 29 Apr 2026 07:44:49 +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=1777448692; cv=none; b=YQnwSXTyF5SwtKj7DJnNsUP+QisNiHe7B1AIFwSYYhjGfpcppMKe/2tCcAIQ0dj+imBHxKH8S3Pcvk6ZTFZl9OFag00na+Enljzodes9ZRrOrznPeSnzy+E1kGmAFGUbML+Mt/qRdVeJMQAFeiNxbZAfGHA0AB397YgL9tsZFq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448692; c=relaxed/simple; bh=c54ycmmXNL7RxkCfzxWn0i8aq65sjwGiQUFNX+2OQc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gZmaHQDNmArj+wuQykFsBTqC8+pMxPrRSuxUC7vQqrPwukX2kEGyJr1co8KNC4JEuBT4JUNsduYAY1B37OWZUKWmqevafCsH8Zz8vi/sIHxiMDe2r/qVQMWPcAT7a0Fj13FBJfTJv9GnQtONVZcWi4u24K+0Vjj/7phsntKs3tw= 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=hlMwPf7d; 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="hlMwPf7d" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 5DEC31A347A; Wed, 29 Apr 2026 07:44:48 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 32FA1601DF; Wed, 29 Apr 2026 07:44:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DB8E91072989F; Wed, 29 Apr 2026 09:44:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448687; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=3G44daaR6HwKqj68j84FK3yKhXwmvmSMQaPXApsQR/4=; b=hlMwPf7dwECvlQTBLo/FhK1gUjmiq8mx7esMjGjIH2jHjo7BvEYB8XrIT17/Kq4iQLH7Vz meu5Zq4o56jak1sN44iLh8HLvWKiNr40hBg8yAGaCn52W0H8eh7qIA7sglcWfGbDtPQ7Yn Y6gdc+LMfMMObqWjAX90UFoqL3iZNS7STt8KJt05LHNh6rxcdlLB48GaXDNZCG0ad5XcDw WtGFUinknqRcYlCpxkz6wQIEsNcFZmznjaD+DIJG08W5jx17tr5iTlg9Uw5n21QEv9ROvL Sr5c2zSn1v4PYFQ5L75zmiPQRoOf2+gvgQlRfchex9CSBY/YG5kkVS+OYaaJfA== 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 v2 14/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-ranges Date: Wed, 29 Apr 2026 09:43:50 +0200 Message-ID: <20260429074356.118420-15-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 | 310 +++++++++++++++++++++++++++- 1 file changed, 305 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index 4f4a3c10f883..b25332a76549 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 int *simple_amp_alloc_tlv_ranges(const struct simple_amp_ranges *ra= nges) +{ + 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,172 @@ 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; + } + 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 <=3D 0) + return ret; + + /* + * 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 +738,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 +784,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.53.0 From nobody Tue Jun 16 20:35:36 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 5371F3AC0F9; Wed, 29 Apr 2026 07:44:52 +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=1777448694; cv=none; b=txzrCSTMHERzf7Cte/TWdWEJHVv2rZM9niUOi+7M6z9INDTXn4SWHotT/LthkydfMQ5qc1z7aWRXzVNARv8ckGluAZ2m0uodf/fzBtoO2NFlFUXwS2iXxn1DmH7qnxDClte36X4mY8dGhx8/kBBpbGvUY7oq9QeMbT3WxXAjwgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448694; c=relaxed/simple; bh=iKc3QYrFOcmY1MCPB4FxrTH+D7zAdtAOJ4RcBhuIqH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mR6rSNgo+9G79u2NCRTrpPKdEkf9TkYahBZ3p2aSlrdsfgSGaGgYmsXc3RKVeBZk9ido00gtKHXkh0hJYkJej3MnPmk1WNGUTS2NQWCsgyQVJS7W4wZeuivMRqrJ50HVir1yiI/O7c+14bu5PjD1JzVcJuSHlRFE8oV6Y8CjpfM= 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=WjCwr/0L; 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="WjCwr/0L" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 0B26E4E42ADE; Wed, 29 Apr 2026 07:44:51 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CF5BA601DF; Wed, 29 Apr 2026 07:44:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C59911072989E; Wed, 29 Apr 2026 09:44:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448689; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=pcpQ7WpaW4lGxE92Wx2KSCv7DhOVSwNrRADnBFLqbNw=; b=WjCwr/0LnWUZZTL5k5bAYml9YJxUC4039wCuyoN1ASIaSwv0XBuFVqnN05FCvzLcbyYMmZ StjiDSBnj5y//dSMMOhkWebV+/7Uvt0pGloG/kFHzCv8j1ZEwM3in6oI47se9FBGTGRfa0 fENuXSYV3AIWTs4wLShDvTsDBUYISYOv7NJtChk1vwHGlAt1HyLaNi1RftoZHcVvmT17ee qWoynWSF/4T9G6mGVe+6PKTy/Xm8hTPJddKw06vO2skfhKPp9LXAEcHAdpraMti2cqSgK6 nCaSU9ikhDt7Eh0RdLk4RN5rg6pVNRB0F02TFtKbpAKXhmTKptqCOmQy9CEgaQ== 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 v2 15/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-labels Date: Wed, 29 Apr 2026 09:43:51 +0200 Message-ID: <20260429074356.118420-16-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 | 112 +++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-= amplifier.c index b25332a76549..a7fbfcc4ec0d 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 int *simple_amp_alloc_tlv_ranges(const struct simple_amp_ranges *ra= nges) { 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; @@ -712,10 +767,40 @@ 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 <=3D 0) + return ret; + + 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; @@ -745,6 +830,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; @@ -785,7 +877,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; } @@ -795,6 +887,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.53.0 From nobody Tue Jun 16 20:35:36 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 C5FA63BC693 for ; Wed, 29 Apr 2026 07:44:54 +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=1777448696; cv=none; b=EhUJLxkvOkww0VHh7CvAxfmUh3bsafA76qS4FbmWAklpC+oHmUhyEH39kEi/2uUaHhImqElZvI/E04TkNWFtFikyRCRfZU6FkG2fVZC1SP5g8S+rumlawRLcH+E2ert9/O4RLfTNGj/9185xi3yuRuEjV/d8Z5zHEHObKlB89L0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448696; c=relaxed/simple; bh=juStJNcfV7KjmE/LU0kVIQ+8d1FBUV24oHAKybg13/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rk/behE9LGkazdJiCQ/jDPt8N/xyvHI2FGxt1HFms12frwEI+LZqoKY+2j3AKz6GeUKmyQEH96cXO5PpoOPy8jzSbwPcFbvwiZsLY/bdyLsIZusHfZOxN02W91evqGF/9kA1Yx3bAm+36J08WYXHoUXXTeSa2RGIAMlMCV7zp7k= 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=0HmwpJwW; 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="0HmwpJwW" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8BF041A347A; Wed, 29 Apr 2026 07:44:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5C116601DF; Wed, 29 Apr 2026 07:44:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 43CCB10729898; Wed, 29 Apr 2026 09:44:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448692; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=9QLwGF5jb+oga4BqW3y5KpwsRAOpzcDnt9w/lqu+R0Q=; b=0HmwpJwWfbl0+K20zJpSighylQ/sm5p0ZyWqTVfBOp7q0DIoDWXbXPyvor+LcmE7JKCevK vAiEKQZ40Nz4wNqouOdGTVvIW9rkmglHnEw6vs4p0yaut2hh4d7WeZF6K7ETeQm8tGyBVe im7gk62n2063rjJjKxvJInkIPlidzUnhJaOtUWjHjtSp2dSN3NbckYZ0zn2mSNzoaqXcDt iJYxjj2P0hMf8f5p4U2LGb3MWzSgWdu1gyg6Wd04LAL6YViah9f5P1rNEmLrp/JDZNqesK 6BPaADAL1dNTKl9lWzq6y9xwc3qwO1fI+gWf1CVKVo34YEkI1C/yBzb6+sDYCQ== 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 v2 16/17] ASoC: simple-amplifier: Update author and copyright Date: Wed, 29 Apr 2026 09:43:52 +0200 Message-ID: <20260429074356.118420-17-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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 a7fbfcc4ec0d..e65ac29b4998 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 @@ -956,4 +961,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.53.0 From nobody Tue Jun 16 20:35:36 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 74C373BED18 for ; Wed, 29 Apr 2026 07:44: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=1777448698; cv=none; b=MdahzhcpGAyXgF/1SVwM/+gRtzTwRIAbAkfZVuazxOYHccq0xWbDeIMERkq/Mt2YZTYYQTtESSR7RoYtTsMBSj4gjpdYf483J3TELDU1Y8N/KPJhNGA/z0/KVJZq6Jga9ul2yUnLo9Sf1fsm8sVYaTSTz2XUT7vOV2FdLO3Q3us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777448698; c=relaxed/simple; bh=op2dyqGMPf45Zp004/cYcTotxRMgO+sGnvJdpRf3ngA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EVNd67gxAVdCKL47wcEt0u46w1ysF+CCTSR/GoBQmZz0sC1LlEC7rdnXMJLi2UrMUyyG+FXOwfIGaJTWG3QjJZx1/SfDwQMMHnsTlRt444KglkjT4AmgwR9YbzW6dDGlLMzUKCUwZ7oFbfHCrNuHwrGtEXtkBaC1z8ofl/AdeF8= 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=xsKLxOKV; 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="xsKLxOKV" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 4CB35C5CD50; Wed, 29 Apr 2026 07:45:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4211160537; Wed, 29 Apr 2026 07:44:56 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E847B107298A5; Wed, 29 Apr 2026 09:44:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777448695; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=BBUTlQzRbcWMTsEb0Kt5D7Leu3NTlQjVFL2I0uveIu0=; b=xsKLxOKVcSg85hNBTKS1T7Eabf8uQw5GUSP1e7/cOxGcbansFbn49NMOE9HWf2S8XKMsLZ al4bol33Z8sRtOexztmqLkba9zKm2qF5IPJCaz70MfJOSkmySh79WKLEM9yI6OwDExsn2p 9lCBFUFufyfmzefY1+FUE/vgvd+3dbQaVCqWpPSogx480/Oo3wAU9EDDG5+pNOyylMuQ+p DCVZIlZkTHZASlNeD70z0UVmCF89UiHYvGk1TKqWeLCaV9mjdREdwM0/Jys6P0/okgVe0y 7c/vTRHlN8fRMZosrtFFUuTM4KGOSMEzERHq05Lcg/W91GVlHFceawl/5xB6HA== 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 v2 17/17] MAINTAINERS: Add the ASoC gpio audio amplifier entry Date: Wed, 29 Apr 2026 09:43:53 +0200 Message-ID: <20260429074356.118420-18-herve.codina@bootlin.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429074356.118420-1-herve.codina@bootlin.com> References: <20260429074356.118420-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.53.0