* [PATCH] ASoC: sun8i-codec-analog: Add the headphone inversion control
@ 2026-11-03 13:39 Romain TISSERAND
0 siblings, 0 replies; only message in thread
From: Romain TISSERAND @ 2026-11-03 13:39 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-sunxi,
linux-arm-kernel, linux-kernel, sashiko-reviews
Bits 1 and 0 of PAEN_HP_CTRL (analog register 0x07; LTRNMUTE, RTLNMUTE)
feed the inverted left output to the right one and the inverted right
output to the left one ("Left HPOUT Negative To Right HPOUT Mute" and
the reverse in the A23 and A33 user manuals and the V3s datasheet; 0 =
mute, the reset value). The driver defines them but nothing can set
them.
They are needed when a mono speaker amplifier is bridged across HPL and
HPR, as on the PocketGo S30 (A33): with the same signal on both outputs
the speaker gets almost nothing. With a mono mix on both DACs and the
inverted left added to the right output, HPL - HPR carries the signal.
Expose them as one enum, "Off", "Left to Right" or "Right to Left", so
that the two outputs are never fed with each other at the same time. It
defaults to "Off" (both muted), so nothing changes for existing boards.
Signed-off-by: Romain TISSERAND <romain.tisserand@gmail.com>
---
Notes:
- Testing: built with W=1 for arm (multi_v7_defconfig) and arm64
(defconfig), SND_SUN8I_CODEC_ANALOG=m, no warnings. On a PocketGo S30
(A33, mono speaker amplifier bridged across HPL and HPR), first with
the bits written by hand while a 600 Hz tone played (same tone on both
channels, AIF1 DA0 route "Mix Mono"): with PAEN_HP_CTRL = 0xf4 (HPCOM
driven, no inversion) the speaker is much quieter than with 0xf6
(bit 1 set) or 0xf5 (bit 0 set, the other output muted).
Then on 7.3.1 with this patch, same tone through PipeWire: "Headphone
Inversion Playback Route" = "Left to Right" sets bit 1 (0xf4 -> 0xf6)
and the speaker is clearly louder than with "Off"; "Right to Left"
sets bit 0 (0xf5).
- The A23 shares this code path; its user manual (v1.0, PAEN_HP_CTRL)
documents the same two bits, with the same names and reset value.
- Tool disclosure: this patch was prepared with Claude Opus 5.5
(Anthropic) as a coding assistant, in an interactive session where I
asked it to get the PocketGo S30 speaker working. It ran the register
tests above while I listened, found the two unused bits in the A33
manual and drafted the change and the message. I reviewed and
understand the change and tested it as described above.
sound/soc/sunxi/sun8i-codec-analog.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/sound/soc/sunxi/sun8i-codec-analog.c b/sound/soc/sunxi/sun8i-codec-analog.c
index 3335855c6311..7188b498fb08 100644
--- a/sound/soc/sunxi/sun8i-codec-analog.c
+++ b/sound/soc/sunxi/sun8i-codec-analog.c
@@ -314,6 +314,25 @@ static const struct snd_soc_dapm_route sun8i_codec_mixer_routes[] = {
/* headphone specific controls, widgets, and routes */
static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1);
+
+/* For a speaker bridged across HPL and HPR: one direction at a time */
+static const char * const sun8i_codec_hp_inv_enum_text[] = {
+ "Off", "Left to Right", "Right to Left",
+};
+
+static const unsigned int sun8i_codec_hp_inv_enum_values[] = {
+ 0,
+ BIT(SUN8I_ADDA_PAEN_HP_CTRL_LTRNMUTE),
+ BIT(SUN8I_ADDA_PAEN_HP_CTRL_RTLNMUTE),
+};
+
+static SOC_VALUE_ENUM_SINGLE_DECL(sun8i_codec_hp_inv_enum,
+ SUN8I_ADDA_PAEN_HP_CTRL, 0,
+ BIT(SUN8I_ADDA_PAEN_HP_CTRL_LTRNMUTE) |
+ BIT(SUN8I_ADDA_PAEN_HP_CTRL_RTLNMUTE),
+ sun8i_codec_hp_inv_enum_text,
+ sun8i_codec_hp_inv_enum_values);
+
static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = {
SOC_SINGLE_TLV("Headphone Playback Volume",
SUN8I_ADDA_HP_VOLC,
@@ -323,6 +342,8 @@ static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] = {
SUN8I_ADDA_DAC_PA_SRC,
SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE,
SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE, 1, 0),
+ SOC_ENUM("Headphone Inversion Playback Route",
+ sun8i_codec_hp_inv_enum),
};
static const char * const sun8i_codec_hp_src_enum_text[] = {
base-commit: aae83f3931bc3a5497bcc8351b5f954ad7ac895c
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 13:39 [PATCH] ASoC: sun8i-codec-analog: Add the headphone inversion control Romain TISSERAND
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®