1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #ifndef EDID_H 4 #define EDID_H 5 6 #include <stdint.h> 7 #include <framebuffer_info.h> 8 #include "commonlib/coreboot_tables.h" 9 10 enum edid_modes { 11 EDID_MODE_640x480_60Hz, 12 EDID_MODE_720x480_60Hz, 13 EDID_MODE_1280x720_60Hz, 14 EDID_MODE_1920x1080_60Hz, 15 NUM_KNOWN_MODES, 16 17 EDID_MODE_AUTO 18 }; 19 20 struct edid_mode { 21 const char *name; 22 unsigned int pixel_clock; 23 int lvds_dual_channel; 24 unsigned int refresh; 25 unsigned int ha; 26 unsigned int hbl; 27 unsigned int hso; 28 unsigned int hspw; 29 unsigned int hborder; 30 unsigned int va; 31 unsigned int vbl; 32 unsigned int vso; 33 unsigned int vspw; 34 unsigned int vborder; 35 unsigned char phsync; 36 unsigned char pvsync; 37 unsigned int x_mm; 38 unsigned int y_mm; 39 }; 40 41 /* structure for communicating EDID information from a raw EDID block to 42 * higher level functions. 43 * The size of the data types is not critical, so we leave them as 44 * unsigned int. We can move more into this struct as needed. 45 */ 46 47 #define EDID_ASCII_STRING_LENGTH 13 48 49 struct edid { 50 /* These next three things used to all be called bpp. 51 * Merriment ensued. The identifier 52 * 'bpp' is herewith banished from our 53 * Kingdom. 54 */ 55 /* How many bits in the framebuffer per pixel. 56 * Under all reasonable circumstances, it's 32. 57 */ 58 unsigned int framebuffer_bits_per_pixel; 59 /* On the panel, how many bits per color? 60 * In almost all cases, it's 6 or 8. 61 * The standard allows for much more! 62 */ 63 unsigned int panel_bits_per_color; 64 /* On the panel, how many bits per pixel. 65 * On Planet Earth, there are three colors 66 * per pixel, but this is convenient to have here 67 * instead of having 3*panel_bits_per_color 68 * all over the place. 69 */ 70 unsigned int panel_bits_per_pixel; 71 /* used to compute timing for graphics chips. */ 72 struct edid_mode mode; 73 u8 mode_is_supported[NUM_KNOWN_MODES]; 74 unsigned int link_clock; 75 /* 3 variables needed for coreboot framebuffer. 76 * In most cases, they are the same as the ha 77 * and va variables, but not always, as in the 78 * case of a 1366 wide display. 79 */ 80 u32 x_resolution; 81 u32 y_resolution; 82 u32 bytes_per_line; 83 84 int hdmi_monitor_detected; 85 char ascii_string[EDID_ASCII_STRING_LENGTH + 1]; 86 char manufacturer_name[3 + 1]; 87 }; 88 89 enum edid_status { 90 EDID_CONFORMANT, 91 EDID_NOT_CONFORMANT, 92 EDID_ABSENT, 93 }; 94 95 /* Defined in src/lib/edid.c */ 96 int decode_edid(unsigned char *edid, int size, struct edid *out); 97 void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, 98 int row_byte_alignment); 99 int set_display_mode(struct edid *edid, enum edid_modes mode); 100 101 #endif /* EDID_H */ 102