blob: 7536a66119a197daf275629880a51b4df8e77255 [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -07002
3#ifndef EDID_H
4#define EDID_H
5
Nico Huber3db76532017-05-18 18:07:34 +02006#include <stdint.h>
Nicolas Boichat87f265b2019-08-06 08:29:52 +08007#include "commonlib/coreboot_tables.h"
Nico Huber3db76532017-05-18 18:07:34 +02008
David Hendricks7dbf9c62015-07-30 18:49:48 -07009enum edid_modes {
David Hendricks7dbf9c62015-07-30 18:49:48 -070010 EDID_MODE_640x480_60Hz,
David Hendrickse2054102015-08-07 18:41:37 -070011 EDID_MODE_720x480_60Hz,
12 EDID_MODE_1280x720_60Hz,
13 EDID_MODE_1920x1080_60Hz,
14 NUM_KNOWN_MODES,
15
16 EDID_MODE_AUTO
David Hendricks7dbf9c62015-07-30 18:49:48 -070017};
18
19struct edid_mode {
20 const char *name;
21 unsigned int pixel_clock;
Vladimir Serbinenko551cff02015-10-10 23:58:08 +020022 int lvds_dual_channel;
David Hendricks7dbf9c62015-07-30 18:49:48 -070023 unsigned int refresh;
24 unsigned int ha;
25 unsigned int hbl;
26 unsigned int hso;
27 unsigned int hspw;
28 unsigned int hborder;
29 unsigned int va;
30 unsigned int vbl;
31 unsigned int vso;
32 unsigned int vspw;
33 unsigned int vborder;
34 unsigned char phsync;
35 unsigned char pvsync;
36 unsigned int x_mm;
37 unsigned int y_mm;
38};
39
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070040/* structure for communicating EDID information from a raw EDID block to
41 * higher level functions.
42 * The size of the data types is not critical, so we leave them as
43 * unsigned int. We can move more into into this struct as needed.
44 */
45
Arthur Heymansdbe81612017-04-29 14:00:47 +020046#define EDID_ASCII_STRING_LENGTH 13
47
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070048struct edid {
Ronald G. Minnich9518b562013-09-19 16:45:22 -070049 /* These next three things used to all be called bpp.
50 * Merriment ensued. The identifier
51 * 'bpp' is herewith banished from our
52 * Kingdom.
53 */
54 /* How many bits in the framebuffer per pixel.
55 * Under all reasonable circumstances, it's 32.
56 */
57 unsigned int framebuffer_bits_per_pixel;
58 /* On the panel, how many bits per color?
59 * In almost all cases, it's 6 or 8.
60 * The standard allows for much more!
61 */
62 unsigned int panel_bits_per_color;
63 /* On the panel, how many bits per pixel.
64 * On Planet Earth, there are three colors
65 * per pixel, but this is convenient to have here
66 * instead of having 3*panel_bits_per_color
67 * all over the place.
68 */
69 unsigned int panel_bits_per_pixel;
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070070 /* used to compute timing for graphics chips. */
David Hendricks7dbf9c62015-07-30 18:49:48 -070071 struct edid_mode mode;
David Hendrickse2054102015-08-07 18:41:37 -070072 u8 mode_is_supported[NUM_KNOWN_MODES];
Furquan Shaikh6b190712013-07-22 16:18:31 -070073 unsigned int link_clock;
Ronald G. Minnich4c5b1612013-06-28 14:33:30 -070074 /* 3 variables needed for coreboot framebuffer.
75 * In most cases, they are the same as the ha
76 * and va variables, but not always, as in the
77 * case of a 1366 wide display.
78 */
79 u32 x_resolution;
80 u32 y_resolution;
81 u32 bytes_per_line;
Yakir Yang85810cc2015-10-27 16:17:13 +080082
83 int hdmi_monitor_detected;
Arthur Heymansdbe81612017-04-29 14:00:47 +020084 char ascii_string[EDID_ASCII_STRING_LENGTH + 1];
Hung-Te Lin6673e8e2019-08-13 12:06:27 +080085 char manufacturer_name[3 + 1];
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070086};
87
Arthur Heymans8c5884e2017-04-30 08:28:05 +020088enum edid_status {
89 EDID_CONFORMANT,
90 EDID_NOT_CONFORMANT,
91 EDID_ABSENT,
92};
93
Ronald G. Minnichb2893a012013-04-23 10:59:11 -070094/* Defined in src/lib/edid.c */
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070095int decode_edid(unsigned char *edid, int size, struct edid *out);
Julius Werner2b6db972016-04-06 12:50:40 -070096void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
97 int row_byte_alignment);
Nico Huber994a4a12016-06-16 05:57:49 +020098void set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr);
Nicolas Boichat87f265b2019-08-06 08:29:52 +080099void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation);
David Hendrickse2054102015-08-07 18:41:37 -0700100int set_display_mode(struct edid *edid, enum edid_modes mode);
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700101
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -0700102#endif /* EDID_H */