Repository navigation
ASoC: cs42l84: enable soft ramp and midrail settle on DAC/ADC power-up - #3560
Conversation
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]>
|
@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! |
There was a problem hiding this comment.
Verdict: MERGE at 91452c65
Blockers: none (await the queued CI checks at 91452c65 before merging)
Checked:
sound/soc/codecs/cs42l84.{c,h}andcs42l84-test.c:cs42l84_component_probe(): setsCS42L84_HP_VOL_CTL_SOFT | CS42L84_HP_VOL_CTL_ZERO_CROSS(0x03), matchingcs42l42soft-ramp behavior.cs42l84_hp_adc_settle_event()/cs42l84_hp_adc_ev(): wired asPRE_PMU | POST_PMUonDACandADCunder sleepable DAPM context (card->dapm_mutex), waiting once (20–21 ms, matchingCS42L42_HP_ADC_EN_TIME_US) per simultaneous power-up and cleared oncs42l84_resume().cs42l84_mute_stream(): checksplayback_active(stream == SNDRV_PCM_STREAM_PLAYBACK && (stream_use & BIT(PLAYBACK))) before clearingstream_use, clearsCS42L84_DAC_CTL1_UNMUTE, and sleeps20–25 msonly when tearing down an active playback stream so the soft-mute ramp finishes before switchingCCM_CTL1back toRCOand 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/21arm64 KUnit pass).
- Hardware & static verification: J713 M4 Air (
cirrus,cs42l84rev0x36, default cmdline, identicalcs42l84*code) confirmed0x3020=03,S24_LEplayback/capture, 5x rapid start/stop stress,s2idle, anddeepS2R + post-deep playback with0failed units and0audio errors;checkpatch --strict0/0/0,LLVM=1 W=10warnings;two-waydoor;MERGEABLEonmain.
Evidence
- Head:
91452c65(MERGEABLEonmain,+117/-5across 3 files). - CI at review time: checks
QUEUED.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Merging at |
What: Enable
CS42L84_HP_VOL_CTL_SOFTalongside zero-cross ramping, waitCS42L84_MUTE_RAMP_TIME_US(20 ms) after muting an active playback stream before returningCCM_CTL1to RCO and stopping the PLL, and add a 20 msPRE_PMU/POST_PMUmidrail settle on the CS42L84DACandADCDAPM widgets (matchingcs42l42_hp_adc_ev()from commit4ae1d8f911d6). 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 ontolocal/j713-272en38dbfa2895b93asac2bdf4de4ba; zero diff vsmaininsound/soc/codecs/cs42l84*): boots default command line (0failed units,/dev/dri/renderD128present,0new kernel errors),CS42L84_HP_VOL_CTL(0x3020) reads0x03,hw:AppleJack,0S24_LEplayback, capture, 5x rapid start/stop stress,1x s2idle, and1x deepS2R all pass with clean register restore and0audio 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=10 warnings;checkpatch.pl --strict0 errors / 0 warnings / 0 checks.Risk: two-way door · M1 Pro/Max and M2–M5 Macs with
cirrus,cs42l84Not yet: nothing
Details
Background
cs42l42.c(used bycs42l83on base M1 Macs) enables soft-ramp volume/mute (SFTRAMP_RATE/SLOW_START_ENABLE) and runs a single 20 msPRE_PMU/POST_PMUmidrail stabilization delay (cs42l42_hp_adc_ev(), upstream commit4ae1d8f911d6) when powering upHP/ADC. Incs42l84.c, three pieces were missing:cs42l84_component_probe()clearedCS42L84_HP_VOL_CTL_SOFTwhile leaving onlyCS42L84_HP_VOL_CTL_ZERO_CROSS, causing abrupt mute/unmute transitions.cs42l84_mute_stream()clearedCS42L84_DAC_CTL1_UNMUTEand immediately switchedCCM_CTL1back toRCOand disabled the PLL, cutting clocks before the DAC soft-mute ramp could complete.DACandADCDAPM widgets had noPRE_PMU/POST_PMUsettle delay after settingCS42L84_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: defineCS42L84_HP_ADC_EN_TIME_US(20000 us) andCS42L84_MUTE_RAMP_TIME_US(20000 us).sound/soc/codecs/cs42l84.c:CS42L84_HP_VOL_CTL_SOFT | CS42L84_HP_VOL_CTL_ZERO_CROSSincs42l84_component_probe().cs42l84_hp_adc_settle_event()/cs42l84_hp_adc_ev()wired asPRE_PMU | POST_PMUonDACandADC(hp_adc_up_pendingensures one 20 ms wait per DAPM power-up sequence and is cleared oncs42l84_resume()).CS42L84_MUTE_RAMP_TIME_USafter clearingCS42L84_DAC_CTL1_UNMUTEwhen tearing down an active playback stream (stream_use & BIT(SNDRV_PCM_STREAM_PLAYBACK)), before switchingCCM_CTL1toRCOand stopping the PLL.sound/soc/codecs/cs42l84-test.c: addcs42l84_test_probe_enables_soft_rampandcs42l84_test_hp_adc_ev_settleKUnit tests.No model/board/chip gating, no kernel command-line knobs, and no UAPI or DT changes.
Evidence
Commits
91452c659418ae61f902b771272fc84cd637cff3onmain(a441f2a6b29d)ac2bdf4de4ba(91452c659418cherry-picked ontolocal/j713-272en38dbfa2895b93;git diff a441f2a6b29d..8dbfa2895b93 -- sound/soc/codecs/cs42l84*is empty), kernel7.3.0-cs42l84pop+Static checks & KUnit
git format-patch -1 --stdout | ./scripts/checkpatch.pl --strict -:total: 0 errors, 0 warnings, 0 checks, 181 lines checkedmake ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 W=1 sound/soc/codecs/cs42l84.o: 0 warningssnd-soc-cs42l84-test+snd-soc-cs42l84-sleep-test):21/21passedLive hardware verification — J713 M4 MacBook Air (
cirrus,cs42l84rev0x36)Default kernel command line (
plymouth.ignore-serial-consoles user4k=on loglevel=7 console=tty0),0failed systemd units,/dev/dri/renderD128present,0cs42l84/apple-mca/asocerrors 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/registersduring headless automated pass (0600=CCM_CTL1,0800=PLL_CTL1,1801=MSM_BLOCK_EN2,3000=DAC_CTL1,3020=HP_VOL_CTL):