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