1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 20:25:47 +00:00

gfx/drm: fix mode vrefresh calculation (#16376)

When using an interlaced/doublescan mode, the vertical refresh rate is mis-calculated.
Replaced the current calc method with the one from libdrm's 'modetest' utility [1].

[1] https://gitlab.freedesktop.org/mesa/drm/-/blob/main/tests/modetest/modetest.c?ref_type=heads#L140
This commit is contained in:
Cristi Mitrana 2024-03-20 23:02:51 +02:00 committed by GitHub
parent 8bb7173f97
commit b541d1e2d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -123,8 +123,19 @@ bool drm_get_connector(int fd, unsigned monitor_index)
float drm_calc_refresh_rate(drmModeModeInfo *mode)
{
float refresh_rate = (mode->clock * 1000.0f) / (mode->htotal * mode->vtotal);
return refresh_rate;
unsigned int num, den;
num = mode->clock;
den = mode->htotal * mode->vtotal;
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
num *= 2;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
den *= 2;
if (mode->vscan > 1)
den *= mode->vscan;
return num * 1000.0f / den;
}
bool drm_get_encoder(int fd)