Skip to content

Instantly share code, notes, and snippets.

@JohannesRudolph
Last active February 24, 2023 18:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesRudolph/440b5027da0b83e390582beccf4e8084 to your computer and use it in GitHub Desktop.
Save JohannesRudolph/440b5027da0b83e390582beccf4e8084 to your computer and use it in GitHub Desktop.
4k at 60Hz via HDMI 2.0 on a Coffee Lake integrated GPU using Fedora

Fixing Monitor Refresh Rate 4k @ 60Hz

Hardware Specs:

  • Gigabyte Z370N WIFI mainboard
  • Intell Coffe Lake i7-8700k CPU, using integrated Intel GPU
  • 2x LG 27MU58-B 4k Displays

The Mainboard has DisplayPort 1.2, HDMI 2.0 and HDMI 1.4 ports (one each). The first two are capable of outputting 4k @ 60Hz. However, I could not get the HDMI 2.0 output to deliver more than 30Hz out of the box using Fedora 28 with Wayland and Gnome Desktop on a 4.17 Kernel.

The Hardware

While researching this, it turns out Cofee Lake doesn't support HDMI 2.0 in Hardware at all. Mainboard manufacturers thus build DisplayPort to HDMI 2.0 converters on their boards. On my Mainboard this is a MCDP2800.

My first hunch was that this thing needs a driver or anything, but that's a dead end. This thing is a stupid (in a good way) converter chip that Linux doesn't even see.

Fixing incorrect EDIDs

In short, EDID is some metadata that your monitor's firmware hands out to a graphics card to tell it about its supported modes (resolutions, refresh rate, color depth etc.). To get 60Hz, your system needs to think that this is going to be supported by the Monitor. When you're using Wayland, forget about xrandr and all that to manipulate modelines or force a certain refresh rate. Wayland uses Kernel Mode Setting and will strictly allow only the modes that the kernel deems valid.

Reading EDIDs

You can skip this section if you have the same monitor and just use the edid firmware blob lg.bin from this gist

So to find out what's wrong, let's see what EDIDs we have for a monitor workign at 4k 60Hz (connected to DP) and one working at 30Hz (connected via HDMI 2.0)

sudo dnf install monitor-edid

Note: The fedora package is currently broken, you need to apply patch from https://bugzilla.redhat.com/show_bug.cgi?id=1538829 manually

We can see a few interesting things from the output:

  • as far as the Kernel is concerned, both displays are connected via Display Port internally (HDMI 2.0 is via MCDP2800 adapter)
  • The exact same physical monitor will report two different EDIDs depending on the connection method
[jrudolph@localhost ~]$ monitor-parse-edid /sys/class/drm/card0-DP-2/edid 
Name: LG Ultra HD
EISA ID: GSM5b09
EDID version: 1.4
EDID extension blocks: 1
Screen size: 60.0 cm x 34.0 cm (27.15 inches, aspect ratio 16/9 = 1.76)
Gamma: 2.2
Digital signal
Max video bandwidth: 560 MHz

	HorizSync 30-135
	VertRefresh 56-61

	# Monitor preferred modeline (60.0 Hz vsync, 133.3 kHz hsync, ratio 16/9, 162 dpi)
	ModeLine "3840x2160" 533.25 3840 3888 3920 4000 2160 2214 2219 2222 -hsync +vsync

	# Monitor supported modeline (30.0 Hz vsync, 66.7 kHz hsync, ratio 16/9, 162 dpi)
	ModeLine "3840x2160" 266.64 3840 3848 3992 4000 2160 2214 2219 2222 -hsync +vsync

	# Monitor supported CEA modeline (60.0 Hz vsync, 67.5 kHz hsync, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 148.5 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync

	# Monitor supported CEA modeline (60.0 Hz vsync, 45.0 kHz hsync, ratio 16/9, 54 dpi)
	ModeLine "1280x720" 74.25 1280 1390 1430 1650 720 725 730 750 +hsync +vsync

	# Monitor supported CEA modeline (59.9 Hz vsync, 31.5 kHz hsync, ratio 3/2, 30x35 dpi) (bad ratio)
	ModeLine "720x480" 27 720 736 798 858 480 489 495 525 -hsync -vsync

	# Monitor supported CEA modeline (59.9 Hz vsync, 31.5 kHz hsync, ratio 4/3, 27x35 dpi) (bad ratio)
	ModeLine "640x480" 25.175 640 656 752 800 480 490 492 525 -hsync -vsync

	# Monitor supported modeline (60.0 Hz vsync, 67.5 kHz hsync, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 148.5 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync

	# Monitor supported modeline (60.0 Hz vsync, 88.8 kHz hsync, ratio 16/9, 108 dpi)
	ModeLine "2560x1440" 241.5 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync

