| 1 |
// SPDX-License-Identifier: MIT |
| 2 |
/* |
| 3 |
* Copyright 2006-2012 Red Hat, Inc. |
| 4 |
* Copyright 2018-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
| 5 |
* |
| 6 |
* Author: Adam Jackson <[email protected]> |
| 7 |
* Maintainer: Hans Verkuil <[email protected]> |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef __EDID_DECODE_H_ |
| 11 |
#define __EDID_DECODE_H_ |
| 12 |
|
| 13 |
#include <string> |
| 14 |
#include <vector> |
| 15 |
#include <set> |
| 16 |
#include <string.h> |
| 17 |
|
| 18 |
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) |
| 19 |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
| 20 |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
| 21 |
|
| 22 |
#define EDID_PAGE_SIZE 128U |
| 23 |
#define EDID_MAX_BLOCKS 256U |
| 24 |
|
| 25 |
#define RB_ALT (1U << 7) |
| 26 |
|
| 27 |
#define RB_NONE (0U) |
| 28 |
#define RB_CVT_V1 (1U) |
| 29 |
#define RB_CVT_V2 (2U) |
| 30 |
#define RB_CVT_V3 (3U) |
| 31 |
#define RB_GTF (4U) |
| 32 |
|
| 33 |
// Video Timings |
| 34 |
// If interlaced is true, then the vertical blanking |
| 35 |
// for each field is (vfp + vsync + vbp + 0.5), except for |
| 36 |
// the VIC 39 timings that doesn't have the 0.5 constant. |
| 37 |
// |
| 38 |
// The sequence of the various video parameters is as follows: |
| 39 |
// |
| 40 |
// border - front porch - sync - back porch - border - active video |
| 41 |
// |
| 42 |
// Note: this is slightly different from EDID 1.4 which calls |
| 43 |
// 'active video' as 'addressable video' and the EDID 1.4 term |
| 44 |
// 'active video' includes the borders. |
| 45 |
// |
| 46 |
// But since borders are rarely used, the term 'active video' will |
| 47 |
// typically be the same as 'addressable video', and that's how I |
| 48 |
// use it. |
| 49 |
struct timings { |
| 50 |
// Active horizontal and vertical frame height, excluding any |
| 51 |
// borders, if present. |
| 52 |
// Note: for interlaced formats the active field height is vact / 2 |
| 53 |
unsigned hact, vact; |
| 54 |
unsigned hratio, vratio; |
| 55 |
unsigned pixclk_khz; |
| 56 |
// 0: no reduced blanking |
| 57 |
// 1: CVT reduced blanking version 1 |
| 58 |
// 2: CVT reduced blanking version 2 |
| 59 |
// 2 | RB_ALT: CVT reduced blanking version 2 video-optimized (1000/1001 fps) |
| 60 |
// 3: CVT reduced blanking version 3 |
| 61 |
// 3 | RB_ALT: v3 with a horizontal blank of 160 |
| 62 |
// 4: GTF Secondary Curve |
| 63 |
unsigned rb; |
| 64 |
bool interlaced; |
| 65 |
// The horizontal frontporch may be negative in GTF calculations, |
| 66 |
// so use int instead of unsigned for hfp. Example: 292x176@76. |
| 67 |
int hfp; |
| 68 |
unsigned hsync; |
| 69 |
// The backporch may be negative in buggy detailed timings. |
| 70 |
// So use int instead of unsigned for hbp and vbp. |
| 71 |
int hbp; |
| 72 |
bool pos_pol_hsync; |
| 73 |
// For interlaced formats the vertical front porch of the Even Field |
| 74 |
// is actually a half-line longer. |
| 75 |
unsigned vfp, vsync; |
| 76 |
// For interlaced formats the vertical back porch of the Odd Field |
| 77 |
// is actually a half-line longer. |
| 78 |
int vbp; |
| 79 |
bool pos_pol_vsync; |
| 80 |
unsigned hborder, vborder; |
| 81 |
bool even_vtotal; // special for VIC 39 |
| 82 |
bool no_pol_vsync; // digital composite signals have no vsync polarity |
| 83 |
unsigned hsize_mm, vsize_mm; |
| 84 |
bool ycbcr420; // YCbCr 4:2:0 encoding |
| 85 |
}; |
| 86 |
|
| 87 |
struct timings_ext { |
| 88 |
timings_ext() |
| 89 |
{ |
| 90 |
memset(&t, 0, sizeof(t)); |
| 91 |
} |
| 92 |
timings_ext(unsigned svr, const std::string &_type) |
| 93 |
{ |
| 94 |
memset(&t, 0, sizeof(t)); |
| 95 |
t.hact = svr; |
| 96 |
type = _type; |
| 97 |
} |
| 98 |
timings_ext(const timings &_t, const std::string &_type, const std::string &_flags) |
| 99 |
{ |
| 100 |
t = _t; |
| 101 |
type = _type; |
| 102 |
flags = _flags; |
| 103 |
} |
| 104 |
|
| 105 |
bool is_valid() const { return t.hact; } |
| 106 |
bool has_svr() const { return t.hact && !t.vact; } |
| 107 |
unsigned svr() const { return t.hact; } |
| 108 |
timings t; |
| 109 |
std::string type; |
| 110 |
std::string flags; |
| 111 |
}; |
| 112 |
|
| 113 |
enum gtf_ip_parm { |
| 114 |
gtf_ip_vert_freq = 1, |
| 115 |
gtf_ip_hor_freq, |
| 116 |
gtf_ip_clk_freq, |
| 117 |
}; |
| 118 |
|
| 119 |
enum hdmi_image_size { |
| 120 |
hdmi_image_size_none, |
| 121 |
hdmi_image_size_ratio, |
| 122 |
hdmi_image_size_rounded, |
| 123 |
hdmi_image_size_5cm, |
| 124 |
}; |
| 125 |
|
| 126 |
typedef std::vector<timings_ext> vec_timings_ext; |
| 127 |
|
| 128 |
struct cta_rid { |
| 129 |
unsigned hact, vact; |
| 130 |
unsigned hratio, vratio; |
| 131 |
}; |
| 132 |
|
| 133 |
struct cta_vfd { |
| 134 |
unsigned char rid; |
| 135 |
unsigned char fr_factor; |
| 136 |
unsigned int bfr50:1; |
| 137 |
unsigned int fr24:1; |
| 138 |
unsigned int bfr60:1; |
| 139 |
unsigned int fr144:1; |
| 140 |
unsigned int fr48:1; |
| 141 |
}; |
| 142 |
|
| 143 |
struct edid_state { |
| 144 |
edid_state() |
| 145 |
{ |
| 146 |
// Global state |
| 147 |
edid_size = num_blocks = block_nr = 0; |
| 148 |
max_hor_freq_hz = max_vert_freq_hz = max_pixclk_khz = 0; |
| 149 |
min_hor_freq_hz = 0xffffff; |
| 150 |
min_vert_freq_hz = 0xffffffff; |
| 151 |
dtd_max_vsize_mm = dtd_max_hsize_mm = 0; |
| 152 |
warnings = failures = 0; |
| 153 |
has_cta = has_dispid = false; |
| 154 |
// Note: for now we do not support native DisplayID data, |
| 155 |
// so this is always false. But some tests are different |
| 156 |
// depending on whether it is a native DisplayID structure |
| 157 |
// or an extension block, so they can use this bool. |
| 158 |
native_dispid = false; |
| 159 |
hide_serial_numbers = false; |
| 160 |
replace_unique_ids = false; |
| 161 |
image_width = image_height = diagonal = 0; |
| 162 |
serial_string_cnt = 0; |
| 163 |
serial_strings.clear(); |
| 164 |
|
| 165 |
// Base block state |
| 166 |
base.edid_minor = 0; |
| 167 |
base.has_name_descriptor = base.has_display_range_descriptor = |
| 168 |
base.supports_continuous_freq = base.supports_gtf = |
| 169 |
base.supports_cvt = base.seen_non_detailed_descriptor = |
| 170 |
base.has_640x480p60_est_timing = base.has_spwg = |
| 171 |
base.preferred_is_also_native = false; |
| 172 |
base.serial_number = 0; |
| 173 |
base.week = base.year = 0; |
| 174 |
base.is_analog = false; |
| 175 |
base.supports_sec_gtf = false; |
| 176 |
base.sec_gtf_start_freq = 0; |
| 177 |
base.C = base.M = base.K = base.J = 0; |
| 178 |
base.max_pos_neg_hor_freq_khz = 0; |
| 179 |
base.uses_srgb = false; |
| 180 |
base.detailed_block_cnt = base.dtd_cnt = 0; |
| 181 |
|
| 182 |
base.min_display_hor_freq_hz = base.max_display_hor_freq_hz = |
| 183 |
base.min_display_vert_freq_hz = base.max_display_vert_freq_hz = |
| 184 |
base.max_display_pixclk_khz = base.max_display_width_mm = |
| 185 |
base.max_display_height_mm = 0; |
| 186 |
|
| 187 |
// CTA-861 block state |
| 188 |
cta.has_vic_1 = cta.first_svd_might_be_preferred = cta.has_sldb = |
| 189 |
cta.has_hdmi = cta.has_vcdb = cta.has_vfpdb = cta.has_cdb = |
| 190 |
cta.has_nvrdb = cta.has_pidb = false; |
| 191 |
cta.previous_cta_tag = 0xfff; |
| 192 |
cta.have_hf_vsdb = cta.have_hf_scdb = false; |
| 193 |
cta.hdmi_max_rate = 0; |
| 194 |
cta.hf_eeodb_blocks = 0; |
| 195 |
cta.image_width = cta.image_height = 0; |
| 196 |
cta.nvrdb_has_size = false; |
| 197 |
cta.block_number = 0; |
| 198 |
cta.has_svrs = false; |
| 199 |
cta.first_svd = true; |
| 200 |
cta.first_cta = true; |
| 201 |
cta.supported_hdmi_vic_codes = cta.supported_hdmi_vic_vsb_codes = 0; |
| 202 |
memset(cta.vics, 0, sizeof(cta.vics)); |
| 203 |
memset(cta.preparsed_has_vic, 0, sizeof(cta.preparsed_has_vic)); |
| 204 |
memset(&cta.preparsed_first_vfd, 0, sizeof(cta.preparsed_first_vfd)); |
| 205 |
cta.preparsed_phys_addr = 0xffff; |
| 206 |
cta.preparsed_speaker_count = 0; |
| 207 |
cta.preparsed_sld = false; |
| 208 |
cta.preparsed_sld_has_coord = false; |
| 209 |
cta.preparsed_total_dtds = 0; |
| 210 |
cta.preparsed_total_vtdbs = 0; |
| 211 |
cta.preparsed_has_t8vtdb = false; |
| 212 |
cta.preparsed_t8vtdb_dmt = 0; |
| 213 |
cta.preparsed_max_vic_pixclk_khz = 0; |
| 214 |
cta.preparsed_image_size = hdmi_image_size_none; |
| 215 |
cta.warn_about_hdmi_2x_dtd = false; |
| 216 |
cta.avi_version = 2; |
| 217 |
cta.avi_v4_length = 14; |
| 218 |
cta.has_ycbcr444 = false; |
| 219 |
cta.has_ycbcr422 = false; |
| 220 |
cta.has_ycbcr420 = false; |
| 221 |
|
| 222 |
// DisplayID block state |
| 223 |
dispid.version = 0; |
| 224 |
dispid.native_width = dispid.native_height = 0; |
| 225 |
dispid.preparsed_color_ids = dispid.preparsed_xfer_ids = 0; |
| 226 |
dispid.preparsed_displayid_blocks = 0; |
| 227 |
dispid.is_base_block = true; |
| 228 |
dispid.is_display = dispid.has_product_identification = |
| 229 |
dispid.has_display_parameters = dispid.has_type_1_7 = |
| 230 |
dispid.has_display_interface_features = |
| 231 |
dispid.has_tiled_display_topology = dispid.has_ycbcr_420 = |
| 232 |
dispid.is_arvr = dispid.has_arvr_hdm = dispid.has_arvr_layer = |
| 233 |
dispid.has_stereo = dispid.has_stereo_display_interface = false; |
| 234 |
dispid.block_number = 0; |
| 235 |
dispid.image_width = dispid.image_height = 0; |
| 236 |
|
| 237 |
// Block Map block state |
| 238 |
block_map.saw_block_1 = false; |
| 239 |
block_map.saw_block_128 = false; |
| 240 |
} |
| 241 |
|
| 242 |
// Global state |
| 243 |
unsigned edid_size; |
| 244 |
unsigned num_blocks; |
| 245 |
unsigned block_nr; |
| 246 |
std::string block; |
| 247 |
std::string data_block; |
| 248 |
unsigned unused_bytes; |
| 249 |
bool has_cta; |
| 250 |
bool has_dispid; |
| 251 |
bool native_dispid; |
| 252 |
bool hide_serial_numbers; |
| 253 |
bool replace_unique_ids; |
| 254 |
std::vector<std::string> serial_strings; |
| 255 |
unsigned serial_string_cnt; |
| 256 |
|
| 257 |
unsigned min_hor_freq_hz; |
| 258 |
unsigned max_hor_freq_hz; |
| 259 |
double min_vert_freq_hz; |
| 260 |
double max_vert_freq_hz; |
| 261 |
unsigned max_pixclk_khz; |
| 262 |
unsigned dtd_max_hsize_mm; |
| 263 |
unsigned dtd_max_vsize_mm; |
| 264 |
|
| 265 |
// in 0.1 mm units |
| 266 |
unsigned image_width, image_height; |
| 267 |
// in inches |
| 268 |
double diagonal; |
| 269 |
|
| 270 |
unsigned warnings; |
| 271 |
unsigned failures; |
| 272 |
|
| 273 |
// Base block state |
| 274 |
struct { |
| 275 |
unsigned edid_minor; |
| 276 |
bool has_name_descriptor; |
| 277 |
bool has_display_range_descriptor; |
| 278 |
unsigned serial_number; |
| 279 |
unsigned char week, year; |
| 280 |
bool is_analog; |
| 281 |
bool supports_continuous_freq; |
| 282 |
bool supports_gtf; |
| 283 |
bool supports_sec_gtf; |
| 284 |
unsigned sec_gtf_start_freq; |
| 285 |
double C, M, K, J; |
| 286 |
bool supports_cvt; |
| 287 |
bool has_spwg; |
| 288 |
bool uses_srgb; |
| 289 |
unsigned detailed_block_cnt; |
| 290 |
unsigned dtd_cnt; |
| 291 |
bool seen_non_detailed_descriptor; |
| 292 |
bool has_640x480p60_est_timing; |
| 293 |
bool preferred_is_also_native; |
| 294 |
timings_ext preferred_timing; |
| 295 |
|
| 296 |
unsigned min_display_hor_freq_hz; |
| 297 |
unsigned max_display_hor_freq_hz; |
| 298 |
unsigned min_display_vert_freq_hz; |
| 299 |
unsigned max_display_vert_freq_hz; |
| 300 |
unsigned max_display_pixclk_khz; |
| 301 |
unsigned max_display_width_mm; |
| 302 |
unsigned max_display_height_mm; |
| 303 |
unsigned max_pos_neg_hor_freq_khz; |
| 304 |
} base; |
| 305 |
|
| 306 |
// CTA-861 block state |
| 307 |
struct { |
| 308 |
unsigned preparsed_total_dtds; |
| 309 |
vec_timings_ext vec_dtds; |
| 310 |
unsigned preparsed_total_vtdbs; |
| 311 |
vec_timings_ext vec_vtdbs; |
| 312 |
cta_vfd preparsed_first_vfd; |
| 313 |
vec_timings_ext preferred_timings; |
| 314 |
vec_timings_ext preferred_timings_vfpdb; |
| 315 |
bool preparsed_has_t8vtdb; |
| 316 |
unsigned preparsed_t8vtdb_dmt; |
| 317 |
// Keep track of the found Tag/Extended Tag pairs. |
| 318 |
// The unsigned value is equal to: (tag) | (OUI enum << 12) or (extended tag) | (tag << 8) | (OUI enum << 12) |
| 319 |
std::vector<unsigned> found_tags; |
| 320 |
timings_ext t8vtdb; |
| 321 |
vec_timings_ext native_timings; |
| 322 |
vec_timings_ext native_timing_nvrdb; |
| 323 |
// in 0.1 mm units |
| 324 |
unsigned image_width, image_height; |
| 325 |
bool nvrdb_has_size; |
| 326 |
bool has_vic_1; |
| 327 |
bool first_svd_might_be_preferred; |
| 328 |
unsigned char byte3; |
| 329 |
bool has_hdmi; |
| 330 |
unsigned hdmi_max_rate; |
| 331 |
bool has_vcdb; |
| 332 |
bool has_vfpdb; |
| 333 |
bool has_nvrdb; |
| 334 |
bool has_cdb; |
| 335 |
unsigned preparsed_speaker_count; |
| 336 |
bool preparsed_sld_has_coord; |
| 337 |
bool preparsed_sld; |
| 338 |
bool has_sldb; |
| 339 |
bool has_pidb; |
| 340 |
unsigned short preparsed_phys_addr; |
| 341 |
unsigned previous_cta_tag; |
| 342 |
bool have_hf_vsdb, have_hf_scdb; |
| 343 |
unsigned hf_eeodb_blocks; |
| 344 |
unsigned block_number; |
| 345 |
bool has_svrs; |
| 346 |
bool first_svd; |
| 347 |
unsigned supported_hdmi_vic_codes; |
| 348 |
unsigned supported_hdmi_vic_vsb_codes; |
| 349 |
unsigned short vics[256][2]; |
| 350 |
bool preparsed_has_vic[2][256]; |
| 351 |
std::vector<unsigned char> preparsed_svds[2]; |
| 352 |
unsigned preparsed_max_vic_pixclk_khz; |
| 353 |
enum hdmi_image_size preparsed_image_size; |
| 354 |
bool warn_about_hdmi_2x_dtd; |
| 355 |
unsigned avi_version; |
| 356 |
unsigned avi_v4_length; |
| 357 |
bool has_ycbcr444; |
| 358 |
bool has_ycbcr422; |
| 359 |
bool has_ycbcr420; |
| 360 |
bool first_cta; |
| 361 |
} cta; |
| 362 |
|
| 363 |
// DisplayID block state |
| 364 |
struct { |
| 365 |
unsigned char version; |
| 366 |
unsigned short preparsed_color_ids; |
| 367 |
unsigned short preparsed_xfer_ids; |
| 368 |
unsigned preparsed_displayid_blocks; |
| 369 |
bool is_base_block; |
| 370 |
bool is_display; |
| 371 |
bool is_arvr; |
| 372 |
bool has_product_identification; |
| 373 |
bool has_display_parameters; |
| 374 |
bool has_type_1_7; |
| 375 |
bool has_display_interface_features; |
| 376 |
bool has_tiled_display_topology; |
| 377 |
bool has_stereo_display_interface; |
| 378 |
bool has_arvr_hdm; |
| 379 |
bool has_arvr_layer; |
| 380 |
bool has_ycbcr_420; |
| 381 |
bool has_stereo; |
| 382 |
vec_timings_ext preferred_timings; |
| 383 |
unsigned native_width, native_height; |
| 384 |
// in 0.1 mm units |
| 385 |
unsigned image_width, image_height; |
| 386 |
unsigned block_number; |
| 387 |
// Keep track of the found CTA-861 Tag/Extended Tag pairs. |
| 388 |
// The unsigned value is equal to: (tag) | (OUI enum << 12) or (extended tag) | (tag << 8) | (OUI enum << 12) |
| 389 |
std::vector<unsigned> found_tags; |
| 390 |
} dispid; |
| 391 |
|
| 392 |
// Block Map block state |
| 393 |
struct { |
| 394 |
bool saw_block_1; |
| 395 |
bool saw_block_128; |
| 396 |
} block_map; |
| 397 |
|
| 398 |
std::string dtd_type(unsigned dtd); |
| 399 |
std::string dtd_type() { return dtd_type(base.dtd_cnt); } |
| 400 |
bool print_timings(const char *prefix, const struct timings *t, |
| 401 |
const char *type, const char *flags = "", |
| 402 |
bool detailed = false, bool do_checks = true, |
| 403 |
unsigned ntsc = 2); |
| 404 |
bool print_timings(const char *prefix, const struct timings_ext &t, |
| 405 |
bool detailed = false, bool do_checks = true, |
| 406 |
unsigned ntsc = 2) |
| 407 |
{ |
| 408 |
return print_timings(prefix, &t.t, t.type.c_str(), t.flags.c_str(), |
| 409 |
detailed, do_checks, ntsc); |
| 410 |
}; |
| 411 |
timings calc_gtf_mode(unsigned h_pixels, unsigned v_lines, |
| 412 |
double ip_freq_rqd, bool int_rqd = false, |
| 413 |
enum gtf_ip_parm ip_parm = gtf_ip_vert_freq, |
| 414 |
bool margins_rqd = false, bool secondary = false, |
| 415 |
double C = 40, double M = 600, double K = 128, double J = 20); |
| 416 |
void edid_gtf_mode(unsigned refresh, struct timings &t); |
| 417 |
timings calc_cvt_mode(unsigned h_pixels, unsigned v_lines, |
| 418 |
double ip_freq_rqd, unsigned rb, bool int_rqd = false, |
| 419 |
bool margins_rqd = false, bool alt = false, |
| 420 |
unsigned rb_h_blank = 0, unsigned rb_v_blank = 460, |
| 421 |
bool early_vsync_rqd = false); |
| 422 |
void edid_cvt_mode(unsigned refresh, struct timings &t, unsigned rb_h_blank = 0, |
| 423 |
unsigned rb_v_blank = 460, bool early_vsync_rqd = false); |
| 424 |
void detailed_cvt_descriptor(const char *prefix, const unsigned char *x, bool first); |
| 425 |
timings calc_ovt_mode(unsigned hact, unsigned vact, |
| 426 |
unsigned hratio, unsigned vratio, |
| 427 |
unsigned frame_rate); |
| 428 |
void print_standard_timing(const char *prefix, unsigned char b1, unsigned char b2, |
| 429 |
bool gtf_only = false, bool show_both = false); |
| 430 |
void detailed_display_range_limits(const unsigned char *x); |
| 431 |
void detailed_epi(const unsigned char *x); |
| 432 |
void detailed_timings(const char *prefix, const unsigned char *x, |
| 433 |
bool base_or_cta = true); |
| 434 |
bool preparse_detailed_block(unsigned char *x); |
| 435 |
void preparse_base_block(unsigned char *x); |
| 436 |
void detailed_block(const unsigned char *x); |
| 437 |
void parse_base_block(const unsigned char *x); |
| 438 |
void check_base_block(const unsigned char *x); |
| 439 |
void list_dmts(); |
| 440 |
void list_established_timings(); |
| 441 |
char *manufacturer_name(const unsigned char *x); |
| 442 |
|
| 443 |
void data_block_oui(std::string block_name, const unsigned char *x, unsigned length, unsigned *ouinum, |
| 444 |
bool ignorezeros = false, bool do_ascii = false, bool big_endian = false, |
| 445 |
bool silent = false); |
| 446 |
|
| 447 |
void print_vic_index(const char *prefix, unsigned idx, const char *suffix, bool ycbcr420 = false); |
| 448 |
void hdmi_latency(unsigned char vid_lat, unsigned char aud_lat, bool is_ilaced); |
| 449 |
void cta_vcdb(const unsigned char *x, unsigned length); |
| 450 |
void cta_svd(const unsigned char *x, unsigned n, bool for_ycbcr420); |
| 451 |
void cta_vfdb(const unsigned char *x, unsigned n); |
| 452 |
void cta_y420cmdb(const unsigned char *x, unsigned length); |
| 453 |
void cta_print_svr(unsigned char svr, vec_timings_ext &vec_tim); |
| 454 |
void cta_vfpdb(const unsigned char *x, unsigned length); |
| 455 |
void cta_nvrdb(const unsigned char *x, unsigned length); |
| 456 |
cta_vfd cta_parse_vfd(const unsigned char *x, unsigned lvfd); |
| 457 |
void cta_rcdb(const unsigned char *x, unsigned length); |
| 458 |
void cta_sldb(const unsigned char *x, unsigned length); |
| 459 |
void cta_pidb(const unsigned char *x, unsigned length); |
| 460 |
void cta_preparse_sldb(const unsigned char *x, unsigned length); |
| 461 |
void cta_colorimetry_block(const unsigned char *x, unsigned length); |
| 462 |
void cta_hdmi_block(const unsigned char *x, unsigned length); |
| 463 |
void cta_hf_scdb(const unsigned char *x, unsigned length); |
| 464 |
void cta_displayid_type_7(const unsigned char *x, unsigned length); |
| 465 |
void cta_displayid_type_8(const unsigned char *x, unsigned length); |
| 466 |
void cta_displayid_type_10(const unsigned char *x, unsigned length); |
| 467 |
void cta_block(const unsigned char *x, std::vector<unsigned> &found_tags); |
| 468 |
void cta_sadb(const unsigned char *x, unsigned length); |
| 469 |
void cta_audio_block(const unsigned char *x, unsigned length); |
| 470 |
void preparse_cta_block(unsigned char *x); |
| 471 |
void parse_cta_block(const unsigned char *x); |
| 472 |
void cta_resolve_svr(timings_ext &t_ext); |
| 473 |
void cta_resolve_svrs(); |
| 474 |
void check_cta_blocks(); |
| 475 |
void cta_list_vics(); |
| 476 |
void cta_list_hdmi_vics(); |
| 477 |
void cta_list_rids(); |
| 478 |
void cta_list_rid_timings(unsigned list_rid = 0); |
| 479 |
|
| 480 |
void set_displayid_native_res(unsigned w, unsigned h); |
| 481 |
void parse_digital_interface(const unsigned char *x); |
| 482 |
void parse_display_device(const unsigned char *x); |
| 483 |
void parse_display_caps(const unsigned char *x); |
| 484 |
void parse_display_xfer(const unsigned char *x); |
| 485 |
void parse_di_ext_block(const unsigned char *x); |
| 486 |
|
| 487 |
void check_displayid_datablock_revision(unsigned char hdr, |
| 488 |
unsigned char valid_flags = 0, |
| 489 |
unsigned char rev = 0); |
| 490 |
void parse_displayid_product_id(const unsigned char *x); |
| 491 |
std::string product_type(unsigned char x, bool heading); |
| 492 |
void parse_displayid_interface_features(const unsigned char *x); |
| 493 |
void parse_displayid_parameters(const unsigned char *x); |
| 494 |
void parse_displayid_parameters_v2(const unsigned char *x, unsigned block_rev); |
| 495 |
void parse_displayid_display_intf(const unsigned char *x); |
| 496 |
void parse_displayid_color_characteristics(const unsigned char *x); |
| 497 |
void parse_displayid_transfer_characteristics(const unsigned char *x); |
| 498 |
void parse_displayid_stereo_display_intf(const unsigned char *x); |
| 499 |
void parse_displayid_type_1_7_timing(const unsigned char *x, |
| 500 |
bool type7, unsigned block_rev, bool is_cta = false); |
| 501 |
void parse_displayid_type_2_timing(const unsigned char *x); |
| 502 |
void parse_displayid_type_3_timing(const unsigned char *x); |
| 503 |
void parse_displayid_type_4_8_timing(unsigned char type, unsigned short id, bool is_cta = false); |
| 504 |
void parse_displayid_video_timing_range_limits(const unsigned char *x); |
| 505 |
void parse_displayid_string(const unsigned char *x); |
| 506 |
void parse_displayid_display_device(const unsigned char *x); |
| 507 |
void parse_displayid_intf_power_sequencing(const unsigned char *x); |
| 508 |
void parse_displayid_type_5_timing(const unsigned char *x); |
| 509 |
void parse_displayid_tiled_display_topology(const unsigned char *x, bool is_v2); |
| 510 |
void parse_displayid_type_6_timing(const unsigned char *x); |
| 511 |
void parse_displayid_type_9_timing(const unsigned char *x); |
| 512 |
void parse_displayid_dynamic_video_timings_range_limits(const unsigned char *x); |
| 513 |
void parse_displayid_ContainerID(const unsigned char *x); |
| 514 |
void parse_displayid_adaptive_sync(const unsigned char *x); |
| 515 |
void parse_displayid_arvr_hmd(const unsigned char *x); |
| 516 |
void parse_displayid_arvr_layer(const unsigned char *x); |
| 517 |
void parse_displayid_brightness_lum_range(const unsigned char *x); |
| 518 |
void parse_displayid_type_10_timing(const unsigned char *x, unsigned sz, |
| 519 |
bool is_cta = false); |
| 520 |
void preparse_displayid_block(unsigned char *x); |
| 521 |
unsigned displayid_block(const unsigned version, const unsigned char *x, unsigned length); |
| 522 |
void parse_displayid_block(const unsigned char *x); |
| 523 |
void parse_displayid_vesa(const unsigned char *x); |
| 524 |
void parse_displayid_apple(const unsigned char *x); |
| 525 |
void parse_displayid_cta_data_block(const unsigned char *x); |
| 526 |
void check_displayid_blocks(); |
| 527 |
|
| 528 |
void parse_vtb_ext_block(const unsigned char *x); |
| 529 |
|
| 530 |
void parse_string_table(const unsigned char *x); |
| 531 |
void preparse_ls_ext_block(unsigned char *x); |
| 532 |
void parse_ls_ext_block(const unsigned char *x); |
| 533 |
|
| 534 |
void parse_block_map(const unsigned char *x); |
| 535 |
|
| 536 |
void preparse_extension(unsigned char *x); |
| 537 |
void parse_extension(const unsigned char *x); |
| 538 |
void print_preferred_timings(); |
| 539 |
void print_native_res(); |
| 540 |
int parse_edid(); |
| 541 |
|
| 542 |
int parse_if(const std::string &fname); |
| 543 |
int parse_if_hdr(const unsigned char *x, unsigned size, unsigned char mask = 0xff); |
| 544 |
void parse_if_hdmi(const unsigned char *x, unsigned len); |
| 545 |
void parse_if_hdmi_forum(const unsigned char *x, unsigned len); |
| 546 |
void parse_if_vendor(const unsigned char *x, unsigned size); |
| 547 |
void parse_if_avi(const unsigned char *x, unsigned size); |
| 548 |
void parse_if_spd(const unsigned char *x, unsigned size); |
| 549 |
void parse_if_audio(const unsigned char *x, unsigned size); |
| 550 |
void parse_if_mpeg_source(const unsigned char *x, unsigned size); |
| 551 |
void parse_if_ntsc_vbi(const unsigned char *x, unsigned size); |
| 552 |
void parse_if_drm(const unsigned char *x, unsigned size); |
| 553 |
|
| 554 |
int parse_eld(const std::string &fname); |
| 555 |
void parse_eld_baseline(const unsigned char *x, unsigned size); |
| 556 |
}; |
| 557 |
|
| 558 |
static inline void add_str(std::string &s, const std::string &add) |
| 559 |
{ |
| 560 |
if (s.empty()) |
| 561 |
s = add; |
| 562 |
else if (!add.empty()) |
| 563 |
s = s + ", " + add; |
| 564 |
} |
| 565 |
|
| 566 |
void msg(bool is_warn, const char *fmt, ...); |
| 567 |
|
| 568 |
#ifdef _WIN32 |
| 569 |
|
| 570 |
#define warn(fmt, ...) msg(true, fmt, __VA_ARGS__) |
| 571 |
#define warn_once(fmt, ...) \ |
| 572 |
do { \ |
| 573 |
static bool shown_warn; \ |
| 574 |
if (!shown_warn) { \ |
| 575 |
shown_warn = true; \ |
| 576 |
msg(true, fmt, __VA_ARGS__); \ |
| 577 |
} \ |
| 578 |
} while (0) |
| 579 |
#define fail(fmt, ...) msg(false, fmt, __VA_ARGS__) |
| 580 |
|
| 581 |
#else |
| 582 |
|
| 583 |
#define warn(fmt, args...) msg(true, fmt, ##args) |
| 584 |
#define warn_once(fmt, args...) \ |
| 585 |
do { \ |
| 586 |
static bool shown_warn; \ |
| 587 |
if (!shown_warn) { \ |
| 588 |
shown_warn = true; \ |
| 589 |
msg(true, fmt, ##args); \ |
| 590 |
} \ |
| 591 |
} while (0) |
| 592 |
#define fail(fmt, args...) msg(false, fmt, ##args) |
| 593 |
|
| 594 |
#endif |
| 595 |
|
| 596 |
// NULL terminated array |
| 597 |
extern const char *cta_speaker_map[]; |
| 598 |
|
| 599 |
static inline double chrom2d(const unsigned char *x) |
| 600 |
{ |
| 601 |
unsigned v = x[0] + (x[1] << 8); |
| 602 |
|
| 603 |
return v * 0.00002; |
| 604 |
} |
| 605 |
|
| 606 |
std::string utohex(unsigned char x); |
| 607 |
std::string ouitohex(unsigned oui); |
| 608 |
std::string containerid2s(const unsigned char *x); |
| 609 |
bool memchk(const unsigned char *x, unsigned len, unsigned char v = 0); |
| 610 |
void hex_block(const char *prefix, const unsigned char *x, unsigned length, |
| 611 |
bool show_ascii = true, unsigned step = 16); |
| 612 |
std::string block_name(unsigned char block); |
| 613 |
void do_checksum(const char *prefix, const unsigned char *x, size_t len, size_t checksum_pos, |
| 614 |
unsigned unused_bytes = 0); |
| 615 |
void replace_checksum(unsigned char *x, size_t len); |
| 616 |
void calc_ratio(struct timings *t); |
| 617 |
unsigned calc_fps(const struct timings *t); |
| 618 |
const char *oui_name(unsigned oui, unsigned *ouinum = NULL); |
| 619 |
unsigned gcd(unsigned a, unsigned b); |
| 620 |
|
| 621 |
bool match_timings(const timings &t1, const timings &t2); |
| 622 |
bool timings_close_match(const timings &t1, const timings &t2); |
| 623 |
const struct timings *find_dmt_id(unsigned char dmt_id); |
| 624 |
const struct timings *close_match_to_dmt(const timings &t, unsigned &dmt); |
| 625 |
const struct timings *find_vic_id(unsigned char vic); |
| 626 |
const struct cta_rid *find_rid(unsigned char rid); |
| 627 |
unsigned char rid_fps_to_vic(unsigned char rid, unsigned fps); |
| 628 |
const struct timings *find_hdmi_vic_id(unsigned char hdmi_vic); |
| 629 |
const struct timings *cta_close_match_to_vic(const timings &t, unsigned &vic); |
| 630 |
bool cta_matches_vic(const timings &t, unsigned &vic); |
| 631 |
unsigned char hdmi_vic_to_vic(unsigned char hdmi_vic); |
| 632 |
|
| 633 |
extern bool to_utf8; |
| 634 |
char *extract_string(const unsigned char *x, unsigned len, bool is_cp437); |
| 635 |
|
| 636 |
#define oneoui(c,k,n) const unsigned kOUI_##k = __LINE__<<12; |
| 637 |
#include "oui.h" |
| 638 |
|
| 639 |
#ifdef __HAS_I2C_DEV__ |
| 640 |
|
| 641 |
int request_i2c_adapter(const char *device); |
| 642 |
int read_edid(int adapter_fd, unsigned char *edid, bool silent = false); |
| 643 |
int test_reliability(int adapter_fd, unsigned secs, unsigned msleep); |
| 644 |
int read_hdcp(int adapter_fd); |
| 645 |
int read_hdcp_ri(int adapter_fd, double ri_time); |
| 646 |
|
| 647 |
#else |
| 648 |
|
| 649 |
static inline int read_edid(int adapter_fd, unsigned char *edid) { return -ENODEV; } |
| 650 |
static inline int test_reliability(int adapter_fd, unsigned secs, unsigned msleep) { return -ENODEV; } |
| 651 |
static inline int read_hdcp(int adapter_fd) { return -ENODEV; } |
| 652 |
static inline int read_hdcp_ri(int adapter_fd, double ri_time) { return -ENODEV; } |
| 653 |
|
| 654 |
#endif |
| 655 |
|
| 656 |
#endif |