akatrevorjay / edid-generator

Hackerswork to generate an EDID blob from given Xorg Modelines, complete with valid checksum.
GNU General Public License v3.0
224 stars 50 forks source link

Ubuntu 16.04.1 LTS : 3840x2160.bin contains wrong data #5

Open MPolymath opened 7 years ago

MPolymath commented 7 years ago

Operating system: Ubuntu 16.04.1 LTS

Problem:

When using the parse-edid program (sudo apt-get install read-edid): parse-edid < /etc/X11/3840x2160.bin

The data outputted does not match the data that should be outputted:

Section "Monitor"
        Identifier "3840x2160"
        ModelName "3840x2160"
        VendorName "LNX"
        # Monitor Manufactured week 5 of 2012
        # EDID version 1.3
        # Analog Display
        DisplaySize 1000 560
        Gamma 2.20
        Option "DPMS" "true"
        Horizsync 134-136
        VertRefresh 59-61
        # Maximum pixel clock is 600MHz
        #Not giving standard mode: 1792x1008, 60Hz
        Modeline        "Mode 0" 594.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync 
EndSection

I have tried creating a edid.bin as instructed in the readme but that also gives me the wrong value:

_./modeline2edid - <<< 'Modeline "3840x216060.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync'

Searching for runaway unicorns in '/dev/stdin'
 Found naughty unicorn: Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 
2237 -hsync +vsync
Wrote 3840x2160_60.00.S

make

cc -c -DCRC="0x00" -o 3840x2160_60.00.o 3840x2160_60.00.S
edid.S: Assembler messages:
edid.S:171: Warning: value 0x1c1 truncated to 0xc1
edid.S:180: Warning: value 0x1166b truncated to 0x166b
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 3840x2160_60.00.o 3840x2160_60.00.bin.nocrc
cat 3840x2160_60.00.bin.nocrc | edid-decode \
        | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >3840x2160_60.00.crc
cc -c -DCRC="$(cat 3840x2160_60.00.crc)" -o 3840x2160_60.00.p 3840x2160_60.00.S
edid.S: Assembler messages:
edid.S:171: Warning: value 0x1c1 truncated to 0xc1
edid.S:180: Warning: value 0x1166b truncated to 0x166b
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 3840x2160_60.00.p 3840x2160_60.00.bin
objcopy -Oihex 3840x2160_60.00.p 3840x2160_60.00.bin.ihex
dos2unix 3840x2160_60.00.bin.ihex 2>/dev/null
rm 3840x2160_60.00.crc 3840x2160_60.00.p 3840x2160_60.00.o 3840x2160_60.00.bin.nocrc

_parse-edid < 3840x216060.00.bin

You seem to have too many extension blocks. Will not continue to parse
Something strange happened. Please contact the author,
Matthew Kern at <pyrophobicman@gmail.com>

Would you have any idea on why this is happening?

vith commented 6 years ago

I'm having similar results with the modeline I'm trying to convert:

$ ./modeline2edid - <<< 'Modeline "1920x1080x120.00"  297.000000  1920 2028 2060 2200  1080 1084 1088 1125  +HSync -Vsync'

Searching for runaway unicorns in '/dev/stdin'
-- Found naughty unicorn: Modeline "1920x1080x120.00" 297.000000 1920 2028 2060 2200 1080 1084 1088 1125 +HSync -Vsync
Wrote 1920x1080x120.00.S

$ make
cc -c -DCRC="0x00" -o 1920x1080x120.00.o 1920x1080x120.00.S
edid.S: Assembler messages:
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 1920x1080x120.00.o 1920x1080x120.00.bin.nocrc
cat 1920x1080x120.00.bin.nocrc | edid-decode \
    | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >1920x1080x120.00.crc
cc -c -DCRC="$(cat 1920x1080x120.00.crc)" -o 1920x1080x120.00.p 1920x1080x120.00.S
edid.S: Assembler messages:
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 1920x1080x120.00.p 1920x1080x120.00.bin
cc -c -DCRC="0x00" -o 1600x1200.o 1600x1200.S
objcopy -Obinary 1600x1200.o 1600x1200.bin.nocrc
cat 1600x1200.bin.nocrc | edid-decode \
    | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >1600x1200.crc
cc -c -DCRC="$(cat 1600x1200.crc)" -o 1600x1200.p 1600x1200.S
objcopy -Oihex 1600x1200.p 1600x1200.bin.ihex
dos2unix 1600x1200.bin.ihex 2>/dev/null
make: *** [Makefile:33: 1600x1200.bin.ihex] Error 127
rm 1920x1080x120.00.bin.nocrc 1600x1200.bin.nocrc 1920x1080x120.00.crc 1600x1200.crc 1600x1200.p 1920x1080x120.00.o 1600x1200.o 1920x1080x120.00.p

