Skip to content

Commit e76ccf1

Browse files
committed
ASoC: Add support for GPIOs driven amplifiers
Herve Codina <herve.codina@bootlin.com> says: On some embedded system boards, audio amplifiers are designed using discrete components such as op-amp, several resistors and switches to either adjust the gain (switching resistors) or fully switch the audio signal path (mute and/or bypass features). Those switches are usually driven by simple GPIOs. This kind of amplifiers are not handled in ASoC and the fallback is to let the user-space handle those GPIOs out of the ALSA world. In order to have those kind of amplifiers fully integrated in the audio stack, this series introduces the audio-gpio-amp to handle them. This new ASoC component allows to have the amplifiers seen as ASoC auxiliarty devices and so it allows to control them through audio mixer controls. In order to ease the review, I choose to split modifications related to the merge of the gpio-audio-amp part into the simple-amplfier driver in several commits. Link: https://patch.msgid.link/20260513081702.317117-1-herve.codina@bootlin.com
2 parents e383531 + 5bd8c4b commit e76ccf1

375 files changed

Lines changed: 5923 additions & 2414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ Tobias Klauser <tklauser@distanz.ch> <klto@zhaw.ch>
857857
Tobias Klauser <tklauser@distanz.ch> <tklauser@nuerscht.ch>
858858
Tobias Klauser <tklauser@distanz.ch> <tklauser@xenon.tklauser.home>
859859
Todor Tomov <todor.too@gmail.com> <todor.tomov@linaro.org>
860+
Tomasz Jeznach <tomasz.jeznach@linux.dev> <tjeznach@rivosinc.com>
860861
Tony Luck <tony.luck@intel.com>
861862
Trilok Soni <quic_tsoni@quicinc.com> <tsoni@codeaurora.org>
862863
TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>

Documentation/arch/riscv/cmodx.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ call at each patchable function entry, and patches it dynamically at runtime to
2121
enable or disable the redirection. In the case of RISC-V, 2 instructions,
2222
AUIPC + JALR, are required to compose a function call. However, it is impossible
2323
to patch 2 instructions and expect that a concurrent read-side executes them
24-
without a race condition. This series makes atmoic code patching possible in
24+
without a race condition. This series makes atomic code patching possible in
2525
RISC-V ftrace. Kernel preemption makes things even worse as it allows the old
2626
state to persist across the patching process with stop_machine().
2727

2828
In order to get rid of stop_machine() and run dynamic ftrace with full kernel
2929
preemption, we partially initialize each patchable function entry at boot-time,
30-
setting the first instruction to AUIPC, and the second to NOP. Now, atmoic
30+
setting the first instruction to AUIPC, and the second to NOP. Now, atomic
3131
patching is possible because the kernel only has to update one instruction.
3232
According to Ziccif, as long as an instruction is naturally aligned, the ISA
3333
guarantee an atomic update.
@@ -36,8 +36,8 @@ By fixing down the first instruction, AUIPC, the range of the ftrace trampoline
3636
is limited to +-2K from the predetermined target, ftrace_caller, due to the lack
3737
of immediate encoding space in RISC-V. To address the issue, we introduce
3838
CALL_OPS, where an 8B naturally align metadata is added in front of each
39-
pacthable function. The metadata is resolved at the first trampoline, then the
40-
execution can be derect to another custom trampoline.
39+
patchable function. The metadata is resolved at the first trampoline, then the
40+
execution can be directed to another custom trampoline.
4141

4242
CMODX in the User Space
4343
-----------------------

Documentation/arch/riscv/zicfilp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ the program.
7878

