Skip to content

fix(audio): KONKR Pocket FIT headphone jack: detection and the HPH PCM path - #803

Open
ovid-io wants to merge 3 commits into
armada-os:mainfrom
ovid-io:fix/pocket-fit-headphones
Open

ovid-io wants to merge 3 commits into
armada-os:mainfrom
ovid-io:fix/pocket-fit-headphones

Conversation

@ovid-io

@ovid-io ovid-io commented Oct 27, 2026 •

Copy link
Copy Markdown

Fixes #426.

Two problems with the 3.5mm jack on the KONKR Pocket FIT (SM8650, G3 Gen 3), one commit each.

1. The jack is never detected

Plugging headphones in does nothing: mbhc sw intr counts every plug and unplug, but Elect Insert stays 0, the Headphone Jack control stays off, and sound stays on the speakers.

Cause. The Pocket FIT shares sm8650-ayaneo-common.dtsi with the Pocket S2, whose wcd939x node has no qcom,hphl-jack-type-normally-closed / qcom,ground-jack-type-normally-closed. Without them MBHC assumes normally-open jack switches and reads every insertion as a removal. The Pocket FIT's own stock Android device tree (/sys/firmware/fdt on its firmware) has qcom,msm-mbhc-hphl-swh = <0> and qcom,msm-mbhc-gnd-swh = <0>, i.e. normally closed, with qcom,msm-mbhc-usbc-audio-supported = <0> (the jack doesn't go through the USB-C audio switch). The FIT Elite's board file already sets both; #663 found the same for the Pocket S2.

Change. Both properties on &wcd939x in the Pocket FIT's board patch (sm8650-konkr-pf.dts.patch), so the Pocket S2 is untouched.

2. Constant hiss on the jack (none through a USB-C DAC)

The APS2 profile plays headphones on the WCD939x PDM receive path, which hisses here, as 0073's description says it does on the FIT Elite. Stock Android on this board plays the jack in HPH PCM mode (HPH PCM Enable 1, RX_HPH PCM 1 by default in every pineapple mixer_paths) with RX HPH Mode CLS_H_ULP, and is silent with the same headphones.

What PCM mode needed on SM8650:

  • The port. Stock Android's RX swr-port-mapping puts HIFI_PCM_L/R (0x3b/0x3c) on master port 9, as qcom,rx-port-mapping already does, but sm8650.dtsi leaves port 9's transport timing unset (0xff) and there is no qcom,pcm-ports-mask. The board patch gives port 9 the PCM timing sm8650.dtsi already has at port 8 (sinterval 0x31, offsets 0, hstart 0, hstop 0xf, 24-bit, block packing 1, lane 1: the values the FIT Elite uses at its port 9) and qcom,pcm-ports-mask = <0x200>. With HIFI_PCM mapped to port 8 instead, the stream ran (DMA advancing, ports enabled on both ends with matching timing) but the codec received silence: the RX macro's PCM tap feeds port 9.
  • The order of the switches. HPHL Switch/HPHR Switch enable whichever port HPH PCM Switch selects at that moment. A port left on from the other mode (alsa-state restore at boot) collides on the bus (qcom_swrm_irq_handler: SWR Port collision detected) and nothing plays. So the Pocket FIT's enable sequence first turns both off in both modes, then selects PCM.
  • After the shared sequences. A small include, PocketFitHeadphones.conf, runs last. It sets Android's ULP mode and keeps the digital level at 0 dB, as stock Android (the class-H fixes are in fix(kernel): WCD939x class-H: program the class-H port window and run the start-up once #876). On disable it leaves PCM mode only after the shared disable sequence has turned the HIFI_PCM ports off.
  • Volume. Software volume (PlaybackMixerElem "HP Digital", as on the Elite and Odin 3), since in this mode the compander drives the PA.

The profile change is limited to the Pocket FIT by the model condition the APS2 profile already uses; other APS2 devices keep their current sequence.

Testing

On a Pocket FIT running 20261010.c3d178c (kernel 7.2.6), with these device-tree changes made to the deployed sm8650-konkr-pf.dtb (boot image rebuilt by armada-bootimg-update) and the same profile in a user UCM copy, 27 Oct 2026:

  • Headphone Jack goes on with headphones in and sound moves to them (Elect Insert stays 0; plug type and impedance are read: HPH Type 2, 21/22 ohm)
  • Back to the speakers on unplug
  • HPH PCM with ULP plays and the constant hiss is gone. The WCD939x registers then match a stock Android dump on the same device except BIAS_VBG_FINE_ADJ (a5 vs 55), CLASSH_MODE_2/3, FLYBACK_VNEGDAC_CTRL_2 and the PA gain field
  • No SWR Port collision with the switch-clearing sequence
  • The little noise when the amplifier powers up and the clipping at full volume: both came from the kernel class-H handling, fixed in fix(kernel): WCD939x class-H: program the class-H port window and run the start-up once #876 (merged). Headphones now play clean at full volume at 0 dB, as stock Android.

