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