$ parse-edid < 1920x1080x120.00.bin 
You seem to have too many extension blocks. Will not continue to parse
Something strange happened. Please contact the author,
Matthew Kern at <pyrophobicman@gmail.com>
akatrevorjay commented 6 years ago

What's in the generated template file? ie, 1920x1080x120.00.S

akatrevorjay commented 6 years ago

I was using Ubuntu 16.04.1 when I wrote this, so I'm curious !

akatrevorjay commented 6 years ago

This is what's curious to me:

edid.S: Assembler messages:
edid.S:270: Warning: repeat < 0; .fill ignored
akatrevorjay commented 6 years ago

@MPolymath Did you mean to have a newline in there?

ie ``` Modeline "3840x2160_60.00" 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync +vsync

vith commented 6 years ago
$ cat 1920x1080x120.00.S 
/* 1920x1080x120.00: Modeline "1920x1080x120.00" 297.000000 1920 2028 2060 2200 1080 1084 1088 1125 +HSync -Vsync */
#define HSYNC_POL 1
#define VSYNC_POL 1
#define YPULSE (63+4)
#define XPULSE 32
#define YPIX 1080
#define XPIX 1920
#define VFREQ 60
#define DPI 96
#define CLOCK 297000
#define VERSION 1
#define XOFFSET 108
#define REVISION 3
#define YOFFSET (63+4)
#define YBLANK 45
#define XY_RATIO XY_RATIO_16_9
#define XBLANK 280
#define TIMING_NAME "1920x1080x120.00"
#include "edid.S"
akatrevorjay commented 6 years ago

@vith Care to try the latest commit I made?

akatrevorjay commented 6 years ago

It's not working because it's not finished building. I'm curious how you even have .bin files since it doesn't get to that point? You at least aren't supposed to ;)

Here's an example from mine:

~/git/edid-generator master*
❯ parse-edid < 3840x2160.bin
Checksum Correct

Section "Monitor"
    Identifier "3840x2160"
    ModelName "3840x2160"
    VendorName "LNX"
    # Monitor Manufactured week 5 of 2012
    # EDID version 1.3
    # Analog Display
    DisplaySize 1000 560
    Gamma 2.20
    Option "DPMS" "true"
    Horizsync 134-136
    VertRefresh 59-61
    # Maximum pixel clock is 600MHz
    #Not giving standard mode: 1792x1008, 60Hz
    Modeline    "Mode 0" 594.00 3840 4016 4104 4400 2160 2168 2178 2250 +hsync +vsync 
EndSection
akatrevorjay commented 6 years ago

Ah I see, 1600x1200 is seemingly invalid as far as it's concerned.

vith commented 6 years ago

tried with 5d79400:

~/code/edid-generator master
❯ ./modeline2edid - <<< 'Modeline "1920x1080x120.00"  297.000000  1920 2028 2060 2200  1080 1084 1088 1125  +HSync -Vsync'
Searching for modelines in '/dev/stdin'
-- Found modeline: Modeline "1920x1080x120.00" 297.000000 1920 2028 2060 2200 1080 1084 1088 1125 +HSync -Vsync
Computed ratio: 16:9Wrote 1920x1080x120.00.S

~/code/edid-generator master*
❯ make
cc -c -DCRC="0x00" -o 1920x1080x120.00.o 1920x1080x120.00.S
edid.S: Assembler messages:
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 1920x1080x120.00.o 1920x1080x120.00.bin.nocrc
cat 1920x1080x120.00.bin.nocrc | edid-decode \
    | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >1920x1080x120.00.crc
cc -c -DCRC="$(cat 1920x1080x120.00.crc)" -o 1920x1080x120.00.p 1920x1080x120.00.S
edid.S: Assembler messages:
edid.S:270: Warning: repeat < 0; .fill ignored
objcopy -Obinary 1920x1080x120.00.p 1920x1080x120.00.bin
cc -c -DCRC="0x00" -o 1600x1200.o 1600x1200.S
objcopy -Obinary 1600x1200.o 1600x1200.bin.nocrc
cat 1600x1200.bin.nocrc | edid-decode \
    | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >1600x1200.crc
cc -c -DCRC="$(cat 1600x1200.crc)" -o 1600x1200.p 1600x1200.S
objcopy -Oihex 1600x1200.p 1600x1200.bin.ihex
dos2unix 1600x1200.bin.ihex 2>/dev/null
make: *** [Makefile:33: 1600x1200.bin.ihex] Error 127
rm 1920x1080x120.00.bin.nocrc 1600x1200.bin.nocrc 1920x1080x120.00.crc 1600x1200.crc 1600x1200.p 1920x1080x120.00.o 1600x1200.o 1920x1080x120.00.p

~/code/edid-generator master*
❯ parse-edid < 1920x1080x120.00.bin
You seem to have too many extension blocks. Will not continue to parse
Something strange happened. Please contact the author,
Matthew Kern at <pyrophobicman@gmail.com>

~/code/edid-generator master*
❯ cat 1920x1080x120.00.S
/* 1920x1080x120.00: Modeline "1920x1080x120.00" 297.000000 1920 2028 2060 2200 1080 1084 1088 1125 +HSync -Vsync */
#define HSYNC_POL 1
#define VSYNC_POL 1
#define YPULSE (63+4)
#define XPULSE 32
#define YPIX 1080
#define XPIX 1920
#define VFREQ 60
#define DPI 96
#define CLOCK 297000
#define VERSION 1
#define REVISION 3
#define XOFFSET 108
#define YOFFSET (63+4)
#define XY_RATIO XY_RATIO_16_9
#define YBLANK 45
#define XBLANK 280
#define TIMING_NAME "1920x1080x120.00"
#include "edid.S"
akatrevorjay commented 6 years ago

@vith install dos2unix :)

akatrevorjay commented 6 years ago

@vith ret code 127 is normally a missing command. In this case, it's dos2unix

akatrevorjay commented 6 years ago

There's another error past that however, where it's actually mistempating your modeline (open up the .c file generated, and you'll see what's wrong pretty quickly ;)

akatrevorjay commented 6 years ago

So, you want a 120hz refresh rate, but it's generating it with 60. Interesting.

akatrevorjay commented 6 years ago

Ah, I cheated here with vfreq_hz. You can manually append vfreq=120 and it will set that. There's a couple options I added that way that are less used:

    local -i hsync_polarity=0 vsync_polarity=0 dpi=96 vfreq_hz=60
    local edid_version="1.3" ratio="compute"

    local arg
    for arg in "$@"; do
        case "${(L)arg}" in
            [-+]hsync) [[ "${arg:1:1}" == "-" ]] || hsync_polarity=1 ;;
            [-+]vsync) [[ "${arg:1:1}" == "-" ]] || vsync_polarity=1 ;;
            ratio=*|xy_ratio=*) ratio="${arg#*=}" ;;
            dpi=*) dpi="${arg#*=}" ;;
            edid_version=*) edid_version="${arg#*=}" ;;
            vfreq=*|vfreq_hz=*) vfreq_hz="${arg#*=}" ;;
            *) echo "Ignoring unknown modeline option passed: '$arg'" >&2 ;;
        esac
    done
akatrevorjay commented 6 years ago

Bahaha, it's the name of the mode!

vith commented 6 years ago

My bad about the dos2unix thing. I thought it was installed and didn't notice the problem because the usual command not found stderr output was hidden.

Unfortunately I'm running Linux under virtualization now so I can't easily test a generated EDID anymore :frowning_face:

akatrevorjay commented 6 years ago

Haha, yeah, that'll do it (also no prob, thanks for mentioning that and the PR to make it easier)

akatrevorjay commented 6 years ago

I started rewriting this as a python script to avoid the gotchas as well, I hope to have something out this weekend. I made this as a quick hack for myself, thought others may as well, but, go figure, it has the most stars of my repos, so I figured it's worth a little time in the end.

vith commented 6 years ago

Sounds good. There's definitely a need for an easy to use tool to do this now that wayland is more common. Honestly seems like something that should be integrated into desktop environments' settings GUIs and not require editing kernel parameters manually, but what do I know.

akatrevorjay commented 6 years ago

lol, I agree with you there, it's crazy that in 2018 we're still dealing with bad EDID data from devices!

Rotaride commented 5 years ago

Remove consecutive spaces from modeline you are giving to modeline2edid and try again. "1920x1080x120.00" 297.000000 1920

should instead be

"1920x1080x120.00" 297.000000 1920

JKJameson commented 4 years ago

I got an invalid edid file generated using this command echo 'Modeline "2560x1440_144.00" 808.75 2560 2792 3072 3584 1440 1443 1448 1568 -hsync +vsync' | ./modeline2edid -

It was fixed by changing the name of the mode to not have the refresh rate. echo 'Modeline "2560x1440" 808.75 2560 2792 3072 3584 1440 1443 1448 1568 -hsync +vsync' | ./modeline2edid -

cristiantm commented 4 years ago

Just wanted to share that the problem seems to be on the modeline name. as having similar issues with "1600x900_60.00", changing it to "1600x900" made it work fine.

jason-eu commented 2 years ago

Just wanted to share that the problem seems to be on the modeline name. as having similar issues with "1600x900_60.00", changing it to "1600x900" made it work fine.

So with that change we can say that this is a working method now?

parkerlreed commented 2 years ago

Not working for 120Hz. I limited name to 12 chars and the file is too small

(130)(deck@steamdeck edid-generator)$ ./modeline2edid modeline
Searching for modelines in 'modeline'
-- Found modeline: Modeline "1920x1080120" 297.00 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync
Computed ratio: 16:9Wrote 1920x1080120.S
(deck@steamdeck edid-generator)$ make
cc -c -DCRC="0x00" -o 1920x1080120.o 1920x1080120.S
objcopy -Obinary 1920x1080120.o 1920x1080120.bin.nocrc
cat 1920x1080120.bin.nocrc | edid-decode \
        | sed -ne 's/^[ ]*Checksum: 0x\w\+ (should be \(0x\w\+\))$/\1/p' >1920x1080120.crc
cc -c -DCRC="$(cat 1920x1080120.crc)" -o 1920x1080120.p 1920x1080120.S
objcopy -Obinary 1920x1080120.p 1920x1080120.bin
objcopy -Oihex 1920x1080120.p 1920x1080120.bin.ihex
dos2unix --quiet 1920x1080120.bin.ihex
rm 1920x1080120.o 1920x1080120.p 1920x1080120.bin.nocrc 1920x1080120.crc
(deck@steamdeck edid-generator)$ cat 1920x1080120.bin | edid-decode
EDID length 127 is not a multiple of 128.
alejandro097 commented 2 years ago

you got it working now?In my case, I got the script to generate bin successfully but it doesn't change refresh rate to 75hz

parkerlreed commented 2 years ago

I'm still stuck with it creating the wrong sized bins

mzpqnxow commented 3 months ago

Also, see #31 - seems to include the ability to generate 4k EDIDs. It hasn't been merged, but you can use his fork:

$ git clone https://github.com/ahm-forks/edid-generator --branch edid-header
mzpqnxow commented 3 months ago

The qemu qemu-edid application seems to work for my 6k display

I built qemu from source, you may also be able to install it via your package manager

$ git clone https://gitlab.com/qemu-project/qemu
$ cd qemu
$ ./configure
$ make -j

You may need to install a few dependencies (flex, bison, glib-2.0-dev, sphinx, ninja-build, build-essential) but it otherwise builds cleanly on Debian 12..

Then I tested it:

user@personal:~/edid_kernel/edid-generator/edid-creator/qemu/hw/display$ ../../build/qemu-bundle/usr/local/bin/qemu-edid -x 6144 -y 3456 -v DEL -n 'DELL U3224KB' -X 6144 -Y 3456 | edid-decode 
edid-decode (hex):

00 ff ff ff ff ff ff 00 10 ac 34 12 00 00 00 00
2a 18 01 04 a5 9c 57 78 06 ee 91 a3 54 4c 99 26
0f 50 54 21 08 00 e1 c0 d1 c0 d1 00 a9 40 b3 00
95 00 81 80 81 40 00 00 00 f7 00 0a 00 40 82 00
28 20 00 00 00 00 00 00 00 00 00 fd 00 32 7d 1e
a0 ff 01 0a 20 20 20 20 20 20 00 00 00 fc 00 44
45 4c 4c 20 55 33 32 32 34 4b 42 0a 00 00 00 10
00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 0f

02 03 0b 00 46 7d 65 60 59 1f 61 00 00 00 10 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2f

70 13 17 03 00 03 00 14 ed 64 03 88 ff 17 65 08
ff 05 b7 00 7f 0d 77 00 10 00 10 00 7f 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90

----------------

Block 0, Base EDID:
  EDID Structure Version & Revision: 1.4
  Vendor & Product Identification:
    Manufacturer: DEL
    Model: 4660
    Made in: week 42 of 2014
  Basic Display Parameters & Features:
    Digital display
    Bits per primary color channel: 8
    DisplayPort interface
    Maximum image size: 156 cm x 87 cm
    Gamma: 2.20
    Supported color formats: RGB 4:4:4
    Default (sRGB) color space is primary color space
    First detailed timing includes the native pixel format and preferred refresh rate
  Color Characteristics:
    Red  : 0.6396, 0.3300
    Green: 0.2998, 0.5996
    Blue : 0.1503, 0.0595
    White: 0.3125, 0.3291
  Established Timings I & II:
    DMT 0x04:   640x480    59.940476 Hz   4:3     31.469 kHz     25.175000 MHz
    DMT 0x09:   800x600    60.316541 Hz   4:3     37.879 kHz     40.000000 MHz
    DMT 0x10:  1024x768    60.003840 Hz   4:3     48.363 kHz     65.000000 MHz
  Standard Timings:
    DMT 0x54:  2048x1152   60.000000 Hz  16:9     72.000 kHz    162.000000 MHz (RB)
    DMT 0x52:  1920x1080   60.000000 Hz  16:9     67.500 kHz    148.500000 MHz
    DMT 0x45:  1920x1200   59.884600 Hz  16:10    74.556 kHz    193.250000 MHz
    DMT 0x33:  1600x1200   60.000000 Hz   4:3     75.000 kHz    162.000000 MHz
    DMT 0x3a:  1680x1050   59.954250 Hz  16:10    65.290 kHz    146.250000 MHz
    DMT 0x2f:  1440x900    59.887445 Hz  16:10    55.935 kHz    106.500000 MHz
    DMT 0x23:  1280x1024   60.019740 Hz   5:4     63.981 kHz    108.000000 MHz
    DMT 0x20:  1280x960    60.000000 Hz   4:3     60.000 kHz    108.000000 MHz
  Detailed Timing Descriptors:
    Established timings III:
      DMT 0x17:  1280x768    59.870228 Hz   5:3     47.776 kHz     79.500000 MHz
      DMT 0x27:  1360x768    60.015162 Hz  85:48    47.712 kHz     85.500000 MHz
      DMT 0x2a:  1400x1050   59.978442 Hz   4:3     65.317 kHz    121.750000 MHz
      DMT 0x3e:  1792x1344   59.999789 Hz   4:3     83.640 kHz    204.750000 MHz
      DMT 0x41:  1856x1392   59.995184 Hz   4:3     86.333 kHz    218.250000 MHz
      DMT 0x49:  1920x1440   60.000000 Hz   4:3     90.000 kHz    234.000000 MHz
    Display Range Limits:
      Monitor ranges (Bare Limits): 50-125 Hz V, 30-160 kHz H, max dotclock 2550 MHz
    Display Product Name: 'DELL U3224KB'
    Dummy Descriptor:
  Extension blocks: 2
Checksum: 0x0f

----------------

Block 1, CTA-861 Extension Block:
  Revision: 3
  Native detailed modes: 0
  Video Data Block:
    VIC 125:  5120x2160   50.000000 Hz  64:27   112.500 kHz    742.500000 MHz
    VIC 101:  4096x2160   50.000000 Hz 256:135  112.500 kHz    594.000000 MHz
    VIC  96:  3840x2160   50.000000 Hz  16:9    112.500 kHz    594.000000 MHz
    VIC  89:  2560x1080   50.000000 Hz  64:27    56.250 kHz    185.625000 MHz
    VIC  31:  1920x1080   50.000000 Hz  16:9     56.250 kHz    148.500000 MHz
    VIC  97:  3840x2160   60.000000 Hz  16:9    135.000 kHz    594.000000 MHz
  Detailed Timing Descriptors:
    Dummy Descriptor:
    Dummy Descriptor:
    Dummy Descriptor:
    Dummy Descriptor:
    Dummy Descriptor:
    Dummy Descriptor:
Checksum: 0x2f

----------------

Block 2, DisplayID Extension Block:
  Version: 1.3
  Extension Count: 0
  Display Product Type: Standalone display device
  Video Timing Modes Type 1 - Detailed Timings Data Block:
    DTD:  6144x3456   75.000310 Hz   0:0    268.201 kHz   2224.460000 MHz (aspect undefined, no 3D stereo, preferred)
               Hfront 1536 Hsync 184 Hback  430 Hpol N
               Vfront   17 Vsync  17 Vback   86 Vpol N
  Checksum: 0x7f
Checksum: 0x90

Haven't tested it to see if it actually has the desired effect on the display, but it looks about right in edid-decode ...

mzpqnxow commented 3 months ago

@parkerlreed you might want to give qemu-edid a try.. though I'm hoping you have your monitor working one way or another by now ...