7979
Per-task indirect branch tracking state can be monitored and
8080
controlled via the :c:macro:`PR_GET_CFI` and :c:macro:`PR_SET_CFI`
81-
``prctl()` arguments (respectively), by supplying
81+
``prctl()`` arguments (respectively), by supplying
8282
:c:macro:`PR_CFI_BRANCH_LANDING_PADS` as the second argument. These
8383
are architecture-agnostic, and will return -EINVAL if the underlying
8484
functionality is not supported.
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/gpio-audio-amp.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Audio amplifier driven by GPIOs
8+
9+
maintainers:
10+
- Herve Codina <herve.codina@bootlin.com>
11+
12+
description: |
13+
Audio GPIO amplifiers are driven by GPIO in order to control the gain value
14+
of the amplifier, its mute function and/or its bypass function.
15+
16+
Those amplifiers are based on discrete components (analog switches, op-amps
17+
and more) where some of them, mostly analog switches, are controlled by GPIOs
18+
to adjust the gain value of the whole amplifier and/or to control
19+
the mute and/or bypass function.
20+
21+
For instance, the following piece of hardware is a GPIO amplifier
22+
23+
+5VA
24+
^
25+
|\ |
26+
| \
27+
Vin >---------------------------|+ \
28+
| +-------+-----> Vout
29+
.--\/\/\/--+------------|- / |
30+
| | | / |
31+
v | |/ | |
32+
GND o v |
33+
\ GND |
34+
gpio >-----------> \ |
35+
o o |
36+
| | |
37+
| '--\/\/\/--. |
38+
| +--\/\/\/--'
39+
'---------------'
40+
41+
properties:
42+
compatible:
43+
oneOf:
44+
- const: gpio-audio-amp-mono
45+
description:
46+
A single channel amplifier. All features apply to this sole channel.
47+
48+
- const: gpio-audio-amp-stereo
49+
description:
50+
A dual channel amplifier (left and right). All features apply to both
51+
channels producing the same effect on both channels at the same time.
52+
53+
vdd-supply:
54+
description: Main power supply of the amplifier
55+
56+
vddio-supply:
57+
description: Power supply related to the control path
58+
59+
vdda1-supply:
60+
description: Analog power supply
61+
62+
vdda2-supply:
63+
description: Additional analog power supply
64+
65+
mute-gpios:
66+
description: GPIO to control the mute function
67+
maxItems: 1
68+
69+
bypass-gpios:
70+
description: GPIO to control the bypass function
71+
maxItems: 1
72+
73+
gain-gpios:
74+
description: |
75+
GPIOs to control the amplifier gain
76+
77+
The gain value is computed from GPIOs value from 0 to 2^N-1 with N the
78+
number of GPIO described. The first GPIO described is the lsb of the gain
79+
value.
80+
81+
For instance assuming 2 gpios
82+
gain-gpios = <&gpio1 GPIO_ACTIVE_HIGH> <&gpio2 GPIO_ACTIVE_HIGH>;
83+
The gain value will be the following:
84+
85+
gpio1 | gpio2 | gain
86+
------+-------+-----
87+
0 | 0 | 0b00 -> 0
88+
1 | 0 | 0b01 -> 1
89+
0 | 1 | 0b10 -> 2
90+
1 | 1 | 0b11 -> 3
91+
------+-------+-----
92+
93+
Note: The gain value, bits set to 1 or 0, indicate the state active (bit
94+
set) or the state inactive (bit unset) of the related GPIO. The
95+
physical voltage corresponding to this active/inactive state is
96+
given by the GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags.
97+
98+
minItems: 1
99+
maxItems: 16
100+
101+
gain-ranges:
102+
$ref: /schemas/types.yaml#/definitions/int32-matrix
103+
description: |
104+
A list of one or more ranges of possible values. Each range is defined by
105+
the first and last point in the range. Each point is defined by the pair
106+
(GPIOs value, Gain in 0.01 dB unit).
107+
108+
Ranges can be contiguous or holes can be present between ranges if some
109+
gpios value should not be used. Also in a range the first point and the
110+
last point can be identical. In that case, the range contains only one
111+
item, the given point.
112+
113+
items:
114+
items:
115+
- description: GPIOs value of the first point in the range
116+
- description: Gain in 0.01 dB unit of the first point in the range
117+
- description: GPIOs value of the last point in the range
118+
- description: Gain in 0.01 dB unit of the last point in the range
119+
description: |
120+
A range defines a linear function (linear in dB) from the first point
121+
to the last point, both included. The number of items in the range is
122+
N = abs(first_point.gpio_value - last_point.gpio_value) + 1
123+
124+
It allows to define the gain range from the first_point.gain to
125+
the last_point.gain, both points included.
126+
127+
Gain (0.01 dB unit)
128+
^
129+
| last
130+
+- - - - - - - - - - + point
131+
| + .
132+
| + .
133+
| + .
134+
+- - - - + .
135+
| first . .
136+
| point . .
137+
| . .
138+
+--------+-----------+---> gpios
139+
value
140+
141+
Note: Even if first_point.gpio_value is lower than last_point.gpio_value
142+
and first_point.gain is lower than last_point.gain in the above
143+
graphic, all combination of values are supported leading to an
144+
increasing or a decreasing linear segment.
145+
146+
minItems: 1
147+
maxItems: 65536
148+
149+
gain-labels:
150+
$ref: /schemas/types.yaml#/definitions/string-array
151+
minItems: 2
152+
maxItems: 65536
153+
description: |
154+
List of the gain labels attached to the combination of GPIOs controlling
155+
the gain. The first label is related to the gain value 0, the second label
156+
is related to the gain value 1 and so on.
157+
158+
With 2 GPIOs controlling the gain, GPIOs value can be 0, 1, 2 and 3.
159+
Assuming that gain value set the hardware according to the following
160+
table:
161+
162+
GPIOs | Hardware
163+
value | amplification
164+
------+--------------
165+
0 | Low
166+
1 | Middle
167+
2 | High
168+
3 | Max
169+
------+--------------
170+
171+
The description using gain labels can be:
172+
gain-labels = "Low", "Middle", "High", "Max";
173+
174+
dependencies:
175+
gain-ranges: [ gain-gpios ]
176+
gain-labels: [ gain-gpios ]
177+
178+
required:
179+
- compatible
180+
- vdd-supply
181+
182+
anyOf:
183+
- required:
184+
- gain-gpios
185+
- required:
186+
- mute-gpios
187+
- required:
188+
- bypass-gpios
189+
190+
allOf:
191+
- $ref: component-common.yaml#
192+
- if:
193+
required:
194+
- gain-ranges
195+
then:
196+
properties:
197+
gain-labels: false
198+
- if:
199+
required:
200+
- gain-labels
201+
then:
202+
properties:
203+
gain-ranges: false
204+
205+
unevaluatedProperties: false
206+
207+
examples:
208+
- |
209+
#include <dt-bindings/gpio/gpio.h>
210+
211+
/* Gain controlled by gpios */
212+
amplifier-0 {
213+
compatible = "gpio-audio-amp-mono";
214+
vdd-supply = <&regulator>;
215+
gain-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>, <&gpio 1 GPIO_ACTIVE_HIGH>;
216+
};
217+
218+
/* Gain controlled by gpio using a simple range on a stereo amplifier */
219+
amplifier-1 {
220+
compatible = "gpio-audio-amp-stereo";
221+
vdd-supply = <&regulator>;
222+
gain-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>, <&gpio 1 GPIO_ACTIVE_HIGH>;
223+
gain-ranges = <0 (-300) 3 600>;
224+
};
225+
226+
/* Gain controlled by gpio with labels */
227+
amplifier-3 {
228+
compatible = "gpio-audio-amp-mono";
229+
vdd-supply = <&regulator>;
230+
gain-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
231+
gain-labels = "Low", "High";
232+
};
233+
234+
/* A mutable stereo amplifier without any gain control */
235+
amplifier-4 {
236+
compatible = "gpio-audio-amp-stereo";
237+
vdd-supply = <&regulator>;
238+
mute-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
239+
};
240+
241+
/*
242+
* Several supplies, gain controlled using more complex ranges, mute and
243+
* bypass.
244+
*
245+
* Assuming 3 gpios for controlling the gain with the following table
246+
* gpios value Gain
247+
* 0b000 Do not use (gpios value not allowed)
248+
* 0b001 - 3dB
249+
* 0b010 + 3dB
250+
* 0b011 + 10dB
251+
* 0b100 Do not use (gpios value not allowed)
252+
* 0b101 + 6dB
253+
* 0b110 + 7dB
254+
* 0b111 + 8dB
255+
*/
256+
amplifier-5 {
257+
compatible = "gpio-audio-amp-mono";
258+
vdd-supply = <&regulator>;
259+
vddio-supply = <&regulator1>;
260+
vdda1-supply = <&regulator2>;
261+
gain-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>,
262+
<&gpio 1 GPIO_ACTIVE_HIGH>,
263+
<&gpio 2 GPIO_ACTIVE_HIGH>;
264+
gain-ranges = <1 (-300) 2 300>,
265+
<3 1000 3 1000>,
266+
<5 600 7 800>;
267+
mute-gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
268+
bypass-gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
269+
};
270+
...

Documentation/hwmon/sy7636a-hwmon.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ The following sensors are supported
2222
sysfs-Interface
2323
---------------
2424

25-
temp0_input
25+
temp1_input
2626
- Temperature of external NTC (milli-degree C)

Documentation/netlink/genetlink-c.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ properties:
6969
header:
7070
description: For C-compatible languages, header which already defines this value.
7171
type: string
72+
scope:
73+
description: |
74+
Visibility of this definition. "uapi" (default) renders into
75+
the uAPI header, "kernel" renders into the kernel-side
76+
generated header, "user" renders into the user-side
77+
generated header. When combined with `header:`, the
78+
definition is not rendered, and the named header is
79+
included only by code matching the scope.
80+
enum: [ uapi, kernel, user ]
7281
type:
7382
enum: [ const, enum, flags ]
7483
doc:

Documentation/netlink/genetlink-legacy.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ properties:
8383
header:
8484
description: For C-compatible languages, header which already defines this value.
8585
type: string
86+
scope:
87+
description: |
88+
Visibility of this definition. "uapi" (default) renders into
89+
the uAPI header, "kernel" renders into the kernel-side
90+
generated header, "user" renders into the user-side
91+
generated header. When combined with `header:`, the
92+
definition is not rendered, and the named header is
93+
included only by code matching the scope.
94+
enum: [ uapi, kernel, user ]
8695
type:
8796
enum: [ const, enum, flags, struct ] # Trim
8897
doc:

Documentation/netlink/genetlink.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ properties:
5555
header:
5656
description: For C-compatible languages, header which already defines this value.
5757
type: string
58+
scope:
59+
description: |
60+
Visibility of this definition. "uapi" (default) renders into
61+
the uAPI header, "kernel" renders into the kernel-side
62+
generated header, "user" renders into the user-side
63+
generated header. When combined with `header:`, the
64+
definition is not rendered, and the named header is
65+
included only by code matching the scope.
66+
enum: [ uapi, kernel, user ]
5867
type:
5968
enum: [ const, enum, flags ]
6069
doc:

Documentation/netlink/netlink-raw.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ properties:
8787
header:
8888
description: For C-compatible languages, header which already defines this value.
8989
type: string
90+
scope:
91+
description: |
92+
Visibility of this definition. "uapi" (default) renders into
93+
the uAPI header, "kernel" renders into the kernel-side
94+
generated header, "user" renders into the user-side
95+
generated header. When combined with `header:`, the
96+
definition is not rendered, and the named header is
97+
included only by code matching the scope.
98+
enum: [ uapi, kernel, user ]
9099
type:
91100
enum: [ const, enum, flags, struct ] # Trim
92101
doc:

0 commit comments

Comments
 (0)