EDID,Extended display identification data,中文名称扩展显示器识别数据,是VESA在制定DDC显示器数据通道通信协议时,制定的有关显示器识别数据的标准。EDID存储在显示器中的DDC存储器中,当电脑主机与显示器连接后,电脑主机会通过DDC通道读取显示器DDC存储器中的存储的EDID。(参考百度百科)
UEFI 应用中可以使用EFI_EDID_DISCOVERED_PROTOCOL 这个protocol 来获取一个视频输出设备的EDID信息。
typedef struct {
UINT32 SizeOfEdid;
UINT8 *Edid;
} EFI_EDID_DISCOVERED_PROTOCOL
SizeOfEdid:EDID 存储区大小,如果没有获取到EDID,则为0;否则最小为128bytes。
Edid:指向一组只读数据的指针,这组数据包含EDID信息。
UINT8 *EdidDataPtr = NULL
Status = gBS->LocateProtocol (
&EfiEdidDiscoveredProtocolGuid,
NULL,
&EdidDiscoveredProtocol
);
EdidDataPtr=EdidDiscoveredProtocol->Edid;
这样就找到了EDID数据存储区的起始地址,参考EDID spec,其数据结构如下
Table 3.1: EDID Structure Version 1, Revision 4
Address | Bytes | Description | Format |
00h | 8 | Header: = (00 FF FF FF FF FF FF 00)h | See Section 3.3 |
08h | 10 | Vendor & Product Identification: | See Section 3.4 |
08h | 2 | ID Manufacturer Name | ISA 3-character ID Code |
0Ah | 2 | ID Product Code | Vendor assigned code |
0Ch | 4 | ID Serial Number | 32-bit serial number |
10h | 1 | Week of Manufacture | Week number or Model Year Flag |
11h | 1 | Year of Manufacture or Model Year | Manufacture Year or Model Year |
12h | 2 | EDID Structure Version & Revision: | See Section 3.5 |
12h | 1 | Version Number: = 01h | Binary |
13h | 1 | Revision Number: = 04h | Binary |
14h | 5 | Basic Display Parameters & Features: | See Section 3.6 |
14h | 1 | Video Input Definition | See Section 3.6.1 |
15h | 1 | Horizontal Screen Size or Aspect Ratio | Listed in cm. → Aspect Ratio --- Landscape |
16h | 1 | Vertical Screen Size or Aspect Ratio | Listed in cm. → Aspect Ratio --- Portrait |
17h | 1 | Display Transfer Characteristic (Gamma) | Binary --- Factory Default Value |
18h | 1 | Feature Support | See Section 3.6.4 |
19h | 10 | Color Characteristics: | See Section 3.7 |
19h | 1 | Red/Green: Low Order Bits | Rx1 Rx0 Ry1 Ry0 Gx1 Gx0 Gy1Gy0 |
1Ah | 1 | Blue/White: Low Order Bits | Bx1 Bx0 By1 By0 Wx1 Wx0 Wy1 Wy0 |
1Bh | 1 | Red-x: High Order Bits | Red-x Bits 9 → 2 |
1Ch | 1 | Red-y: High Order Bits | Red-y Bits 9 → 2 |
1Dh | 1 | Green-x: High Order Bits | Green-x Bits 9 → 2 |
1Eh | 1 | Green-y: High Order Bits | Green-y Bits 9 → 2 |
1Fh | 1 | Blue-x: High Order Bits | Blue-x Bits 9 → 2 |
20h | 1 | Blue-y: High Order Bits | Blue-y Bits 9 → 2 |
21h | 1 | White-x: High Order Bits | White-x Bits 9 → 2 |
22h | 1 | White-y: High Order Bits | White-y Bits 9 → 2 |
23h | 3 | Established Timings | See Section 3.8 |
23h | 1 | Established Timings I | |
24h | 1 | Established Timings II | |
25h | 1 | Manufacturer's Reserved Timings | |
26h | 16 | Standard Timings: Identification 1 → 8 | See Section 3.9 |
36h | 72 | 18 Byte Data Blocks | See Section 3.10 |
36h | 18 | Preferred Timing Mode | |
48h | 18 | Detailed Timing # 2 or Display Descriptor | |
5Ah | 18 | Detailed Timing # 3 or Display Descriptor | |
6Ch | 18 | Detailed Timing # 4 or Display Descriptor | |
7Eh | 1 | Extension Block Count N If Block Maps are used then 00h ≤ N ≤ FEh and FFh is invalid. If Block Maps are not used then 00h ≤ N ≤ FFh. | Number of (optional) 128-byte EDID EXTENSION blocks to follow – if Block Maps are used then 254 is the maximum value of ‘N’. If Block Maps are not used then 255 is the maximum value of ‘N’. |
7Fh | 1 | Checksum C 00h ≤ C ≤ FFh | The 1-byte sum of all 128 bytes in this EDID block shall equal zero |
offset 36h是4组18 bytes的Timing 数据结构,如Pixel clock,Horizontal Addressable Video,Horizontal Blanking等等,这里面数据都需要根据屏实际数据来设置正确,否则会影响屏工作。
例如Pixel clock135MHz ,十进制表示13500 ,会以 BCh, 34h存值