mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +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:
parent
8bb7173f97
commit
b541d1e2d3
@ -123,8 +123,19 @@ bool drm_get_connector(int fd, unsigned monitor_index)
|
|||||||
|
|
||||||
float drm_calc_refresh_rate(drmModeModeInfo *mode)
|
float drm_calc_refresh_rate(drmModeModeInfo *mode)
|
||||||
{
|
{
|
||||||
float refresh_rate = (mode->clock * 1000.0f) / (mode->htotal * mode->vtotal);
|
unsigned int num, den;
|
||||||
return refresh_rate;
|
|
||||||
|
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)
|
bool drm_get_encoder(int fd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user