Device tree: building sm8650-konkr-pf.dtb from source the way build-kernel.sh does reproduces the Beta image's tree byte for byte. On main (cb3a439) these patches change only the two jack properties, qcom,pcm-ports-mask and the port 9 entries of the nine qcom,ports-* tables, the same change tested on the device. Both profiles parse with alsa-lib's config parser.

AI usage

The investigation (stock Android register and device-tree comparison, SoundWire register dumps), the patches and this text were drafted with Claude (Anthropic). The changes were applied to my own Pocket FIT and tested there as listed above.

Ovid added 2 commits October 27, 2026 13:00
The Pocket FIT shares sm8650-ayaneo-common.dtsi with the Pocket S2, whose WCD939x node lacks qcom,hphl-jack-type-normally-closed and qcom,ground-jack-type-normally-closed, so MBHC never reports a plug. Set both in the Pocket FIT's own board file, as the FIT Elite's and the stock Android tree do.

Fixes armada-os#426
The PDM receive path hisses on this jack. Like stock Android, play it in HPH PCM mode with CLS_H_ULP: give RX SoundWire port 9 the PCM timing and format enable in the board DT, and switch the Pocket FIT's headphone sequence in the APS2 profile to PCM, clearing both HPH port sets first so they don't collide.
@JPyke3

JPyke3 commented Oct 27, 2026

Copy link
Copy Markdown
Member

@mrdidit any thoughts on this one? One day I will crack and buy this device 🤣

@mrdidit

mrdidit commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

@mrdidit any thoughts on this one? One day I will crack and buy this device 🤣
@JPyke3

I don’t own the regular KPF, but I’ve been investigating similar headphone issues on the Pocket S2 😅 After fixing jack detection, audio was badly distorted above roughly 10%, and volume control wasn’t behaving properly. The first improvement kept PDM and disabled the codec companders, which made playback sound much better.

I went through this PR, then checked stock Android’s actual mixer and register settings. Android uses PCM/ULP with codec companders enabled, and sounded clean right up to maximum volume. One difference worth comparing: the S2’s active Android transport uses packing mode 0, while this PR sets 1.

There’s now an S2-specific PCM build based on the latest preview, using those captured Android settings without the −8 dB attenuation. It plays cleanly up to 32%, which sounds close to Android’s maximum loudness to my ears, but higher settings pop and distort. So the PCM approach makes sense, but the remaining clipping still needs investigating. Packing is a difference, can't confirm if it's the cause.

@ovid-io

ovid-io commented Oct 28, 2026

Copy link
Copy Markdown
Author

@mrdidit my port 9 values (sinterval 0x31, offsets 0, hstart 0, hstop 0xf, 24-bit, block packing 1, lane 1) are copied from the tree's port 8, which match what the FIT Elite uses at port 9. My Android dump on the G3 Pocket FIT only captured the codec (0x3000+), LPASS and tinymix, not the SoundWire port registers, so I can't yet say what Android uses on this device. How did you capture the S2's transport? I'll grab the same on the G3 Pocket FIT

Also does anyone know when the next beta release is gonna be out?

@mrdidit

mrdidit commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@ovid-io

Rooted Android over ADB, with headphones connected and audio actively playing. I mounted debugfs read-only and captured rx_swr_ctrl/swrm_reg_dump, alongside tinymix and the codec registers. Two consecutive captures showed port 9 active, with bank 1 selected and identical settings in both banks. Packing mode was 0; the other port 9 timing values matched yours. The important part is capturing during playback, since the port shuts down afterward.

@ovid-io

ovid-io commented Oct 28, 2026

Copy link
Copy Markdown
Author

@mrdidit thanks for that! I ran the checks now and packing is actually 1, but the capture turned up something else on the class-H port, that I now confirmed on Armada.

The master's BLOCK_CTRL3 reads back 0 whatever is written. Qualcomm's own SM8650 driver programs the HIFI row of pineapple-port-config.h (si 49, off 0/0, hstart 0, hstop 15, wd 24, bp_mode 1, lane 1) on both the master and the codec, yet 0x1938 reads 0 on Android, just as it does on Armada. Reading the codec directly instead (Android, wcd939x-slave debugfs swrslave_peek, music playing), DP6 shows BlockCtrl1 0x18, ChEn 0x3, SampleCtrl 0x31, HCtrl 0x0f, BlockCtrl3 1, Lane 1 in both banks. Armada with this PR (Beta 20261010, port 9, PCM/ULP, playing) has exactly the same DP6.

