Inconsistent monitor wake-up behaviour with modesetting + i915 KMS driver
I found inconsistent behaviour across different hardware with Xorg.
If the machine is booted without a (HDMI) monitor plugged in, and later the HDMI cable is plugged in, some devices wake up the monitor properly (i7-8700 - Coffe Lake) but some (e.g. Celeron J3455 - Apollo Lake) are not. The symptom on the latter is that the monitor indicates "no signal" and goes to sleep.
The strange thing is that the kernel does wake up the monitor and shows the console login prompt if I press Ctrl-Alt-F2. Pressing Alt-F1 makes the monitor sleep again.
I found an adequate workaround with the following pieces:
udev rule:
# cat /etc/udev/rules.d/drm.rules
SUBSYSTEM=="graphics", ACTION=="add", RUN+="/usr/sbin/monitorhotplug-wrapper.sh graphics add"
SUBSYSTEM=="drm", ACTION=="change", RUN+="/usr/sbin/monitorhotplug-wrapper.sh drm change"
wrapper script to protect against multiple executions:
# cat /usr/sbin/monitorhotplug-wrapper.sh
#!/bin/bash
logger "monitorhotplug-wrapper: Executing monitorhotplug in the background ($*)"
flock -n /usr/sbin/monitorhotplug.sh /usr/sbin/monitorhotplug.sh "$@" &
actual script:
# cat /usr/sbin/monitorhotplug.sh
#!/bin/bash
[[ $(systemctl is-active xorg) = "active" ]] || { logger -s "monitorhotplug: Xorg is not active yet, exiting." ; exit 0 ; }
logger -s "monitorhotplug: Starting with options: $1 $2"
if [[ $1 = "graphics" ]] && [[ $2 = "add" ]]; then
PRINTFB=1
while [[ ! -a /dev/fb0 ]]; do
if [[ $PRINTFB = 1 ]]; then
logger -s "monitorhotplug: Waiting for the framebuffer device to appear"
PRINTFB=0
fi
sleep 2
done
elif [[ $1 = "drm" ]] && [[ $2 = "change" ]]; then
if [[ ! -a /dev/fb0 ]]; then
logger -s "monitorhotplug: Early call, exiting."
exit 0
fi
fi
logger -s "monitorhotplug: Reconfiguring Xorg"
for i in ":0" ":0.1" ":0.2" ":0.3" ; do
DISPLAY="$i" xrandr --auto >/dev/null 2>/dev/null
done
exit 0
But it would be better if Xorg behaved consistently without the need to execute xrandr --auto
.
This a custom Linux system built from Yocto 4.2 or thereabout.
Xorg X-server version 21.1.8
modesetting DDX driver is used
Kernel version is indifferent, the issue is seen with several kernel versions, 5.x or 6.x