我只希望我的 4K 显示器在插入时可以用作 4K 显示器。像素有帮助,FPS 没那么多。
基本上就像标题所说的那样,我办公室的屏幕是通过 HDMI 到 Mini Display Port 电缆插入的。监视器确实显示在位置和分辨率以及其他设置的视频设置中。但是,如果不发送 xrandr 命令或摆弄 /etc/X11/xorg.conf 文件,则 3840x2160 不是分辨率的选项。
监视器 edid 信息确实具有我认为在工厂嵌入的模式列表中可以接受的模式。它使用的是 HDMI 1.4(而不是 2.0)。
Anyhoo,这是我的解决方法-您能找到更好的处理方法吗?
那是我的问题,如果硬件不会自动配置所有东西,是否有更好的内置方法来做到这一点?
#!/usr/bin/env bash
apt update
apt -y upgrade
apt -y autoremove
#ubuntu-drivers devices
## Output:
## == /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
## modalias : pci:v000010DEd00001290sv000017AAsd0000221Ebc03sc00i00
## vendor : NVIDIA Corporation
## model : GK208M [GeForce GT 730M]
## driver : nvidia-340 - distro non-free
## driver : nvidia-driver-390 - distro non-free recommended
## driver : xserver-xorg-video-nouveau - distro free builtin
##
## == /sys/devices/pci0000:00/0000:00:1c.1/0000:04:00.0 ==
## modalias : pci:v00008086d000008B2sv00008086sd0000C270bc02sc80i00
## vendor : Intel Corporation
## model : Wireless 7260 (Dual Band Wireless-AC 7260)
## manual_install: True
## driver : backport-iwlwifi-dkms - distro free
ubuntu-drivers autoinstall
apt install -y get-edid
get-edid
## Output:
## This is read-edid version 3.0.2. Prepare for some fun.
## Attempting to use i2c interface
## No EDID on bus 1
## No EDID on bus 2
## No EDID on bus 3
## No EDID on bus 4
## No EDID on bus 6
## No EDID on bus 8
## No EDID on bus 9
## 3 potential busses found: 0 5 7
## Will scan through until the first EDID is found.
## Pass a bus number as an option to this program to go only for that one.
## Bus 0 doesn't really have an EDID...
## 256-byte EDID successfully retrieved from i2c bus 5
## ������N�▒�
##ץ�YJ�$PT�������@��t0�pZ��X�Ď!f!P�Q@p6?C!�LP
## �W55
## �5tS�_^] & Pm
## < `�`a�rQ� n(UĎ!�▒q X,%Ď!��
## Њ �->��!▒�
## Looks like i2c was successful. Have a good day.
## А @1
## @U�!▒5
### <!> As it turns out, I wanted the info on bus 5.
### <!> Let's get the Modelines
get-edid -b5 | parse-edid
## Output:
## 5
## This is read-edid version 3.0.2. Prepare for some fun.
## Attempting to use i2c interface
## Only trying 5 as per your request.
## 256-byte EDID successfully retrieved from i2c bus 5
## Looks like i2c was successful. Have a good day.
## Checksum Correct
##
## Section "Monitor"
## Identifier "W55"
## ModelName "W55"
## VendorName "SPT"
## # Monitor Manufactured week 24 of 2018
## # EDID version 1.3
## # Digital Display
## # Display Physical Size not given. Normal for projectors.
## Gamma 1.00
## Option "DPMS" "false"
## Horizsync 30-80
## VertRefresh 30-76
## # Maximum pixel clock is 300MHz
## #Not giving standard mode: 1920x1080, 60Hz
## #Not giving standard mode: 1680x1050, 60Hz
## #Not giving standard mode: 1280x800, 60Hz
## #Not giving standard mode: 1280x1024, 60Hz
## #Not giving standard mode: 1280x960, 60Hz
## #Not giving standard mode: 1280x720, 60Hz
##
## #Extension block found. Parsing...
## #WARNING: I may have missed a mode (CEA mode 95)
## #WARNING: I may have missed a mode (CEA mode 94)
## #WARNING: I may have missed a mode (CEA mode 93)
## Modeline "Mode 18" 74.25 1280 1390 1430 1650 720 725 730 750 +hsync +vsync
## Modeline "Mode 0" 297.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync
## Modeline "Mode 1" 85.50 1360 1424 1536 1792 768 771 777 795 +hsync +vsync
## Modeline "Mode 2" 148.500 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync
## Modeline "Mode 3" 74.250 1920 2008 2052 2200 1080 1082 1087 1125 +hsync +vsync interlace
## Modeline "Mode 4" 74.250 1280 1390 1420 1650 720 725 730 750 +hsync +vsync
## Modeline "Mode 5" 27.027 720 736 798 858 480 489 495 525 -hsync -vsync
## Modeline "Mode 6" 27.027 1440 1478 1602 1716 480 484 487 525 -hsync -vsync interlace
## Modeline "Mode 7" 27.027 720 736 798 858 480 489 495 525 -hsync -vsync
## Modeline "Mode 8" 27.027 1440 1478 1602 1716 480 484 487 525 -hsync -vsync interlace
## Modeline "Mode 9" 25.200 640 656 752 800 480 490 492 525 -hsync -vsync
## Modeline "Mode 10" 148.500 1920 2448 2492 2640 1080 1084 1089 1125 +hsync +vsync
## Modeline "Mode 11" 74.250 1920 2448 2492 2640 1080 1082 1089 1125 +hsync +vsync interlace
## Modeline "Mode 12" 74.250 1280 1720 1760 1980 720 725 730 750 +hsync +vsync
## Modeline "Mode 13" 27.000 720 732 796 864 576 581 586 625 -hsync -vsync
## Modeline "Mode 14" 27.000 1440 1464 1590 1728 576 578 581 625 -hsync -vsync interlace
## Modeline "Mode 15" 27.000 720 732 796 864 576 581 586 625 -hsync -vsync
## Modeline "Mode 16" 27.000 1440 1464 1590 1728 576 578 581 625 -hsync -vsync interlace
## Modeline "Mode 17" 74.250 1920 2558 2602 2750 1080 1084 1089 1125 +hsync +vsync
## Modeline "Mode 19" 74.25 1920 2008 2052 2200 540 542 547 562 +hsync +vsync interlace
## Modeline "Mode 20" 27.00 720 736 798 858 480 489 495 525 -hsync -vsync
## Modeline "Mode 21" 27.00 720 732 796 864 576 581 586 625 -hsync -vsync
## Option "PreferredMode" "Mode 18"
## EndSection
### <!> It did not work for me, but you can try generating Modelines with cvt
#cvt 3840 2160
## Output:
## # 3840x2160 59.98 Hz (CVT 8.29M9) hsync: 134.18 kHz; pclk: 712.75 MHz
## Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync
### <!> 60Hz is the default for cvt refresh rate parameter-- my screen is 60Hz...
### <!> A more specifica cvt refresh rate is the optional third parameter
### <!> The only line I see that is 4K is "Mode 0"
### <!> Modeline "Mode 0" 297.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync
### <!> The quoted part of the Modeline is just a label
### <!> Changing "Mode 0" to "3480x2160" for my own nitpicky self
xrandr --newmode "3840x2160" 297.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync
### <!> cvt generated mode
#xrandr --newmode "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync
xrandr --addmode HDMI-1-1 "3840x2160"
### <!> cvt generated mode
#xrandr --addmode HDMI-1-1 "3840x2160_60.00"
### <!> To see what's what and the available modes for each
#xrandr -q
### <!> Used arandr for help with xrandr bash command that follows
#apt install arandr && arandr
# ...save output file as xrandr-example.sh from GUI application
#tail xrandr-example.sh
## Output:
## #!/bin/sh
## xrandr --output HDMI-1-2 --off --output HDMI-1-1 --mode 1920x1080 --pos 1920x0 --rotate normal --output eDP-1-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VGA-1-1 --off --output DP-1-2 --off --output DP-1-1 --off
### <!> I took that "template" and substituted my own mode and positions
xrandr --output HDMI-1-1 --mode 3840x2160 --pos 0x0 --rotate normal --output HDMI-1-2 --off --output eDP-1-1 --primary --mode 1920x1080 pos 960x2160 --rotate normal --output VGA-1-1 --off --output DP-1-2 --off --output DP-1-1 --off
### <!> Now I want it to happen when I plug in my monitor
### <!> If W55 is seen, then run my xrandr command
#udevadm monitor
## Output:
## monitor will print the received events for:
## UDEV - the event which udev sends out after rule processing
## KERNEL - the kernel uevent
##
## KERNEL[10928.549817] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
## UDEV [10928.551102] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
## KERNEL[10939.083981] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
## UDEV [10939.085367] change /devices/pci0000:00/0000:00:02.0/drm/card1 (drm)
### <!> So, it is a drm UDEV change
### <!> We can use the change to trigger a script
echo "SUBSYSTEM==\"drm\", ACTION==\"change\", RUN+=\"/usr/local/bin/xrandr-for-W55-monitor.sh\"" > /etc/udev/rules.d/xrandr-for-W55-monitor.rules
### <!> Create the script and make it executable
### <!> There's a second way to get edid info
ls -1 /sys/class/drm/*/edid
## Output:
## /sys/class/drm/card1-DP-1/edid
## /sys/class/drm/card1-DP-2/edid
## /sys/class/drm/card1-eDP-1/edid
## /sys/class/drm/card1-HDMI-A-1/edid
## /sys/class/drm/card1-HDMI-A-2/edid
## /sys/class/drm/card1-VGA-1/edid
### <!> To get the bash script "heredoc" to respect indent spacing below, the indents must be tabs...
cat <<-EOF > /usr/local/bin/xrandr-for-W55-monitor.sh
#!/usr/bin/env bash
if [[ $(xrandr | grep "HDMI-1-1 connected" | wc -l) -gt 0 ]]
then
#echo $(date) "drm event HDMI-1-1 changed" >> /tmp/checkin.txt
if [[ $(parse-edid < /sys/class/drm/card1-HDMI-A-1/edid | grep "Identifier \"W55\"" | wc -l) -gt 0 ]]
then
#echo "IT'S W55!!!" >> /tmp/checkin.txt
xrandr --newmode "3840x2160" 297.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync
xrandr --addmode HDMI-1-1 "3840x2160"
xrandr --output HDMI-1-1 --mode 3840x2160 --pos 0x0 --rotate normal --output HDMI-1-2 --off --output eDP-1-1 --primary --mode 1920x1080 --pos 960x2160 --rotate normal --output VGA-1-1 --off --output DP-1-2 --off --output DP-1-1 --off
else
xrandr --output HDMI-1-1 --mode 1920x1080 --above eDP-1-1
fi
else
xrandr --output HDMI-1-1 --off
fi
EOF
chmod 550 /usr/local/bin/xrandr-for-W55-monitor.sh
### <!> That ought to do it...