Linux – Detect and Re-Probe Monitors with Intel i915 Driver

driverslinuxlinux-kernelmonitors

I have a laptop running linux with nvidia optimus/intel hybrid graphics where all outputs are connected to the intel card. It is driven by the i915 driver.

An external monitor or beamer is discovered only one time a boot cycle: If I disable or unplug it (and then plug it again), it cannot be enabled again, because the linux kernel does not detect it anymore: There are no udev or acpi events on plug/unplug and the sysfs, in my case /sys/class/drm/card0-DP-1/status, indicates that the output is disconnected. After a reboot the display is detected again, and again exactly one time. Suspending/hibernating and resuming suffice as well, but only if the output is uplugged while rebooting.

I think this is somehow related to the kernel probing/reprobing for output devices on boot. Can the kernel be somehow induced to re-probe for monitors, and thus to hopefully detect them again?

Best Answer

This isn't the xrandr-approach the I know works in X, but for console you can try this — you can write to that /sys/class/drm/card0-DP-1/status file as well. I couldn't find proper documentation, but thankfully Linux is open source. Reviewing the source code, it looks like it takes a few values: detect, on, on-digital, and off.

So echo detect > /sys/class/drm/card0-DP-1/status should force a re-check for a monitor. Or echo on-digital > /sys/class/drm/card0-DP-1/status might manage to turn it on, regardless of what the detection thinks.

edit: Under X, I've used this to deal with HDMI that did not detect being plugged it — it'll force-enable the output. But unfortunately video only, HDMI audio won't work (and apparently isn't possible without a kernel patch):

xrandr --newmode "Mode 2" 148.500 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync
xrandr --addmode HDMI-1 "Mode 2"
xrandr --output HDMI-1 --mode "Mode 2" --right-of LVDS-1

All those numbers specify the video timings; normally it's auto-detected, the easiest way to get them is to grab the mode it's using when you've booted with it so it's working (xrandr --verbose will show them).

Related Question