Class-H (DP2) on Linux two thighs disagree

  • Android codec: SampleCtrl 0x3f, HCtrl 0x36 (hstart 3, hstop 6), BlockCtrl3 0. Android master: HCTRL 0x63 (same 3/6).
  • Armada codec: SampleCtrl 0x1f, HCtrl 0x0f (0/15, the reset value), BlockCtrl3 1. Armada master: 0x100001f, HCTRL 0x63 (3/6, as the DT asks).

So on Linux the master sends class-H in columns 3-6 while the codec reads 0-15. Cause: wcd939x-sdw.c declares the RX ports SDW_DPN_SIMPLE, and _sdw_program_slave_port_params() in stream.c bails out before OffsetCtrl2/SampleCtrl2/HCtrl unless the port is SDW_DPN_FULL. Android programs DP2's HCtrl and reads back 0x36, so the codec does implement it. HIFI only works because its window (0/15) happens to equal the codec's reset value. (Unexplained: the DT asks for packing 0 on port 2, and stream.c writes BlockCtrl3 for every port, yet DP2 reads 1 on Armada.)

If the codec misreads the class-H control, the HPH supply won't track the signal, which would fit clipping and pops only at high levels, on both the S2 and the Pocket FIT. Android also uses si 63 for class-H (HPH_CLH row), where the DT has 31 (the DSD row's value).

Moving the master's port 2 window to 0/15 in the DT would land on the HIFI port's columns, so I think the fix belongs in the codec driver: program DP2's HCtrl (or declare it FULL) and use si 0x3f. Since you build S2 kernels, would you be up for trying that? I can't build a kernel for the Pocket FIT on Beta right now.

@mrdidit

mrdidit commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

@ovid-io You were right about packing. The earlier claim of 0 came from the master dump without checking codec DP6 That was a gap in my investigation. Direct codec reads on the S2 now show packing 1, matching your findings. The Class-H DP2 timing and packing differences you described are present too.

The follow-up also found another lead in Class-H startup. Android briefly applies startup settings, then restores the normal playback values. On Linux, enabling the second headphone channel can reapply those startup settings without repeating the restoration. That matches the values captured on the S2.

A new S2 test build is running with a small WCD939x ULP sequencing change to prevent that repeated setup. This build tests the startup-sequencing issue first. The DP2 transport changes you suggested remain under consideration, depending on the results.

@ovid-io

ovid-io commented Nov 10, 2026 •

Copy link
Copy Markdown
Author

@mrdidit an update, and a correction to my earlier comment.

Correction: I wrote that stream.c writes BlockCtrl3 for every port. It doesn't. In sdw_program_slave_port_params() the call to _sdw_program_slave_port_params() (OffsetCtrl2, BlockCtrl3, SampleCtrl2, HCtrl) only happens for non-simple ports, so none of the four is ever written for the WCD939x's RX ports. DP2's BlockCtrl3 = 1 on Armada is just its reset value, like its HCtrl 0x0f. DP6 happens to want exactly its reset values (packing 1, window 0/15), which is why HiFi PCM works.

Good news: with two kernel fixes the Pocket FIT's headphones are clean and loud at full volume at 0 dB digital, compander on, ULP, the same as stock Android. Your start-up lead was exactly it. The fixes are in #876 (commit):

  1. Class-H start-up (your finding), 0083. wcd_clsh_v3_state_hph_l/_r force the start-up IQ values, and only the first channel's buck/flyback enable restores them. The second channel left CLASSH_MODE_2/3 and FLYBACK_VNEGDAC_CTRL_2 at 0x1c/0xf2/0xb8 (Android: 0x3a/0xf0/0xf8). Downstream's state machine calls the stereo state (a no-op) for the second channel, so the fix runs the start-up only when buck and flyback are both off.
  2. The class-H port window, 0082. The CLSH port is declared SDW_DPN_FULL, so the codec gets HCtrl 0x36 (as Android) instead of keeping 0x0f.

I tested both as rebuilt modules on 20261109: the registers read back as Android's, the dropouts at loud peaks are gone, and so is the little noise when the amplifier powers up. #876 credits you for the start-up. Once it's merged, this PR's 8 dB of headroom can drop to 0 dB, and I'll update it then. If you can try 0083 on the S2 (#817), that would confirm it there too.

@FeralAI FeralAI self-assigned this 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.
@ovid-io

ovid-io commented Nov 16, 2026

Copy link
Copy Markdown
Author

#876 is merged, so I've dropped the 8 dB of headroom: the Pocket FIT's headphones play clean at full volume at 0 dB, compander on, ULP, as stock Android. Ready for review.

@github-actions

Copy link
Copy Markdown

Disk image

armada-disk-pr803, built from 587c96d

Downloads as a zip holding armada-*.img.gz and its .sha256.
GitHub requires you to be signed in to download run artifacts.

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.

# 3.5mm headphone jack never auto-detects on KONKR Pocket FIT (SM8650)

4 participants