diff --git a/src/util/edidHelper.c b/src/util/edidHelper.c index 0537907ba..3b44f3556 100644 --- a/src/util/edidHelper.c +++ b/src/util/edidHelper.c @@ -7,24 +7,41 @@ void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint3 *height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5]; } -void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) +void ffEdidGetVendorAndModel(const uint8_t edid[128], FFstrbuf* result) +{ + // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c + ffStrbufAppendF(result, "%c%c%c%04X", + (char) (((uint32_t)edid[8] >> 2 & 0x1f) + 'A' - 1), + (char) (((((uint32_t)edid[8] & 0x3) << 3) | (((uint32_t)edid[9] & 0xe0) >> 5)) + 'A' - 1), + (char) (((uint32_t)edid[9] & 0x1f) + 'A' - 1), + (uint32_t) (edid[10] + (uint32_t) (edid[11] << 8)) + ); +} + +bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name) { // https://github.com/jinksong/read_edid/blob/master/parse-edid/parse-edid.c for (uint32_t i = 0x36; i < 0x7E; i += 0x12) { // read through descriptor blocks... if (edid[i] == 0x00) { // not a timing descriptor - if (edid[i+3] == 0xfc) + if (edid[i + 3] == 0xfc) { // Model Name tag for (uint32_t j = 0; j < 13; j++) { if (edid[i + 5 + j] == 0x0a) - return; - ffStrbufAppendC(name, (char) edid[i + 5 + j]); + { + ffStrbufAppendNS(name, j, (const char*) &edid[i + 5]); + return true; + } } } } } + + // use manufacturer + model number as monitor name + ffEdidGetVendorAndModel(edid, name); + return false; } void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height) diff --git a/src/util/edidHelper.h b/src/util/edidHelper.h index 4081dceba..1c424e1f4 100644 --- a/src/util/edidHelper.h +++ b/src/util/edidHelper.h @@ -6,7 +6,8 @@ #include #include "util/FFstrbuf.h" -void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); +void ffEdidGetVendorAndModel(const uint8_t edid[128], FFstrbuf* result); +bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name); void ffEdidGetPhysicalResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height); void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height); // in mm