Linux Kernel – How to Make EDID

compilingedidkernel-moduleslinux-kernel

I read the post here and I tried to make do with what I understood from the post but here are some questions:

  1. Where is the /lib/firmware located in for example /usr/src/linux/lib/firmware or /usr/lib/firmware or elsewhere?
  2. Could I use a pre-build EDID in that address the post gave and tweak it with an editor like Gvim and pass it to kernel using the info below? The resolution I am trying to set is 1600×900@60:

      1: [H PIXELS RND]  :  1600.000000
      2: [V LINES RND]  :  450.000000
      3: [V FIELD RATE RQD]  :  120.000000
      4: [TOP MARGIN (LINES)]  :  8.000000
      5: [BOT MARGIN (LINES)]  :  8.000000
      6: [INTERLACE]  :  0.500000
      7: [H PERIOD EST]  :  16.648841
      8: [V SYNC+BP]  :  33.000000
      9: [V BACK PORCH]  :  30.000000
      10: [TOTAL V LINES]  :  500.500000
      11: [V FIELD RATE EST]  :  120.008471
      12: [H PERIOD]  :  16.650017
      13: [V FIELD RATE]  :  120.000000
      14: [V FRAME RATE]  :  60.000000
      15: [LEFT MARGIN (PIXELS)]  :  32.000000
      16: [RIGHT MARGIN (PIXELS)]  :  32.000000
      17: [TOTAL ACTIVE PIXELS]  :  1664.000000
      18: [IDEAL DUTY CYCLE]  :  25.004995
      19: [H BLANK (PIXELS)]  :  560.000000
      20: [TOTAL PIXELS]  :  2224.000000
      21: [PIXEL FREQ]  :  133.573440
      22: [H FREQ]  :  60.060000
      17: [H SYNC (PIXELS)]  :  176.000000
      18: [H FRONT PORCH (PIXELS)]  :  104.000000
      36: [V ODD FRONT PORCH(LINES)]  :  1.500000

    If yes where could I get an edid.bin file?

  3. Or should I build an EDID file from scratch; if yes how could I make an EDID file?

Best Answer

Where is /lib/firmware?

The final resting place for your EDID mode firmware should be under /lib/firmware/edid. However, many linux distributions place the example EDID mode-setting firmware source and the Makefile under the directory for the linux kernel documentation. For Fedora, this is provided by the kernel-doc package and resides under /usr/share/doc/kernel-doc-3.11.4/Documentation/EDID. After you compile the firmware for your monitor, you can place the edid binary anywhere that is accessable to grub upon boot, but the convention is /lib/firmware/edid/.

Can I tweak an existing edid.bin file to match my monitor's resolution?

The edid.bin files are in binary format so the correct way to tweak it would not be intuitive.

How can I make an EDID file from scratch?

The post you provided links to the official kernel documentation for building your custom edid file. The same instructions are also provided in the HOWTO.txt file in the kernel documentation directory referenced above. Essentially you edit one of the example firmware files, say 1024x768.S, providing the parameters for your monitor. Then compile it with the provided Makefile and configure grub to use the new firmware.

For me, there were two tricky bits to accomplishing this. The first one is where to find the edid source file that needs to be compiled. This was answered for Fedora above.

The second tricky bit is finding the correct values to place in 1024x768.S for your monitor. This is achieved by running cvt to generate your desired modeline and then doing a little arithmetic. For a resolution of 1600x900 with 60 Hz refresh rate and reduced blanking (recommended for LCDs), you would have:

[user@host ~]$ cvt 1600 900 60 -r
# 1600x900 59.82 Hz (CVT 1.44M9-R) hsync: 55.40 kHz; pclk: 97.50 MHz
Modeline "1600x900R"   97.50  1600 1648 1680 1760  900 903 908 926 +hsync -vsync

You can match the last line of this output to the instructions in HOWTO.txt:

Please note that the EDID data structure expects the timing
values in a different way as compared to the standard X11 format.

X11:
HTimings:  hdisp hsyncstart hsyncend htotal
VTimings:  vdisp vsyncstart vsyncend vtotal

EDID:
#define XPIX hdisp
#define XBLANK htotal-hdisp
#define XOFFSET hsyncstart-hdisp
#define XPULSE hsyncend-hsyncstart

#define YPIX vdisp
#define YBLANK vtotal-vdisp
#define YOFFSET (63+(vsyncstart-vdisp))
#define YPULSE (63+(vsyncend-vsyncstart))

The 2nd - 5th numbers in the last line of the cvt output (1600 1648 1680 1760) are the four "HTimings" parameters (hdisp hsyncstart hsyncend htotal) and the 6th - 9th numbers (900 903 908 926) are the four "VTimings" parameters (vdisp vsyncstart vsyncend vtotal).

Lastly, you'll need to compile the firmware a second time in order to set the correct CRC value in the last line (see the HOWTO.txt for details).

Related Question