KMSDRM: better detection for the current video mode

This commit is contained in:
cmitu 2019-12-01 06:45:43 +00:00
parent b382ea2a33
commit 3953659901
3 changed files with 12 additions and 5 deletions

View File

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

View File

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

View File

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