Repository navigation
HID: apple-mtp-kiwi, drm/apple: map touches onto the picture when the notch is hidden - #3722
Conversation
The touch screen of a notched panel reports positions over the whole panel, while the display may scan its picture out below the notch rows. Only the display driver knows which, and the touch driver must work with or without it, in any load order. Add a small built-in record of the geometry: the panel's active rows and the rows above the picture. The display driver publishes it with every frame; readers take it lock-free in any context. Nothing published reads as a picture on the whole panel. Two helpers map a touch axis that spans the whole panel onto the picture: the hidden band is reported as such, the band's lower edge maps to 0 and the panel's bottom edge stays the axis maximum. KUnit covers the published state and the translation. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Wherever a swap records the rows above the frame (the notch rows for a notch-free mode, else 0), also publish them with the panel's active rows to the built-in panel notch record, for the touch screen. It follows what is scanned out, so the "notch" property, the sysfs attribute, the boot default and the console's notch-free geometry are all covered. Only a pipe with notch rows publishes, and unbinding it withdraws the geometry. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…idden The touch screen reports positions over the whole panel, notch rows included. With the notch hidden at run time the display offers only the notch-free modes, the compositor maps the whole ABS_Y range onto that shorter output, and every touch lands too high, most near the top. Read the panel's scanned-out geometry with every frame and, while a band is hidden above the picture, map the panel below it onto the whole ABS_Y range: the band's lower edge reports 0 and the bottom edge the maximum. A contact in the band is not reported until it first reaches the picture, so a tap on the black band is never seen and a swipe down from the glass edge starts at the picture's top edge; a reported contact that slides back into the band stays on that edge. When the geometry changes, every contact lifts for one frame and touches down again under the new geometry. The ABS ranges never change, and with the notch shown or no display driver the positions are as before. Closes: #3719 Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Local CI at
|
|
Hosted CI at |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at cd76b9ae061e8bb350e28248834e709fa57d413f
Blockers:
- No K114s touch row at this head. The change targets the K114s touch screen, and the only row so far is the J616s no-regression run, which never runs the kiwi path. Add the K114s row listed under "Not yet" (taps at the top, middle, bottom and corners with the notch shown and hidden, plus a toggle with a finger held down) built from
cd76b9ae061e; after that it merges without another review. The code itself has no blocking finding.
Checked: no Apple material, no gates (the geometry comes from the DT notch rows and the scanned-out mode), no new parameters, no safety values; existing behaviour unchanged on every path I could find; CI: every build and KUnit check green at this head, PR-text and readiness still queued; my own build and KUnit run of this head pass.
Evidence
Read the three commits at cd76b9ae061e against main (f3fd30f44208).
- Macs without a notch, and external pipes:
dcp->notch_rowsis 0, sodcp_notch_scanned_out()anddcp_comp_unbind()never publish; an external DCP cannot overwrite the internal panel's record. - Notch shown:
dcp_notch_offset()returns 0 unless the mode is exactlypanel_rows - rowstall, so the publishedtopis 0,apple_panel_notch_band()returns 0 andapple_panel_notch_map()is the identity. Inkiwi_report()the band never changes, so there is no relift, and everyoncontact is marked shown on its first frame: the reported slots and positions are whatmainreports. - No provider: with
DRM_APPLE=nthe header stubs return an empty geometry (band 0, identity); with apple-drm unbound or not yet loaded the built-in record reads 0. A later unbind publishes(0, 0), which lifts and re-reports contacts once. - Lifetime and locking: the state is one built-in
atomic64_t, written whole and read whole, so a reader never sees a tornrows/toppair; nothing to free, and no module dependency between appledrm and the kiwi module.k->notch_bandis only touched inkiwi_report(), under the existing raw-event path. shownis cleared inkiwi_centroid()for every new contact and carried acrosskiwi_track()'s slot claim, so a tracked finger keeps it.- Ordering:
APPLE_PANEL_NOTCHis bool, default y whenDRM_APPLEis y or m, inside theARCH_APPLE || COMPILE_TESTblock;drivers/soc/Makefilealways descends intoapple/.
Ran:
- KUnit
drivers/soc/apple/panel-notch.kunitconfig, arm64 QEMU, GCC: 4/4 pass. - arm64 defconfig with
DRM_APPLE=n,HID_APPLE_MTP_KIWI=m(soAPPLE_PANEL_NOTCHis off and the stubs are used):drivers/hid/hid-apple-mtp-kiwi.obuilds withW=1, no warnings. - Hosted CI at this head: 27 build and KUnit checks pass, none failed; pr-text and readiness still queued when this was posted.
Follow-ups (not blocking):
- The hosted "Apple build and KUnit" run at this head has no
panel-notchjob: the matrix comes from the base branch's workflow, so the new entry only takes effect after merge. Worth confirming it appears on the first run after merge. dcp_notch_scanned_out()publishes on every frame even when nothing changed; a compare before the store would skip a cache-line write per frame. Negligible.- With the notch hidden, a contact born in the band is never reported until it reaches the picture, so a tap on the band does nothing; the PR states this, but the K114s row should confirm that top-edge swipes still open what they open with the notch shown.
DjDeveloperr
left a comment
There was a problem hiding this comment.
FINISH, then merge at cd76b9ae061e8bb350e28248834e709fa57d413f
drivers/gpu/drm/apple/iomfb_template.c:4707publishes the new geometry while building the swap. If the panel is showing the full picture and firmware rejects the first hidden-notch swap at line 3641 or 3606, kiwi starts dropping touches on rows that are still visible. Keep the geometry with its swap and publish it when that frame is displayed. A rejected swap should leave the previous mapping in place.drivers/soc/apple/panel-notch-test.c:22writes test values into the record kiwi reads. If apple-drm publishes its first frame after the check on line 19, the test can overwrite it and leave the band at zero until another frame arrives. Exercise the state changes on a record owned by the test.
Checked the full diff, slot tracking and locking, touch ranges in both modes, the device-tree notch height, module load order, and the swap rejection and unbind paths. The author reports KUnit 4/4, passing DCP host tests and a J616s pass at this head. The K114s touch check is pending. I skipped a local build.
The template flush published the rows above the picture while it built the swap request. If the firmware then rejected that swap, the touch screen mapped onto a picture that never appeared; after the first hidden-notch swap of a full-panel picture failed, it dropped touches on rows that were still visible. Keep the rows with the swap being submitted and publish them, with the debugfs scanout rows, in dcp_swapped() once the firmware has taken it. A rejected swap leaves the previous frame's geometry in place. The firmware-M4 path already publishes only after a successful present. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The state test wrote test values into the live record that the touch screen reads, so a display frame published between its check and its writes could be overwritten, leaving the band at zero until the next frame. Move the packing of the record into header helpers, test those on a value the test owns, and keep apple_panel_notch_publish() and apple_panel_notch_get() as thin wrappers over the live record. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Both points from the review at
KUnit |
|
J616s (MacBook Pro 16" M4 Pro, T6040) at |
…wapped() dcp_swapped() now publishes the panel's notch geometry once the firmware takes a swap. Give the harness the new field and a recording stub, and check that a rejected, missing or cancelled swap response publishes nothing while an accepted one publishes the rows recorded with its swap. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
The hosted Locally at
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Local CI at |
apple-build-kunit.yml now takes its KUnit suites from scripts/ci/apple-kunit.py (#3738): the panel-notch matrix entry becomes a table row there, selected by the panel notch record, its header and the kiwi driver. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
I merged This PR's kernel diff against |
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Merged |
There was a problem hiding this comment.
Verdict: MERGE at 9013ead
Checked:
- DjDeveloperr's point 1 at cd76b9a (a rejected swap would publish a notch geometry that never reached the screen): fixed in 702e912.
iomfb_flushnow only storesnotch_swap_y, anddcp_swapped()publishes it after theif (status) { ... return; }reject branch. A rejected, cancelled or missing response returns before the publish, so the previous geometry stays. The firmware-M4 path iniomfb.cpublishes only on!retfromiomfb_m4_present_at(). - DjDeveloperr's point 2 (the KUnit state test wrote into the live record): fixed in 945689d. The test now packs and unpacks a value it owns (
apple_panel_notch_pack()/_unpack()), andpublish/getare thin wrappers, so the test never writes the record kiwi reads. - satchlj's only blocker was the K114s touch row, not a code fault. Under the current bar the merge gate is one row on one Mac at the head (J616s here). pr-readiness tracks it; I am not holding the code for it.
- Tried to break the mapping:
apple_panel_notch_band()returns 0 fortop == 0,top >= panel_rows,size < 2and any band>= size - 1.apple_panel_notch_map()also treatsband >= size - 1as the identity, sospan = size - 1 - bandis never 0 and no input divides by zero. Aypast the axis is clamped before the subtraction. - kiwi:
shownis cleared for every new contact inkiwi_centroid()and carried throughkiwi_track()'s slot claim. On a band change everyoncontact reports released for one frame (relift), then reappears once it is on the picture. With the notch shown or no provider, the band is 0 and the reported slots and positions match main. - Publishers: only a pipe with
notch_rowspublishes, so an external DCP cannot overwrite the internal panel's record. Unbind publishes (0, 0). - The two merges of main touch only
scripts/ci/apple-kunit.pyamong this PR's files (the panel-notch suite row). No Apple-derived values (the geometry comes from DT notch rows and the mode), no AI attribution.
Follow-ups:
notch_swap_yis written only for a visible plane, so a swap with no surface publishes whatever the last visible-plane flush stored. That matches what is on the panel in practice, but resetting it at the start of the flush would make it exact.dcp_notch_scanned_out()does an atomic store every frame even when nothing changed (satchlj's note); negligible.- K114s touch row (taps top/middle/bottom/corners in both states, toggle with a finger held): pr-readiness shows it. Top-edge swipe behaviour with the notch hidden is worth a look in that row.
- CI at this head is still queued.
|
Hosted The two cancelled |
|
Hosted CI at |
|
K114s (M5 Pro, T6050) at From the kit's touch log (raw evdev positions, every contact down/up), Ryan's run on 12-01 17:48–17:51:
This verdict comes from the recorded positions. A per-tap "acted under the finger" note from Ryan was not relayed. The one incident during that session (touch stopped after a three-finger swipe) is #3758. It traces to a pre-existing kiwi baseline path on |
What: Fixes #3719. With the notch hidden at run time, touches on the K114s (M5 Pro) touch screen land too high. The error is largest near the top. The touch driver reports the whole panel, notch rows included, but the compositor maps that range onto the shorter notch-free output. This PR adds a small built-in record of the panel's scanned-out notch geometry (
drivers/soc/apple/panel-notch.c). apple-drm publishes it with every frame it swaps in.hid-apple-mtp-kiwireads it on every frame and, while a band is hidden, maps the panel below the band onto the wholeABS_MT_POSITION_Yrange: the band's lower edge reports 0 and the panel's bottom edge the maximum. Contacts in the band are not reported until they reach the picture. The ABS ranges never change, and no userspace change is needed.Tested: K114s (MacBook Pro 14" M5 Pro, T6050) at
9013ead8610b— PASS (touch with the notch shown and hidden, swipe from the top edge, finger held across a toggle; one-shot of this PR's kernel sources on the K114s stack source, positions in the comment); J616s (MacBook Pro 16" M4 Pro, T6040) at9013ead8610b— PASS (kernel built from945689d69bb1, whose kernel sources are identical to this head; also atcd76b9ae061e) (no-regression; one-shot kernel = this head with the J616s's own config: notch toggle hidden/shown x2 under gnome-shell, modes 3456x2160 <-> 3456x2234, a kprobe onapple_panel_notch_publishshowsrows=2234 top=74hidden andtop=0shown, 0 DCP crashes, 0 warnings, 0 failed units, Enforcing; restored to its default after); KUnitapple-panel-notch4/4 on arm64 QEMU at both heads (LLVM=1, as the new CI matrix entry); host tests--only dcp69/69,dcpext23/23,lifetime4/4,apple-dcp1/1,display7/7;checkpatch.pl --strict0/0/0 on all three commits.Risk: two-way · K114s/K114c touch screen while the notch is hidden; every Mac whose panel has notch rows publishes the geometry (one atomic store per frame). A plain revert restores today's behaviour. With the notch shown, or without apple-drm, the touch positions are unchanged: the published band is 0 and the mapping is the identity. When the geometry changes with fingers down, every contact lifts for one frame and touches down again, so userspace sees a release at the finger's position.
ABS_MT_POSITION_Y's resolution stays the whole panel's, so a unit is about 4 % shorter on the glass while the notch is hidden. The firmware 14.7/26.6 standalone pipes publish nothing (no touch Mac uses them).Not yet: nothing for this change. The kiwi stall seen during the K114s session (#3758) is pre-existing on
mainand gets its own fix.Details
soc: apple: record the built-in panel's scanned-out notch geometry:apple_panel_notch_publish(panel_rows, top)/apple_panel_notch_get()over oneatomic64_t, safe in any context. It is built in (APPLE_PANEL_NOTCH, default y withDRM_APPLE, the same pattern asAPPLE_J613_DISPLAY_SYNC), so neither driver depends on the other and load order does not matter. Header helpersapple_panel_notch_band()(band in an axis' own units, scaled when the axis size differs from the panel rows) andapple_panel_notch_map(). KUnit suite plus itsapple-build-kunit.ymlmatrix entry.drm/apple: publish the internal panel's notch geometry with each frame+drm/apple: publish the notch geometry once the firmware takes the swap:dcp_notch_scanned_out()replaces the twonotch_scanout_ywriters. The firmware-M4 path publishes after a successful present; the template flush records the rows with the swap anddcp_swapped()publishes them once the firmware takes it, so a rejected swap keeps the previous geometry. Only a pipe with notch rows publishes;dcp_comp_unbind()withdraws. Following the scanned-out geometry rather than the policy covers the property, the sysfs attribute, the boot default, a compositor picking a notch-free mode itself, and the console (always notch-free).HID: apple-mtp-kiwi: ...: band =top * size_y / panel_rows;y' = (y - band) * (size - 1) / (size - 1 - band). A contact is reported once it first reaches the picture, so a tap on the black band is never seen and a swipe down from the glass edge starts at the picture's top edge. A reported contact that slides back into the band stays on that edge. A geometry change lifts every contact for one frame (new tracking ids on the next).Documentation/gpu/apple-dcp-notch.rstgains a "The touch screen" section.Evidence
touch-notch/j616s, tracesdisplay/20261201-touch-notch): baseline on the saved 7.3.0-aurora-edge (933f822, which predates drm/apple: control the panel notch at run time #2814, so it has no notch attribute); one-shot 7.3.0-touchnotch1 = this head, the same cmdline as the saved entry; after the toggles the panel was restored to its starting policy, then a plain reboot to the saved default (next_entry empty, Enforcing, 0 failed).LACS_ERROR,updateFrequencies EDT ERROR) also appear on the baseline boot.cc @joshuaswarren (kiwi driver maintainer)