Skip to content

kernel: iPad 5: Switch the panel off in system sleep, as iOS does - #170

Merged
henrikklee merged 6 commits into
OrchardLinux:mainfrom
brkosebay:j71t-panel-off-sleep
Nov 18, 2026
Merged

henrikklee merged 6 commits into
OrchardLinux:mainfrom
brkosebay:j71t-panel-off-sleep

Conversation

@brkosebay

@brkosebay brkosebay commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #168. Only the last 4 commits are new in this PR.

In s2idle the iPad 5's panel stayed powered. The pipe kept scanning out a black framebuffer to a panel whose TCON and source drivers ran on, with only the backlight off. iOS turns the panel off on every display sleep:

  • AppleDPDisplayPowerController drops lcd_ldo and keeps it off for at least 125 ms.
  • On enable it waits for hot-plug detect and lights the backlight no earlier than 193 ms after the supply.
  • The DisplayPort driver (an Analogix DP core) then trains the link again with a fast, no-handshake training: 4 lanes, 1.62 Gb/s, enhanced framing, ASSR.

This series does the same around system sleep. The pipe and the transmitter stay as the boot loader set them up; only the sink loses power.

  • Binding (drm/0009). The DisplayPort transmitter's window becomes a "dp" region. Two properties are added: apple,lcd-ldo-gpios (the ADT displayport function-lcd_ldo) and backlight. The A10's pipe does not take apple,lcd-ldo-gpios.
  • Driver (drm/0010).
    • Before cutting the supply, the driver checks that the live link passes everything the wake needs, using AUX reads only:
      • receiver capabilities and link configuration;
      • a trained lane status;
      • a sink that allows no-handshake training, with an ASSR mode that matches the transmitter;
      • a supply that reads on.
    • If any check fails, the panel stays on for that sleep and the reason is logged.
    • On resume:
      1. supply on after the 125 ms minimum;
      2. wait for hot-plug detect;
      3. write back the saved link configuration;
      4. send TPS1 then TPS2;
      5. check the lane status.
    • A failed wake retries twice. If the panel still does not come back, the backlight is held off, the supply is left on, and panel-off sleeps stop.
    • apple_adbe_drm.sleep_panel_off=0 keeps the panel on in sleep. The debugfs file adbe_panel runs the pre-sleep checks on demand.
  • DT (devices/s8000/0018, devices/s800x/0004). The S8003 pipe gets the transmitter window (0x206700000). The iPad 5 gets PMU GPIO 22 as the panel supply, plus its DWI backlight. Line 22 is no longer reserved.

Other devices

  • iPad 5 J71t/J72t (S8003) only. The S8000 iPad 5s (J71s/J72s) have no display-pipe node on main yet.
  • A10: iPad 6 and iPad 7 have the same supply (PMU GPIO 22) and transmitter address in their ADTs. Their transmitter (displayport,t8010, 0x4000 window) has not been read in an A10 kernelcache. Enabling it would mean AUX traffic at unverified offsets on a live link, so the A10 stays as it is. The driver changes nothing without apple,lcd-ldo-gpios.

How to test

On an iPad 5 (J71t/J72t), as root:

