Wednesday, July 3, 2013

Create A Custom EDID File Using The Code Under Linux Kernel Tree

      These days I read a article in arch wiki descring how to make kms use a custom  edid file so that can get a acceptable resolution,so I work on it for several days.
Now I has find out how to make it.
Step 1.

 git clone git://anongit.freedesktop.org/xorg/app/edid-decode 

and compile , then copy  edid-decode executable file to /usr/bin.

Step 2.

cvt 1440 900

get this output :

# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
Modeline "1440x900_60.00"  106.50
1440 1528 1672 1904
900 903 909 934
 -hsync +vsync

Step 3.

get the kernel code and unpack , configure and complie, then

add  "edid/1440x900.bin",   to  drivers/gpu/drm/drm_edid_load.c

cd Documentation/EDID
cp 1024x768.S 1440x900.S
nano  1440x900.S

open another window and

nano  HOWTO.txt

then you will see

"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))"

It means:

HTimings:  hdisp hsyncstart hsyncend htotal
                      1440      1528          1672          1904
VTimings:  vdisp vsyncstart vsyncend vtotal
                      900        903            909             934

then caculate  XPIX  XBLANK  XOFFSET  XPULSE YPIX  YBLANK  YOFFSET  YPULSE youself and edit 1440x900.S

change    #define ESTABLISHED_TIMINGS_BITS 0x0  to
  #define ESTABLISHED_TIMINGS_BITS 0x00 .

As you see, the  -hsync +vsync  also need to be used.

so change

#define HSYNC_POL 0
#define VSYNC_POL 0

to

#define HSYNC_POL 1
#define VSYNC_POL 0

then 

make 

edid-decode 1440x900.bin

you will see that checksum failed and the output will tell you to change 

#define CRC 0x55

the run make again

Step 4.

 mkdir   /lib/firmware/edid

 cp 1440x900.bin /lib/firmware/edid
 cd  ../../

add  CONFIG_EXTRA_FIRMWARE="edid/1440x900.bin"  to .config ,

recompile kernel and copy to the right place.

Step 5.
add drm_kms_helper.edid_firmware=edid/1440x900.bin to grub commandline.


Here is my 1440x900.S

/* EDID */
#define VERSION 1
#define REVISION 3

/* Display */
#define CLOCK 106500 /* kHz */
#define XPIX 1440
#define YPIX 900
#define XY_RATIO XY_RATIO_16_10
#define XBLANK 464
#define YBLANK 34
#define XOFFSET 88
#define XPULSE 144
#define YOFFSET (63+3)
#define YPULSE (63+6)
#define DPI 96
#define VFREQ 60 /* Hz */
#define TIMING_NAME "Linux XGA"
#define ESTABLISHED_TIMINGS_BITS 0x00
#define HSYNC_POL 1
#define VSYNC_POL 0
#define CRC 0xd

#include "edid.S"