Skip to content

Commit

Permalink
Edid: use screen size in DTD if make sense
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Dec 6, 2024
1 parent 8410a66 commit d897472
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/util/edidHelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,25 @@ bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name)

void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height)
{
*width = edid[21] * 10;
*height = edid[22] * 10;
// Detailed Timing Descriptors
uint32_t dw = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66];
uint32_t dh = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67];

// Basic Display Parameters
uint32_t bw = edid[21] * 10;
uint32_t bh = edid[22] * 10;

// Some monitors report invalid data in DTD. See #1406
if (abs((int)dw - (int)bw) < 10 && abs((int)dh - (int)bh) < 10)
{
*width = dw;
*height = dh;
}
else
{
*width = bw;
*height = bh;
}
}

void ffEdidGetSerialAndManufactureDate(const uint8_t edid[128], uint32_t* serial, uint16_t* year, uint16_t* week)
Expand Down

0 comments on commit d897472

Please sign in to comment.