Skip to content

ASoC: cs42l84: enable soft ramp and midrail settle on DAC/ADC power-up - #3560

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/cs42l84-hp-pop-sequencing
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/cs42l84-hp-pop-sequencing

Conversation

@erikwb

@erikwb erikwb commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What: Enable CS42L84_HP_VOL_CTL_SOFT alongside zero-cross ramping, wait CS42L84_MUTE_RAMP_TIME_US (20 ms) after muting an active playback stream before returning CCM_CTL1 to RCO and stopping the PLL, and add a 20 ms PRE_PMU/POST_PMU midrail settle on the CS42L84 DAC and ADC DAPM widgets (matching cs42l42_hp_adc_ev() from commit 4ae1d8f911d6). This addresses the codec pop-suppression gaps so the headphone path can power down and back up cleanly when idle.
Tested: J713 M4 Air at 91452c659418 (cherry-picked onto local/j713-272en3 8dbfa2895b93 as ac2bdf4de4ba; zero diff vs main in sound/soc/codecs/cs42l84*): boots default command line (0 failed units, /dev/dri/renderD128 present, 0 new kernel errors), CS42L84_HP_VOL_CTL (0x3020) reads 0x03, hw:AppleJack,0 S24_LE playback, capture, 5x rapid start/stop stress, 1x s2idle, and 1x deep S2R all pass with clean register restore and 0 audio errors; listening test with headphones plugged into the 3.5 mm jack sounds great (nothing on resume, at most a barely noticeable tiny tick on suspend); ARM64 KUnit (snd-soc-cs42l84-test + snd-soc-cs42l84-sleep-test) 21/21 pass; LLVM=1 W=1 0 warnings; checkpatch.pl --strict 0 errors / 0 warnings / 0 checks.
Risk: two-way door · M1 Pro/Max and M2–M5 Macs with cirrus,cs42l84
Not yet: nothing

Details

Background

cs42l42.c (used by cs42l83 on base M1 Macs) enables soft-ramp volume/mute (SFTRAMP_RATE / SLOW_START_ENABLE) and runs a single 20 ms PRE_PMU/POST_PMU midrail stabilization delay (cs42l42_hp_adc_ev(), upstream commit 4ae1d8f911d6) when powering up HP/ADC. In cs42l84.c, three pieces were missing:

  1. cs42l84_component_probe() cleared CS42L84_HP_VOL_CTL_SOFT while leaving only CS42L84_HP_VOL_CTL_ZERO_CROSS, causing abrupt mute/unmute transitions.
  2. cs42l84_mute_stream() cleared CS42L84_DAC_CTL1_UNMUTE and immediately switched CCM_CTL1 back to RCO and disabled the PLL, cutting clocks before the DAC soft-mute ramp could complete.
  3. The DAC and ADC DAPM widgets had no PRE_PMU/POST_PMU settle delay after setting CS42L84_MSM_BLOCK_EN2, allowing stream unmute to start the PLL and unmute the DAC before the HP/ADC midrail supply settled.

Changes

  • sound/soc/codecs/cs42l84.h: define CS42L84_HP_ADC_EN_TIME_US (20000 us) and CS42L84_MUTE_RAMP_TIME_US (20000 us).
  • sound/soc/codecs/cs42l84.c:
    • Set CS42L84_HP_VOL_CTL_SOFT | CS42L84_HP_VOL_CTL_ZERO_CROSS in cs42l84_component_probe().
    • Add cs42l84_hp_adc_settle_event() / cs42l84_hp_adc_ev() wired as PRE_PMU | POST_PMU on DAC and ADC (hp_adc_up_pending ensures one 20 ms wait per DAPM power-up sequence and is cleared on cs42l84_resume()).
    • Wait CS42L84_MUTE_RAMP_TIME_US after clearing CS42L84_DAC_CTL1_UNMUTE when tearing down an active playback stream (stream_use & BIT(SNDRV_PCM_STREAM_PLAYBACK)), before switching CCM_CTL1 to RCO and stopping the PLL.
  • sound/soc/codecs/cs42l84-test.c: add cs42l84_test_probe_enables_soft_ramp and cs42l84_test_hp_adc_ev_settle KUnit tests.

