Repository navigation
Conversation
984b7c8 to
00f350b
Compare
|
Blockers: 1. The write-back is correct. sound/soc/codecs/cs42l84.c:1319-1343 restores the plug-detection registers first, in
Nit: HW row: the resume path is shared by every CS42L84 Mac that sleeps via firmware, so add one more besides the J713 (J604 or J616s). Run 3 deep sleeps (empty, headset in, unplugged during sleep) on this head built in, not as an out-of-tree module, with jack state and Assisted-by: LLM (Claude:Opus 5.5) |
|
Blockers: 1.
The write-back itself looks right. Plug detection is restored first in the order Rows still needed: this head built in (not as a module), plus one more cs42l84 Mac besides the J713 (J604 or J616s). On each, 3 firmware deep sleeps (jack empty, headset in, unplugged during the sleep), with the jack state and |
00f350b to
7952eb8
Compare
|
Thanks. I dropped the The Air runs so far used this exact code as an out-of-tree module on an a7dd26e kernel; I'll add in-tree rows when the Air next gets a kernel with this head. I don't have a J604 or J616s. |
|
On "built in (not as a module)": every Aurora kernel config builds this driver as a module. |
|
Re-review of 7952eb8: No blockers.
The two earlier nits (a comment near the HW row: the J713 rows on a kernel built at this head (3 firmware deep sleeps: jack empty, headset in, unplugged during the sleep, with jack state and Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train note: #1895 (J604 cs42l84 init) landed in batch 1 (integration/aurora 606d37e) and conflicts with this branch in |
|
Heads-up: at 7952eb8 this no longer merges cleanly into |
|
@niteria, a tidy-up pass over the open PRs here. These of yours need something:
If any of these are no longer needed, closing them helps; otherwise a merge or rebase onto integration/aurora is usually all they need. Thanks! |
After a firmware sleep, the codec comes out of reset and the resume writes its cached registers back with regcache_sync(), in address order, with the interrupt still off. Turning tip and ring sensing on latches plug events at once, as do some later writes (MSM_BLOCK_EN3 among them), and the remote button sources come up latched (0x60 in REMOTE_BUTTON_STATUS1). Nothing reads them, and the codec stops answering the bus a write or two later: the write times out (-ETIME), the resume fails, and the jack stays dead until the driver is bound again. On the MacBook Air (M4, J713) this happened on every deep sleep. Write plug detection back first, in the order the probe sets it up, then every other register the cache holds, once each, in address order, and read the plug interrupt status after each write to clear what it latched, as the interrupt thread does. The remote button status is read once, after plug detection. A KUnit suite checks that order, that the plug detection list matches what the probe writes, and that a codec that stops answering ends the write-back with the error. Fixes: b912083 ("ASoC: cs42l84: Bring the codec back after a firmware sleep") Signed-off-by: Bartosz Nitka <niteria@gmail.com>
A headset unplugged during a firmware sleep leaves its bias on. The resume writes the cache back, the 2.7 V mic bias included, finds the jack empty and reports it, but unlike the interrupt thread's unplug path it does not call cs42l84_revert_hs(). The bias stays powered, disconnected from the jack, until the next plug. Revert the headset setup when the jack is empty after the wake, on both the tip-sense and ring-sense paths, as the unplug paths do. Fixes: b912083 ("ASoC: cs42l84: Bring the codec back after a firmware sleep") Fixes: 2f122e3 ("ASoC: cs42l84: add ring-sense plug detection, selected from DT") Signed-off-by: Bartosz Nitka <niteria@gmail.com>
7952eb8 to
60fbca7
Compare
|
Rebased onto
KUnit ( |
|
Re-checked 60fbca7: the conflict with #1895 is resolved in the right order ( Assisted-by: LLM (Claude:Opus 5.5) |
After a deep sleep, the cs42l84 headphone codec stops answering the bus while its registers are written back, so the jack stays dead until the driver is bound again. On the MacBook Air (M4, J713) this happened on every deep sleep:
Cause
The resume (b912083) releases the reset, checks the device ID, and writes the cache back with
regcache_sync(), in address order, with the interrupt still off. Turning tip and ring sensing on latches plug events at once (TSRS_PLUG_INT_STATUSreads 0xd right afterTIP_SENSE_CTL2), some later writes latch more (MSM_BLOCK_EN3), and the remote button sources come up latched (REMOTE_BUTTON_STATUS1= 0x60, as #1895 found on the J604). Nothing reads them, and a write or two later the codec stops answering. Which register fails moves with the order; the latched events are what it follows. A rebind (probe's sequence, with the interrupt live) works at any time after the wake.Change
Two fixes to the resume from b912083.
Write the registers back without leaving events latched. Plug detection is written back first, in the order
cs42l84_setup_plug_detect()sets it up, andREMOTE_BUTTON_STATUS1is read once after it. Then every other register the cache holds is written once, in address order.TSRS_PLUG_INT_STATUSis read after every write to clear what it latched, as the interrupt thread does.A KUnit suite,
snd-soc-cs42l84-sleep-test, runs the write-back on a regmap with the driver's cache and volatile registers. It checks that order, that the plug detection list matches what the probe writes, and that a codec that stops answering ends the write-back with the error.Power the headset bias down after an unplug in a sleep. When a headset was unplugged during the sleep, the resume reported the empty jack but, unlike the interrupt thread's unplug path, did not call
cs42l84_revert_hs(). The headset's 2.7 V mic bias (MISC_DET_CTL0x1f) stayed on, disconnected from the jack, until the next plug. The resume now reverts the headset setup as the unplug path does.Tested
J713 (MacBook Air M4), integration/aurora a7dd26e with this as an out-of-tree snd-soc-cs42l84.ko (the cs42l84 files are unchanged on integration since), the built-in 3.5 mm jack and a headset whose mic the codec detects, so the cache holds the mic bias on across a sleep with it plugged in. Woken by the RTC (rtc1) or the power key.
Before: every deep sleep failed to restore the codec (-62), and the jack stayed dead until a rebind.
Playback was checked by ear after five of them: the headset after the music, idle and plug-in sleeps, and the speakers after both unplugs. After an unplug in a sleep
MISC_DET_CTLreads 0x03 (bias off), where it read 0x1f without the bias fix. The headset-in sleeps, three of the empty ones and one unplug ran without the bias fix, which only changes what the resume does when it finds the jack empty.KUnit on UML:
snd-soc-cs42l84-test17/17 andsnd-soc-cs42l84-sleep-test2/2. The new suite fails on the oldregcache_sync()write-back and on five other mutations: plug detection written a second time, no status read, the list out of step with the probe, no button read, errors ignored.Host tests (tools/asahi/run-host-tests.py, full run): 427/427 on each commit and on the base. It merges cleanly with #2112 (jack reporting at attach and after a sleep that keeps the codec powered), which covers a different case, and with #1895.
Assisted-by: LLM (Claude:Opus 5.5)