Skip to content

Commit d897472

Browse files
committed
Edid: use screen size in DTD if make sense
1 parent 8410a66 commit d897472

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/util/edidHelper.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,25 @@ bool ffEdidGetName(const uint8_t edid[128], FFstrbuf* name)
6565

6666
void ffEdidGetPhysicalSize(const uint8_t edid[128], uint32_t* width, uint32_t* height)
6767
{
68-
*width = edid[21] * 10;
69-
*height = edid[22] * 10;
68+
// Detailed Timing Descriptors
69+
uint32_t dw = (((uint32_t) edid[68] & 0xF0) << 4) + edid[66];
70+
uint32_t dh = (((uint32_t) edid[68] & 0x0F) << 8) + edid[67];
71+
72+
// Basic Display Parameters
73+
uint32_t bw = edid[21] * 10;
74+
uint32_t bh = edid[22] * 10;
75+
76+
// Some monitors report invalid data in DTD. See #1406
77+
if (abs((int)dw - (int)bw) < 10 && abs((int)dh - (int)bh) < 10)
78+
{
79+
*width = dw;
80+
*height = dh;
81+
}
82+
else
83+
{
84+
*width = bw;
85+
*height = bh;
86+
}
7087
}
7188

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

0 commit comments

Comments
 (0)