Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save synaptiko/b59d814ea07186a9a9f210724930f2ca to your computer and use it in GitHub Desktop.
Save synaptiko/b59d814ea07186a9a9f210724930f2ca to your computer and use it in GitHub Desktop.
How to modify physical display size in EDID (on ArchLinux with systemd boot)

How to modify physical display size in EDID

Following method describes how to fix EDID display size information of your monitor if it's wrong (some of Samsung's monitors report incorrect size when connected over HDMI, for example). It assumes that your monitor is connected to HDMI1 port (HDMI-A-1 is full kernel address).

I used following tools:

  1. get the current edid file
cat /sys/class/drm/card0-HDMI-A-1/edid > incorrect-edid.bin
  1. find display size saved in your edid file
parse-edid < incorrect-edid.bin | grep DisplaySize

you should see something like:

Checksum Correct
        DisplaySize 160 90

it means your monitor tells you it has 160mm×90mm size

  1. update size information
  • display size lives on offset 0x15 (width) and 0x16 (height) of the binary file
  • it's in centimeters! it means 160mm -> 16cm -> 0x10 and 90mm -> 9cm -> 0x09
  • open the binary file in hexadecimal editor (I used Bless)
  • find the index and verify that it's the incorrect size you want to fix (in my case 0x10 on 0x15 offset and 0x09 on 0x16 offset)
  • delete these two numbers and type new ones instead, 530mm -> 53cm -> 0x35 and 300mm -> 30cm -> 0x1E in my case
  1. save as correct-edid.py and update checksum

create edid-checksum.py (see below)

chmod u+x edid-checksum.py
./edid-checksum.py < correct-edid.bin

you should see that checksum is now invalid:

You need to fix checksum on offset 0x7f
0x75 is BAD, should be 0x65

update the checksum on offset 0x7f to value 0x65; save and check again, you should see:

Checksums are correct!
  1. copy fixed edid file
sudo cp correct-edid.bin /usr/lib/firmware/edid/syncmaster-2494hm.bin
  1. use it in your kernel; there are two parts:

  2. update your /etc/mkinitcpio.conf (if you want to have it early when booting) add your graphics driver to modules

MODULES=( … i915 … )

add binary file to files which are added to your initramfs

FILES=(/usr/lib/firmware/edid/syncmaster-2494hm.bin)

regenerate your initramfs

sudo mkinitcpio -p linux
  1. add kernel options to your bootloader, I use systemd bootloader so I updated /boot/loader/entries/arch.conf
options drm_kms_helper.edid_firmware=HDMI-A-1:edid/syncmaster-2494hm.bin …
  1. reboot and be happy again!!!

Do it on your own risk!!! You can really mess up your system if you don't know what exactly you are doing!

#!/usr/bin/env python
import os, sys, array
EDID_LEN = (128, 256)
def getlen(edidhdr):
if edidhdr[18] <= 0 or edidhdr[18] > len(EDID_LEN):
sys.exit('ERROR: Unknown EDID version %d' % edidhdr[18])
return EDID_LEN[edidhdr[18] - 1]
def checksum(edid):
return (0 - (sum(edid[:-1]) % 256)) % 256
def main():
edid = array.array('B', os.read(sys.stdin.fileno(), 256)).tolist()
edid_len = getlen(edid)
edid_n = edid[edid_len - 2]
nbytes = edid_len + (edid_len * edid_n)
if len(edid) != nbytes:
sys.exit('ERROR: Input must be %d bytes' % nbytes)
for b in range(edid_n + 1):
x = (b + 1) * edid_len
actsum = edid[x - 1]
calsum = checksum(edid[x - edid_len:x])
if actsum != calsum:
sys.exit('You need to fix checksum on offset 0x%02x\n'
'0x%02x is BAD, should be 0x%02x' % (x - 1, actsum, calsum))
sys.exit('Checksums are correct!')
if __name__ == '__main__':
main()
@Blisstar
Copy link

Blisstar commented Apr 1, 2023

how could steps 4-6 be in debian?

@synaptiko
Copy link
Author

@Blisstar It's a long time I've created these steps and I wasn't ever Debian user so I don't know about specifics. But I asked GPT-4 about it, maybe you can give it a try. But please make sure the instructions make sense, I haven't verified it and you could break your system if they are wrong or you don't know what you are doing:
image

I hope it helps.

@Blisstar
Copy link

Blisstar commented Apr 1, 2023

I don't know if that helps but thanks to you and what I found this morning I was able to fix it: https://wiki.debian.org/RepairEDID
In the page it explains how to know the bus number of your screen (in my case it is not a screen connected by HDMI, I have a Samsung All in one), it also tells you how to get the correct edid but it does not explain how to make the Checksums correct which I got with your script edid-checksum.py .
I recommend to verify well that the bus number as the edid are corresponding to your screen, it warns you every time who made the article.
Once you have the correct-edid.bin and the bus number of your screen you create the executable flash.sh with both (this is explained in the article) and run it.
Thank you very much for helping me to fix the edid, I don't know much about this so without you I wouldn't have been able to do it.

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