diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index 577d2f09a5..3cc41eedd1 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -27,7 +27,7 @@ uint32_t g_connector_id = 0; int g_drm_fd = 0; uint32_t g_crtc_id = 0; -static drmModeCrtc *g_orig_crtc = NULL; +drmModeCrtc *g_orig_crtc = NULL; static drmModeRes *g_drm_resources = NULL; drmModeConnector *g_drm_connector = NULL; diff --git a/gfx/common/drm_common.h b/gfx/common/drm_common.h index 6baca96ab7..462e847bff 100644 --- a/gfx/common/drm_common.h +++ b/gfx/common/drm_common.h @@ -39,6 +39,7 @@ extern struct pollfd g_drm_fds; extern drmModeConnector *g_drm_connector; extern drmModeModeInfo *g_drm_mode; +extern drmModeCrtc *g_orig_crtc; extern drmEventContext g_drm_evctx; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 682019a5cc..2512058acc 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -388,10 +388,16 @@ nextgpu: drm_setup(fd); - /* First mode is assumed to be the "optimal" - * one for get_video_size() purposes. */ - drm->fb_width = g_drm_connector->modes[0].hdisplay; - drm->fb_height = g_drm_connector->modes[0].vdisplay; + /* Choose the optimal video mode for get_video_size(): + - the current video mode from the CRTC + - otherwise pick first connector mode */ + if (g_orig_crtc->mode_valid) { + drm->fb_width = g_orig_crtc->mode.hdisplay; + drm->fb_height = g_orig_crtc->mode.vdisplay; + } else { + drm->fb_width = g_drm_connector->modes[0].hdisplay; + drm->fb_height = g_drm_connector->modes[0].vdisplay; + } drmSetMaster(g_drm_fd);