[jrudolph@localhost ~]$ monitor-parse-edid /sys/class/drm/card0-DP-1/edid 
Name: LG Ultra HD
EISA ID: GSM5b08
EDID version: 1.3
EDID extension blocks: 1
Screen size: 60.0 cm x 34.0 cm (27.15 inches, aspect ratio 16/9 = 1.76)
Gamma: 2.2
Digital signal
Max video bandwidth: 300 MHz

	HorizSync 30-135
	VertRefresh 56-61

	# Monitor preferred modeline (30.0 Hz vsync, 67.5 kHz hsync, ratio 16/9, 162 dpi)
	ModeLine "3840x2160" 297 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync

	# Monitor supported modeline (60.0 Hz vsync, 88.8 kHz hsync, ratio 16/9, 108 dpi)
	ModeLine "2560x1440" 241.5 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync

	# Monitor supported CEA modeline (60.0 Hz vsync, 67.5 kHz hsync, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 148.5 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync

	# Monitor supported CEA modeline (30.0 Hz vsync, 33.8 kHz hsync, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 74.25 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync

	# Monitor supported CEA modeline (60.0 Hz vsync, 33.8 kHz hsync, interlaced, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 74.25 1920 2008 2052 2200 1080 1084 1094 1125 +hsync +vsync Interlace

	# Monitor supported CEA modeline (60.0 Hz vsync, 45.0 kHz hsync, ratio 16/9, 54 dpi)
	ModeLine "1280x720" 74.25 1280 1390 1430 1650 720 725 730 750 +hsync +vsync

	# Monitor supported CEA modeline (59.9 Hz vsync, 31.5 kHz hsync, ratio 3/2, 30x35 dpi) (bad ratio)
	ModeLine "720x480" 27 720 736 798 858 480 489 495 525 -hsync -vsync

	# Monitor supported CEA modeline (59.9 Hz vsync, 31.5 kHz hsync, ratio 4/3, 27x35 dpi) (bad ratio)
	ModeLine "640x480" 25.175 640 656 752 800 480 490 492 525 -hsync -vsync

	# Monitor supported modeline (60.0 Hz vsync, 67.5 kHz hsync, ratio 16/9, 81 dpi)
	ModeLine "1920x1080" 148.5 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync

Patching EDIDs

# capture correct edid firmware blob that supports 4k@60Hz
sudo cp /sys/class/drm/card0-DP-2/edid /usr/lib/firmware/edid/lg.bin

# Setup grub to to load firmware blob
sudo grubby --default-kernel
sudo grubby --args="drm_kms_helper.edid_firmware=DP-1:edid/lg.bin" --update-kernel /boot/vmlinuz-4.17.11-200.fc28.x86_64

# bake firmware blob into initramfs
echo 'install_items+="/usr/lib/firmware/edid/lg.bin"' > /etc/dracut.conf.d/99-local.conf
# rebuild initramfs
dracut -f
# verify blob is in in intramfs
lsinitrd | grep lg.bin

And now you can reboot. If it's not working by now, check dmesg output for any errors. On my first attempt I had a request_firmware error -22 which I traced via drm_edid_load.c to the Firmware API and -22 is just the -EINVAL error code: the blob was not included in initramfs.

Sources

@JohannesRudolph
Copy link
Author

JohannesRudolph commented Jul 16, 2019

one step script (assuming you have updated dracut.conf.d already):

sudo -s
grubby --args="drm_kms_helper.edid_firmware=DP-1:edid/lg.bin" --update-kernel $(grubby --default-kernel)
dracut -f
lsinitrd | grep lg.bin

@JohannesRudolph
Copy link
Author

Note, you can also enable this on all kernels available via grub

sudo grubby --update-kernel=ALL --args="drm_kms_helper.edid_firmware=DP-1:edid/lg.bin"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment