Patrick Georgi | 593124d | 2020-05-10 19:44:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: MIT */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 2 | |
| 3 | /* this is a pretty robust parser for EDID, and we're tasked with parsing |
| 4 | * an arbitrary panel. We will pass it a raw EDID block and a struct which |
| 5 | * it must fill in with values. The set of values we need is pretty limited |
| 6 | * at present. |
| 7 | */ |
| 8 | |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 9 | #include <assert.h> |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 10 | #include <commonlib/helpers.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 11 | #include <console/console.h> |
Joel Kitching | 393c71c | 2019-06-16 16:09:42 +0800 | [diff] [blame] | 12 | #include <ctype.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | #include <string.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 15 | #include <edid.h> |
Ronald G. Minnich | b2893a01 | 2013-04-23 10:59:11 -0700 | [diff] [blame] | 16 | #include <vbe.h> |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 17 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 18 | struct edid_context { |
| 19 | int claims_one_point_oh; |
| 20 | int claims_one_point_two; |
| 21 | int claims_one_point_three; |
| 22 | int claims_one_point_four; |
| 23 | int nonconformant_digital_display; |
| 24 | int nonconformant_extension; |
| 25 | int did_detailed_timing; |
| 26 | int has_name_descriptor; |
| 27 | int has_range_descriptor; |
| 28 | int has_preferred_timing; |
| 29 | int has_valid_checksum; |
| 30 | int has_valid_cvt; |
| 31 | int has_valid_dummy_block; |
| 32 | int has_valid_week; |
| 33 | int has_valid_year; |
| 34 | int has_valid_detailed_blocks; |
| 35 | int has_valid_extension_count; |
| 36 | int has_valid_descriptor_ordering; |
| 37 | int has_valid_descriptor_pad; |
| 38 | int has_valid_range_descriptor; |
| 39 | int has_valid_max_dotclock; |
| 40 | int has_valid_string_termination; |
| 41 | int manufacturer_name_well_formed; |
| 42 | int seen_non_detailed_descriptor; |
| 43 | int warning_excessive_dotclock_correction; |
| 44 | int warning_zero_preferred_refresh; |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 45 | enum edid_status conformant; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 46 | }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 47 | |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 48 | /* Stuff that isn't used anywhere but is nice to pretty-print while |
| 49 | we're decoding everything else. */ |
| 50 | static struct { |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 51 | unsigned int model; |
| 52 | unsigned int serial; |
| 53 | unsigned int year; |
| 54 | unsigned int week; |
| 55 | unsigned int version[2]; |
| 56 | unsigned int nonconformant; |
| 57 | unsigned int type; |
| 58 | |
| 59 | unsigned int x_mm; |
| 60 | unsigned int y_mm; |
| 61 | |
| 62 | unsigned int voltage; |
| 63 | unsigned int sync; |
| 64 | |
| 65 | const char *syncmethod; |
| 66 | const char *range_class; |
| 67 | const char *stereo; |
| 68 | } extra_info; |
| 69 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 70 | static struct edid tmp_edid; |
| 71 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 72 | static int manufacturer_name(unsigned char *x, char *output) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 73 | { |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 74 | output[0] = ((x[0] & 0x7C) >> 2) + '@'; |
| 75 | output[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xE0) >> 5) + '@'; |
| 76 | output[2] = (x[1] & 0x1F) + '@'; |
| 77 | output[3] = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 78 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 79 | if (isupper(output[0]) && |
| 80 | isupper(output[1]) && |
| 81 | isupper(output[2])) |
| 82 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 83 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 84 | memset(output, 0, 4); |
| 85 | return 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static int |
Douglas Anderson | 14dd370 | 2015-10-28 11:19:57 -0700 | [diff] [blame] | 89 | detailed_cvt_descriptor(unsigned char *x, int first) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 90 | { |
| 91 | const unsigned char empty[3] = { 0, 0, 0 }; |
Lee Leahy | 36984d8 | 2017-03-10 17:56:44 -0800 | [diff] [blame] | 92 | static const char *names[] = { "50", "60", "75", "85" }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 93 | int width = 0, height = 0; |
| 94 | int valid = 1; |
| 95 | int fifty = 0, sixty = 0, seventyfive = 0, eightyfive = 0, reduced = 0; |
| 96 | |
| 97 | if (!first && !memcmp(x, empty, 3)) |
| 98 | return valid; |
| 99 | |
| 100 | height = x[0]; |
| 101 | height |= (x[1] & 0xf0) << 4; |
| 102 | height++; |
| 103 | height *= 2; |
| 104 | |
| 105 | switch (x[1] & 0x0c) { |
| 106 | case 0x00: |
| 107 | width = (height * 4) / 3; break; |
| 108 | case 0x04: |
| 109 | width = (height * 16) / 9; break; |
| 110 | case 0x08: |
| 111 | width = (height * 16) / 10; break; |
| 112 | case 0x0c: |
| 113 | width = (height * 15) / 9; break; |
| 114 | } |
| 115 | |
| 116 | if (x[1] & 0x03) |
| 117 | valid = 0; |
| 118 | if (x[2] & 0x80) |
| 119 | valid = 0; |
| 120 | if (!(x[2] & 0x1f)) |
| 121 | valid = 0; |
| 122 | |
| 123 | fifty = (x[2] & 0x10); |
| 124 | sixty = (x[2] & 0x08); |
| 125 | seventyfive = (x[2] & 0x04); |
| 126 | eightyfive = (x[2] & 0x02); |
| 127 | reduced = (x[2] & 0x01); |
| 128 | |
| 129 | if (!valid) { |
| 130 | printk(BIOS_SPEW, " (broken)\n"); |
| 131 | } else { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 132 | printk(BIOS_SPEW, |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 133 | " %dx%d @ (%s%s%s%s%s) Hz (%s%s preferred)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 134 | width, height, |
| 135 | fifty ? "50 " : "", |
| 136 | sixty ? "60 " : "", |
| 137 | seventyfive ? "75 " : "", |
| 138 | eightyfive ? "85 " : "", |
| 139 | reduced ? "60RB " : "", |
| 140 | names[(x[2] & 0x60) >> 5], |
| 141 | (((x[2] & 0x60) == 0x20) && reduced) ? "RB" : ""); |
| 142 | } |
| 143 | |
| 144 | return valid; |
| 145 | } |
| 146 | |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 147 | /* extract a CP437 string from a detailed subblock, checking for termination (if |
| 148 | * less than len of bytes) with LF and padded with SP. |
| 149 | */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 150 | static char * |
| 151 | extract_string(unsigned char *x, int *valid_termination, int len) |
| 152 | { |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 153 | static char ret[EDID_ASCII_STRING_LENGTH + 1]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 154 | int i, seen_newline = 0; |
| 155 | |
| 156 | memset(ret, 0, sizeof(ret)); |
| 157 | |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 158 | for (i = 0; i < MIN(len, EDID_ASCII_STRING_LENGTH); i++) { |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 159 | if (seen_newline) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 160 | if (x[i] != 0x20) { |
| 161 | *valid_termination = 0; |
| 162 | return ret; |
| 163 | } |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 164 | } else if (x[i] == 0x0a) { |
| 165 | seen_newline = 1; |
| 166 | } else { |
| 167 | /* normal characters */ |
| 168 | ret[i] = x[i]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
| 172 | return ret; |
| 173 | } |
| 174 | |
| 175 | /* 1 means valid data */ |
| 176 | static int |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 177 | detailed_block(struct edid *result_edid, unsigned char *x, int in_extension, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 178 | struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 179 | { |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 180 | struct edid *out = &tmp_edid; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 181 | int i; |
Angel Pons | cc335c7 | 2018-10-02 11:58:28 +0200 | [diff] [blame] | 182 | |
| 183 | if (console_log_level(BIOS_SPEW)) { |
| 184 | printk(BIOS_SPEW, "Hex of detail: "); |
| 185 | for (i = 0; i < 18; i++) |
| 186 | printk(BIOS_SPEW, "%02x", x[i]); |
| 187 | printk(BIOS_SPEW, "\n"); |
| 188 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 189 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 190 | /* Result might already have some valid fields like mode_is_supported */ |
| 191 | *out = *result_edid; |
| 192 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 193 | if (x[0] == 0 && x[1] == 0) { |
| 194 | /* Monitor descriptor block, not detailed timing descriptor. */ |
| 195 | if (x[2] != 0) { |
| 196 | /* 1.3, 3.10.3 */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 197 | printk(BIOS_SPEW, |
| 198 | "Monitor descriptor block has byte 2 nonzero (0x%02x)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 199 | x[2]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 200 | c->has_valid_descriptor_pad = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 201 | } |
| 202 | if (x[3] != 0xfd && x[4] != 0x00) { |
| 203 | /* 1.3, 3.10.3 */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 204 | printk(BIOS_SPEW, |
| 205 | "Monitor descriptor block has byte 4 nonzero (0x%02x)\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 206 | x[4]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 207 | c->has_valid_descriptor_pad = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 208 | } |
| 209 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 210 | c->seen_non_detailed_descriptor = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 211 | if (x[3] <= 0xF) { |
| 212 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 213 | * in principle we can decode these, if we know what |
| 214 | * they are. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 215 | * 0x0f seems to be common in laptop panels. |
| 216 | * 0x0e is used by EPI: http://www.epi-standard.org/ |
| 217 | */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 218 | printk(BIOS_SPEW, |
| 219 | "Manufacturer-specified data, tag %d\n", x[3]); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 220 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 221 | } |
| 222 | switch (x[3]) { |
| 223 | case 0x10: |
| 224 | printk(BIOS_SPEW, "Dummy block\n"); |
| 225 | for (i = 5; i < 18; i++) |
| 226 | if (x[i] != 0x00) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 227 | c->has_valid_dummy_block = 0; |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 228 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 229 | case 0xF7: |
| 230 | /* TODO */ |
| 231 | printk(BIOS_SPEW, "Established timings III\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 232 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 233 | case 0xF8: |
| 234 | { |
| 235 | int valid_cvt = 1; /* just this block */ |
| 236 | printk(BIOS_SPEW, "CVT 3-byte code descriptor:\n"); |
| 237 | if (x[5] != 0x01) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 238 | c->has_valid_cvt = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | for (i = 0; i < 4; i++) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 242 | valid_cvt &= detailed_cvt_descriptor(x + 6 |
| 243 | + (i * 3), (i == 0)); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 244 | c->has_valid_cvt &= valid_cvt; |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 245 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 246 | } |
| 247 | case 0xF9: |
| 248 | /* TODO */ |
| 249 | printk(BIOS_SPEW, "Color management data\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 250 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 251 | case 0xFA: |
| 252 | /* TODO */ |
| 253 | printk(BIOS_SPEW, "More standard timings\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 254 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 255 | case 0xFB: |
| 256 | /* TODO */ |
| 257 | printk(BIOS_SPEW, "Color point\n"); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 258 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 259 | case 0xFC: |
Hung-Te Lin | 2536c1a | 2014-04-03 19:21:03 +0800 | [diff] [blame] | 260 | printk(BIOS_SPEW, "Monitor name: %s\n", |
| 261 | extract_string(x + 5, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 262 | &c->has_valid_string_termination, |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 263 | EDID_ASCII_STRING_LENGTH)); |
Jakub Czapiga | 43439f6 | 2020-10-23 15:54:46 +0200 | [diff] [blame] | 264 | c->has_name_descriptor = 1; |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 265 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 266 | case 0xFD: |
| 267 | { |
| 268 | int h_max_offset = 0, h_min_offset = 0; |
| 269 | int v_max_offset = 0, v_min_offset = 0; |
| 270 | int is_cvt = 0; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 271 | c->has_range_descriptor = 1; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 272 | extra_info.range_class = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 273 | /* |
| 274 | * XXX todo: implement feature flags, vtd blocks |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 275 | * XXX check: ranges are well-formed; block termination |
| 276 | * if no vtd |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 277 | */ |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 278 | if (c->claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 279 | if (x[4] & 0x02) { |
| 280 | v_max_offset = 255; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 281 | if (x[4] & 0x01) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 282 | v_min_offset = 255; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 283 | } |
| 284 | if (x[4] & 0x04) { |
| 285 | h_max_offset = 255; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 286 | if (x[4] & 0x03) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 287 | h_min_offset = 255; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 288 | } |
| 289 | } else if (x[4]) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 290 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | /* |
| 294 | * despite the values, this is not a bitfield. |
| 295 | */ |
| 296 | switch (x[10]) { |
| 297 | case 0x00: /* default gtf */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 298 | extra_info.range_class = "GTF"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 299 | break; |
| 300 | case 0x01: /* range limits only */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 301 | extra_info.range_class = "bare limits"; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 302 | if (!c->claims_one_point_four) |
| 303 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 304 | break; |
| 305 | case 0x02: /* secondary gtf curve */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 306 | extra_info.range_class = "GTF with icing"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 307 | break; |
| 308 | case 0x04: /* cvt */ |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 309 | extra_info.range_class = "CVT"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 310 | is_cvt = 1; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 311 | if (!c->claims_one_point_four) |
| 312 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 313 | break; |
| 314 | default: /* invalid */ |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 315 | c->has_valid_range_descriptor = 0; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 316 | extra_info.range_class = "invalid"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 317 | break; |
| 318 | } |
| 319 | |
| 320 | if (x[5] + v_min_offset > x[6] + v_max_offset) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 321 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 322 | if (x[7] + h_min_offset > x[8] + h_max_offset) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 323 | c->has_valid_range_descriptor = 0; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 324 | printk(BIOS_SPEW, |
| 325 | "Monitor ranges (%s): %d-%dHz V, %d-%dkHz H", |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 326 | extra_info.range_class, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 327 | x[5] + v_min_offset, x[6] + v_max_offset, |
| 328 | x[7] + h_min_offset, x[8] + h_max_offset); |
| 329 | if (x[9]) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 330 | printk(BIOS_SPEW, |
| 331 | ", max dotclock %dMHz\n", x[9] * 10); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 332 | else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 333 | if (c->claims_one_point_four) |
| 334 | c->has_valid_max_dotclock = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 335 | printk(BIOS_SPEW, "\n"); |
| 336 | } |
| 337 | |
| 338 | if (is_cvt) { |
| 339 | int max_h_pixels = 0; |
| 340 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 341 | printk(BIOS_SPEW, "CVT version %d.%d\n", |
| 342 | x[11] & 0xf0 >> 4, x[11] & 0x0f); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 343 | |
| 344 | if (x[12] & 0xfc) { |
| 345 | int raw_offset = (x[12] & 0xfc) >> 2; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 346 | printk(BIOS_SPEW, |
| 347 | "Real max dotclock: %dKHz\n", |
| 348 | (x[9] * 10000) |
| 349 | - (raw_offset * 250)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 350 | if (raw_offset >= 40) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 351 | c->warning_excessive_dotclock_correction = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | max_h_pixels = x[12] & 0x03; |
| 355 | max_h_pixels <<= 8; |
| 356 | max_h_pixels |= x[13]; |
| 357 | max_h_pixels *= 8; |
| 358 | if (max_h_pixels) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 359 | printk(BIOS_SPEW, |
| 360 | "Max active pixels per line: %d\n", |
| 361 | max_h_pixels); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 362 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 363 | printk(BIOS_SPEW, |
| 364 | "Supported aspect ratios: %s %s %s %s %s\n", |
| 365 | x[14] & 0x80 ? "4:3" : "", |
| 366 | x[14] & 0x40 ? "16:9" : "", |
| 367 | x[14] & 0x20 ? "16:10" : "", |
| 368 | x[14] & 0x10 ? "5:4" : "", |
| 369 | x[14] & 0x08 ? "15:9" : ""); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 370 | if (x[14] & 0x07) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 371 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 372 | |
| 373 | printk(BIOS_SPEW, "Preferred aspect ratio: "); |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 374 | switch ((x[15] & 0xe0) >> 5) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 375 | case 0x00: |
| 376 | printk(BIOS_SPEW, "4:3"); |
| 377 | break; |
| 378 | case 0x01: |
| 379 | printk(BIOS_SPEW, "16:9"); |
| 380 | break; |
| 381 | case 0x02: |
| 382 | printk(BIOS_SPEW, "16:10"); |
| 383 | break; |
| 384 | case 0x03: |
| 385 | printk(BIOS_SPEW, "5:4"); |
| 386 | break; |
| 387 | case 0x04: |
| 388 | printk(BIOS_SPEW, "15:9"); |
| 389 | break; |
| 390 | default: |
| 391 | printk(BIOS_SPEW, "(broken)"); |
| 392 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 393 | } |
| 394 | printk(BIOS_SPEW, "\n"); |
| 395 | |
| 396 | if (x[15] & 0x04) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 397 | printk(BIOS_SPEW, |
| 398 | "Supports CVT standard blanking\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 399 | if (x[15] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 400 | printk(BIOS_SPEW, |
| 401 | "Supports CVT reduced blanking\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 402 | |
| 403 | if (x[15] & 0x07) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 404 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 405 | |
| 406 | if (x[16] & 0xf0) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 407 | printk(BIOS_SPEW, |
| 408 | "Supported display scaling:\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 409 | if (x[16] & 0x80) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 410 | printk(BIOS_SPEW, |
| 411 | " Horizontal shrink\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 412 | if (x[16] & 0x40) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 413 | printk(BIOS_SPEW, |
| 414 | " Horizontal stretch\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 415 | if (x[16] & 0x20) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 416 | printk(BIOS_SPEW, |
| 417 | " Vertical shrink\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 418 | if (x[16] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 419 | printk(BIOS_SPEW, |
| 420 | " Vertical stretch\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | if (x[16] & 0x0f) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 424 | c->has_valid_range_descriptor = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 425 | |
| 426 | if (x[17]) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 427 | printk(BIOS_SPEW, |
| 428 | "Preferred vertical refresh: %d Hz\n", |
| 429 | x[17]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 430 | else |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 431 | c->warning_zero_preferred_refresh = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 435 | * Slightly weird to return a global, but I've never |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 436 | * seen any EDID block with two range descriptors, so |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 437 | * it's harmless. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 438 | */ |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 439 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 440 | } |
| 441 | case 0xFE: |
| 442 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 443 | * TODO: Two of these in a row, in the third and fourth |
| 444 | * slots, seems to be specified by SPWG: |
| 445 | * http://www.spwg.org/ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 446 | */ |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 447 | strcpy(result_edid->ascii_string, extract_string(x + 5, |
| 448 | &c->has_valid_string_termination, |
| 449 | EDID_ASCII_STRING_LENGTH)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 450 | printk(BIOS_SPEW, "ASCII string: %s\n", |
Arthur Heymans | dbe8161 | 2017-04-29 14:00:47 +0200 | [diff] [blame] | 451 | result_edid->ascii_string); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 452 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 453 | case 0xFF: |
| 454 | printk(BIOS_SPEW, "Serial number: %s\n", |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 455 | extract_string(x + 5, |
Patrick Georgi | d840e2b | 2018-09-18 18:01:02 +0200 | [diff] [blame] | 456 | &c->has_valid_string_termination, |
| 457 | EDID_ASCII_STRING_LENGTH)); |
Hung-Te Lin | b2c1062 | 2014-04-03 19:59:37 +0800 | [diff] [blame] | 458 | return 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 459 | default: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 460 | printk(BIOS_SPEW, |
| 461 | "Unknown monitor description type %d\n", |
| 462 | x[3]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 463 | return 0; |
| 464 | } |
| 465 | } |
| 466 | |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 467 | if (c->seen_non_detailed_descriptor && !in_extension) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 468 | c->has_valid_descriptor_ordering = 0; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 469 | |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 470 | /* Edid contains pixel clock in terms of 10KHz */ |
| 471 | out->mode.pixel_clock = (x[0] + (x[1] << 8)) * 10; |
| 472 | /* |
| 473 | LVDS supports following pixel clocks |
| 474 | 25000...112000 kHz: single channel |
| 475 | 80000...224000 kHz: dual channel |
| 476 | There is some overlap in theoretically supported |
| 477 | pixel clock between single-channel and dual-channel. |
| 478 | In practice with current panels all panels |
| 479 | <= 75200 kHz: single channel |
| 480 | >= 97750 kHz: dual channel |
| 481 | We have no samples between those values, so put a |
| 482 | threshold at 95000 kHz. If we get anything over |
| 483 | 95000 kHz with single channel, we can make this |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 484 | more sophisticated but it's currently not needed. |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 485 | */ |
| 486 | out->mode.lvds_dual_channel = (out->mode.pixel_clock >= 95000); |
| 487 | extra_info.x_mm = (x[12] + ((x[14] & 0xF0) << 4)); |
| 488 | extra_info.y_mm = (x[13] + ((x[14] & 0x0F) << 8)); |
| 489 | out->mode.ha = (x[2] + ((x[4] & 0xF0) << 4)); |
| 490 | out->mode.hbl = (x[3] + ((x[4] & 0x0F) << 8)); |
| 491 | out->mode.hso = (x[8] + ((x[11] & 0xC0) << 2)); |
| 492 | out->mode.hspw = (x[9] + ((x[11] & 0x30) << 4)); |
| 493 | out->mode.hborder = x[15]; |
| 494 | out->mode.va = (x[5] + ((x[7] & 0xF0) << 4)); |
| 495 | out->mode.vbl = (x[6] + ((x[7] & 0x0F) << 8)); |
| 496 | out->mode.vso = ((x[10] >> 4) + ((x[11] & 0x0C) << 2)); |
| 497 | out->mode.vspw = ((x[10] & 0x0F) + ((x[11] & 0x03) << 4)); |
| 498 | out->mode.vborder = x[16]; |
Furquan Shaikh | d0a81f7 | 2013-07-30 12:41:08 -0700 | [diff] [blame] | 499 | |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 500 | /* We assume rgb888 (32 bits per pixel) framebuffers by default. |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 501 | * Chipsets that want something else will need to override this with |
| 502 | * another call to edid_set_framebuffer_bits_per_pixel(). As a cheap |
| 503 | * heuristic, assume that X86 systems require a 64-byte row alignment |
| 504 | * (since that seems to be true for most Intel chipsets). */ |
Kyösti Mälkki | 7336f97 | 2020-06-08 06:05:03 +0300 | [diff] [blame] | 505 | if (ENV_X86) |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 506 | edid_set_framebuffer_bits_per_pixel(out, 32, 64); |
| 507 | else |
| 508 | edid_set_framebuffer_bits_per_pixel(out, 32, 0); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 509 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 510 | switch ((x[17] & 0x18) >> 3) { |
| 511 | case 0x00: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 512 | extra_info.syncmethod = " analog composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 513 | break; |
| 514 | case 0x01: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 515 | extra_info.syncmethod = " bipolar analog composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 516 | break; |
| 517 | case 0x02: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 518 | extra_info.syncmethod = " digital composite"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 519 | break; |
| 520 | case 0x03: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 521 | extra_info.syncmethod = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 522 | break; |
| 523 | } |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 524 | out->mode.pvsync = (x[17] & (1 << 2)) ? '+' : '-'; |
| 525 | out->mode.phsync = (x[17] & (1 << 1)) ? '+' : '-'; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 526 | switch (x[17] & 0x61) { |
| 527 | case 0x20: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 528 | extra_info.stereo = "field sequential L/R"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 529 | break; |
| 530 | case 0x40: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 531 | extra_info.stereo = "field sequential R/L"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 532 | break; |
| 533 | case 0x21: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 534 | extra_info.stereo = "interleaved right even"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 535 | break; |
| 536 | case 0x41: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 537 | extra_info.stereo = "interleaved left even"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 538 | break; |
| 539 | case 0x60: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 540 | extra_info.stereo = "four way interleaved"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 541 | break; |
| 542 | case 0x61: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 543 | extra_info.stereo = "side by side interleaved"; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 544 | break; |
| 545 | default: |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 546 | extra_info.stereo = ""; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 547 | break; |
| 548 | } |
| 549 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 550 | printk(BIOS_SPEW, |
| 551 | "Detailed mode (IN HEX): Clock %d KHz, %x mm x %x mm\n" |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 552 | " %04x %04x %04x %04x hborder %x\n" |
| 553 | " %04x %04x %04x %04x vborder %x\n" |
Paul Menzel | 433bf77 | 2016-11-29 21:02:04 +0100 | [diff] [blame] | 554 | " %chsync %cvsync%s%s%s\n", |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 555 | out->mode.pixel_clock, |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 556 | extra_info.x_mm, |
| 557 | extra_info.y_mm, |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 558 | out->mode.ha, out->mode.ha + out->mode.hso, |
| 559 | out->mode.ha + out->mode.hso + out->mode.hspw, |
| 560 | out->mode.ha + out->mode.hbl, out->mode.hborder, |
| 561 | out->mode.va, out->mode.va + out->mode.vso, |
| 562 | out->mode.va + out->mode.vso + out->mode.vspw, |
| 563 | out->mode.va + out->mode.vbl, out->mode.vborder, |
| 564 | out->mode.phsync, out->mode.pvsync, |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 565 | extra_info.syncmethod, x[17] & 0x80 ? " interlaced" : "", |
David Hendricks | 7dbf9c6 | 2015-07-30 18:49:48 -0700 | [diff] [blame] | 566 | extra_info.stereo); |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 567 | |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 568 | if (!c->did_detailed_timing) { |
Douglas Anderson | bca67fb | 2015-10-28 09:18:28 -0700 | [diff] [blame] | 569 | printk(BIOS_SPEW, "Did detailed timing\n"); |
| 570 | c->did_detailed_timing = 1; |
| 571 | *result_edid = *out; |
| 572 | } |
| 573 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 574 | return 1; |
| 575 | } |
| 576 | |
| 577 | static int |
| 578 | do_checksum(unsigned char *x) |
| 579 | { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 580 | int valid = 0; |
Alexandru Gagniuc | 9d0ae59 | 2014-12-10 16:44:44 -0600 | [diff] [blame] | 581 | printk(BIOS_SPEW, "Checksum: 0x%hhx", x[0x7f]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 582 | { |
| 583 | unsigned char sum = 0; |
| 584 | int i; |
| 585 | for (i = 0; i < 128; i++) |
| 586 | sum += x[i]; |
| 587 | if (sum) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 588 | printk(BIOS_SPEW, " (should be 0x%hhx)", |
| 589 | (unsigned char)(x[0x7f] - sum)); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 590 | } else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 591 | valid = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 592 | printk(BIOS_SPEW, " (valid)"); |
| 593 | } |
| 594 | } |
| 595 | printk(BIOS_SPEW, "\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 596 | return valid; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | /* CEA extension */ |
| 600 | |
| 601 | static const char * |
| 602 | audio_format(unsigned char x) |
| 603 | { |
| 604 | switch (x) { |
| 605 | case 0: return "RESERVED"; |
| 606 | case 1: return "Linear PCM"; |
| 607 | case 2: return "AC-3"; |
| 608 | case 3: return "MPEG 1 (Layers 1 & 2)"; |
| 609 | case 4: return "MPEG 1 Layer 3 (MP3)"; |
| 610 | case 5: return "MPEG2 (multichannel)"; |
| 611 | case 6: return "AAC"; |
| 612 | case 7: return "DTS"; |
| 613 | case 8: return "ATRAC"; |
| 614 | case 9: return "One Bit Audio"; |
| 615 | case 10: return "Dolby Digital+"; |
| 616 | case 11: return "DTS-HD"; |
| 617 | case 12: return "MAT (MLP)"; |
| 618 | case 13: return "DST"; |
| 619 | case 14: return "WMA Pro"; |
| 620 | case 15: return "RESERVED"; |
| 621 | } |
| 622 | return "BROKEN"; /* can't happen */ |
| 623 | } |
| 624 | |
| 625 | static void |
| 626 | cea_audio_block(unsigned char *x) |
| 627 | { |
| 628 | int i, format; |
| 629 | int length = x[0] & 0x1f; |
| 630 | |
| 631 | if (length % 3) { |
| 632 | printk(BIOS_SPEW, "Broken CEA audio block length %d\n", length); |
| 633 | /* XXX non-conformant */ |
| 634 | return; |
| 635 | } |
| 636 | |
| 637 | for (i = 1; i < length; i += 3) { |
| 638 | format = (x[i] & 0x78) >> 3; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 639 | printk(BIOS_SPEW, " %s, max channels %d\n", |
| 640 | audio_format(format), x[i] & 0x07); |
| 641 | printk(BIOS_SPEW, |
| 642 | " Supported sample rates (kHz):%s%s%s%s%s%s%s\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 643 | (x[i+1] & 0x40) ? " 192" : "", |
| 644 | (x[i+1] & 0x20) ? " 176.4" : "", |
| 645 | (x[i+1] & 0x10) ? " 96" : "", |
| 646 | (x[i+1] & 0x08) ? " 88.2" : "", |
| 647 | (x[i+1] & 0x04) ? " 48" : "", |
| 648 | (x[i+1] & 0x02) ? " 44.1" : "", |
| 649 | (x[i+1] & 0x01) ? " 32" : ""); |
| 650 | if (format == 1) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 651 | printk(BIOS_SPEW, |
| 652 | " Supported sample sizes (bits):%s%s%s\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 653 | (x[2] & 0x04) ? " 24" : "", |
| 654 | (x[2] & 0x02) ? " 20" : "", |
| 655 | (x[2] & 0x01) ? " 16" : ""); |
| 656 | } else if (format <= 8) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 657 | printk(BIOS_SPEW, |
| 658 | " Maximum bit rate: %d kHz\n", x[2] * 8); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | static void |
| 664 | cea_video_block(unsigned char *x) |
| 665 | { |
| 666 | int i; |
| 667 | int length = x[0] & 0x1f; |
| 668 | |
| 669 | for (i = 1; i < length; i++) |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 670 | printk(BIOS_SPEW, " VIC %02d %s\n", x[i] & 0x7f, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 671 | x[i] & 0x80 ? "(native)" : ""); |
| 672 | } |
| 673 | |
| 674 | static void |
| 675 | cea_hdmi_block(struct edid *out, unsigned char *x) |
| 676 | { |
| 677 | int length = x[0] & 0x1f; |
| 678 | |
Yakir Yang | 85810cc | 2015-10-27 16:17:13 +0800 | [diff] [blame] | 679 | out->hdmi_monitor_detected = 1; |
| 680 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 681 | printk(BIOS_SPEW, " (HDMI)\n"); |
| 682 | printk(BIOS_SPEW, |
| 683 | " Source physical address %d.%d.%d.%d\n", |
| 684 | x[4] >> 4, x[4] & 0x0f, x[5] >> 4, x[5] & 0x0f); |
| 685 | |
| 686 | if (length > 5) { |
| 687 | if (x[6] & 0x80) |
| 688 | printk(BIOS_SPEW, " Supports_AI\n"); |
| 689 | if (x[6] & 0x40) |
| 690 | printk(BIOS_SPEW, " DC_48bit\n"); |
| 691 | if (x[6] & 0x20) |
| 692 | printk(BIOS_SPEW, " DC_36bit\n"); |
| 693 | if (x[6] & 0x10) |
| 694 | printk(BIOS_SPEW, " DC_30bit\n"); |
| 695 | if (x[6] & 0x08) |
| 696 | printk(BIOS_SPEW, " DC_Y444\n"); |
| 697 | /* two reserved */ |
| 698 | if (x[6] & 0x01) |
| 699 | printk(BIOS_SPEW, " DVI_Dual\n"); |
| 700 | } |
| 701 | |
| 702 | if (length > 6) |
| 703 | printk(BIOS_SPEW, " Maximum TMDS clock: %dMHz\n", x[7] * 5); |
| 704 | |
| 705 | /* XXX the walk here is really ugly, and needs to be length-checked */ |
| 706 | if (length > 7) { |
| 707 | int b = 0; |
| 708 | |
| 709 | if (x[8] & 0x80) { |
| 710 | printk(BIOS_SPEW, " Video latency: %d\n", x[9 + b]); |
| 711 | printk(BIOS_SPEW, " Audio latency: %d\n", x[10 + b]); |
| 712 | b += 2; |
| 713 | } |
| 714 | |
| 715 | if (x[8] & 0x40) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 716 | printk(BIOS_SPEW, |
| 717 | " Interlaced video latency: %d\n", x[9 + b]); |
| 718 | printk(BIOS_SPEW, |
| 719 | " Interlaced audio latency: %d\n", |
| 720 | x[10 + b]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 721 | b += 2; |
| 722 | } |
| 723 | |
| 724 | if (x[8] & 0x20) { |
| 725 | int mask = 0, formats = 0; |
| 726 | int len_xx, len_3d; |
| 727 | printk(BIOS_SPEW, " Extended HDMI video details:\n"); |
| 728 | if (x[9 + b] & 0x80) |
| 729 | printk(BIOS_SPEW, " 3D present\n"); |
| 730 | if ((x[9 + b] & 0x60) == 0x20) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 731 | printk(BIOS_SPEW, |
| 732 | " All advertised VICs are 3D-capable\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 733 | formats = 1; |
| 734 | } |
| 735 | if ((x[9 + b] & 0x60) == 0x40) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 736 | printk(BIOS_SPEW, |
| 737 | " 3D-capable-VIC mask present\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 738 | formats = 1; |
| 739 | mask = 1; |
| 740 | } |
| 741 | switch (x[9 + b] & 0x18) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 742 | case 0x00: |
| 743 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 744 | case 0x08: |
| 745 | printk(BIOS_SPEW, " Base EDID image size is aspect ratio\n"); |
| 746 | break; |
| 747 | case 0x10: |
| 748 | printk(BIOS_SPEW, " Base EDID image size is in units of 1cm\n"); |
| 749 | break; |
| 750 | case 0x18: |
| 751 | printk(BIOS_SPEW, " Base EDID image size is in units of 5cm\n"); |
| 752 | break; |
| 753 | } |
| 754 | len_xx = (x[10 + b] & 0xe0) >> 5; |
| 755 | len_3d = (x[10 + b] & 0x1f) >> 0; |
| 756 | b += 2; |
| 757 | |
| 758 | if (len_xx) { |
| 759 | printk(BIOS_SPEW, " Skipping %d bytes that HDMI refuses to publicly" |
| 760 | " document\n", len_xx); |
| 761 | b += len_xx; |
| 762 | } |
| 763 | |
| 764 | if (len_3d) { |
| 765 | if (formats) { |
| 766 | if (x[9 + b] & 0x01) |
| 767 | printk(BIOS_SPEW, " Side-by-side 3D supported\n"); |
| 768 | if (x[10 + b] & 0x40) |
| 769 | printk(BIOS_SPEW, " Top-and-bottom 3D supported\n"); |
| 770 | if (x[10 + b] & 0x01) |
| 771 | printk(BIOS_SPEW, " Frame-packing 3D supported\n"); |
| 772 | b += 2; |
| 773 | } |
| 774 | if (mask) { |
| 775 | int i; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 776 | printk(BIOS_SPEW, |
| 777 | " 3D VIC indices:"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 778 | /* worst bit ordering ever */ |
| 779 | for (i = 0; i < 8; i++) |
| 780 | if (x[10 + b] & (1 << i)) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 781 | printk(BIOS_SPEW, |
| 782 | " %d", i); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 783 | for (i = 0; i < 8; i++) |
| 784 | if (x[9 + b] & (1 << i)) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 785 | printk(BIOS_SPEW, |
| 786 | " %d", i + 8); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 787 | printk(BIOS_SPEW, "\n"); |
| 788 | b += 2; |
| 789 | } |
| 790 | |
| 791 | /* |
| 792 | * XXX list of nibbles: |
| 793 | * 2D_VIC_Order_X |
| 794 | * 3D_Structure_X |
| 795 | * (optionally: 3D_Detail_X and reserved) |
| 796 | */ |
| 797 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 798 | } |
Richard Spiegel | 2fdbe0c | 2018-08-07 08:43:22 -0700 | [diff] [blame] | 799 | /* Tell static analysis we know index b is left unused. */ |
| 800 | (void)b; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | |
| 804 | static void |
| 805 | cea_block(struct edid *out, unsigned char *x) |
| 806 | { |
| 807 | unsigned int oui; |
| 808 | |
| 809 | switch ((x[0] & 0xe0) >> 5) { |
| 810 | case 0x01: |
| 811 | printk(BIOS_SPEW, " Audio data block\n"); |
| 812 | cea_audio_block(x); |
| 813 | break; |
| 814 | case 0x02: |
| 815 | printk(BIOS_SPEW, " Video data block\n"); |
| 816 | cea_video_block(x); |
| 817 | break; |
| 818 | case 0x03: |
| 819 | /* yes really, endianness lols */ |
| 820 | oui = (x[3] << 16) + (x[2] << 8) + x[1]; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 821 | printk(BIOS_SPEW, " Vendor-specific data block, OUI %06x", |
| 822 | oui); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 823 | if (oui == 0x000c03) |
| 824 | cea_hdmi_block(out, x); |
| 825 | else |
| 826 | printk(BIOS_SPEW, "\n"); |
| 827 | break; |
| 828 | case 0x04: |
| 829 | printk(BIOS_SPEW, " Speaker allocation data block\n"); |
| 830 | break; |
| 831 | case 0x05: |
| 832 | printk(BIOS_SPEW, " VESA DTC data block\n"); |
| 833 | break; |
| 834 | case 0x07: |
| 835 | printk(BIOS_SPEW, " Extended tag: "); |
| 836 | switch (x[1]) { |
| 837 | case 0x00: |
| 838 | printk(BIOS_SPEW, "video capability data block\n"); |
| 839 | break; |
| 840 | case 0x01: |
| 841 | printk(BIOS_SPEW, "vendor-specific video data block\n"); |
| 842 | break; |
| 843 | case 0x02: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 844 | printk(BIOS_SPEW, |
| 845 | "VESA video display device information data block\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 846 | break; |
| 847 | case 0x03: |
| 848 | printk(BIOS_SPEW, "VESA video data block\n"); |
| 849 | break; |
| 850 | case 0x04: |
| 851 | printk(BIOS_SPEW, "HDMI video data block\n"); |
| 852 | break; |
| 853 | case 0x05: |
| 854 | printk(BIOS_SPEW, "Colorimetry data block\n"); |
| 855 | break; |
| 856 | case 0x10: |
| 857 | printk(BIOS_SPEW, "CEA miscellaneous audio fields\n"); |
| 858 | break; |
| 859 | case 0x11: |
| 860 | printk(BIOS_SPEW, "Vendor-specific audio data block\n"); |
| 861 | break; |
| 862 | case 0x12: |
| 863 | printk(BIOS_SPEW, "HDMI audio data block\n"); |
| 864 | break; |
| 865 | default: |
| 866 | if (x[1] >= 6 && x[1] <= 15) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 867 | printk(BIOS_SPEW, |
| 868 | "Reserved video block (%02x)\n", x[1]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 869 | else if (x[1] >= 19 && x[1] <= 31) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 870 | printk(BIOS_SPEW, |
| 871 | "Reserved audio block (%02x)\n", x[1]); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 872 | else |
| 873 | printk(BIOS_SPEW, "Unknown (%02x)\n", x[1]); |
| 874 | break; |
| 875 | } |
| 876 | break; |
| 877 | default: |
| 878 | { |
| 879 | int tag = (*x & 0xe0) >> 5; |
| 880 | int length = *x & 0x1f; |
| 881 | printk(BIOS_SPEW, |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 882 | " Unknown tag %d, length %d (raw %02x)\n", |
| 883 | tag, length, *x); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 884 | break; |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | static int |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 890 | parse_cea(struct edid *out, unsigned char *x, struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 891 | { |
| 892 | int ret = 0; |
| 893 | int version = x[1]; |
| 894 | int offset = x[2]; |
| 895 | unsigned char *detailed; |
| 896 | |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 897 | if (version >= 1) |
| 898 | do { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 899 | if (version == 1 && x[3] != 0) |
| 900 | ret = 1; |
| 901 | |
| 902 | if (offset < 4) |
| 903 | break; |
| 904 | |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 905 | if (version < 3) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 906 | printk(BIOS_SPEW, |
| 907 | "%d 8-byte timing descriptors\n", |
| 908 | (offset - 4) / 8); |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 909 | else if (version == 3) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 910 | int i; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 911 | printk(BIOS_SPEW, |
| 912 | "%d bytes of CEA data\n", offset - 4); |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 913 | for (i = 4; i < offset; i += (x[i] & 0x1f) + 1) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 914 | cea_block(out, x + i); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | if (version >= 2) { |
| 918 | if (x[3] & 0x80) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 919 | printk(BIOS_SPEW, |
| 920 | "Underscans PC formats by default\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 921 | if (x[3] & 0x40) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 922 | printk(BIOS_SPEW, |
| 923 | "Basic audio support\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 924 | if (x[3] & 0x20) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 925 | printk(BIOS_SPEW, |
| 926 | "Supports YCbCr 4:4:4\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 927 | if (x[3] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 928 | printk(BIOS_SPEW, |
| 929 | "Supports YCbCr 4:2:2\n"); |
| 930 | printk(BIOS_SPEW, |
| 931 | "%d native detailed modes\n", |
| 932 | x[3] & 0x0f); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 935 | for (detailed = x + offset; detailed + 18 < x + 127; |
| 936 | detailed += 18) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 937 | if (detailed[0]) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 938 | detailed_block(out, detailed, 1, c); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 939 | } while (0); |
| 940 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 941 | c->has_valid_checksum &= do_checksum(x); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 942 | return ret; |
| 943 | } |
| 944 | |
| 945 | /* generic extension code */ |
| 946 | |
| 947 | static void |
| 948 | extension_version(struct edid *out, unsigned char *x) |
| 949 | { |
| 950 | printk(BIOS_SPEW, "Extension version: %d\n", x[1]); |
| 951 | } |
| 952 | |
| 953 | static int |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 954 | parse_extension(struct edid *out, unsigned char *x, struct edid_context *c) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 955 | { |
| 956 | int conformant_extension = 0; |
| 957 | printk(BIOS_SPEW, "\n"); |
| 958 | |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 959 | switch (x[0]) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 960 | case 0x02: |
| 961 | printk(BIOS_SPEW, "CEA extension block\n"); |
| 962 | extension_version(out, x); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 963 | conformant_extension = parse_cea(out, x, c); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 964 | break; |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 965 | case 0x10: |
| 966 | printk(BIOS_SPEW, "VTB extension block\n"); |
| 967 | break; |
| 968 | case 0x40: |
| 969 | printk(BIOS_SPEW, "DI extension block\n"); |
| 970 | break; |
| 971 | case 0x50: |
| 972 | printk(BIOS_SPEW, "LS extension block\n"); |
| 973 | break; |
| 974 | case 0x60: |
| 975 | printk(BIOS_SPEW, "DPVL extension block\n"); |
| 976 | break; |
| 977 | case 0xF0: |
| 978 | printk(BIOS_SPEW, "Block map\n"); |
| 979 | break; |
| 980 | case 0xFF: |
| 981 | printk(BIOS_SPEW, "Manufacturer-specific extension block\n"); |
Jacob Garber | e447aec | 2019-03-27 17:23:42 -0600 | [diff] [blame] | 982 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 983 | default: |
| 984 | printk(BIOS_SPEW, "Unknown extension block\n"); |
| 985 | break; |
| 986 | } |
| 987 | |
| 988 | printk(BIOS_SPEW, "\n"); |
| 989 | |
| 990 | return conformant_extension; |
| 991 | } |
| 992 | |
| 993 | static const struct { |
| 994 | int x, y, refresh; |
| 995 | } established_timings[] = { |
| 996 | /* 0x23 bit 7 - 0 */ |
| 997 | {720, 400, 70}, |
| 998 | {720, 400, 88}, |
| 999 | {640, 480, 60}, |
| 1000 | {640, 480, 67}, |
| 1001 | {640, 480, 72}, |
| 1002 | {640, 480, 75}, |
| 1003 | {800, 600, 56}, |
| 1004 | {800, 600, 60}, |
| 1005 | /* 0x24 bit 7 - 0 */ |
| 1006 | {800, 600, 72}, |
| 1007 | {800, 600, 75}, |
| 1008 | {832, 624, 75}, |
| 1009 | {1280, 768, 87}, |
| 1010 | {1024, 768, 60}, |
| 1011 | {1024, 768, 70}, |
| 1012 | {1024, 768, 75}, |
| 1013 | {1280, 1024, 75}, |
| 1014 | /* 0x25 bit 7*/ |
| 1015 | {1152, 870, 75}, |
| 1016 | }; |
| 1017 | |
| 1018 | static void print_subsection(const char *name, unsigned char *edid, int start, |
| 1019 | int end) |
| 1020 | { |
| 1021 | int i; |
| 1022 | |
| 1023 | printk(BIOS_SPEW, "%s:", name); |
| 1024 | for (i = strlen(name); i < 15; i++) |
| 1025 | printk(BIOS_SPEW, " "); |
| 1026 | for (i = start; i <= end; i++) |
| 1027 | printk(BIOS_SPEW, " %02x", edid[i]); |
| 1028 | printk(BIOS_SPEW, "\n"); |
| 1029 | } |
| 1030 | |
| 1031 | static void dump_breakdown(unsigned char *edid) |
| 1032 | { |
| 1033 | printk(BIOS_SPEW, "Extracted contents:\n"); |
| 1034 | print_subsection("header", edid, 0, 7); |
| 1035 | print_subsection("serial number", edid, 8, 17); |
Lee Leahy | 35af5c4 | 2017-03-09 17:35:28 -0800 | [diff] [blame] | 1036 | print_subsection("version", edid, 18, 19); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1037 | print_subsection("basic params", edid, 20, 24); |
| 1038 | print_subsection("chroma info", edid, 25, 34); |
| 1039 | print_subsection("established", edid, 35, 37); |
| 1040 | print_subsection("standard", edid, 38, 53); |
| 1041 | print_subsection("descriptor 1", edid, 54, 71); |
| 1042 | print_subsection("descriptor 2", edid, 72, 89); |
| 1043 | print_subsection("descriptor 3", edid, 90, 107); |
| 1044 | print_subsection("descriptor 4", edid, 108, 125); |
| 1045 | print_subsection("extensions", edid, 126, 126); |
| 1046 | print_subsection("checksum", edid, 127, 127); |
| 1047 | printk(BIOS_SPEW, "\n"); |
| 1048 | } |
| 1049 | |
| 1050 | /* |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1051 | * Lookup table of some well-known modes that can be useful in case the |
| 1052 | * auto-detected mode is unsuitable. |
| 1053 | * ha = hdisplay; va = vdisplay; |
| 1054 | * hbl = htotal - hdisplay; vbl = vtotal - vdisplay; |
| 1055 | * hso = hsync_start - hdsiplay; vso = vsync_start - vdisplay; |
| 1056 | * hspw = hsync_end - hsync_start; vspw = vsync_end - vsync_start; |
| 1057 | */ |
| 1058 | static struct edid_mode known_modes[NUM_KNOWN_MODES] = { |
| 1059 | [EDID_MODE_640x480_60Hz] = { |
Douglas Anderson | 78e226cf | 2015-10-28 09:52:22 -0700 | [diff] [blame] | 1060 | .name = "640x480@60Hz", .pixel_clock = 25200, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1061 | .ha = 640, .hbl = 160, .hso = 16, .hspw = 96, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1062 | .va = 480, .vbl = 45, .vso = 10, .vspw = 2, |
| 1063 | .phsync = '-', .pvsync = '-' }, |
| 1064 | [EDID_MODE_720x480_60Hz] = { |
| 1065 | .name = "720x480@60Hz", .pixel_clock = 27000, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1066 | .ha = 720, .hbl = 138, .hso = 16, .hspw = 62, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1067 | .va = 480, .vbl = 45, .vso = 9, .vspw = 6, |
| 1068 | .phsync = '-', .pvsync = '-' }, |
| 1069 | [EDID_MODE_1280x720_60Hz] = { |
| 1070 | .name = "1280x720@60Hz", .pixel_clock = 74250, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1071 | .ha = 1280, .hbl = 370, .hso = 110, .hspw = 40, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1072 | .va = 720, .vbl = 30, .vso = 5, .vspw = 20, |
| 1073 | .phsync = '+', .pvsync = '+' }, |
| 1074 | [EDID_MODE_1920x1080_60Hz] = { |
| 1075 | .name = "1920x1080@60Hz", .pixel_clock = 148500, .refresh = 60, |
Yakir Yang | bedbdc4 | 2015-08-18 04:18:09 -0500 | [diff] [blame] | 1076 | .ha = 1920, .hbl = 280, .hso = 88, .hspw = 44, |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1077 | .va = 1080, .vbl = 45, .vso = 4, .vspw = 5, |
| 1078 | .phsync = '+', .pvsync = '+' }, |
| 1079 | }; |
| 1080 | |
| 1081 | int set_display_mode(struct edid *edid, enum edid_modes mode) |
| 1082 | { |
| 1083 | if (mode == EDID_MODE_AUTO) |
| 1084 | return 0; |
| 1085 | |
| 1086 | if (edid->mode_is_supported[mode]) { |
| 1087 | printk(BIOS_DEBUG, "Forcing mode %s\n", known_modes[mode].name); |
| 1088 | edid->mode = known_modes[mode]; |
| 1089 | return 0; |
| 1090 | } |
| 1091 | |
| 1092 | printk(BIOS_ERR, "Requested display mode not supported.\n"); |
| 1093 | return -1; |
| 1094 | } |
| 1095 | |
| 1096 | /* |
Martin Roth | 0949e73 | 2021-10-01 14:28:22 -0600 | [diff] [blame] | 1097 | * Given a raw edid block, decode it into a form |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1098 | * that other parts of coreboot can use -- mainly |
| 1099 | * graphics bringup functions. The raw block is |
| 1100 | * required to be 128 bytes long, per the standard, |
| 1101 | * but we have no way of checking this minimum length. |
| 1102 | * We accept what we are given. |
| 1103 | */ |
| 1104 | int decode_edid(unsigned char *edid, int size, struct edid *out) |
| 1105 | { |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1106 | int analog, i, j; |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1107 | struct edid_context c = { |
| 1108 | .has_valid_cvt = 1, |
| 1109 | .has_valid_dummy_block = 1, |
| 1110 | .has_valid_descriptor_ordering = 1, |
Vince Hsu | 4213b97 | 2014-04-21 17:07:57 +0800 | [diff] [blame] | 1111 | .has_valid_detailed_blocks = 1, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1112 | .has_valid_descriptor_pad = 1, |
| 1113 | .has_valid_range_descriptor = 1, |
| 1114 | .has_valid_max_dotclock = 1, |
| 1115 | .has_valid_string_termination = 1, |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1116 | .conformant = EDID_CONFORMANT, |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1117 | }; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1118 | |
Jacob Garber | cd23f7f | 2019-03-25 19:53:45 -0600 | [diff] [blame] | 1119 | if (!edid) { |
Jacob Garber | 1855329 | 2019-03-27 12:02:38 -0600 | [diff] [blame] | 1120 | printk(BIOS_ERR, "No EDID found\n"); |
Jacob Garber | cd23f7f | 2019-03-25 19:53:45 -0600 | [diff] [blame] | 1121 | return EDID_ABSENT; |
| 1122 | } |
| 1123 | |
| 1124 | dump_breakdown(edid); |
| 1125 | |
| 1126 | if (memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8)) { |
Jacob Garber | 1855329 | 2019-03-27 12:02:38 -0600 | [diff] [blame] | 1127 | printk(BIOS_ERR, "No header found\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1128 | return EDID_ABSENT; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1129 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1130 | |
Paul Menzel | 1ced4e6 | 2020-02-15 13:12:04 +0100 | [diff] [blame] | 1131 | memset(out, 0, sizeof(*out)); |
| 1132 | |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 1133 | if (manufacturer_name(edid + 0x08, out->manufacturer_name)) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1134 | c.manufacturer_name_well_formed = 1; |
| 1135 | |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1136 | extra_info.model = (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)); |
| 1137 | extra_info.serial = (unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1138 | + (edid[0x0E] << 16) + (edid[0x0F] << 24)); |
| 1139 | |
| 1140 | printk(BIOS_SPEW, "Manufacturer: %s Model %x Serial Number %u\n", |
Hung-Te Lin | 6673e8e | 2019-08-13 12:06:27 +0800 | [diff] [blame] | 1141 | out->manufacturer_name, |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1142 | (unsigned short)(edid[0x0A] + (edid[0x0B] << 8)), |
| 1143 | (unsigned int)(edid[0x0C] + (edid[0x0D] << 8) |
| 1144 | + (edid[0x0E] << 16) + (edid[0x0F] << 24))); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1145 | /* XXX need manufacturer ID table */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1146 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1147 | if (edid[0x10] < 55 || edid[0x10] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1148 | c.has_valid_week = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1149 | if (edid[0x11] > 0x0f) { |
| 1150 | if (edid[0x10] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1151 | c.has_valid_year = 1; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1152 | printk(BIOS_SPEW, |
| 1153 | "Made week %hhd of model year %hhd\n", |
| 1154 | edid[0x10], edid[0x11]); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1155 | extra_info.week = edid[0x10]; |
| 1156 | extra_info.year = edid[0x11]; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1157 | } else { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1158 | /* we know it's at least 2013, when this code |
| 1159 | * was written |
| 1160 | */ |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1161 | if (edid[0x11] + 90 <= 2013) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1162 | c.has_valid_year = 1; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1163 | printk(BIOS_SPEW, |
| 1164 | "Made week %hhd of %d\n", |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1165 | edid[0x10], edid[0x11] + 1990); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1166 | extra_info.week = edid[0x10]; |
| 1167 | extra_info.year = edid[0x11] + 1990; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1168 | } |
| 1169 | } |
| 1170 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1171 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1172 | |
Alexandru Gagniuc | 9d0ae59 | 2014-12-10 16:44:44 -0600 | [diff] [blame] | 1173 | printk(BIOS_SPEW, "EDID version: %hhd.%hhd\n", edid[0x12], edid[0x13]); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1174 | extra_info.version[0] = edid[0x12]; |
| 1175 | extra_info.version[1] = edid[0x13]; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1176 | |
| 1177 | if (edid[0x12] == 1) { |
| 1178 | if (edid[0x13] > 4) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1179 | printk(BIOS_SPEW, |
| 1180 | "Claims > 1.4, assuming 1.4 conformance\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1181 | edid[0x13] = 4; |
| 1182 | } |
| 1183 | switch (edid[0x13]) { |
| 1184 | case 4: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1185 | c.claims_one_point_four = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1186 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1187 | case 3: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1188 | c.claims_one_point_three = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1189 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1190 | case 2: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1191 | c.claims_one_point_two = 1; |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1192 | /* fall through */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1193 | default: |
Jacob Garber | 4c33a3a | 2019-07-12 10:34:06 -0600 | [diff] [blame] | 1194 | c.claims_one_point_oh = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1195 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | /* display section */ |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1199 | if (edid[0x14] & 0x80) { |
| 1200 | int conformance_mask; |
| 1201 | analog = 0; |
| 1202 | printk(BIOS_SPEW, "Digital display\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1203 | if (c.claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1204 | conformance_mask = 0; |
| 1205 | if ((edid[0x14] & 0x70) == 0x00) |
| 1206 | printk(BIOS_SPEW, "Color depth is undefined\n"); |
| 1207 | else if ((edid[0x14] & 0x70) == 0x70) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1208 | c.nonconformant_digital_display = 1; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1209 | else |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1210 | printk(BIOS_SPEW, |
| 1211 | "%d bits per primary color channel\n", |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1212 | ((edid[0x14] & 0x70) >> 3) + 4); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1213 | out->panel_bits_per_color = ((edid[0x14] & 0x70) >> 3) |
| 1214 | + 4; |
Ronald G. Minnich | 9518b56 | 2013-09-19 16:45:22 -0700 | [diff] [blame] | 1215 | out->panel_bits_per_pixel = 3*out->panel_bits_per_color; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1216 | |
| 1217 | switch (edid[0x14] & 0x0f) { |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1218 | case 0x00: |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1219 | printk(BIOS_SPEW, |
| 1220 | "Digital interface is not defined\n"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1221 | break; |
| 1222 | case 0x01: |
| 1223 | printk(BIOS_SPEW, "DVI interface\n"); |
| 1224 | break; |
| 1225 | case 0x02: |
| 1226 | printk(BIOS_SPEW, "HDMI-a interface\n"); |
| 1227 | break; |
| 1228 | case 0x03: |
| 1229 | printk(BIOS_SPEW, "HDMI-b interface\n"); |
| 1230 | break; |
| 1231 | case 0x04: |
| 1232 | printk(BIOS_SPEW, "MDDI interface\n"); |
| 1233 | break; |
| 1234 | case 0x05: |
| 1235 | printk(BIOS_SPEW, "DisplayPort interface\n"); |
| 1236 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1237 | default: |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1238 | c.nonconformant_digital_display = 1; |
| 1239 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1240 | } |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1241 | extra_info.type = edid[0x14] & 0x0f; |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 1242 | } else if (c.claims_one_point_two) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1243 | conformance_mask = 0x7E; |
Lee Leahy | 2f919ec | 2017-03-08 17:37:06 -0800 | [diff] [blame] | 1244 | if (edid[0x14] & 0x01) |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1245 | printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1246 | } else |
| 1247 | conformance_mask = 0x7F; |
| 1248 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1249 | if (!c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1250 | c.nonconformant_digital_display = edid[0x14] |
| 1251 | & conformance_mask; |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1252 | extra_info.nonconformant = c.nonconformant_digital_display; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1253 | } else { |
| 1254 | analog = 1; |
| 1255 | int voltage = (edid[0x14] & 0x60) >> 5; |
| 1256 | int sync = (edid[0x14] & 0x0F); |
David Hendricks | a3b898a | 2015-08-02 18:07:48 -0700 | [diff] [blame] | 1257 | extra_info.voltage = voltage; |
| 1258 | extra_info.sync = sync; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1259 | |
| 1260 | printk(BIOS_SPEW, "Analog display, Input voltage level: %s V\n", |
| 1261 | voltage == 3 ? "0.7/0.7" : |
| 1262 | voltage == 2 ? "1.0/0.4" : |
| 1263 | voltage == 1 ? "0.714/0.286" : |
| 1264 | "0.7/0.3"); |
| 1265 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1266 | if (c.claims_one_point_four) { |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1267 | if (edid[0x14] & 0x10) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1268 | printk(BIOS_SPEW, |
| 1269 | "Blank-to-black setup/pedestal\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1270 | else |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1271 | printk(BIOS_SPEW, |
| 1272 | "Blank level equals black level\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1273 | } else if (edid[0x14] & 0x10) { |
| 1274 | /* |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1275 | * XXX this is just the X text. 1.3 says "if set, |
| 1276 | * display expects a blank-to-black setup or pedestal |
| 1277 | * per appropriate Signal Level Standard". Whatever |
| 1278 | * _that_ means. |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1279 | */ |
| 1280 | printk(BIOS_SPEW, "Configurable signal levels\n"); |
| 1281 | } |
| 1282 | |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1283 | printk(BIOS_SPEW, "Sync: %s%s%s%s\n", |
| 1284 | sync & 0x08 ? "Separate " : "", |
| 1285 | sync & 0x04 ? "Composite " : "", |
| 1286 | sync & 0x02 ? "SyncOnGreen " : "", |
| 1287 | sync & 0x01 ? "Serration " : ""); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1291 | if (edid[0x15] && edid[0x16]) { |
| 1292 | printk(BIOS_SPEW, "Maximum image size: %d cm x %d cm\n", |
| 1293 | edid[0x15], edid[0x16]); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1294 | } else if (c.claims_one_point_four && (edid[0x15] || edid[0x16])) { |
Patrick Georgi | be71ee5d | 2014-12-15 22:52:14 +0100 | [diff] [blame] | 1295 | if (edid[0x15]) { /* edid[0x15] != 0 && edid[0x16] == 0 */ |
| 1296 | unsigned int ratio = 100000/(edid[0x15] + 99); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1297 | printk(BIOS_SPEW, |
| 1298 | "Aspect ratio is %u.%03u (landscape)\n", |
| 1299 | ratio / 1000, ratio % 1000); |
Patrick Georgi | be71ee5d | 2014-12-15 22:52:14 +0100 | [diff] [blame] | 1300 | } else { /* edid[0x15] == 0 && edid[0x16] != 0 */ |
| 1301 | unsigned int ratio = 100000/(edid[0x16] + 99); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1302 | printk(BIOS_SPEW, |
| 1303 | "Aspect ratio is %u.%03u (portrait)\n", |
| 1304 | ratio / 1000, ratio % 1000); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1305 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1306 | } else { |
| 1307 | /* Either or both can be zero for 1.3 and before */ |
| 1308 | printk(BIOS_SPEW, "Image size is variable\n"); |
| 1309 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1310 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1311 | if (edid[0x17] == 0xff) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1312 | if (c.claims_one_point_four) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1313 | printk(BIOS_SPEW, |
| 1314 | "Gamma is defined in an extension block\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1315 | else |
| 1316 | /* XXX Technically 1.3 doesn't say this... */ |
| 1317 | printk(BIOS_SPEW, "Gamma: 1.0\n"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1318 | } else |
| 1319 | printk(BIOS_SPEW, "Gamma: %d%%\n", ((edid[0x17] + 100))); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1320 | printk(BIOS_SPEW, "Check DPMS levels\n"); |
| 1321 | if (edid[0x18] & 0xE0) { |
| 1322 | printk(BIOS_SPEW, "DPMS levels:"); |
Lee Leahy | b6ee0f9 | 2017-03-09 13:35:26 -0800 | [diff] [blame] | 1323 | if (edid[0x18] & 0x80) |
| 1324 | printk(BIOS_SPEW, " Standby"); |
| 1325 | if (edid[0x18] & 0x40) |
| 1326 | printk(BIOS_SPEW, " Suspend"); |
| 1327 | if (edid[0x18] & 0x20) |
| 1328 | printk(BIOS_SPEW, " Off"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1329 | printk(BIOS_SPEW, "\n"); |
| 1330 | } |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1331 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1332 | /* FIXME: this is from 1.4 spec, check earlier */ |
| 1333 | if (analog) { |
| 1334 | switch (edid[0x18] & 0x18) { |
Lee Leahy | e20a319 | 2017-03-09 16:21:34 -0800 | [diff] [blame] | 1335 | case 0x00: |
| 1336 | printk(BIOS_SPEW, "Monochrome or grayscale display\n"); |
| 1337 | break; |
| 1338 | case 0x08: |
| 1339 | printk(BIOS_SPEW, "RGB color display\n"); |
| 1340 | break; |
| 1341 | case 0x10: |
| 1342 | printk(BIOS_SPEW, "Non-RGB color display\n"); |
| 1343 | break; |
| 1344 | case 0x18: |
| 1345 | printk(BIOS_SPEW, "Undefined display color type\n"); |
| 1346 | break; |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1347 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1348 | } else { |
| 1349 | printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4"); |
| 1350 | if (edid[0x18] & 0x10) |
| 1351 | printk(BIOS_SPEW, ", YCrCb 4:4:4"); |
| 1352 | if (edid[0x18] & 0x08) |
| 1353 | printk(BIOS_SPEW, ", YCrCb 4:2:2"); |
| 1354 | printk(BIOS_SPEW, "\n"); |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1355 | } |
| 1356 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1357 | if (edid[0x18] & 0x04) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1358 | printk(BIOS_SPEW, |
| 1359 | "Default (sRGB) color space is primary color space\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1360 | if (edid[0x18] & 0x02) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1361 | printk(BIOS_SPEW, |
| 1362 | "First detailed timing is preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1363 | c.has_preferred_timing = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1364 | } |
| 1365 | if (edid[0x18] & 0x01) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1366 | printk(BIOS_SPEW, |
| 1367 | "Supports GTF timings within operating range\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1368 | |
| 1369 | /* XXX color section */ |
| 1370 | |
| 1371 | printk(BIOS_SPEW, "Established timings supported:\n"); |
| 1372 | /* it's not yet clear we want all this stuff in the edid struct. |
| 1373 | * Let's wait. |
| 1374 | */ |
| 1375 | for (i = 0; i < 17; i++) { |
| 1376 | if (edid[0x23 + i / 8] & (1 << (7 - i % 8))) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1377 | printk(BIOS_SPEW, " %dx%d@%dHz\n", |
| 1378 | established_timings[i].x, |
| 1379 | established_timings[i].y, |
| 1380 | established_timings[i].refresh); |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1381 | |
Douglas Anderson | 9fa0760 | 2015-10-28 10:19:52 -0700 | [diff] [blame] | 1382 | for (j = 0; j < NUM_KNOWN_MODES; j++) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1383 | if (known_modes[j].ha == |
| 1384 | established_timings[i].x |
| 1385 | && known_modes[j].va == |
| 1386 | established_timings[i].y |
| 1387 | && known_modes[j].refresh == |
| 1388 | established_timings[i].refresh) |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1389 | out->mode_is_supported[j] = 1; |
Douglas Anderson | 9fa0760 | 2015-10-28 10:19:52 -0700 | [diff] [blame] | 1390 | } |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1393 | } |
| 1394 | |
| 1395 | printk(BIOS_SPEW, "Standard timings supported:\n"); |
| 1396 | for (i = 0; i < 8; i++) { |
| 1397 | uint8_t b1 = edid[0x26 + i * 2], b2 = edid[0x26 + i * 2 + 1]; |
| 1398 | unsigned int x, y = 0, refresh; |
| 1399 | |
| 1400 | if (b1 == 0x01 && b2 == 0x01) |
| 1401 | continue; |
| 1402 | |
| 1403 | if (b1 == 0) { |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1404 | printk(BIOS_SPEW, |
| 1405 | "non-conformant standard timing (0 horiz)\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1406 | continue; |
| 1407 | } |
| 1408 | x = (b1 + 31) * 8; |
| 1409 | switch ((b2 >> 6) & 0x3) { |
| 1410 | case 0x00: |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1411 | if (c.claims_one_point_three) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1412 | y = x * 10 / 16; |
| 1413 | else |
| 1414 | y = x; |
| 1415 | break; |
| 1416 | case 0x01: |
| 1417 | y = x * 3 / 4; |
| 1418 | break; |
| 1419 | case 0x02: |
| 1420 | y = x * 4 / 5; |
| 1421 | break; |
| 1422 | case 0x03: |
| 1423 | y = x * 9 / 16; |
| 1424 | break; |
| 1425 | } |
| 1426 | refresh = 60 + (b2 & 0x3f); |
| 1427 | |
| 1428 | printk(BIOS_SPEW, " %dx%d@%dHz\n", x, y, refresh); |
David Hendricks | e205410 | 2015-08-07 18:41:37 -0700 | [diff] [blame] | 1429 | for (j = 0; j < NUM_KNOWN_MODES; j++) { |
| 1430 | if (known_modes[j].ha == x && known_modes[j].va == y && |
| 1431 | known_modes[j].refresh == refresh) |
| 1432 | out->mode_is_supported[j] = 1; |
| 1433 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1434 | } |
| 1435 | |
| 1436 | /* detailed timings */ |
| 1437 | printk(BIOS_SPEW, "Detailed timings\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1438 | for (i = 0; i < 4; i++) { |
| 1439 | c.has_valid_detailed_blocks &= detailed_block( |
| 1440 | out, edid + 0x36 + i * 18, 0, &c); |
Lee Leahy | 342f8d6 | 2017-03-10 15:31:56 -0800 | [diff] [blame] | 1441 | if (i == 0 && c.has_preferred_timing |
| 1442 | && !c.did_detailed_timing) { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1443 | /* not really accurate... */ |
| 1444 | c.has_preferred_timing = 0; |
| 1445 | } |
| 1446 | } |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1447 | |
| 1448 | /* check this, 1.4 verification guide says otherwise */ |
| 1449 | if (edid[0x7e]) { |
| 1450 | printk(BIOS_SPEW, "Has %d extension blocks\n", edid[0x7e]); |
| 1451 | /* 2 is impossible because of the block map */ |
| 1452 | if (edid[0x7e] != 2) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1453 | c.has_valid_extension_count = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1454 | } else { |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1455 | c.has_valid_extension_count = 1; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | printk(BIOS_SPEW, "Checksum\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1459 | c.has_valid_checksum = do_checksum(edid); |
Hung-Te Lin | 7944581 | 2014-04-03 18:35:58 +0800 | [diff] [blame] | 1460 | |
| 1461 | /* EDID v2.0 has a larger blob (256 bytes) and may have some problem in |
| 1462 | * the extension parsing loop below. Since v2.0 was quickly deprecated |
| 1463 | * by v1.3 and we are unlikely to use any EDID 2.0 panels, we ignore |
| 1464 | * that case now and can fix it when we need to use a real 2.0 panel. |
| 1465 | */ |
Lee Leahy | 45fde70 | 2017-03-08 18:02:24 -0800 | [diff] [blame] | 1466 | for (i = 128; i < size; i += 128) |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1467 | c.nonconformant_extension += |
| 1468 | parse_extension(out, &edid[i], &c); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1469 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1470 | if (c.claims_one_point_four) { |
| 1471 | if (c.nonconformant_digital_display || |
| 1472 | !c.has_valid_string_termination || |
| 1473 | !c.has_valid_descriptor_pad || |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1474 | !c.has_preferred_timing) { |
| 1475 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1476 | printk(BIOS_ERR, |
| 1477 | "EDID block does NOT conform to EDID 1.4!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1478 | } |
| 1479 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1480 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1481 | printk(BIOS_ERR, |
| 1482 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1483 | c.nonconformant_digital_display); |
| 1484 | if (!c.has_valid_string_termination) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1485 | printk(BIOS_ERR, |
| 1486 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1487 | if (!c.has_valid_descriptor_pad) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1488 | printk(BIOS_ERR, |
| 1489 | "\tInvalid descriptor block padding\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1490 | if (!c.has_preferred_timing) |
Hung-Te Lin | 08f6c80 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1491 | printk(BIOS_ERR, "\tMissing preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1492 | } else if (c.claims_one_point_three) { |
| 1493 | if (c.nonconformant_digital_display || |
| 1494 | !c.has_valid_string_termination || |
| 1495 | !c.has_valid_descriptor_pad || |
| 1496 | !c.has_preferred_timing) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1497 | c.conformant = EDID_NOT_CONFORMANT; |
Hung-Te Lin | 076c317 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1498 | } |
| 1499 | /** |
| 1500 | * According to E-EDID (EDIDv1.3), has_name_descriptor and |
| 1501 | * has_range_descriptor are both required. These fields are |
| 1502 | * optional in v1.4. However some v1.3 panels (Ex, B133XTN01.3) |
| 1503 | * don't have them. As a workaround, we only print warning |
| 1504 | * messages. |
| 1505 | */ |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1506 | if (c.conformant == EDID_NOT_CONFORMANT) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1507 | printk(BIOS_ERR, |
| 1508 | "EDID block does NOT conform to EDID 1.3!\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1509 | else if (!c.has_name_descriptor || !c.has_range_descriptor) |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 1510 | printk(BIOS_WARNING, "EDID block does NOT " |
Hung-Te Lin | 076c317 | 2014-04-03 21:13:11 +0800 | [diff] [blame] | 1511 | "fully conform to EDID 1.3.\n"); |
| 1512 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1513 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1514 | printk(BIOS_ERR, |
| 1515 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1516 | c.nonconformant_digital_display); |
| 1517 | if (!c.has_name_descriptor) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1518 | printk(BIOS_ERR, "\tMissing name descriptor\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1519 | if (!c.has_preferred_timing) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1520 | printk(BIOS_ERR, "\tMissing preferred timing\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1521 | if (!c.has_range_descriptor) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1522 | printk(BIOS_ERR, "\tMissing monitor ranges\n"); |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1523 | /* Might be more than just 1.3 */ |
| 1524 | if (!c.has_valid_descriptor_pad) |
| 1525 | printk(BIOS_ERR, |
| 1526 | "\tInvalid descriptor block padding\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1527 | if (!c.has_valid_string_termination) /* Likewise */ |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1528 | printk(BIOS_ERR, |
| 1529 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1530 | } else if (c.claims_one_point_two) { |
| 1531 | if (c.nonconformant_digital_display || |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1532 | !c.has_valid_string_termination) { |
| 1533 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1534 | printk(BIOS_ERR, |
| 1535 | "EDID block does NOT conform to EDID 1.2!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1536 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1537 | if (c.nonconformant_digital_display) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1538 | printk(BIOS_ERR, |
| 1539 | "\tDigital display field contains garbage: %x\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1540 | c.nonconformant_digital_display); |
| 1541 | if (!c.has_valid_string_termination) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1542 | printk(BIOS_ERR, |
| 1543 | "\tDetailed block string not properly terminated\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1544 | } else if (c.claims_one_point_oh) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1545 | if (c.seen_non_detailed_descriptor) { |
| 1546 | c.conformant = EDID_NOT_CONFORMANT; |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1547 | printk(BIOS_ERR, |
| 1548 | "EDID block does NOT conform to EDID 1.0!\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1549 | } |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1550 | if (c.seen_non_detailed_descriptor) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1551 | printk(BIOS_ERR, |
| 1552 | "\tHas descriptor blocks other than detailed timings\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1553 | } |
| 1554 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1555 | if (c.nonconformant_extension || |
| 1556 | !c.has_valid_checksum || |
| 1557 | !c.has_valid_cvt || |
| 1558 | !c.has_valid_year || |
| 1559 | !c.has_valid_week || |
| 1560 | !c.has_valid_detailed_blocks || |
| 1561 | !c.has_valid_dummy_block || |
| 1562 | !c.has_valid_extension_count || |
| 1563 | !c.has_valid_descriptor_ordering || |
| 1564 | !c.has_valid_range_descriptor || |
| 1565 | !c.manufacturer_name_well_formed) { |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1566 | c.conformant = EDID_NOT_CONFORMANT; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1567 | printk(BIOS_ERR, "EDID block does not conform at all!\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1568 | if (c.nonconformant_extension) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1569 | printk(BIOS_ERR, |
| 1570 | "\tHas %d nonconformant extension block(s)\n", |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1571 | c.nonconformant_extension); |
| 1572 | if (!c.has_valid_checksum) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1573 | printk(BIOS_ERR, "\tBlock has broken checksum\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1574 | if (!c.has_valid_cvt) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1575 | printk(BIOS_ERR, "\tBroken 3-byte CVT blocks\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1576 | if (!c.has_valid_year) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1577 | printk(BIOS_ERR, "\tBad year of manufacture\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1578 | if (!c.has_valid_week) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1579 | printk(BIOS_ERR, "\tBad week of manufacture\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1580 | if (!c.has_valid_detailed_blocks) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1581 | printk(BIOS_ERR, |
| 1582 | "\tDetailed blocks filled with garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1583 | if (!c.has_valid_dummy_block) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1584 | printk(BIOS_ERR, "\tDummy block filled with garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1585 | if (!c.has_valid_extension_count) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1586 | printk(BIOS_ERR, |
| 1587 | "\tImpossible extension block count\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1588 | if (!c.manufacturer_name_well_formed) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1589 | printk(BIOS_ERR, |
| 1590 | "\tManufacturer name field contains garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1591 | if (!c.has_valid_descriptor_ordering) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1592 | printk(BIOS_ERR, |
| 1593 | "\tInvalid detailed timing descriptor ordering\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1594 | if (!c.has_valid_range_descriptor) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1595 | printk(BIOS_ERR, |
| 1596 | "\tRange descriptor contains garbage\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1597 | if (!c.has_valid_max_dotclock) |
Lee Leahy | 7340217 | 2017-03-10 15:23:24 -0800 | [diff] [blame] | 1598 | printk(BIOS_ERR, |
| 1599 | "\tEDID 1.4 block does not set max dotclock\n"); |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1600 | } |
| 1601 | |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1602 | if (c.warning_excessive_dotclock_correction) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1603 | printk(BIOS_ERR, |
| 1604 | "Warning: CVT block corrects dotclock by more than 9.75MHz\n"); |
Hung-Te Lin | 1c8ee21 | 2014-04-17 15:21:37 +0800 | [diff] [blame] | 1605 | if (c.warning_zero_preferred_refresh) |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1606 | printk(BIOS_ERR, |
| 1607 | "Warning: CVT block does not set preferred refresh rate\n"); |
Arthur Heymans | 8c5884e | 2017-04-30 08:28:05 +0200 | [diff] [blame] | 1608 | return c.conformant; |
Hung-Te Lin | fc0d244 | 2014-04-03 18:33:01 +0800 | [diff] [blame] | 1609 | } |
| 1610 | |
Ronald G. Minnich | b3b72f3 | 2013-03-13 14:35:01 -0700 | [diff] [blame] | 1611 | /* |
| 1612 | * Notes on panel extensions: (TODO, implement me in the code) |
| 1613 | * |
| 1614 | * EPI: http://www.epi-standard.org/fileadmin/spec/EPI_Specification1.0.pdf |
| 1615 | * at offset 0x6c (fourth detailed block): (all other bits reserved) |
| 1616 | * 0x6c: 00 00 00 0e 00 |
| 1617 | * 0x71: bit 6-5: data color mapping (00 conventional/fpdi/vesa, 01 openldi) |
| 1618 | * bit 4-3: pixels per clock (00 1, 01 2, 10 4, 11 reserved) |
| 1619 | * bit 2-0: bits per pixel (000 18, 001 24, 010 30, else reserved) |
| 1620 | * 0x72: bit 5: FPSCLK polarity (0 normal 1 inverted) |
| 1621 | * bit 4: DE polarity (0 high active 1 low active) |
| 1622 | * bit 3-0: interface (0000 LVDS TFT |
| 1623 | * 0001 mono STN 4/8bit |
| 1624 | * 0010 color STN 8/16 bit |
| 1625 | * 0011 18 bit tft |
| 1626 | * 0100 24 bit tft |
| 1627 | * 0101 tmds |
| 1628 | * else reserved) |
| 1629 | * 0x73: bit 1: horizontal display mode (0 normal 1 right/left reverse) |
| 1630 | * bit 0: vertical display mode (0 normal 1 up/down reverse) |
| 1631 | * 0x74: bit 7-4: total poweroff seq delay (0000 vga controller default |
| 1632 | * else time in 10ms (10ms to 150ms)) |
| 1633 | * bit 3-0: total poweron seq delay (as above) |
| 1634 | * 0x75: contrast power on/off seq delay, same as 0x74 |
| 1635 | * 0x76: bit 7: backlight control enable (1 means this field is valid) |
| 1636 | * bit 6: backlight enabled at boot (0 on 1 off) |
| 1637 | * bit 5-0: backlight brightness control steps (0..63) |
| 1638 | * 0x77: bit 7: contrast control, same bit pattern as 0x76 except bit 6 resvd |
| 1639 | * 0x78 - 0x7c: reserved |
| 1640 | * 0x7d: bit 7-4: EPI descriptor major version (1) |
| 1641 | * bit 3-0: EPI descriptor minor version (0) |
| 1642 | * |
| 1643 | * ---- |
| 1644 | * |
| 1645 | * SPWG: http://www.spwg.org/spwg_spec_version3.8_3-14-2007.pdf |
| 1646 | * |
| 1647 | * Since these are "dummy" blocks, terminate with 0a 20 20 20 ... as usual |
| 1648 | * |
| 1649 | * detailed descriptor 3: |
| 1650 | * 0x5a - 0x5e: 00 00 00 fe 00 |
| 1651 | * 0x5f - 0x63: PC maker part number |
| 1652 | * 0x64: LCD supplier revision # |
| 1653 | * 0x65 - 0x6b: manufacturer part number |
| 1654 | * |
| 1655 | * detailed descriptor 4: |
| 1656 | * 0x6c - 0x70: 00 00 00 fe 00 |
| 1657 | * 0x71 - 0x78: smbus nits values (whut) |
| 1658 | * 0x79: number of lvds channels (1 or 2) |
| 1659 | * 0x7A: panel self test (1 if present) |
| 1660 | * and then dummy terminator |
| 1661 | * |
| 1662 | * SPWG also says something strange about the LSB of detailed descriptor 1: |
| 1663 | * "LSB is set to "1" if panel is DE-timing only. H/V can be ignored." |
| 1664 | */ |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1665 | |
| 1666 | /* Set the framebuffer bits-per-pixel, recalculating all dependent values. */ |
Julius Werner | 2b6db97 | 2016-04-06 12:50:40 -0700 | [diff] [blame] | 1667 | void edid_set_framebuffer_bits_per_pixel(struct edid *edid, int fb_bpp, |
| 1668 | int row_byte_alignment) |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1669 | { |
| 1670 | /* Caller should pass a supported value, everything else is BUG(). */ |
| 1671 | assert(fb_bpp == 32 || fb_bpp == 24 || fb_bpp == 16); |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 1672 | row_byte_alignment = MAX(row_byte_alignment, 1); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1673 | |
| 1674 | edid->framebuffer_bits_per_pixel = fb_bpp; |
| 1675 | edid->bytes_per_line = ALIGN_UP(edid->mode.ha * |
Elyes HAOUAS | 6df3b64 | 2018-11-26 22:53:49 +0100 | [diff] [blame] | 1676 | DIV_ROUND_UP(fb_bpp, 8), row_byte_alignment); |
Julius Werner | 6911219 | 2016-03-14 17:29:55 -0700 | [diff] [blame] | 1677 | edid->x_resolution = edid->bytes_per_line / (fb_bpp / 8); |
| 1678 | edid->y_resolution = edid->mode.va; |
| 1679 | } |