Add DRM interface for refresh rate.

This commit is contained in:
Brandon Wright 2018-04-16 15:36:46 -05:00
parent 64b2830889
commit 95f8205fd1
5 changed files with 22 additions and 3 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 */