Skip to content

fix(kernel): WCD939x class-H: program the class-H port window and run the start-up once - #876

Merged
FeralAI merged 1 commit into
armada-os:mainfrom
ovid-io:fix/wcd939x-class-h
Nov 15, 2026
Merged

FeralAI merged 1 commit into
armada-os:mainfrom
ovid-io:fix/wcd939x-class-h

Conversation

@ovid-io

@ovid-io ovid-io commented Nov 10, 2026

Copy link
Copy Markdown

What

Two kernel patches for the WCD939x headphone class-H, after 0081:

  • 0082-ASoC-wcd939x-sdw-program-the-class-H-port-window.patch: declares the codec's class-H SoundWire port SDW_DPN_FULL. The RX ports are all SDW_DPN_SIMPLE, and the SoundWire core only writes DPN_OffsetCtrl2, DPN_BlockCtrl3, DPN_SampleCtrl2 and DPN_HCtrl for non-simple ports, so the codec kept its reset window (hstart 0, hstop 15) while the master sends class-H in hstart 3, hstop 6.
  • 0083-ASoC-wcd-clsh-run-the-class-H-start-up-only-once.patch: runs the v3 class-H start-up IQ sequence only for the first headphone channel. The second channel forced the start-up values again (FLYBACK_VNEGDAC_CTRL_2, CLASSH_MODE_3, CLASSH_MODE_2), but buck and flyback were already on, so nothing restored the playback values. Qualcomm's downstream state machine calls the stereo state (a no-op) when the second channel joins, so its sequence runs once.

Why: measured on a KONKR Pocket FIT (WCD9395)

Armada 20261109, HiFi PCM with ULP (as stock Android), compander on, music playing:

Register Stock Android Armada 20261109 With 0082 + 0083
codec DP2 HCtrl (class-H window) 0x36 (3-6) 0x0f (0-15) 0x36
codec DP2 BlockCtrl3 0 1 0
CLASSH_MODE_2 0x3a 0x1c 0x3a
CLASSH_MODE_3 0xf0 0xf2 0xf0
FLYBACK_VNEGDAC_CTRL_2 0xf8 0xb8 0xf8

The master's HCTRL for port 2 is 0x63 (hstart 3, hstop 6) on both.

What it sounds like: before, loud passages dropped out for about a quarter of a second with the compander on, or clipped from about 75% volume with it off, while Android plays the same track clean and louder. With both patches it's clean and loud at full volume with 0 dB digital gain and the compander on, as on Android. The short noise when the amplifier powers up for a sound is gone too.

How it was tested

Each patched file was built as its module (snd-soc-wcd939x-sdw, snd-soc-wcd-classh) against Linux 7.2.6 with Armada 20261109's full series and Armada's config. The modules were loaded on the device in place of Armada's own, with the registers read back from debugfs while playing. On today's main, the series with these two patches applied to 7.2.6 gives exactly those sources.

Scope

  • 0082 changes only the WCD939x class-H port. The SM8550, SM8650 and SM8750 RX masters all give port 2 hstart 3 and hstop 6, so the codec now gets exactly the window the master sends. The HPH and compander ports stay simple: they have no hstart/hstop in the DT, and the HiFi PCM port's window (0/15) already equals the codec's reset value.
  • 0083 is in wcd-clsh-v2's v3 path, shared by WCD937x, WCD938x and WCD939x. It does what Qualcomm's downstream wcd-clsh.c does for all of them.
  • The Odin 3 profile turns the headphone compander off because it "clips loud peaks here". That may not be needed with these patches, so it's worth retesting on an Odin 3.
  • Not changed here: sm8650.dtsi gives port 2 a sample interval of 0x1f, where sm8550.dtsi, sm8750.dtsi and stock Android use 0x3f. It plays clean either way; this is a possible follow-up.

Credits and related

The repeated start-up was found by @mrdidit on the AYANEO Pocket S2. Related: #803 (Pocket FIT jack detection and the HPH PCM path), whose 8 dB of headroom can drop to 0 dB once this is in.

The investigation and patches were prepared with help from an AI assistant (Claude); I tested everything on my own Pocket FIT.

… the start-up once

0082 declares the WCD939x class-H SoundWire port full, so the codec gets the hstart/hstop the master uses (3/6) instead of keeping its reset window (0/15).

0083 runs the v3 class-H start-up IQ sequence only for the first headphone channel, as Qualcomm's downstream driver does; the second channel left CLASSH_MODE_2/3 and FLYBACK_VNEGDAC_CTRL_2 on their start-up values, so loud passages clipped or dropped out.
@FeralAI

FeralAI commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

This looks great. I tested on an Odin 3.

@FeralAI
FeralAI merged commit 567e1b3 into armada-os:main Nov 15, 2026
ovid-io pushed a commit to ovid-io/armada that referenced this pull request Nov 16, 2026
With the WCD939x class-H fixes from armada-os#876 (patches 0082 and 0083) the Pocket FIT's headphones play clean at full volume at 0 dB digital, compander on, ULP, as stock Android. Drop the 8 dB of digital headroom PocketFitHeadphones.conf added as a workaround, and the matching restore on disable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants