Merge pull request #9801 from cmitu/kms-video-mode-selection

KMSDRM: better detection for the current video mode
This commit is contained in:
Twinaphex 2019-12-05 23:39:02 +01:00 committed by GitHub
commit 002f2ab6e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);