1/*
2 * Copyright 2007 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23/* Author: Soren Sandmann <sandmann@redhat.com> */
24
25typedef unsigned char uchar;
26typedef struct MonitorInfo MonitorInfo;
27typedef struct Timing Timing;
28typedef struct DetailedTiming DetailedTiming;
29
30typedef enum
31{
32 UNDEFINED,
33 DVI,
34 HDMI_A,
35 HDMI_B,
36 MDDI,
37 DISPLAY_PORT
38} Interface;
39
40typedef enum
41{
42 UNDEFINED_COLOR,
43 MONOCHROME,
44 RGB,
45 OTHER_COLOR
46} ColorType;
47
48typedef enum
49{
50 NO_STEREO,
51 FIELD_RIGHT,
52 FIELD_LEFT,
53 TWO_WAY_RIGHT_ON_EVEN,
54 TWO_WAY_LEFT_ON_EVEN,
55 FOUR_WAY_INTERLEAVED,
56 SIDE_BY_SIDE
57} StereoType;
58
59struct Timing
60{
61 int width;
62 int height;
63 int frequency;
64};
65
66struct DetailedTiming
67{
68 int pixel_clock;
69 int h_addr;
70 int h_blank;
71 int h_sync;
72 int h_front_porch;
73 int v_addr;
74 int v_blank;
75 int v_sync;
76 int v_front_porch;
77 int width_mm;
78 int height_mm;
79 int right_border;
80 int top_border;
81 int interlaced;
82 StereoType stereo;
83
84 int digital_sync;
85 union
86 {
87 struct
88 {
89 int bipolar;
90 int serrations;
91 int sync_on_green;
92 } analog;
93
94 struct
95 {
96 int composite;
97 int serrations;
98 int negative_vsync;
99 int negative_hsync;
100 } digital;
101 } ad;
102};
103
104struct MonitorInfo
105{
106 int checksum;
107 char manufacturer_code[4];
108 int product_code;
109 unsigned int serial_number;
110
111 int production_week; // -1 if not specified
112 int production_year; // -1 if not specified
113 int model_year; // -1 if not specified
114
115 int major_version;
116 int minor_version;
117
118 int is_digital;
119
120 union
121 {
122 struct
123 {
124 int bits_per_primary;
125 Interface interface;
126 int rgb444;
127 int ycrcb444;
128 int ycrcb422;
129 } digital;
130
131 struct
132 {
133 double video_signal_level;
134 double sync_signal_level;
135 double total_signal_level;
136
137 int blank_to_black;
138
139 int separate_hv_sync;
140 int composite_sync_on_h;
141 int composite_sync_on_green;
142 int serration_on_vsync;
143 ColorType color_type;
144 } analog;
145 } ad;
146
147 int width_mm; // -1 if not specified
148 int height_mm; // -1 if not specified
149 double aspect_ratio; // -1.0 if not specififed
150
151 double gamma; // -1.0 if not specified
152
153 int standby;
154 int suspend;
155 int active_off;
156
157 int srgb_is_standard;
158 int preferred_timing_includes_native;
159 int continuous_frequency;
160
161 double red_x;
162 double red_y;
163 double green_x;
164 double green_y;
165 double blue_x;
166 double blue_y;
167 double white_x;
168 double white_y;
169
170 Timing established[24]; // Terminated by 0x0x0
171 Timing standard[8];
172
173 int n_detailed_timings;
174 DetailedTiming detailed_timings[4]; /* If monitor has a preferred
175 * mode, it is the first one
176 * (whether it has, is
177 * determined by the
178 * preferred_timing_includes
179 * bit.
180 */
181
182 // Optional product description
183 char dsc_serial_number[14];
184 char dsc_product_name[14];
185 char dsc_string[14]; // Unspecified ASCII data
186};
187
188MonitorInfo *decode_edid(const uchar *data);
189void dump_monitor_info(MonitorInfo *info);
190char *make_display_name(const char *output_name,
191 const MonitorInfo *info);
192