diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index 33052c83e1..577d2f09a5 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -168,6 +168,18 @@ void drm_setup(int fd) RARCH_WARN("[DRM]: Cannot find original CRTC.\n"); } +float drm_get_refresh_rate(void *data) +{ + float refresh_rate = 0.0f; + + if (g_drm_mode) + { + refresh_rate = g_drm_mode->clock * 1000.0f / g_drm_mode->htotal / g_drm_mode->vtotal; + } + + return refresh_rate; +} + void drm_free(void) { if (g_drm_encoder) diff --git a/gfx/common/drm_common.h b/gfx/common/drm_common.h index 87458dac9a..e8cb3ac411 100644 --- a/gfx/common/drm_common.h +++ b/gfx/common/drm_common.h @@ -55,6 +55,8 @@ void drm_free(void); bool drm_get_connector(int fd, video_frame_info_t *video_info); +float drm_get_refresh_rate(void *data); + static INLINE bool drm_wait_flip(int timeout) { g_drm_fds.revents = 0; diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 41416b8b3a..ba069adcb5 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -39,6 +39,7 @@ #include "../font_driver.h" #include "../../retroarch.h" #include "../../verbosity.h" +#include "../common/drm_common.h" #include "drm_pixformats.h" @@ -683,6 +684,7 @@ static bool init_drm(void) * on exit in case we change it. */ drm.orig_crtc = drmModeGetCrtc(drm.fd, drm.encoder->crtc_id); drm.current_mode = &(drm.orig_crtc->mode); + g_drm_mode = drm.current_mode; /* Set mode physical video mode. Not really needed, but clears TTY console. */ struct modeset_buf buf; @@ -969,7 +971,7 @@ static const video_poke_interface_t drm_poke_interface = { NULL, NULL, NULL, /* set_video_mode */ - NULL, /* get_refresh_rate */ + drm_get_refresh_rate, NULL, /* set_filtering */ NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ @@ -1012,6 +1014,8 @@ static void drm_gfx_free(void *data) slock_free(_drmvars->vsync_cond_mutex); scond_free(_drmvars->vsync_condition); + g_drm_mode = NULL; + free(_drmvars); } diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 78ed3502c7..659e87bba5 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -663,6 +663,7 @@ static void exynos_deinit(struct exynos_data *pdata) { drm_restore_crtc(); + g_drm_mode = NULL; pdata->width = 0; pdata->height = 0; pdata->num_pages = 0; @@ -1494,7 +1495,7 @@ static const video_poke_interface_t exynos_poke_interface = { NULL, NULL, NULL, /* set_video_mode */ - NULL, /* get_refresh_rate */ + drm_get_refresh_rate, NULL, /* set_filtering */ NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index a4937368f1..434c79502b 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -908,7 +908,7 @@ const gfx_ctx_driver_t gfx_ctx_drm = { gfx_ctx_drm_swap_interval, gfx_ctx_drm_set_video_mode, gfx_ctx_drm_get_video_size, - NULL, /* get_refresh_rate */ + drm_get_refresh_rate, NULL, /* get_video_output_size */ NULL, /* get_video_output_prev */ NULL, /* get_video_output_next */