mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
Merge pull request #12211 from kamicane/vrefresh
[DRM] set the correct video mode
This commit is contained in:
commit
551a671cc6
@ -121,6 +121,12 @@ bool drm_get_connector(int fd, unsigned monitor_index)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float drm_calc_refresh_rate(drmModeModeInfo *mode)
|
||||||
|
{
|
||||||
|
float refresh_rate = (mode->clock * 1000.0f) / (mode->htotal * mode->vtotal);
|
||||||
|
return refresh_rate;
|
||||||
|
}
|
||||||
|
|
||||||
bool drm_get_encoder(int fd)
|
bool drm_get_encoder(int fd)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -147,12 +153,12 @@ bool drm_get_encoder(int fd)
|
|||||||
|
|
||||||
for (i = 0; (int)i < g_drm_connector->count_modes; i++)
|
for (i = 0; (int)i < g_drm_connector->count_modes; i++)
|
||||||
{
|
{
|
||||||
RARCH_LOG("[DRM]: Mode %d: (%s) %d x %d, %u Hz\n",
|
RARCH_LOG("[DRM]: Mode %d: (%s) %d x %d, %f Hz\n",
|
||||||
i,
|
i,
|
||||||
g_drm_connector->modes[i].name,
|
g_drm_connector->modes[i].name,
|
||||||
g_drm_connector->modes[i].hdisplay,
|
g_drm_connector->modes[i].hdisplay,
|
||||||
g_drm_connector->modes[i].vdisplay,
|
g_drm_connector->modes[i].vdisplay,
|
||||||
g_drm_connector->modes[i].vrefresh);
|
drm_calc_refresh_rate(&g_drm_connector->modes[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -173,7 +179,7 @@ float drm_get_refresh_rate(void *data)
|
|||||||
|
|
||||||
if (g_drm_mode)
|
if (g_drm_mode)
|
||||||
{
|
{
|
||||||
refresh_rate = g_drm_mode->clock * 1000.0f / g_drm_mode->htotal / g_drm_mode->vtotal;
|
refresh_rate = drm_calc_refresh_rate(g_drm_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return refresh_rate;
|
return refresh_rate;
|
||||||
|
@ -43,6 +43,8 @@ extern drmModeCrtc *g_orig_crtc;
|
|||||||
|
|
||||||
extern drmEventContext g_drm_evctx;
|
extern drmEventContext g_drm_evctx;
|
||||||
|
|
||||||
|
float drm_calc_refresh_rate(drmModeModeInfo *mode);
|
||||||
|
|
||||||
bool drm_get_encoder(int fd);
|
bool drm_get_encoder(int fd);
|
||||||
|
|
||||||
/* Restore the original CRTC. */
|
/* Restore the original CRTC. */
|
||||||
|
@ -733,19 +733,24 @@ static bool gfx_ctx_drm_set_video_mode(void *data,
|
|||||||
* refresh rates as well.
|
* refresh rates as well.
|
||||||
*/
|
*/
|
||||||
float minimum_fps_diff = 0.0f;
|
float minimum_fps_diff = 0.0f;
|
||||||
|
float mode_vrefresh = 0.0f;
|
||||||
|
drmModeModeInfo *mode;
|
||||||
|
|
||||||
/* Find best match. */
|
/* Find best match. */
|
||||||
for (i = 0; i < g_drm_connector->count_modes; i++) {
|
for (i = 0; i < g_drm_connector->count_modes; i++) {
|
||||||
|
mode = &g_drm_connector->modes[i];
|
||||||
|
|
||||||
float diff;
|
float diff;
|
||||||
if (width != g_drm_connector->modes[i].hdisplay ||
|
if (width != mode->hdisplay ||
|
||||||
height != g_drm_connector->modes[i].vdisplay)
|
height != mode->vdisplay)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
diff = fabsf(refresh_mod * g_drm_connector->modes[i].vrefresh
|
mode_vrefresh = drm_calc_refresh_rate(mode);
|
||||||
- video_refresh_rate);
|
|
||||||
|
diff = fabsf(refresh_mod * mode_vrefresh - video_refresh_rate);
|
||||||
|
|
||||||
if (!g_drm_mode || diff < minimum_fps_diff) {
|
if (!g_drm_mode || diff < minimum_fps_diff) {
|
||||||
g_drm_mode = &g_drm_connector->modes[i];
|
g_drm_mode = mode;
|
||||||
minimum_fps_diff = diff;
|
minimum_fps_diff = diff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user