3

I am looking for a command which prints all visual output ports a laptops has.

I have searched Stack and Google for a while now but I cannot find an answer.

The closest I got is xandr

eDP-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 277mm x 156mm
   1366x768      60.00*+  40.00  
   1360x768      59.80    59.96  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   960x600       60.00  
   960x540       59.99  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   800x512       60.17  
   700x525       59.98  
   640x512       60.02  
   720x450       59.89  
   640x480       60.00    59.94  
   680x384       59.80    59.96  
   576x432       60.06  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

Looking for something like

HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

Unfortunately this output doesn't show the information I need. The information from xrandr is not accurate.

Tried lspci, dmesg(maybe it is in there but couldn't find it), lshw and possible some more hardware listing commands.

The ideal situation would be

VGA x1
HDMI x1 or mini
DP x1
DVI x1

But a finger at the right direction would be greatly appreciated

  • 3
    Something like this? xrandr |awk '/connected/{print $1,$2}' – George Vasiliou Mar 27 '18 at 20:56
  • 1
    I by "ports" you mean "holes in the casing where I can stick a connector" then the only place where those may be listed is the manufacturer's web site. (Example for the HP EliteBook 820 G3.) Only the manufacturer knows what they have designed and assembled. xrandr lists all the ports which the GPU provides; the manufacturer, in their wisdom, may chose not make all of them available externally, or to provide extra connectors via converters. – AlexP May 26 '18 at 17:24
  • There are docking systems that use proprietary connectors (e.g. thinkpads) or USB. So if you want to list all ports that can output video, you should also count them in. My external monitor connects to a travelling dock via HDMI, and the travelling dock connects to laptop via USB, yet xrandr thinks it is a DVI-I device. – Ding-Yi Chen Aug 19 '19 at 13:20
7

This is a complicated problem.

xrandr will display any and all outputs according to the knowledge of all the GPUs that are under control of the X11 server. But a hardware manufacturer may add built-in converters to e.g. convert a GPU chip's DisplayPort output to DVI, or just leave some of the GPU's outputs unwired. The GPU, and by extension xrandr, has no way to know about changes like that. Also, a listed DisplayPort output might physically be a Mini-DP or a Thunderbolt connection.

If you have a laptop with two GPUs and have one of them disabled (either through BIOS or by software like Bumblebee for NVidia Optimus technology), the output information of a disabled GPU will obviously not be available to xrandr.

Another way to approach the problem might be using dmidecode: with dmidecode -t 8, you should get a listing of all connectors/ports the hardware manufacturer has described in BIOS DMI data. However, this information may not always be correct or complete: I have a laptop that lists no DMI connector information at all.

6

So I am messing with trying to change dual monitor setup on my machine and found your post. Because I'm interested in the actual display I'm looking for EDID resource from the attached monitor:

find /sys/devices -name "edid"

which produces an output like:

/sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-HDMI-A-1/edid
/sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-DVI-D-1/edid
/sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-DP-2/edid
/sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-HDMI-A-2/edid
/sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-DP-1/edid

not all of which are valid but if you look at the individual folders in the /sys stuff theres file called status that looks like:

cat /sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-DP-1/status
connected

also more details about the connected display devices (vs the actual video card output) by doing something like:

cat /sys/devices/pci0000:00/0000:00:02.0/0000:03:00.0/drm/card0/card0-DP-1/edid | edid-decode
Extracted contents:
header:          00 ff ff ff ff ff ff 00
serial number:   41 0c 0b 09 cd 0e 00 00 32 1a
version:         01 04
basic params:    b5 46 28 78 3a
chroma info:     59 05 af 4f 42 af 27 0e 50 54
established:     bd 4b 00
standard:        d1 c0 81 80 81 40 95 0f 95 00 b3 00 81 c0 01 01
descriptor 1:    4d d0 00 a0 f0 70 3e 80 30 20 35 00 ba 8e 21 00 00 1a
descriptor 2:    a3 66 00 a0 f0 70 1f 80 30 20 35 00 ba 8e 21 00 00 1a
descriptor 3:    00 00 00 fc 00 50 48 4c 20 33 32 38 50 36 56 0a 20 20
descriptor 4:    00 00 00 fd 00 17 50 1e a0 3c 01 0a 20 20 20 20 20 20
extensions:      01
checksum:        74

Manufacturer: PHL Model 90b Serial Number 3789
Made week 50 of 2016
EDID version: 1.4
Digital display
10 bits per primary color channel
DisplayPort interface
Maximum image size: 70 cm x 40 cm
Gamma: 2.20
DPMS levels: Off
Supported color formats: RGB 4:4:4, YCrCb 4:4:4, YCrCb 4:2:2
First detailed timing is preferred timing
Established timings supported:
  720x400@70Hz
  640x480@60Hz
  640x480@67Hz
  640x480@72Hz
  640x480@75Hz
  800x600@60Hz
  800x600@75Hz
  1024x768@60Hz
  1024x768@75Hz
  1280x1024@75Hz
Standard timings supported:
  1920x1080@60Hz
  1280x1024@60Hz
  1280x960@60Hz
  1440x900@75Hz
  1440x900@60Hz
  1680x1050@60Hz
  1280x720@60Hz
Detailed mode: Clock 533.250 MHz, 698 mm x 398 mm
               3840 3888 3920 4000 hborder 0
               2160 2163 2168 2222 vborder 0
               +hsync -vsync 
Detailed mode: Clock 262.750 MHz, 698 mm x 398 mm
               3840 3888 3920 4000 hborder 0
               2160 2163 2168 2191 vborder 0
               +hsync -vsync 
Monitor name: PHL
Monitor ranges (bare limits): 23-80Hz V, 30-160kHz H, max dotclock 600MHz
Has 1 extension blocks
Checksum: 0x74 (valid)

CEA extension block
Extension version: 3
34 bytes of CEA data
  Video data block
    VIC  16 1920x1080@60Hz 
    VIC  31 1920x1080@50Hz 
    VIC   4 1280x720@60Hz 
    VIC  19 1280x720@50Hz 
    VIC   3 720x480@60Hz 
    VIC  18 720x576@50Hz 
    VIC   2 720x480@60Hz 
    VIC  17 720x576@50Hz 
    VIC   1 640x480@60Hz 
    VIC   5 1920x1080i@60Hz 
    VIC  20 1920x1080i@50Hz 
  Audio data block
    Linear PCM, max channels 2
    Supported sample rates (kHz): 48 44.1 32
    Supported sample sizes (bits): 24 20 16
  Speaker allocation data block
    Speaker map: FL/FR
  Vendor-specific data block, OUI 000c03 (HDMI)
    Source physical address 1.0.0.0
    DC_30bit
    DC_Y444
    DVI_Dual
    Maximum TMDS clock: 600MHz
    Extended HDMI video details:
      HDMI VIC 0 3840x2160@30Hz
      HDMI VIC 1 3840x2160@25Hz
      HDMI VIC 2 3840x2160@24Hz
Underscans PC formats by default
Basic audio support
Supports YCbCr 4:4:4
Supports YCbCr 4:2:2
1 native detailed modes
Detailed mode: Clock 27.000 MHz, 698 mm x 398 mm
                720  736  798  858 hborder 0
                480  489  495  525 vborder 0
               -hsync -vsync 
Detailed mode: Clock 74.250 MHz, 698 mm x 398 mm
               1280 1390 1430 1650 hborder 0
                720  725  730  750 vborder 0
               +hsync +vsync 
Detailed mode: Clock 148.500 MHz, 698 mm x 398 mm
               1920 2448 2492 2640 hborder 0
               1080 1084 1089 1125 vborder 0
               +hsync +vsync 
Detailed mode: Clock 147.170 MHz, 698 mm x 398 mm
               2048 2096 2128 2208 hborder 0
               1080 1083 1093 1111 vborder 0
               +hsync -vsync 
Checksum: 0x18 (valid)

EDID block does NOT conform to EDID 1.3!
        Detailed block string not properly terminated
0
xrandr | awk 'BEGIN { hdmi=dp=0; }; 
    /^HDMI-/ { hdmi++;}; /^DP-/ { dp++; };
    END { printf "%8s%s\n","HDMI x",hdmi; printf "%8s%s\n","DP x",dp; }' 

  HDMI x1
    DP x0
  • Unfortunately this doesn't give me the output I am looking for. I dont have a problem with substracting output but with the inacurate information from xrandr. I have a EliteBook 820 G1 which does not have a HDMI port but xrandr displays HDMI x2. – Rob Michiels Mar 28 '18 at 18:07
0
xmonLines=`xrandr | grep " connected" | while read line ; do echo 'i' ; done`
regex="^(\w+)\s+.+$"
let "int=1"
for i in $xmonLines; do
    xmon=`xrandr | grep " connected" | sed $int!d`
    if [[ $xmon =~ $regex ]]; then
        printf "${BASH_REMATCH[1]}\n"
    fi
    let "int++"
done
0

kernal DRI debug in sysfs shows connectors recognized by your video kernel module.

For example my video kernel module is i915, then I can

 sudo grep "^connector" /sys/kernel/debug/dri/0/i915_display_info

And get

connector 71: type eDP-1, status: connected
connector 80: type DP-1, status: disconnected
connector 86: type HDMI-A-1, status: disconnected
connector 90: type DP-2, status: disconnected
connector 95: type HDMI-A-2, status: disconnected
connector 97: type DP-3, status: disconnected
connector 105: type DP-4, status: connected
connector 101: type DP-5, status: connected

Note that the port listed here may be different from the output from xrandr. For example, my xrandr outputs are eDP-1, DP-2-2, DP-2-3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.