Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

Graphics programming • setterm/DRM & Screen Blanking

$
0
0
Am trying to get my Pi5 Bookworm Desktop (no GUI as such-- just some fullscreen libdrm apps) to support screen blanking. This has proved far more challenging than anticipated. "setterm" with blanking-aware DRM apps seems like the right approach, but no luck. Here are the steps I used to identify the issues (though am no closer to a solution):

After a fresh boot:

$ sudo bash -c 'setterm --term linux --blank </dev/console'
shows 0: blanking inactive
$ sudo bash -c 'setterm --term linux --blank 1 </dev/console'
never does anything after a minute or hour. neither does adding powerdown and/or powersave to it.
$ sudo bash -c 'setterm --term linux --blank force </dev/console'
blanks the screen
$ exec libdrm application to enumerate the current state
crtc[3]: id=97 fb-id=299 x=0 y=0 w=3440 h=1440 ACTIVE=0 MODE_ID=301 OUT_FENCE_PTR=0 VRR_ENABLE
the ACTIVE=0 is apparently a result of the screen blanking
however-- the screen then unblanks upon process termination (after the DRM-fd is closed)

$ exec libdrm application to enumerate the current state a second time
crtc[3]: id=97 fb-id=299 x=0 y=0 w=3440 h=1440 ACTIVE=0 MODE_ID=301 OUT_FENCE_PTR=0 VRR_ENABLE
correctly reports ACTIVE=1 since screen is now visible

$ sudo bash -c 'setterm --term linux --blank </dev/console'
shows 1: setterm still thinks the screen is blank
$ sudo bash -c 'setterm --term linux --blank force </dev/console'
leaves screen visible because setterm thinks the screen is already blank
$ sudo bash -c 'setterm --term linux --blank poke </dev/console'
no visible change since screen already visible, but ...
$ sudo bash -c 'setterm --term linux --blank </dev/console'
shows 0: setterm now thinks the screen is visible
$ sudo bash -c 'setterm --term linux --blank force </dev/console'
blanks the screen again

$ exec libdrm app that is trying to be "screen blanking aware"
at startup: change CRTC ACTIVE property from 0 to 1 (makes screen visible)
while running: libdrm calls operate normally and screen is fine
at shutdown: change CRTC ACTIVE property from 1 to 0 and close DRM-fd
screen remains visible and does not return to blanking mode

$ sudo bash -c 'setterm --term linux --blank poke </dev/console'
in case state is messed up
$ sudo bash -c 'setterm --term linux --blank force </dev/console'
force screen blanking
$ cat /dev/dri/card1
wait a while to convince that screen is staying blank
press ctrl-c
screen will unblank-- simply closing the DRM-fd unblanks the screen

Summarizing these issues:
1: setterm -blank <timeout> does not work at all
2: setterm is not getting the blanking state from DRM and thus easily gets out of sync
3: closing /dev/dri/card0 or card1 reactivates an inactive CRTC, blanking is lost, setterm is confused

Compounding these issues, my brand new ASUS gaming monitor requires "vc4.force_hotplug=3" to prevent blanking/un-blanking cycling, and even then, the monitor cycles between power-savings mode and signal-missing mode. The same monitor is fine with Ubuntu+KDE-Plasma+RTX3060. Appreciate any thoughts on how to get screen-blanking working in desktop mode with libdrm apps. Thanks!

Statistics: Posted by Vraz — Tue Mar 18, 2025 9:40 pm



Viewing all articles
Browse latest Browse all 8621

Trending Articles