Skip to content

AYN Thor second screen support (userspace)#78

Open
brycesub wants to merge 4 commits into
virtudude:mainfrom
brycesub:thor-second-screen
Open

AYN Thor second screen support (userspace)#78
brycesub wants to merge 4 commits into
virtudude:mainfrom
brycesub:thor-second-screen

Conversation

@brycesub

@brycesub brycesub commented Jul 7, 2026

Copy link
Copy Markdown

Userspace half of AYN Thor second-screen support, for #28. Kernel half: virtudude/armada-packages#1 (needs to ship first, plus a KERNEL_PKG digest bump here once it's built).

What you get

  • Gaming mode: unchanged UX — Steam on the top screen with working brightness control; the bottom screen stays dark and its touchscreen is inhibited so fingers on the glass don't move Steam's cursor
  • Desktop mode: one KDE Wayland session spanning both screens — top primary at the top, bottom centered below it, each touchscreen pinned to its own output

Changes

  • ayn-thor.conf: primary connector becomes DSI-2 (top panel, once both DSIs probe); new device vars ARMADA_PRIMARY_BACKLIGHT, ARMADA_SECONDARY_CONNECTOR, ARMADA_PRIMARY/SECONDARY_TOUCHSCREEN
  • steamos-priv-write: accepts backlight brightness writes and steers them to ARMADA_PRIMARY_BACKLIGHT, rescaling between brightness ranges (Steam grabs the first backlight it finds — the bottom panel's, 0-255 — while the top panel is 0-4096). Devices without the var keep current behavior.
  • setup-dual-screen (new) + desktop-bootstrap: one-time dual-screen desktop layout via kscreen-doctor, and touchscreen→output pinning via kcminputrc OutputName plus a live KWin D-Bus set (KWin only reads the config at device-add, and otherwise maps both internal touchscreens to the same output)
  • touchscreen-inhibit (new) + udev ACL on /sys/class/input/*/inhibited: gaming session inhibits the secondary touchscreen, desktop session re-enables it. Could be exposed as an Armada Control toggle later.

Validation (on hardware)

All of the above validated on an AYN Thor running a live-patched DTB matching the kernel PR: gaming↔desktop switching, brightness slider tracking the top panel across its full range, stacked desktop layout, and correct per-screen touch in desktop mode with the bottom digitizer silenced in gaming mode.

Phase 2 (not in this PR)

A bottom-screen UI in gaming mode needs an architecture change — gamescope is a single-output DRM master, so nothing else can drive the second panel while it runs. Findings and options are summarized in #28.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMbeBSJJG1pNfdqkUcG1gn

@brycesub brycesub mentioned this pull request Jul 7, 2026
@virtudude

Copy link
Copy Markdown
Owner

@brycesub Epic. Thanks for your contribution. Will take a closer look after I get this next release out.

brycesub and others added 4 commits July 10, 2026 22:50
With the bottom panel enabled in the kernel, the top screen becomes
DSI-2 and a second backlight (ae94000.dsi.0) appears that Steam picks
up for brightness control instead of the top panel's.

- ayn-thor.conf: primary connector is DSI-2; declare the primary
  backlight, secondary connector, and both touchscreen device names
- steamos-priv-write: accept backlight brightness writes and steer them
  to ARMADA_PRIMARY_BACKLIGHT, rescaling between brightness ranges
  (bottom is 0-255, top is 0-4096)
- desktop-bootstrap/setup-dual-screen: one-time desktop layout for
  dual-screen devices - primary on top at priority 1, secondary
  centered below, each touchscreen pinned to its own output (KWin
  otherwise maps both to the same screen)

Requires the armada-packages kernel with the Thor bottom panel enabled;
on the old kernel DSI-2 does not exist and gamescope falls back to the
only connected output, so ordering is safe.

Fixes virtudude#28 (phase 1: no bottom-screen UI in gaming mode yet)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMbeBSJJG1pNfdqkUcG1gn
Gamescope only lights up the primary panel, but the secondary
touchscreen still feeds it input - fingers resting on the dark glass
move Steam's cursor. Inhibit the device (via /sys/class/input/*/inhibited,
made wheel-writable like the other session-managed sysfs knobs) when the
gaming session starts and re-enable it when the desktop session starts.

A future Armada Control toggle could expose this as a user choice.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMbeBSJJG1pNfdqkUcG1gn
kscreen-doctor -o -j prints the human-readable listing after the JSON
document, so json.loads raised JSONDecodeError and the script died
before applying the layout or pinning the touchscreens. On first boot
that left both touchscreens mapped to the same output: taps on the top
screen landed on the bottom desktop, where a stray double-tap on the
Return to Game Mode icon logged the session out.

Request JSON alone and parse only the first document so trailing text
can never take the script down again. Verified on an AYN Thor: layout
applied, both touchscreens pinned to their own panel.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeRkgMBMwWNcnwMk4j5kVx
The perf-ACL udev rule made every backlight's brightness group-writable,
so Steam's direct sysfs write (its first choice before falling back to
steamos-polkit-helpers/steamos-priv-write) succeeded on whichever
backlight it enumerated first - on Thor the secondary bottom panel. The
priv-write steering to ARMADA_PRIMARY_BACKLIGHT never engaged except for
out-of-range values, so the brightness slider dimmed the desktop screen
instead of the gaming one.

Observed on hardware: at Steam startup a saved 0-4096-scale value hit the
255-max bottom panel (EINVAL, then rescaled to 166 and correctly steered
2666 -> top panel via priv-write), but ordinary slider writes were
in-range for the bottom panel and landed there directly.

The udev grant now goes through backlight-acl, which withholds it from
every backlight when ARMADA_PRIMARY_BACKLIGHT is set: all Steam writes
fail EACCES and funnel through the steering helper, the same path Steam
uses on stock SteamOS where backlight sysfs is not user-writable.
Single-backlight devices keep the direct grant.

Part of virtudude#28

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011roK8EGErjD8eEjjZNNW9w
@brycesub brycesub force-pushed the thor-second-screen branch from 2fe0abf to cb3e6c8 Compare July 11, 2026 03:58
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