Skip to content

drm/apple: answer the DCP PMU temperature query with the battery temperature - #1249

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
gaps8/dcp-battery-pmu-temperature
Nov 8, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
gaps8/dcp-battery-pmu-temperature

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

DCP asks the AP for PMUS/Temperature once while it starts. When no 2D panel temperature has been set it uses the answer as the initial panel temperature for its compensation (initial_guess: ... using PMU temperature as initial guess). Linux answered a constant 3029 on every machine, so the DCP always started from 30.29 (really 29.7 C, see below).

What macOS sends (our own observation, J700 Neo, macOS 26.6.2)

boot DCP log initial_guess AppleSmartBattery Temperature (= SMC B0AT) DCP InitialPanelTemperature (Q16.16)
2026-11-09 04:32 29.969985961 2997 (0.1 K) 1736704 = 26.500 C = (2997 - 2732) / 10, TB0T 26.5
2026-11-02 12:43 29.779998779 (not read) 1611530 = 24.59 C

So macOS answers with the battery gas gauge temperature in 0.1 K; the firmware prints it /100 but converts it as Kelvin. The Neo's macOS also logs the "2D temperature from SMC not set" line (it never sets a 2D field on that machine), so on the Neo this reply is the whole input.

Change

  • dcp_pmu_temperature(): first system-scope battery power supply, POWER_SUPPLY_PROP_TEMP (0.1 C) + 2732 = 0.1 K, read at the time of the query. No battery (desktops, or the battery driver not bound) keeps the old 3029.
  • Used by all three D401 handlers (template mini-LED path, v14.7, H17P).
  • MODULE_SOFTDEP("pre: ... macsmc-power") so the SMC battery exists when DCP starts.

No constants from Apple; the 2732 is the inverse of the 0.1 K -> 0.1 C conversion macsmc-power already does on B0AT.

Not in this PR

The J616s still logs "temperature from SMC not set": its macOS installs a four-corner field at boot (thermalmonitord), which needs its own trace (lane GAPS8-PANELT, spec in the lane note).

🤖 Generated with Claude Code

…erature

DCP asks the AP for "PMUS"/"Temperature" once while it starts and, when
no 2D panel temperature has been set, takes the answer as the initial
panel temperature for its compensation. Linux answered with a constant
3029 on every machine.

Our own macOS observation on the J700 (macOS 26.6.2) shows what macOS
sends: the system battery's gas gauge temperature in 0.1 K, the same
value the SMC reports in B0AT. At one boot the battery read 2997, the
DCP logged "using PMU temperature as initial guess: 29.969985961" and
published InitialPanelTemperature 26.5 C in Q16.16, which is
(2997 - 2732) / 10, the battery temperature. An earlier boot matched in
the same way (29.78 logged, 24.59 C published).

Read the temperature from the system battery power supply at the time
of the query and convert it back to 0.1 K. Without a battery (desktops,
or no battery driver bound) keep the old reply. Load macsmc-power before
the DCP so the battery exists when DCP starts.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware proof, test kernel 7.3.0-aurora-panelt1 = fleet37 (integration 1fadde6) + this commit (cherry-picked as b4725b57), own release string, one-shot boots, displays kept off by the night rules (proof from DCP logs, not visuals). Config identical to fleet37.

Mac battery (0.1 C) reply (0.1 K) DCP initial_guess panelt1 fleet37 same Mac
J616s (M4 Pro, 26.6 desktop fw path) 282 3014 30.139999389 30.289993286
Neo (J700, H17P path) 271 3003 30.029998779 30.289993286
M1 Pro (headless, mini-LED) 234 2966 (dcp_pmu_temperature dyndbg on the test entry only, 3 queries at 0.92 s) (fw does not log it)
  • The reply is read at query time, so it follows the battery at each DCP start.
  • DCP kernel log, panelt1 vs fleet37 on the same Mac (sorted, numbers stripped): J616s only boot-timing/brightness-ramp noise, Neo only brightness ramp values, M1 Pro only the new debug line. No new DCP errors.
  • All three: SELinux Enforcing, 0 AVC, systemctl is-system-running = running, then back to fleet37 with the test kernel removed.
  • macsmc-power lands in the initramfs through the softdep (lsinitrd on the J616s and Neo).
  • M2: not reachable tonight (hung, waiting for a power button press).
  • Build: buildbox, rht 196/196, apple-dcp selftests 87/0.

macOS side (own observation, J700 macOS 26.6.2, 04:32 boot): initial_guess ... 29.969985961, AppleSmartBattery Temperature 2997, SMC B0AT 2997, TB0T 26.5, InitialPanelTemperature 1736704 = 26.5 C (Q16.16).

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 8, 2026 18:13
@RyanTheTide
RyanTheTide merged commit d8963aa into integration/aurora Nov 8, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the gaps8/dcp-battery-pmu-temperature branch November 8, 2026 18:15
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.

1 participant