diff options
author | Burt P <pburt0@gmail.com> | 2019-08-24 00:32:19 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-08-28 13:15:48 +0200 |
commit | f52c88bdfe5ab69a1141b45b40311b172a6d8ea1 (patch) | |
tree | 0a158f739a01a10f35dacb60c77802abb1bbb8d3 /deps | |
parent | e297217fad830e2c2b353ce594dbd80d3bf60c90 (diff) |
monitors: safer strings, some DI-EXT
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/sysobj_early/include/util_edid.h | 14 | ||||
-rw-r--r-- | deps/sysobj_early/src/util_edid.c | 63 |
2 files changed, 67 insertions, 10 deletions
diff --git a/deps/sysobj_early/include/util_edid.h b/deps/sysobj_early/include/util_edid.h index b7204568..d2fe947b 100644 --- a/deps/sysobj_early/include/util_edid.h +++ b/deps/sysobj_early/include/util_edid.h @@ -59,6 +59,13 @@ typedef struct { uint8_t bounds_ok; } DisplayIDBlock; +typedef struct { + edid_addy addy; + uint8_t interface; + uint8_t supports_hdcp; + uint8_t exists; +} DIExtData; + /* order by rising priority */ enum { OUTSRC_INVALID = -1, @@ -86,7 +93,7 @@ typedef struct { uint64_t pixel_clock_khz; int src; /* enum OUTSRC_* */ uint64_t pixels; /* h*v: easier to compare */ - char class_inch[6]; + char class_inch[12]; } edid_output; struct edid_std { @@ -207,6 +214,8 @@ typedef struct _edid { edid_output img_max; uint32_t speaker_alloc_bits; + DIExtData di; + DisplayIDMeta did; int did_block_count; DisplayIDBlock *did_blocks; @@ -224,9 +233,10 @@ edid *edid_new_from_file(const char *path); void edid_free(edid *e); char *edid_dump_hex(edid *e, int tabs, int breaks); -const char *edid_standard(int type); +const char *edid_standard(int std); const char *edid_output_src(int src); const char *edid_interface(int type); +const char *edid_di_interface(int type); const char *edid_descriptor_type(int type); const char *edid_ext_block_type(int type); const char *edid_cea_block_type(int type); diff --git a/deps/sysobj_early/src/util_edid.c b/deps/sysobj_early/src/util_edid.c index 6af3282e..38ad6823 100644 --- a/deps/sysobj_early/src/util_edid.c +++ b/deps/sysobj_early/src/util_edid.c @@ -42,6 +42,18 @@ if (EDID_MSG_STDERR) fprintf (stderr, ">[%s;L%d] " msg "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ g_string_append_printf(e->msg_log, "[%s;L%d] " msg "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); } +static int str_make_printable(char *str) { + int rc = 0; + char *p; + for(p = str; *p; p++) { + if (!isprint(*p)) { + *p = '.'; + rc++; + } + } + return rc; +} + static inline uint32_t bf_value(uint32_t value, uint32_t mask) { uint32_t result = value & mask; @@ -584,6 +596,16 @@ edid *edid_new(const char *data, unsigned int len) { if (r) e->ext_blocks_ok++; else e->ext_blocks_fail++; + if (u8[0] == 0x40) { + /* DI-EXT */ + e->di.exists = 1; + e->di.addy.e = e; + e->di.addy.offset = offset; + + e->di.interface = r8(e, offset + 2, NOMASK); + e->di.supports_hdcp = r8(e, offset + 3, 0x8); + } + if (u8[0] == 0x70) { /* DisplayID */ e->did.version = u8[1]; @@ -660,10 +682,8 @@ edid *edid_new(const char *data, unsigned int len) { /* strings */ for(i = 0; i < 4; i++) { - if (!g_utf8_validate(e->d[i].text, -1, NULL)) { - strcpy(e->d[i].text, "(INVALID)"); - } g_strstrip(e->d[i].text); + str_make_printable(e->d[i].text); switch(e->d[i].type) { case 0xfc: e->name = e->d[i].text; @@ -693,6 +713,11 @@ edid *edid_new(const char *data, unsigned int len) { if (e->ut2 && !e->serial) e->serial = e->ut2; } } + if (!e->interface && e->di.interface) { + if (e->di.interface >= 1 + && e->di.interface <= 5) + e->interface = 1; /* DVI */ + } /* largest in ETB */ for (i = 0; i < e->etb_count; i++) { @@ -936,6 +961,7 @@ const char *edid_output_src(int src) { const char *edid_interface(int type) { switch(type) { case 0: return N_("undefined"); + case 0x1: return N_("DVI"); case 0x2: return N_("HDMIa"); case 0x3: return N_("HDMIb"); case 0x4: return N_("MDDI"); @@ -944,6 +970,23 @@ const char *edid_interface(int type) { return N_("unknown"); } +const char *edid_di_interface(int type) { + switch(type) { + case 0: return N_("Analog"); + case 0x1: return N_("DVI"); + case 0x2: return N_("DVI - Single Link"); + case 0x3: return N_("DVI - Dual Link (Hi-Resolution)"); + case 0x4: return N_("DVI - Dual Link (Hi-Color)"); + case 0x5: return N_("DVI for Consumer Electronics"); + case 0x6: return N_("PnD"); + case 0x7: return N_("DFP"); + case 0x8: return N_("OpenLDI - Single Link"); + case 0x9: return N_("OpenLDI - Dual Link"); + case 0xa: return N_("OpenLDI for Consumer Electronics"); + }; + return N_("unknown"); +} + const char *edid_cea_audio_type(int type) { switch(type) { case 0: case 15: return N_("reserved"); @@ -1025,17 +1068,17 @@ const char *edid_ext_block_type(int type) { case 0x00: return N_("timing extension"); case 0x02: - return N_("EIA/CEA-861 extension block"); + return N_("EIA/CEA-861 extension (CEA-EXT)"); case 0x10: - return N_("video timing block"); + return N_("Video Timing Block extension (VTB-EXT)"); case 0x20: return N_("EDID 2.0 extension"); case 0x40: - return N_("DVI feature data/display information"); + return N_("Display Information extension (DI-EXT)"); case 0x50: - return N_("localized strings"); + return N_("Localized String extension (LS-EXT)"); case 0x60: - return N_("microdisplay interface"); + return N_("Digital Packet Video Link extension (DPVL-EXT)"); case 0x70: return N_("DisplayID"); case 0xa7: @@ -1293,6 +1336,10 @@ char *edid_dump2(edid *e) { ret = appfnl(ret, "bits per color channel: %d", e->bpc); if (e->interface) ret = appfnl(ret, "interface: %s", _(edid_interface(e->interface))); + if (e->di.exists) { + ret = appfnl(ret, "interface_ext: %s", _(edid_di_interface(e->di.interface))); + ret = appfnl(ret, "hdcp: %s", e->di.supports_hdcp ? "supported" : "no"); + } char *desc = edid_output_describe(&e->img); char *desc_svd = edid_output_describe(&e->img_svd); |