EdidHelper: use vendor / model id if model name is not set in EDID

This commit is contained in:
李通洲 2023-08-09 22:59:23 +08:00 committed by 李通洲
parent fada8113c1
commit 3bab3eddfc
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
2 changed files with 23 additions and 5 deletions

View File

@ -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)

View File

@ -6,7 +6,8 @@
#include <stdint.h>
#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