cat /sys/kernel/debug/dri/*/adbe_panel        # pre-sleep checks on the live link: all pass
rtcwake -m freeze -s 20                       # the panel is fully dark, not just backlight-off
dmesg | grep -iE 'adbe.*(panel|link)'          # supply off at suspend; link trained again on wake

The screen must come back with a correct picture after every wake. To compare with the panel left on: echo 0 > /sys/module/apple_adbe_drm/parameters/sleep_panel_off.

Hardware

iPad 5 (J71t), cold boot, on a development kernel with Orchard main plus the same panel-off patch:

  • The panel supply went off in every s2idle: Smart Cover, Power button and idle sleeps.
  • On wake the eDP link trained again in about 200 ms, and the screen lit as powerd woke the desktop.
  • The picture was correct after every wake.

That kernel had our own earlier version of the display-DART patches. On main, adbe_drv.c comes from the merged #158, so this patch was rebased onto it. Only the file's header comment and include list differed.

Release candidate: Orchard main + #167, #168, #169, #170

Cold boot on the iPad 5 (J71t) of current main (89c9640) with exactly these four PRs merged on top, built with main's own kernel/build and apple-16k config, booted with a standard install's options (prepared tree 24ac68ed5ce7ae1c35f4430ea047c291e1403292, 643 patches):

  • The desktop came up on its own, with rotation and Bluetooth.
  • The display DART self-check passed, with scanout through the DART.
  • RTC: woke on time (wake: PMU event(s) 16).
  • Power button: sleep and wake.
  • Smart Cover: a close slept for 114.7 s; the open woke it (wake: PMU event(s) 58, lit in 0.6 ms).
  • Plug: wake: PMU event(s) 72 on plug and on unplug. powerd lights the screen on plug and stays dark on unplug, as iOS does.
  • Panel: the supply was off in every sleep, and the link trained again in 200 ms on every wake.
  • Charging: the grant stayed at 2400 mA across sleep.
  • Wi-Fi worked after every wake.
  • suspend_stats: 6 successes and 1 failure. The failure was a Power press during suspend entry, which aborts the attempt as it should.

…ransmitter and panel supply

On the A9, iOS switches the panel off whenever the display sleeps: the
DisplayPort driver drops the panel's supply (the Apple device tree's
function-lcd_ldo on the displayport node) and trains the eDP link again
when it comes back. Allow the DisplayPort transmitter's register window as
a ninth "dp" region, the panel supply as apple,lcd-ldo-gpios and the
panel's backlight, so the display pipe's driver can do the same in system
sleep. The A10's pipe has neither.

Assisted-by: LLM
In s2idle the iPad 5 panel stayed powered: the pipe kept scanning out the
black boot framebuffer to a panel whose TCON and source drivers ran on,
with only the backlight off. iOS turns the panel off on every display
sleep. AppleDPDisplayPowerController drops lcd_ldo, keeps it off at least
125 ms, and on enable waits for hot-plug detect (expected within 67 ms)
and lets the backlight on no earlier than 193 ms after the supply. The
DisplayPort driver, an Analogix DP core (AppleANXDPTX), then trains the
link again. Its event log on J71t shows a no-handshake (fast) training at
the link the boot loader set up: 4 lanes, 1.62 Gb/s, enhanced framing,
swing 0, pre-emphasis 0, ASSR on.

Do the same around system sleep, leaving the pipe and the transmitter as
the boot loader set them up; only the sink loses power:

- Before the first sleep, look up the supply and the backlight, and order
  sleep so that the pipe suspends before the PMU GPIO (behind I2C) and
  the backlight resumes after the pipe. Neither holds up probe.
- At suspend, after the CRTC is off and the pipe shows the black boot
  framebuffer, the supply goes off only if the live link passes every
  check the wake needs: AUX reads of the receiver capabilities and of the
  sink's link configuration, a lane status that reads trained, a sink
  that allows no-handshake training, a sink whose scrambler seed mode
  (ASSR) matches the transmitter's (0x614 bit 0), and a supply that reads
  on and then off. Otherwise the panel stays on for that sleep, with the
  reason logged. 50 ms after the supply goes off, the hot-plug detect
  level and one AUX read are logged as a witness that the sink went away.
- On resume, before the CRTC is restored: supply on after the 125 ms
  minimum (counted in boot time: s2idle stops the monotonic clock), wait
  for hot-plug detect, read the capabilities back over AUX, write the
  saved link configuration (D0, ASSR as the transmitter has it,
  downspread, rate, lane count), send TPS1 then TPS2 with the transmitter
  and the DPCD, then check the lane status. A failed wake retries the
  whole sequence twice. If the panel still does not come back, the
  backlight is held off, the supply is left on and panel-off sleeps stop.

AUX follows iOS's readDPCDGated/writeDPCDGated. Unlike the Analogix
layout, the request nibble sits next to address bits 19:16 at 0x7a0, the
length at 0x794, the data at 0xc00, and the buffer clears with 0x790 bit
9. Completion is DP_INT_STA bit 1, an error bit 0 with the cause in
AUX_CH_STA.

sleep_panel_off=0 keeps the panel on in sleep, as before. The debugfs
file adbe_panel runs the pre-sleep checks on demand, with AUX reads only,
so their result can be seen before any sleep.

Assisted-by: LLM
…mitter window

The display pipe's driver trains the eDP link again after a sleep with the
panel off. Add the DisplayPort transmitter's registers (ADT displayport,
0x206700000, "displayport,s8003") to the pipe as its "dp" window. The
transmitter is in the dp power domain the pipe already holds.

Assisted-by: LLM
…ply and backlight

The ADT displayport node's function-lcd_ldo is PMU GPIO 22 on every iPad 5
board: the panel supply, which iOS switches off when the display sleeps.
Hand it and the DWI backlight to the display pipe, which now turns the
panel off in system sleep. Both are post-init providers: the pipe's probe
does not wait for the PMU or the backlight, and the driver looks them up
before the first sleep. Line 22 is no longer reserved.

Assisted-by: LLM
… switches

Rework of OrchardLinux#170 on current main:

- Renumber after main: drivers/drm 0010 (binding) and 0011 (driver), whose
  0009 collided with OrchardLinux#166's; devices/s800x 0003.
- drm/adbe: the transmitter's AUX channel is a struct drm_dp_aux with a
  transfer hook; DPCD access, retries, the capability and link status
  reads, the lane checks and DP_SET_POWER come from the shared DP helpers.
  The no-handshake TPS1/TPS2 sequence stays in the driver: it drives the
  transmitter's own training pattern register and the helpers have none.
- Panel-off sleep is unconditional wherever the device tree gives the
  panel supply: the sleep_panel_off parameter, the adbe_panel debugfs
  file, the post-power-off witness read and the info-level logging are
  gone (gate reasons are dev_dbg).
- The binding no longer forbids the panel supply on the A10 and allows
  the "dp" window there too; the T8010 device trees are unchanged until
  their supply line is known.
- The driver selects DRM_DISPLAY_DP_HELPER (configs updated).

Assisted-by: LLM
@henrikklee

Copy link
Copy Markdown
Contributor

Thanks, Berkay. I rebased this onto main (after #166, #167, #168) and reworked it before merging, so it needs one run on your iPad 5 first:

  • The sleep_panel_off parameter, the adbe_panel debugfs file and the post-power-off read are gone; the panel switches off whenever the DT names the panel supply. Info logging is now dev_dbg.
  • The AUX channel is now a struct drm_dp_aux with its own .transfer; DPCD reads/writes, retries, capability/link-status reads, lane checks and DP_SET_POWER go through the kernel's DP helpers. Only the short fixed-pattern training on wake is still hand-written (it drives the transmitter's pattern register, which has no helper).
  • Patches renumbered (drm 0010/0011, s800x 0003); the binding no longer forbids the property on A10.

Could you build this branch and check on the iPad 5: a few Power-button and Smart Cover sleeps, the panel really off during sleep, and a clean picture after every wake (no garbling, no black screen)? If the AUX transfer misbehaves, a dyndbg log of adbe from one wake would help. We'll merge once you confirm.

@brkosebay

Copy link
Copy Markdown
Contributor Author

Tested your rework on the iPad 5 (J71t). The kernel was this branch at 4462886d55 (current main + your #170 rework), plus #174 and a USB patch that only touches dwc2/pmdomain. It was a cold boot from DFU with the standard install's boot options.

  • Sleeps: a Power-button sleep of 149 s, woken by Power, and a Smart Cover sleep, closed then opened. Both were clean s2idle cycles. suspend_stats shows 3 successes and 0 failures this boot.
  • Panel really off. I traced the lcd_ldo line (PMU GPIO 22, global 742) with the gpio:gpio_value and power:suspend_resume trace events across the cover sleep:
    1316.400  dpm_suspend[2] begin
    1316.418  gpio_value: 742 set 0      <- panel supply off
    1316.968  machine_suspend[1] begin
    1318.019  machine_suspend[1] end
    1318.408  gpio_value: 742 set 1      <- panel supply back on
    
  • Clean wakes: the picture came back correctly after each wake, with no garbling and no black screen. dyndbg was on for adbe_drv.c, and none of its four debug sites fired: no "panel stays on in sleep", no AUX failure and no missing hot-plug detect. So the drm_dp_aux path and the fast retrain went through cleanly. The Power wake lit the screen 268 ms after the press.

Good to merge from my side.

@henrikklee
henrikklee merged commit 4702641 into OrchardLinux:main Nov 18, 2026
12 checks passed
henrikklee added a commit that referenced this pull request Nov 19, 2026
brkosebay's J71t results across #28 (bring-up checks), #118 (Smart
Cover), #124 (install), #167 (charging grant), #168 and #170 (sleep)
and omarchy-a#65 (Bluetooth controller): screen off, backlight, touch,
the Power button, NVMe read and write, Wi-Fi, Bluetooth input, battery,
charging and its grant, suspend and resume. Each line names its source.

Bluetooth audio and the microphones stay untested: no J71t result on
Orchard yet.
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.

2 participants