ovr_sdk

annotate 3rdParty/EDID/edid.cpp @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 * Copyright 2007 Red Hat, Inc.
nuclear@0 3 *
nuclear@0 4 * Permission is hereby granted, free of charge, to any person obtaining a
nuclear@0 5 * copy of this software and associated documentation files (the "Software"),
nuclear@0 6 * to deal in the Software without restriction, including without limitation
nuclear@0 7 * on the rights to use, copy, modify, merge, publish, distribute, sub
nuclear@0 8 * license, and/or sell copies of the Software, and to permit persons to whom
nuclear@0 9 * the Software is furnished to do so, subject to the following conditions:
nuclear@0 10 *
nuclear@0 11 * The above copyright notice and this permission notice (including the next
nuclear@0 12 * paragraph) shall be included in all copies or substantial portions of the
nuclear@0 13 * Software.
nuclear@0 14 *
nuclear@0 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
nuclear@0 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
nuclear@0 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
nuclear@0 18 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
nuclear@0 19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
nuclear@0 20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nuclear@0 21 */
nuclear@0 22
nuclear@0 23 /* Author: Soren Sandmann <sandmann@redhat.com> */
nuclear@0 24 #include "edid.h"
nuclear@0 25 #include <stdint.h>
nuclear@0 26 #include <math.h>
nuclear@0 27 #include <memory.h>
nuclear@0 28 #include <X11/Xatom.h>
nuclear@0 29
nuclear@0 30
nuclear@0 31 static int get_bit(int in, int bit) {
nuclear@0 32 return (in & (1 << bit)) >> bit;
nuclear@0 33 }
nuclear@0 34
nuclear@0 35 static int get_bits(int in, int begin, int end) {
nuclear@0 36 int mask = (1 << (end - begin + 1)) - 1;
nuclear@0 37
nuclear@0 38 return (in >> begin) & mask;
nuclear@0 39 }
nuclear@0 40
nuclear@0 41 static bool decode_header(const uint8_t *edid) {
nuclear@0 42 if (memcmp(edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0)
nuclear@0 43 return true;
nuclear@0 44 return false;
nuclear@0 45 }
nuclear@0 46
nuclear@0 47 static int decode_vendor_and_product_identification(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 48
nuclear@0 49 /* Manufacturer Code */
nuclear@0 50 info->manufacturer_code[0] = get_bits(edid[0x08], 2, 6);
nuclear@0 51 info->manufacturer_code[1] = get_bits(edid[0x08], 0, 1) << 3;
nuclear@0 52 info->manufacturer_code[1] |= get_bits(edid[0x09], 5, 7);
nuclear@0 53 info->manufacturer_code[2] = get_bits(edid[0x09], 0, 4);
nuclear@0 54 info->manufacturer_code[3] = '\0';
nuclear@0 55
nuclear@0 56 info->manufacturer_code[0] += 'A' - 1;
nuclear@0 57 info->manufacturer_code[1] += 'A' - 1;
nuclear@0 58 info->manufacturer_code[2] += 'A' - 1;
nuclear@0 59
nuclear@0 60 /* Product Code */
nuclear@0 61 info->product_code = edid[0x0b] << 8 | edid[0x0a];
nuclear@0 62
nuclear@0 63 /* Serial Number */
nuclear@0 64 info->serial_number = edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24;
nuclear@0 65
nuclear@0 66 /* Week and Year */
nuclear@0 67 bool is_model_year = false;
nuclear@0 68 switch (edid[0x10]) {
nuclear@0 69 case 0x00:
nuclear@0 70 info->production_week = -1;
nuclear@0 71 break;
nuclear@0 72
nuclear@0 73 case 0xff:
nuclear@0 74 info->production_week = -1;
nuclear@0 75 is_model_year = true;
nuclear@0 76 break;
nuclear@0 77
nuclear@0 78 default:
nuclear@0 79 info->production_week = edid[0x10];
nuclear@0 80 break;
nuclear@0 81 }
nuclear@0 82
nuclear@0 83 if (is_model_year) {
nuclear@0 84 info->production_year = -1;
nuclear@0 85 info->model_year = 1990 + edid[0x11];
nuclear@0 86 } else {
nuclear@0 87 info->production_year = 1990 + edid[0x11];
nuclear@0 88 info->model_year = -1;
nuclear@0 89 }
nuclear@0 90
nuclear@0 91 return true;
nuclear@0 92 }
nuclear@0 93
nuclear@0 94 static bool decode_edid_version(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 95 info->major_version = edid[0x12];
nuclear@0 96 info->minor_version = edid[0x13];
nuclear@0 97 return true;
nuclear@0 98 }
nuclear@0 99
nuclear@0 100 static bool decode_display_parameters(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 101 /* Digital vs Analog */
nuclear@0 102 info->is_digital = get_bit(edid[0x14], 7);
nuclear@0 103
nuclear@0 104 if (info->is_digital) {
nuclear@0 105 static const int bit_depth[8] = { -1, 6, 8, 10, 12, 14, 16, -1 };
nuclear@0 106 static const Interface interfaces[6] = { UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT };
nuclear@0 107
nuclear@0 108 int bits = get_bits(edid[0x14], 4, 6);
nuclear@0 109 info->connector.digital.bits_per_primary = bit_depth[bits];
nuclear@0 110
nuclear@0 111 bits = get_bits(edid[0x14], 0, 3);
nuclear@0 112 if (bits <= 5)
nuclear@0 113 info->connector.digital.interface = interfaces[bits];
nuclear@0 114 else
nuclear@0 115 info->connector.digital.interface = UNDEFINED;
nuclear@0 116 } else {
nuclear@0 117 int bits = get_bits(edid[0x14], 5, 6);
nuclear@0 118 static const double levels[][3] = { //
nuclear@0 119 { 0.7, 0.3, 1.0 }, //
nuclear@0 120 { 0.714, 0.286, 1.0 }, //
nuclear@0 121 { 1.0, 0.4, 1.4 }, //
nuclear@0 122 { 0.7, 0.0, 0.7 }, //
nuclear@0 123 };
nuclear@0 124
nuclear@0 125 info->connector.analog.video_signal_level = levels[bits][0];
nuclear@0 126 info->connector.analog.sync_signal_level = levels[bits][1];
nuclear@0 127 info->connector.analog.total_signal_level = levels[bits][2];
nuclear@0 128 info->connector.analog.blank_to_black = get_bit(edid[0x14], 4);
nuclear@0 129 info->connector.analog.separate_hv_sync = get_bit(edid[0x14], 3);
nuclear@0 130 info->connector.analog.composite_sync_on_h = get_bit(edid[0x14], 2);
nuclear@0 131 info->connector.analog.composite_sync_on_green = get_bit(edid[0x14], 1);
nuclear@0 132 info->connector.analog.serration_on_vsync = get_bit(edid[0x14], 0);
nuclear@0 133 }
nuclear@0 134
nuclear@0 135 /* Screen Size / Aspect Ratio */
nuclear@0 136 if (edid[0x15] == 0 && edid[0x16] == 0) {
nuclear@0 137 info->width_mm = -1;
nuclear@0 138 info->height_mm = -1;
nuclear@0 139 info->aspect_ratio = -1.0;
nuclear@0 140 } else if (edid[0x16] == 0) {
nuclear@0 141 info->width_mm = -1;
nuclear@0 142 info->height_mm = -1;
nuclear@0 143 info->aspect_ratio = 100.0 / (edid[0x15] + 99);
nuclear@0 144 } else if (edid[0x15] == 0) {
nuclear@0 145 info->width_mm = -1;
nuclear@0 146 info->height_mm = -1;
nuclear@0 147 info->aspect_ratio = 100.0 / (edid[0x16] + 99);
nuclear@0 148 info->aspect_ratio = 1 / info->aspect_ratio; /* portrait */
nuclear@0 149 } else {
nuclear@0 150 info->width_mm = 10 * edid[0x15];
nuclear@0 151 info->height_mm = 10 * edid[0x16];
nuclear@0 152 }
nuclear@0 153
nuclear@0 154 /* Gamma */
nuclear@0 155 if (edid[0x17] == 0xFF)
nuclear@0 156 info->gamma = -1.0;
nuclear@0 157 else
nuclear@0 158 info->gamma = (edid[0x17] + 100.0) / 100.0;
nuclear@0 159
nuclear@0 160 /* Features */
nuclear@0 161 info->standby = get_bit(edid[0x18], 7);
nuclear@0 162 info->suspend = get_bit(edid[0x18], 6);
nuclear@0 163 info->active_off = get_bit(edid[0x18], 5);
nuclear@0 164
nuclear@0 165 if (info->is_digital) {
nuclear@0 166 info->connector.digital.rgb444 = 1;
nuclear@0 167 if (get_bit(edid[0x18], 3))
nuclear@0 168 info->connector.digital.ycrcb444 = 1;
nuclear@0 169 if (get_bit(edid[0x18], 4))
nuclear@0 170 info->connector.digital.ycrcb422 = 1;
nuclear@0 171 } else {
nuclear@0 172 int bits = get_bits(edid[0x18], 3, 4);
nuclear@0 173 ColorType color_type[4] = { MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR };
nuclear@0 174
nuclear@0 175 info->connector.analog.color_type = color_type[bits];
nuclear@0 176 }
nuclear@0 177
nuclear@0 178 info->srgb_is_standard = get_bit(edid[0x18], 2);
nuclear@0 179
nuclear@0 180 /* In 1.3 this is called "has preferred timing" */
nuclear@0 181 info->preferred_timing_includes_native = get_bit(edid[0x18], 1);
nuclear@0 182
nuclear@0 183 /* FIXME: In 1.3 this indicates whether the monitor accepts GTF */
nuclear@0 184 info->continuous_frequency = get_bit(edid[0x18], 0);
nuclear@0 185 return true;
nuclear@0 186 }
nuclear@0 187
nuclear@0 188 static double decode_fraction(int high, int low) {
nuclear@0 189 double result = 0.0;
nuclear@0 190 high = (high << 2) | low;
nuclear@0 191 for (int i = 0; i < 10; ++i)
nuclear@0 192 result += get_bit(high, i) * pow(2, i - 10);
nuclear@0 193 return result;
nuclear@0 194 }
nuclear@0 195
nuclear@0 196 static bool decode_color_characteristics(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 197 info->red_x = decode_fraction(edid[0x1b], get_bits(edid[0x19], 6, 7));
nuclear@0 198 info->red_y = decode_fraction(edid[0x1c], get_bits(edid[0x19], 5, 4));
nuclear@0 199 info->green_x = decode_fraction(edid[0x1d], get_bits(edid[0x19], 2, 3));
nuclear@0 200 info->green_y = decode_fraction(edid[0x1e], get_bits(edid[0x19], 0, 1));
nuclear@0 201 info->blue_x = decode_fraction(edid[0x1f], get_bits(edid[0x1a], 6, 7));
nuclear@0 202 info->blue_y = decode_fraction(edid[0x20], get_bits(edid[0x1a], 4, 5));
nuclear@0 203 info->white_x = decode_fraction(edid[0x21], get_bits(edid[0x1a], 2, 3));
nuclear@0 204 info->white_y = decode_fraction(edid[0x22], get_bits(edid[0x1a], 0, 1));
nuclear@0 205
nuclear@0 206 return true;
nuclear@0 207 }
nuclear@0 208
nuclear@0 209 static bool decode_established_timings(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 210 static const Timing established[][8] = { //
nuclear@0 211 { { 800, 600, 60 }, { 800, 600, 56 }, //
nuclear@0 212 { 640, 480, 75 }, { 640, 480, 72 }, //
nuclear@0 213 { 640, 480, 67 }, { 640, 480, 60 }, //
nuclear@0 214 { 720, 400, 88 }, { 720, 400, 70 } }, //
nuclear@0 215 { { 1280, 1024, 75 }, { 1024, 768, 75 }, //
nuclear@0 216 { 1024, 768, 70 }, { 1024, 768, 60 }, //
nuclear@0 217 { 1024, 768, 87 }, { 832, 624, 75 }, //
nuclear@0 218 { 800, 600, 75 }, { 800, 600, 72 } }, //
nuclear@0 219 { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, //
nuclear@0 220 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1152, 870, 75 } }, //
nuclear@0 221 };
nuclear@0 222
nuclear@0 223 int idx = 0;
nuclear@0 224 for (int i = 0; i < 3; ++i) {
nuclear@0 225 for (int j = 0; j < 8; ++j) {
nuclear@0 226 int byte = edid[0x23 + i];
nuclear@0 227
nuclear@0 228 if (get_bit(byte, j) && established[i][j].frequency != 0)
nuclear@0 229 info->established[idx++] = established[i][j];
nuclear@0 230 }
nuclear@0 231 }
nuclear@0 232 return true;
nuclear@0 233 }
nuclear@0 234
nuclear@0 235 static bool decode_standard_timings(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 236 int i;
nuclear@0 237
nuclear@0 238 for (i = 0; i < 8; i++) {
nuclear@0 239 int first = edid[0x26 + 2 * i];
nuclear@0 240 int second = edid[0x27 + 2 * i];
nuclear@0 241
nuclear@0 242 if (first != 0x01 && second != 0x01) {
nuclear@0 243 int w = 8 * (first + 31);
nuclear@0 244 int h = 0;
nuclear@0 245
nuclear@0 246 switch (get_bits(second, 6, 7)) {
nuclear@0 247 case 0x00:
nuclear@0 248 h = (w / 16) * 10;
nuclear@0 249 break;
nuclear@0 250 case 0x01:
nuclear@0 251 h = (w / 4) * 3;
nuclear@0 252 break;
nuclear@0 253 case 0x02:
nuclear@0 254 h = (w / 5) * 4;
nuclear@0 255 break;
nuclear@0 256 case 0x03:
nuclear@0 257 h = (w / 16) * 9;
nuclear@0 258 break;
nuclear@0 259 }
nuclear@0 260
nuclear@0 261 info->standard[i].width = w;
nuclear@0 262 info->standard[i].height = h;
nuclear@0 263 info->standard[i].frequency = get_bits(second, 0, 5) + 60;
nuclear@0 264 }
nuclear@0 265 }
nuclear@0 266
nuclear@0 267 return true;
nuclear@0 268 }
nuclear@0 269
nuclear@0 270 static void decode_lf_string(const uint8_t *s, int n_chars, char *result) {
nuclear@0 271 int i;
nuclear@0 272 for (i = 0; i < n_chars; ++i) {
nuclear@0 273 if (s[i] == 0x0a) {
nuclear@0 274 *result++ = '\0';
nuclear@0 275 break;
nuclear@0 276 } else if (s[i] == 0x00) {
nuclear@0 277 /* Convert embedded 0's to spaces */
nuclear@0 278 *result++ = ' ';
nuclear@0 279 } else {
nuclear@0 280 *result++ = s[i];
nuclear@0 281 }
nuclear@0 282 }
nuclear@0 283 }
nuclear@0 284
nuclear@0 285 static void decode_display_descriptor(const uint8_t *desc, MonitorInfo *info) {
nuclear@0 286 switch (desc[0x03]) {
nuclear@0 287 case 0xFC:
nuclear@0 288 decode_lf_string(desc + 5, 13, info->dsc_product_name);
nuclear@0 289 break;
nuclear@0 290 case 0xFF:
nuclear@0 291 decode_lf_string(desc + 5, 13, info->dsc_serial_number);
nuclear@0 292 break;
nuclear@0 293 case 0xFE:
nuclear@0 294 decode_lf_string(desc + 5, 13, info->dsc_string);
nuclear@0 295 break;
nuclear@0 296 case 0xFD:
nuclear@0 297 /* Range Limits */
nuclear@0 298 break;
nuclear@0 299 case 0xFB:
nuclear@0 300 /* Color Point */
nuclear@0 301 break;
nuclear@0 302 case 0xFA:
nuclear@0 303 /* Timing Identifications */
nuclear@0 304 break;
nuclear@0 305 case 0xF9:
nuclear@0 306 /* Color Management */
nuclear@0 307 break;
nuclear@0 308 case 0xF8:
nuclear@0 309 /* Timing Codes */
nuclear@0 310 break;
nuclear@0 311 case 0xF7:
nuclear@0 312 /* Established Timings */
nuclear@0 313 break;
nuclear@0 314 case 0x10:
nuclear@0 315 break;
nuclear@0 316 }
nuclear@0 317 }
nuclear@0 318
nuclear@0 319 static void decode_detailed_timing(const uint8_t *timing, DetailedTiming *detailed) {
nuclear@0 320 int bits;
nuclear@0 321 StereoType stereo[] = { //
nuclear@0 322 NO_STEREO, NO_STEREO, //
nuclear@0 323 FIELD_RIGHT, FIELD_LEFT, //
nuclear@0 324 TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN, //
nuclear@0 325 FOUR_WAY_INTERLEAVED, //
nuclear@0 326 SIDE_BY_SIDE //
nuclear@0 327 };
nuclear@0 328
nuclear@0 329 detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000;
nuclear@0 330 detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4);
nuclear@0 331 detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8);
nuclear@0 332 detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4);
nuclear@0 333 detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8);
nuclear@0 334 detailed->h_front_porch = timing[0x08] | get_bits(timing[0x0b], 6, 7) << 8;
nuclear@0 335 detailed->h_sync = timing[0x09] | get_bits(timing[0x0b], 4, 5) << 8;
nuclear@0 336 detailed->v_front_porch = get_bits(timing[0x0a], 4, 7) | get_bits(timing[0x0b], 2, 3) << 4;
nuclear@0 337 detailed->v_sync = get_bits(timing[0x0a], 0, 3) | get_bits(timing[0x0b], 0, 1) << 4;
nuclear@0 338 detailed->width_mm = timing[0x0c] | get_bits(timing[0x0e], 4, 7) << 8;
nuclear@0 339 detailed->height_mm = timing[0x0d] | get_bits(timing[0x0e], 0, 3) << 8;
nuclear@0 340 detailed->right_border = timing[0x0f];
nuclear@0 341 detailed->top_border = timing[0x10];
nuclear@0 342 detailed->interlaced = get_bit(timing[0x11], 7);
nuclear@0 343
nuclear@0 344 /* Stereo */
nuclear@0 345 bits = get_bits(timing[0x11], 5, 6) << 1 | get_bit(timing[0x11], 0);
nuclear@0 346 detailed->stereo = stereo[bits];
nuclear@0 347
nuclear@0 348 /* Sync */
nuclear@0 349 bits = timing[0x11];
nuclear@0 350
nuclear@0 351 detailed->digital_sync = get_bit(bits, 4);
nuclear@0 352 if (detailed->digital_sync) {
nuclear@0 353 detailed->connector.digital.composite = !get_bit(bits, 3);
nuclear@0 354 if (detailed->connector.digital.composite) {
nuclear@0 355 detailed->connector.digital.serrations = get_bit(bits, 2);
nuclear@0 356 detailed->connector.digital.negative_vsync = 0;
nuclear@0 357 } else {
nuclear@0 358 detailed->connector.digital.serrations = 0;
nuclear@0 359 detailed->connector.digital.negative_vsync = !get_bit(bits, 2);
nuclear@0 360 }
nuclear@0 361 detailed->connector.digital.negative_hsync = !get_bit(bits, 0);
nuclear@0 362 } else {
nuclear@0 363 detailed->connector.analog.bipolar = get_bit(bits, 3);
nuclear@0 364 detailed->connector.analog.serrations = get_bit(bits, 2);
nuclear@0 365 detailed->connector.analog.sync_on_green = !get_bit(bits, 1);
nuclear@0 366 }
nuclear@0 367 }
nuclear@0 368
nuclear@0 369 static bool decode_descriptors(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 370 int timing_idx = 0;
nuclear@0 371 for (int i = 0; i < 4; ++i) {
nuclear@0 372 int index = 0x36 + i * 18;
nuclear@0 373 if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00) {
nuclear@0 374 decode_display_descriptor(edid + index, info);
nuclear@0 375 } else {
nuclear@0 376 decode_detailed_timing(edid + index, &(info->detailed_timings[timing_idx++]));
nuclear@0 377 }
nuclear@0 378 }
nuclear@0 379 info->n_detailed_timings = timing_idx;
nuclear@0 380 return true;
nuclear@0 381 }
nuclear@0 382
nuclear@0 383 static void decode_check_sum(const uint8_t *edid, MonitorInfo *info) {
nuclear@0 384 uint8_t check = 0;
nuclear@0 385 for (int i = 0; i < 128; ++i)
nuclear@0 386 check += edid[i];
nuclear@0 387 info->checksum = check;
nuclear@0 388 }
nuclear@0 389
nuclear@0 390 MonitorInfo * decode_edid(const uint8_t *edid) {
nuclear@0 391 MonitorInfo *info = new MonitorInfo();
nuclear@0 392 decode_check_sum(edid, info);
nuclear@0 393 if (decode_header(edid) && //
nuclear@0 394 decode_vendor_and_product_identification(edid, info) && //
nuclear@0 395 decode_edid_version(edid, info) && //
nuclear@0 396 decode_display_parameters(edid, info) && //
nuclear@0 397 decode_color_characteristics(edid, info) && //
nuclear@0 398 decode_established_timings(edid, info) && //
nuclear@0 399 decode_standard_timings(edid, info) && //
nuclear@0 400 decode_descriptors(edid, info)) {
nuclear@0 401 return info;
nuclear@0 402 } else {
nuclear@0 403 delete info;
nuclear@0 404 return 0;
nuclear@0 405 }
nuclear@0 406 }
nuclear@0 407
nuclear@0 408 static uint8_t * get_property(Display *dpy, RROutput output, Atom atom, int *len) {
nuclear@0 409 unsigned char *prop;
nuclear@0 410 int actual_format;
nuclear@0 411 unsigned long nitems, bytes_after;
nuclear@0 412 Atom actual_type;
nuclear@0 413 uint8_t *result = NULL;
nuclear@0 414
nuclear@0 415 XRRGetOutputProperty(dpy, output, atom, 0, 100, False, False,
nuclear@0 416 AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop);
nuclear@0 417
nuclear@0 418 if (actual_type == XA_INTEGER && actual_format == 8) {
nuclear@0 419 result = new uint8_t[nitems];
nuclear@0 420 memcpy(result, prop, nitems);
nuclear@0 421 if (len)
nuclear@0 422 *len = nitems;
nuclear@0 423 }
nuclear@0 424 XFree(prop);
nuclear@0 425 return result;
nuclear@0 426 }
nuclear@0 427
nuclear@0 428 MonitorInfo * read_edid_data(Display * disp, RROutput id) {
nuclear@0 429 int len;
nuclear@0 430 Atom edid_atom = XInternAtom(disp, "EDID", false);
nuclear@0 431 uint8_t *edid = get_property(disp, id, edid_atom, &len);
nuclear@0 432 if (!edid) {
nuclear@0 433 edid_atom = XInternAtom(disp, "EDID_DATA", false);
nuclear@0 434 edid = get_property(disp, id, edid_atom, &len);
nuclear@0 435 }
nuclear@0 436
nuclear@0 437 MonitorInfo * result = 0;
nuclear@0 438 if (edid) {
nuclear@0 439 if (len % 128 == 0) {
nuclear@0 440 result = decode_edid(edid);
nuclear@0 441 }
nuclear@0 442 delete[] edid;
nuclear@0 443 }
nuclear@0 444
nuclear@0 445 return result;
nuclear@0 446 }