No model/board/chip gating, no kernel command-line knobs, and no UAPI or DT changes.

Evidence

Commits

  • PR head: 91452c659418ae61f902b771272fc84cd637cff3 on main (a441f2a6b29d)
  • J713 live test build: ac2bdf4de4ba (91452c659418 cherry-picked onto local/j713-272en3 8dbfa2895b93; git diff a441f2a6b29d..8dbfa2895b93 -- sound/soc/codecs/cs42l84* is empty), kernel 7.3.0-cs42l84pop+

Static checks & KUnit

  • git format-patch -1 --stdout | ./scripts/checkpatch.pl --strict -: total: 0 errors, 0 warnings, 0 checks, 181 lines checked
  • make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 W=1 sound/soc/codecs/cs42l84.o: 0 warnings
  • ARM64 KUnit (snd-soc-cs42l84-test + snd-soc-cs42l84-sleep-test): 21/21 passed

Live hardware verification — J713 M4 MacBook Air (cirrus,cs42l84 rev 0x36)

Default kernel command line (plymouth.ignore-serial-consoles user4k=on loglevel=7 console=tty0), 0 failed systemd units, /dev/dri/renderD128 present, 0 cs42l84/apple-mca/asoc errors before or after S2R (3 pre-existing DCP/SEP boot errors unchanged).

Listening test with headphones plugged into the 3.5 mm jack: audio sounds clean with no pop on resume and at most a barely noticeable tiny tick on suspend.

Regmap /sys/kernel/debug/regmap/0-004b/registers during headless automated pass (0600=CCM_CTL1, 0800=PLL_CTL1, 1801=MSM_BLOCK_EN2, 3000=DAC_CTL1, 3020=HP_VOL_CTL):

INITIAL_IDLE:          0600=00 0800=06 1801=00 3000=60 3020=03
ACTIVE_PLAY (S24_LE):  0600=0b 0800=07 1801=00 3000=61 3020=03  (aplay rc=0)
POST_PLAY_IDLE (+6s):  0600=00 0800=06 1801=00 3000=60 3020=03
ACTIVE_CAP  (S24_LE):  0600=0b 0800=07 1801=00 3000=60 3020=03  (arecord rc=0)
POST_CAP_IDLE  (+6s):  0600=00 0800=06 1801=00 3000=60 3020=03
STRESS_5X (1s play):   [(0, 0, 1.04s), (1, 0, 1.04s), (2, 0, 1.04s), (3, 0, 1.04s), (4, 0, 1.04s)]
POST_STRESS_IDLE (+6s):0600=00 0800=06 1801=00 3000=60 3020=03
S2IDLE (rtcwake rtc1): rc=0; POST_S2IDLE: 0600=00 0800=06 1801=00 3000=60 3020=03; play rc=0
DEEP   (rtcwake rtc1): rc=0; POST_DEEP:   0600=00 0800=06 1801=00 3000=60 3020=03
POST_DEEP_ACTIVE_PLAY: 0600=0b 0800=07 1801=00 3000=61 3020=03  (aplay rc=0)
POST_DEEP_IDLE (+6s):  0600=00 0800=06 1801=00 3000=60 3020=03

Allow the CS42L84 headphone path to power down and back up cleanly when
userspace suspends an idle PCM instead of keeping the sink pinned open:

- Enable CS42L84_HP_VOL_CTL_SOFT alongside CS42L84_HP_VOL_CTL_ZERO_CROSS
  in cs42l84_component_probe() so mute and volume transitions soft-ramp
  on zero crossings rather than stepping abruptly.
- Wait CS42L84_MUTE_RAMP_TIME_US after clearing CS42L84_DAC_CTL1_UNMUTE
  on an active playback stream so the soft-mute ramp finishes while the
  DAC is still clocked before returning to the internal oscillator and
  powering down the DAC widget.
