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