YaLTeR/niri

Support Custom modeline

Opened this issue · 5 comments

My display needs custom modeline timings set to work properly (my gpu can't reclock its memory). I'm just checking out Niri, but even if I don't end up using Niri long-term, this will be helpful for others.

An example config could be something like this:

output "DP-1" {
    mode "1332.75 3840 3888 3920 4000 2160 2163 2168 2314 +HSync -VSync"
}

Hm, I'm not sure off the bat how to do that, might need Smithay support.

Sway/wlroots supports it with output DP-1 modeline <modeline>. That might be useful for reference.

Should I create a related issue in Smithay?

I'll ask in the Smithay room. Maybe it can already do it.

FYI, I found out that linux can load custom edid firmware in KMS -- so it isn't strictly necessary to configure custom modelines from the compositor. That said, it will be much more user friendly to be able to set it from the compositor.


Here is some more info for anyone else who comes across this thread.

Having the kernel load custom edid firmware was easy. Just put the .bin in /usr/lib/firmware/edid/ and add drm.edid_firmware=edid/your_edid.bin to kernel cmdline.

The trouble comes in getting a proper edid binary. You can try edid-generator or building one from scratch, but most will be better off editing a copy of the existing firmware. You can grab a connection's edid with e.g. cat /sys/class/drm/card2-DP-5/edid > edid.bin.

In my case, I had to edit it by hand with a hex editor. None of the edid editors I found worked properly. wxEDID doesn't support DisplayID extension blocks -- though it may work for edid bins only containing EDID with CTA extension. CRU on wine supported all the exensions, but rewrote the entire edid assuming my display was a generic analog CRT. There is also edid-generator, but I didn't try that because I wanted to keep the other display properties from the original edid.

If one of the above tools I mentioned works for you, lucky you! Else, you can use a hex editor and follow the byte-maps described on Wikipedia's EDID and DisplayID pages. To help guide the edits, and to validate the changes use edid-decode. When you are done make sure to update the checksum bytes, if edid-decode says they don't match.

edrex commented

@FlyingWombat I went down the edid rabbit hole several years ago to add a missing half-res mode to my hidpi laptop panel. It worked but I don't recall what method I used to modify the edid file. I admire your determination :D Good job documenting the process; it's rather esoteric. Agreed that modelines in compositor are a desirable feature.