Skip to content

simpledrm: a NEON turned copy, and landscape for a turned scanout - #163

Merged
henrikklee merged 2 commits into
OrchardLinux:armv7from
Developerr86:ipad3-simpledrm-landscape
Dec 5, 2026
Merged

henrikklee merged 2 commits into
OrchardLinux:armv7from
Developerr86:ipad3-simpledrm-landscape

Conversation

@Developerr86

Copy link
Copy Markdown

Two changes to simpledrm's turned copy (the opt-in rotation from #103), for GPU-less boards whose scanout is turned.

What users get: on the iPad 3, full-screen updates cost less than half as much CPU, and the desktop can turn to landscape and upside down (auto-rotation) at no extra cost per frame.

1. drm/tiny: simpledrm: Gather turned tiles with NEON

The rotation-90 tile copy gathered one pixel at a time: about 23 cycles a pixel on the A5X, 73.6 ms per full 1536×2048 frame. simpledrm_neon.c transposes 4×4 blocks with VTRN. It includes only arm_neon.h (as crypto/aegis128-neon-inner.c does, hence the uint32_t), is built with CC_FLAGS_FPU only when simpledrm is built in on ARM with KERNEL_MODE_NEON, and runs between kernel_neon_begin()/end() when may_use_simd(). The scalar path stays for everything else. It matched the scalar mapping on 2000 random tiles under QEMU (0 wrong pixels). Measured on the iPad3,3: 28.6 ms per full frame (11.5 ns a pixel), from 73.6 ms.

2. drm/tiny: simpledrm: Offer a turned scanout in its own shape too, and flip

A turned scanout was offered upright only. Turning the picture in the compositor (wlr-randr --transform) makes pixman turn every frame, which on the A5X cost about 3× per full frame. That's 2.5 s of labwc CPU for the turn itself and 0.3 s per full-screen frame afterwards, so auto-rotation was unusable. So:

  • the connector lists a second mode in the scanout's own shape (2048×1536 here, after the preferred upright 1536×2048). It is copied unturned, a plain row copy, cheaper than the turned one;
  • a flip parameter (/sys/module/simpledrm/parameters/flip) turns either mode a further 180°. Setting it reverses what is on the scanout in place, so nothing has to redraw. One mutex orders it against the copies.

A compositor reaches all four orientations with a mode change and flip, and keeps transform normal. Touch follows with a libinput calibration matrix. Without a rotation property nothing changes: one mode, no flip.

On the interface: flip is a presentation choice like zoom, not hardware behaviour. The standard alternative would be the primary plane's rotation property (DRM_MODE_ROTATE_180), but wlroots never sets it and renders transforms itself. I'm happy to switch to it, or to another shape, if you prefer. The user of flip is omarchy-a's rotation daemon; the change for it is in his fork's image script (j2a-rotate/rotate-patch.py) and will be an omarchy-a PR.

Testing

  • On the device (iPad3,3, 32 GB, Omarchy A from flash): Developerr86/linux d90efddd and 65192f2c, which are the same code on top of his debugfs counters (left out here). The NEON copy has run on every boot since 2026-12-04 15:20, and the copy was measured with those counters. Rotation was tried on 2026-12-04 21:40 with the LIS331DLH from ARM: dts: apple: ipad3: Add I2C1 and I2C2 sensor buses #137 and iio-sensor-proxy: all four orientations, with touch, the bottom-edge swipe and a side-switch rotation lock working in landscape. A turn costs about 0.7 s until the new picture settles; a flip write takes 73 ms.
  • This revision: built with orchard_applearmv7_defconfig (simpledrm built in, NEON on) and W=1, no warnings. checkpatch --strict: only the Assisted-by trailer, MAINTAINERS for the new file, and the intended uint32_t in the NEON file. Not booted in this exact form yet (it is the same code minus the counters), hence draft; I'll boot it on the J2A and mark it ready.
  • Other devices: every board whose simple-framebuffer has rotation. Here that is the iPad 3 (s5l8945x-ipad3.dtsi) and the A6X iPad 4 (s5l8955x.dtsi, P101-P103, untested): they get the NEON copy and the second mode. Boards without rotation are unchanged.

Proposed CHANGELOG line (Unreleased): iPad 3 and iPad 4: a twice-as-fast screen copy, and landscape and upside-down without a GPU.

At native resolution the iPad 3's simpledrm spent 73.6 ms on each
full-screen update (23 ns a pixel at 1 GHz), most of it in the scalar
gather that builds each scanout run one pixel at a time. On ARM with
kernel-mode NEON and simpledrm built in, the unzoomed rotation-90 case
now gathers a tile in 4x4 blocks instead: four upright rows loaded,
transposed with VTRN, and stored as four runs of a scanout row. Other
cases, partial blocks and contexts where may_use_simd() is false keep
the scalar loop.

simpledrm_neon.c includes only the compiler's arm_neon.h, because its
stdint.h and the kernel's types do not mix (as in
crypto/aegis128-neon-inner.c). It is therefore built in only, with
CC_FLAGS_FPU. Checked against the scalar mapping on 2000 random tiles
under QEMU.

Assisted-by: LLM
Signed-off-by: Developerr86 <138863457+Developerr86@users.noreply.github.com>
A turned scanout was offered only upright. Offer its own shape as a second
mode, copied unturned, so that a compositor can put the picture on its side
by a mode change instead of turning every frame itself, which costs pixman
about three times as much per frame here.

Assisted-by: LLM
Signed-off-by: Developerr86 <138863457+Developerr86@users.noreply.github.com>
[Orchard: dropped the flip parameter; rotation should use the plane rotation property]
Signed-off-by: Henrik Klee <henrik@goat-code.com>
@henrikklee
henrikklee force-pushed the ipad3-simpledrm-landscape branch from e765f28 to 82cf642 Compare December 5, 2026 01:14
@henrikklee
henrikklee marked this pull request as ready for review December 5, 2026 01:14
@henrikklee
henrikklee merged commit efa753f into OrchardLinux:armv7 Dec 5, 2026
3 checks passed
@henrikklee

Copy link
Copy Markdown

Thank you, Ashish! Cutting the full-screen copy from 73.6 ms to 28.6 ms is a big win on the A5X, and offering the scanout's own shape as a second mode is a clean, standard way to get landscape.

What we changed on your branch:

  • Commit 1 (NEON copy): unchanged.
  • Commit 2: kept the second mode (2048x1536 landscape, copied unturned) and dropped the writable flip module parameter. A sysfs switch that changes how the hardware draws is not a standard interface, and turning the picture belongs to the primary plane's rotation property (DRM_MODE_ROTATE_180). Your authorship and sign-off stay; the commit message has an [Orchard: ...] note saying what we dropped, plus our sign-off.

Nothing is lost: your original commit is tagged contrib/Developerr86-simpledrm-flip, and the iPad 3's README in orchard lists it under "Unmerged code" and the rotation property under "Open work".

Upside down through the plane's standard rotation property would be a very welcome follow-up, then the rotation daemon can set it. Orchard picks this up when it moves its armv7 kernel lock; the nightly after that is the first build with it.

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