blob: e5f7d98926bebaf9cbab7eaea2e2318cf572fa65 [file] [log] [blame]
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright 2013 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070014 */
15
16#ifndef EDID_H
17#define EDID_H
18
Nico Huber3db76532017-05-18 18:07:34 +020019#include <stdint.h>
Nicolas Boichat87f265b2019-08-06 08:29:52 +080020#include "commonlib/coreboot_tables.h"
Nico Huber3db76532017-05-18 18:07:34 +020021
David Hendricks7dbf9c62015-07-30 18:49:48 -070022enum edid_modes {
David Hendricks7dbf9c62015-07-30 18:49:48 -070023 EDID_MODE_640x480_60Hz,
David Hendrickse2054102015-08-07 18:41:37 -070024 EDID_MODE_720x480_60Hz,
25 EDID_MODE_1280x720_60Hz,
26 EDID_MODE_1920x1080_60Hz,
27 NUM_KNOWN_MODES,
28
29 EDID_MODE_AUTO
David Hendricks7dbf9c62015-07-30 18:49:48 -070030};
31
32struct edid_mode {
33 const char *name;
34 unsigned int pixel_clock;
Vladimir Serbinenko551cff02015-10-10 23:58:08 +020035 int lvds_dual_channel;
David Hendricks7dbf9c62015-07-30 18:49:48 -070036 unsigned int refresh;
37 unsigned int ha;
38 unsigned int hbl;
39 unsigned int hso;
40 unsigned int hspw;
41 unsigned int hborder;
42 unsigned int va;
43 unsigned int vbl;
44 unsigned int vso;
45 unsigned int vspw;
46 unsigned int vborder;
47 unsigned char phsync;
48 unsigned char pvsync;
49 unsigned int x_mm;
50 unsigned int y_mm;
51};
52
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070053/* structure for communicating EDID information from a raw EDID block to
54 * higher level functions.
55 * The size of the data types is not critical, so we leave them as
56 * unsigned int. We can move more into into this struct as needed.
57 */
58
Arthur Heymansdbe81612017-04-29 14:00:47 +020059#define EDID_ASCII_STRING_LENGTH 13
60
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070061struct edid {
Ronald G. Minnich9518b562013-09-19 16:45:22 -070062 /* These next three things used to all be called bpp.
63 * Merriment ensued. The identifier
64 * 'bpp' is herewith banished from our
65 * Kingdom.
66 */
67 /* How many bits in the framebuffer per pixel.
68 * Under all reasonable circumstances, it's 32.
69 */
70 unsigned int framebuffer_bits_per_pixel;
71 /* On the panel, how many bits per color?
72 * In almost all cases, it's 6 or 8.
73 * The standard allows for much more!
74 */
75 unsigned int panel_bits_per_color;
76 /* On the panel, how many bits per pixel.
77 * On Planet Earth, there are three colors
78 * per pixel, but this is convenient to have here
79 * instead of having 3*panel_bits_per_color
80 * all over the place.
81 */
82 unsigned int panel_bits_per_pixel;
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070083 /* used to compute timing for graphics chips. */
David Hendricks7dbf9c62015-07-30 18:49:48 -070084 struct edid_mode mode;
David Hendrickse2054102015-08-07 18:41:37 -070085 u8 mode_is_supported[NUM_KNOWN_MODES];
Furquan Shaikh6b190712013-07-22 16:18:31 -070086 unsigned int link_clock;
Ronald G. Minnich4c5b1612013-06-28 14:33:30 -070087 /* 3 variables needed for coreboot framebuffer.
88 * In most cases, they are the same as the ha
89 * and va variables, but not always, as in the
90 * case of a 1366 wide display.
91 */
92 u32 x_resolution;
93 u32 y_resolution;
94 u32 bytes_per_line;
Yakir Yang85810cc2015-10-27 16:17:13 +080095
96 int hdmi_monitor_detected;
Arthur Heymansdbe81612017-04-29 14:00:47 +020097 char ascii_string[EDID_ASCII_STRING_LENGTH + 1];
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -070098};
99
Arthur Heymans8c5884e2017-04-30 08:28:05 +0200100enum edid_status {
101 EDID_CONFORMANT,
102 EDID_NOT_CONFORMANT,
103 EDID_ABSENT,
104};
105
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700106/* Defined in src/lib/edid.c */
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -0700107int decode_edid(unsigned char *edid, int size, struct edid *out);
Julius Werner2b6db972016-04-06 12:50:40 -0700108void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
109 int row_byte_alignment);
Nico Huber994a4a12016-06-16 05:57:49 +0200110void set_vbe_mode_info_valid(const struct edid *edid, uintptr_t fb_addr);
Nicolas Boichat87f265b2019-08-06 08:29:52 +0800111void set_vbe_framebuffer_orientation(enum lb_fb_orientation orientation);
David Hendrickse2054102015-08-07 18:41:37 -0700112int set_display_mode(struct edid *edid, enum edid_modes mode);
Ronald G. Minnichb2893a012013-04-23 10:59:11 -0700113
Ronald G. Minnichb3b72f32013-03-13 14:35:01 -0700114#endif /* EDID_H */