aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
authorHerve Codina <herve.codina@bootlin.com>2026-05-13 10:16:53 +0200
committerMark Brown <broonie@kernel.org>2026-05-18 17:44:09 +0100
commit41e3ebbfcab1eb5c6403e24130bc1690dae4f108 (patch)
treeb8c4142d6a20c2a4b29f5e268e7e560d5acd471d /sound
parent4d84b75e5eecd729e31ed5981353f84baa351c49 (diff)
downloadlinux-next-history-41e3ebbfcab1eb5c6403e24130bc1690dae4f108.tar.gz
ASoC: simple-amplifier: Introduce support for gpio-audio-amp
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 <herve.codina@bootlin.com> Link: https://patch.msgid.link/20260513081702.317117-10-herve.codina@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/simple-amplifier.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c
index 3e644c1c26960..1704cdbb7de5d 100644
--- a/sound/soc/codecs/simple-amplifier.c
+++ b/sound/soc/codecs/simple-amplifier.c
@@ -4,6 +4,7 @@
* Author: Jerome Brunet <jbrunet@baylibre.com>
*/
+#include <linux/bits.h>
#include <linux/gpio/consumer.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
@@ -12,6 +13,9 @@
#include <sound/soc.h>
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_routes[] = {
{ "OUTR", NULL, "DRV" },
};
+static const struct snd_soc_dapm_widget simple_amp_mono_pga_dapm_widgets[] = {
+ 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_event,
+ (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[] = {
+ { "PGA", NULL, "IN" },
+ { "PGA", NULL, "vdd" },
+ { "OUT", NULL, "PGA" },
+};
+
+static const struct snd_soc_dapm_widget simple_amp_stereo_pga_dapm_widgets[] = {
+ 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_event,
+ (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[] = {
+ { "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 = snd_soc_component_to_dapm(component);
@@ -133,9 +169,27 @@ static const struct simple_amp_data simple_audio_amplifier_data = {
.num_dapm_routes = ARRAY_SIZE(simple_amp_dapm_routes),
};
+static const struct simple_amp_data simple_audio_mono_pga_data = {
+ .supports = SIMPLE_AUDIO_SUPPORT_PGA,
+ .dapm_widgets = simple_amp_mono_pga_dapm_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(simple_amp_mono_pga_dapm_widgets),
+ .dapm_routes = simple_amp_mono_pga_dapm_routes,
+ .num_dapm_routes = ARRAY_SIZE(simple_amp_mono_pga_dapm_routes),
+};
+
+static const struct simple_amp_data simple_audio_stereo_pga_data = {
+ .supports = SIMPLE_AUDIO_SUPPORT_PGA,
+ .dapm_widgets = simple_amp_stereo_pga_dapm_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(simple_amp_stereo_pga_dapm_widgets),
+ .dapm_routes = simple_amp_stereo_pga_dapm_routes,
+ .num_dapm_routes = ARRAY_SIZE(simple_amp_stereo_pga_dapm_routes),
+};
+
static const struct of_device_id simple_amp_ids[] = {
{ .compatible = "dioo,dio2125", .data = &simple_audio_amplifier_data},
{ .compatible = "simple-audio-amplifier", .data = &simple_audio_amplifier_data},
+ { .compatible = "gpio-audio-amp-mono", .data = &simple_audio_mono_pga_data},
+ { .compatible = "gpio-audio-amp-stereo", .data = &simple_audio_stereo_pga_data},
{ }
};
MODULE_DEVICE_TABLE(of, simple_amp_ids);