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