blob: 691cf76b97fe451f004e5be1d6d496f0697def30 [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>
Patrick Rudolph73192882020-02-19 12:10:51 +01007#include <framebuffer_info.h>
Nicolas Boichat87f265b2019-08-06 08:29:52 +08008#include "commonlib/coreboot_tables.h"
Nico Huber3db76532017-05-18 18:07:34 +02009
David Hendricks7dbf9c62015-07-30 18:49:48 -070010enum edid_modes {
David Hendricks7dbf9c62015-07-30 18:49:48 -070011 EDID_MODE_640x480_60Hz,
David Hendrickse2054102015-08-07 18:41:37 -070012 EDID_MODE_720x480_60Hz,
13 EDID_MODE_1280x720_60Hz,
14 EDID_MODE_1920x1080_60Hz,
15 NUM_KNOWN_MODES,
16
17 EDID_MODE_AUTO
David Hendricks7dbf9c62015-07-30 18:49:48 -070018};
19
20struct edid_mode {
21 const char *name;
22 unsigned int pixel_clock;
Vladimir Serbinenko551cff02015-10-10 23:58:08 +020023 int lvds_dual_channel;
David Hendricks7dbf9c62015-07-30 18:49:48 -070024 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. Minnichb3b72f32013-03-13 14:35:01 -070041/* 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 Heymansdbe81612017-04-29 14:00:47 +020047#define EDID_ASCII_STRING_LENGTH 13
48
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070049struct edid {
Ronald G. Minnich9518b562013-09-19 16:45:22 -070050 /* 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. Minnichb3b72f32013-03-13 14:35:01 -070071 /* used to compute timing for graphics chips. */
David Hendricks7dbf9c62015-07-30 18:49:48 -070072 struct edid_mode mode;
David Hendrickse2054102015-08-07 18:41:37 -070073 u8 mode_is_supported[NUM_KNOWN_MODES];
Furquan Shaikh6b190712013-07-22 16:18:31 -070074 unsigned int link_clock;
Ronald G. Minnich4c5b1612013-06-28 14:33:30 -070075 /* 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 Yang85810cc2015-10-27 16:17:13 +080083
84 int hdmi_monitor_detected;
Arthur Heymansdbe81612017-04-29 14:00:47 +020085 char ascii_string[EDID_ASCII_STRING_LENGTH + 1];
Hung-Te Lin6673e8e2019-08-13 12:06:27 +080086 char manufacturer_name[3 + 1];
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070087};
88
Arthur Heymans8c5884e2017-04-30 08:28:05 +020089enum edid_status {
90 EDID_CONFORMANT,
91 EDID_NOT_CONFORMANT,
92 EDID_ABSENT,
93};
94
Ronald G. Minnichb2893a012013-04-23 10:59:11 -070095/* Defined in src/lib/edid.c */
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070096int decode_edid(unsigned char *edid, int size, struct edid *out);
Julius Werner2b6db972016-04-06 12:50:40 -070097void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
98 int row_byte_alignment);
David Hendrickse2054102015-08-07 18:41:37 -070099int set_display_mode(struct edid *edid, enum edid_modes mode);
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700100
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -0700101#endif /* EDID_H */