Files
fastfetch/src/util/edidHelper.c
T

35 lines
1.1 KiB
C
Raw Normal View History

2023-08-08 20:23:26 +08:00
#include "edidHelper.h"
2023-08-09 10:32:35 +08:00
void ffEdidGetPhycialResolution(const uint8_t edid[128], uint32_t* width, uint32_t* height)
2023-08-08 20:23:26 +08:00
{
const int dtd = 54;
2023-08-08 23:19:22 +08:00
*width = (((uint32_t) edid[dtd + 4] >> 4) << 8) | edid[dtd + 2];
*height = (((uint32_t) edid[dtd + 7] >> 4) << 8) | edid[dtd + 5];
2023-08-08 20:23:26 +08:00
}
2023-08-09 09:00:29 +08:00
2023-08-09 10:11:24 +08:00
void ffEdidGetName(const uint8_t edid[128], FFstrbuf* name)
2023-08-09 09:00:29 +08:00
{
// 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)
{ // 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]);
}
}
}
}
}
2023-08-09 10:52:12 +08:00
void ffEdidGetPhycialSize(const uint8_t edid[128], uint32_t* width, uint32_t* height)
{
*width = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66];
*height = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67];
}