Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 3 | |
| 4 | #ifndef EDID_H |
| 5 | #define EDID_H |
| 6 | |
Nico Huber | 3db7653 | 2017-05-18 18:07:34 +0200 | [diff] [blame] | 7 | #include <stdint.h> |
Nicolas Boichat | 87f265b | 2019-08-06 08:29:52 +0800 | [diff] [blame] | 8 | #include "commonlib/coreboot_tables.h" |
Nico Huber | 3db7653 | 2017-05-18 18:07:34 +0200 | [diff] [blame] | 9 | |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 10 | enum edid_modes { |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 11 | EDID_MODE_640x480_60Hz, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 12 | EDID_MODE_720x480_60Hz, |
| 13 | EDID_MODE_1280x720_60Hz, |
| 14 | EDID_MODE_1920x1080_60Hz, |
| 15 | NUM_KNOWN_MODES, |
| 16 | |
| 17 | EDID_MODE_AUTO |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | struct edid_mode { |
| 21 | const char *name; |
| 22 | unsigned int pixel_clock; |
Vladimir Serbinenko | 551cff0 | 2015-10-10 23:58:08 +0200 | [diff] [blame] | 23 | int lvds_dual_channel; |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 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 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 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 into this struct as needed. |
| 45 | */ |
| 46 | |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 47 | #define EDID_ASCII_STRING_LENGTH 13 |
| 48 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 49 | struct edid { |
Ronald G. Minnich | 9518b56 | 2013-09-19 16:45:22 -0700 | [diff] [blame] | 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; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 71 | /* used to compute timing for graphics chips. */ |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 72 | struct edid_mode mode; |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 73 | u8 mode_is_supported[NUM_KNOWN_MODES]; |
Furquan Shaikh | 6b19071 | 2013-07-22 16:18:31 -0700 | [diff] [blame] | 74 | unsigned int link_clock; |
Ronald G. Minnich | 4c5b161 | 2013-06-28 14:33:30 -0700 | [diff] [blame] | 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; |
Yakir Yang | 85810cc | 2015-10-27 16:17:13 +0800 | [diff] [blame] | 83 | |
| 84 | int hdmi_monitor_detected; |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 85 | char ascii_string[EDID_ASCII_STRING_LENGTH + 1]; |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 86 | char manufacturer_name[3 + 1]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 89 | enum edid_status { |
| 90 | EDID_CONFORMANT, |
| 91 | EDID_NOT_CONFORMANT, |
| 92 | EDID_ABSENT, |
| 93 | }; |
| 94 | |
Ronald G. Minnich | b2893a01 | 2013-04-23 10:59:11 -0700 | [diff] [blame] | 95 | /* Defined in src/lib/edid.c */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 96 | int decode_edid(unsigned char *edid, int size, struct edid *out); |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 97 | void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, |
| 98 | int row_byte_alignment); |
Nico Huber | 994a4a1 | 2016-06-16 05:57:49 +0200 | [diff] [blame] | 99 | void set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr); |
Nicolas Boichat | 87f265b | 2019-08-06 08:29:52 +0800 | [diff] [blame] | 100 | void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation); |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 101 | int set_display_mode(struct edid *edid, enum edid_modes mode); |
Ronald G. Minnich | b2893a01 | 2013-04-23 10:59:11 -0700 | [diff] [blame] | 102 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 103 | #endif /* EDID_H */ |