Saturday, 26 May 2018

linux - System doesn't detect hot-plugged display port(through thunderbolt connector)

My external display(connected to my laptop through thunderbolt) works fine if connected before boot-up. However, once it's unplugged or disconnected by any means, xrandr won't detect the reconnected monitor anymore.


I am running Arch Linux, using bumblebee for graphic card handling. External card is connected through thunderbolt connector. Could someone tell me what is wrong with the machine and how can I make hotplugging work? Thanks.




[Debugging detail]


Following multiple threads on bumblebee and udevadm, I did several testing and made a hotplug script. Yet the problem is still not solved. Result is posted as below.


For bumblebee, I didn't tweak much, since the second monitor is detect fine when not hotplugged.


For hot-plugging related issue. I did the following:


When monitor is working normally, xrandr --query returns


Screen 0: minimum 8 x 8, current 2944 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 382mm x 215mm
1920x1080 60.02*+

...

DP1 connected 1024x768+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm
1024x768 60.00*

...

When unplugging monitor from DP2 with udevadm monitor --environment --udev opened, information gathered is:


UDEV  [979.022342] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=2650
SUBSYSTEM=drm
TAGS=:master-of-seat:uaccess:seat:
USEC_INITIALIZED=3775241

And when plugging the monitor in:


UDEV  [1111.426386] change   /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=2651
SUBSYSTEM=drm
TAGS=:seat:uaccess:master-of-seat:
USEC_INITIALIZED=3775241

UDEV [1111.522857] change /devices/pci0000:00/0000:00:02.0/drm/card0 (drm)
ACTION=change
DEVNAME=/dev/dri/card0
DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
DEVTYPE=drm_minor
HOTPLUG=1
ID_FOR_SEAT=drm-pci-0000_00_02_0
ID_PATH=pci-0000:00:02.0
ID_PATH_TAG=pci-0000_00_02_0
MAJOR=226
MINOR=0
SEQNUM=2652
SUBSYSTEM=drm
TAGS=:seat:uaccess:master-of-seat:
USEC_INITIALIZED=3775241

It seems that udev is able to detect the hardware when the monitor is plugged in, so I setted-up a udev rule to help xrandr use the new monitor. My script for /etc/udev/rules.d/95-monitor-hotplug.rules is as following:


ACTION=="change", SUBSYSTEM=="drm", RUN+="/usr/local/bin/hotplug_monitor.sh"

And /usr/local/bin/hotplug_monitor.sh is


#!/bin/sh
export XAUTHORITY=/home/chong/.Xauthority

function connectDP1(){
DISPLAY=:0 xrandr --output DP1 --auto --right-of eDP1
}

function disconnectDP1(){
DISPLAY=:0 xrandr --output DP1 --off
}

function connectDP2(){
DISPLAY=:0 xrandr --output DP2 --auto --right-of eDP1
}

function disconnectDP2(){
DISPLAY=:0 xrandr --output DP2 --off
}

xrandr | grep "DP1 connected" &> /dev/null && connectDP1 || disconnectDP1
xrandr | grep "DP2 connected" &> /dev/null && connectDP2 || disconnectDP2

The script runs and quits normally, but afterwards xrandr --query still shows DP1 and DP2 disconnected.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...