- Add a PRE_PMU/POST_PMU DAPM event callback on the DAC and ADC widgets
  waiting CS42L84_HP_ADC_EN_TIME_US (20 ms, once per power-up sequence)
  for the HP/ADC midrail supply to stabilize before stream unmute starts
  the PLL and unmutes the DAC, matching cs42l42_hp_adc_ev() from
  commit 4ae1d8f ("ASoC: cs42l42: Allow time for HP/ADC to
  power-up after enable").
- Add KUnit coverage in cs42l84-test.c for soft-ramp probe setup and
  single-wait DAPM power-up sequencing.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 28, 2026 18:45
@erikwb
erikwb requested review from LiamRay11 and malik-na November 28, 2026 18:45
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@RyanTheTide fyi - the idea here is that we can drop omarchy-mac's asahi-audio-no-suspend.conf once this is in, and save 50-150mW!

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 91452c65

Blockers: none (await the queued CI checks at 91452c65 before merging)

Checked:

  • sound/soc/codecs/cs42l84.{c,h} and cs42l84-test.c:
    • cs42l84_component_probe(): sets CS42L84_HP_VOL_CTL_SOFT | CS42L84_HP_VOL_CTL_ZERO_CROSS (0x03), matching cs42l42 soft-ramp behavior.
    • cs42l84_hp_adc_settle_event() / cs42l84_hp_adc_ev(): wired as PRE_PMU | POST_PMU on DAC and ADC under sleepable DAPM context (card->dapm_mutex), waiting once (20–21 ms, matching CS42L42_HP_ADC_EN_TIME_US) per simultaneous power-up and cleared on cs42l84_resume().
    • cs42l84_mute_stream(): checks playback_active (stream == SNDRV_PCM_STREAM_PLAYBACK && (stream_use & BIT(PLAYBACK))) before clearing stream_use, clears CS42L84_DAC_CTL1_UNMUTE, and sleeps 20–25 ms only when tearing down an active playback stream so the soft-mute ramp finishes before switching CCM_CTL1 back to RCO and stopping the PLL.
    • Unit tests (cs42l84_test_probe_enables_soft_ramp, cs42l84_test_hp_adc_ev_settle): verified widget wiring and single-wait state machine (21/21 arm64 KUnit pass).
  • Hardware & static verification: J713 M4 Air (cirrus,cs42l84 rev 0x36, default cmdline, identical cs42l84* code) confirmed 0x3020=03, S24_LE playback/capture, 5x rapid start/stop stress, s2idle, and deep S2R + post-deep playback with 0 failed units and 0 audio errors; checkpatch --strict 0/0/0, LLVM=1 W=1 0 warnings; two-way door; MERGEABLE on main.
Evidence
  • Head: 91452c65 (MERGEABLE on main, +117/-5 across 3 files).
  • CI at review time: checks QUEUED.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 91452c65. App approved (NEON-PR-REVIEW2), J713 row PASS. The cs42l84 driver serves the headphone jack on most M2-and-later Macs, so this needs one second-family row at this head (J413, J473 or J616s: plug and unplug headphones with nothing playing, then a quiet playback ramp; no pop and the volume steps land). It merges under the 6-point rule after that and green CI, unless you object.

@github-actions github-actions Bot added area:audio Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 91452c65: not ready yet

Check Detail
CI at head ok 3 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 91452c65
Conflicts ok not computed yet
PR text ok Risk: two-way · M1 Pro/Max and M2–M5 Macs with cirrus,cs42l84

Areas: area:audio

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 91452c659418 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: in the PR body at 91452c6. CI: linux train L2 = main (after train L1) + #1489 #3223 #3291 #3333 #3395 #3407 #3547 #3560 #3651 #3684 #3569 #3599 (candidate dd0c7bb9): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-topology/ave/asahi all pass; host-tests/dt-checks green at this head where they apply. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 98156ea into main Dec 1, 2026
5 of 8 checks passed
@RyanTheTide
RyanTheTide deleted the fix/cs42l84-hp-pop-sequencing branch December 1, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:audio Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants