-
Notifications
You must be signed in to change notification settings - Fork 1
/
edid.h
140 lines (125 loc) · 3.5 KB
/
edid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef EDID_H
#define EDID_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include "py/mphal.h"
#include "py/runtime.h"
#include "py/mperrno.h"
#include "py/objtype.h"
#include "py/objstr.h"
#include "py/objint.h"
#include "pin.h"
#include "extmod/modmachine.h"
#include "helpers.h"
// #include <framebuffer_info.h>
// #include "commonlib/coreboot_tables.h"
enum edid_modes
{
EDID_MODE_640x480_60Hz,
EDID_MODE_720x480_60Hz,
EDID_MODE_480x800_60Hz,
EDID_MODE_800x600_59Hz,
EDID_MODE_1024x768_60Hz,
EDID_MODE_1280x768_60Hz,
EDID_MODE_1280x720_60Hz,
EDID_MODE_1920x1080_60Hz,
NUM_KNOWN_MODES,
EDID_MODE_AUTO
};
struct edid_mode
{
const char *name;
unsigned int pixel_clock;
int lvds_dual_channel;
unsigned int refresh;
unsigned int ha;
unsigned int hbl;
unsigned int hso;
unsigned int hspw;
unsigned int hborder;
unsigned int va;
unsigned int vbl;
unsigned int vso;
unsigned int vspw;
unsigned int vborder;
unsigned char phsync;
unsigned char pvsync;
unsigned int x_mm;
unsigned int y_mm;
};
struct envie_edid_mode
{
const char *name;
unsigned int pixel_clock;
unsigned int refresh;
unsigned int hactive;
unsigned int hback_porch;
unsigned int hfront_porch;
unsigned int hsync_len;
unsigned int vactive;
unsigned int vsync_len;
unsigned int vback_porch;
unsigned int vfront_porch;
unsigned int voffset;
unsigned int hpol : 1;
unsigned int vpol : 1;
};
/* structure for communicating EDID information from a raw EDID block to
* higher level functions.
* The size of the data types is not critical, so we leave them as
* unsigned int. We can move more into this struct as needed.
*/
#define EDID_ASCII_STRING_LENGTH 13
struct edid
{
/* These next three things used to all be called bpp.
* Merriment ensued. The identifier
* 'bpp' is herewith banished from our
* Kingdom.
*/
/* How many bits in the framebuffer per pixel.
* Under all reasonable circumstances, it's 32.
*/
unsigned int framebuffer_bits_per_pixel;
/* On the panel, how many bits per color?
* In almost all cases, it's 6 or 8.
* The standard allows for much more!
*/
unsigned int panel_bits_per_color;
/* On the panel, how many bits per pixel.
* On Planet Earth, there are three colors
* per pixel, but this is convenient to have here
* instead of having 3*panel_bits_per_color
* all over the place.
*/
unsigned int panel_bits_per_pixel;
/* used to compute timing for graphics chips. */
struct edid_mode mode;
u8 mode_is_supported[NUM_KNOWN_MODES];
unsigned int link_clock;
/* 3 variables needed for coreboot framebuffer.
* In most cases, they are the same as the ha
* and va variables, but not always, as in the
* case of a 1366 wide display.
*/
u32 x_resolution;
u32 y_resolution;
u32 bytes_per_line;
int hdmi_monitor_detected;
char ascii_string[EDID_ASCII_STRING_LENGTH + 1];
char manufacturer_name[3 + 1];
};
enum edid_status
{
EDID_CONFORMANT,
EDID_NOT_CONFORMANT,
EDID_ABSENT,
};
/* Defined in src/lib/edid.c */
int decode_edid(unsigned char *edid, int size, struct edid *out);
void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp,
int row_byte_alignment);
int set_display_mode(struct edid *edid, enum edid_modes mode);
#endif /* EDID_H */