From 13d233edba558b6be642e3ec3544073120f53888 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 11 Sep 2017 14:06:11 +0300 Subject: [PATCH] compositor-drm: get current mode on head discovery The inherited mode is the video mode on the connector when we have not yet reconfigured the connector, if set. Get the inherited mode the moment we create a drm_head, not when we determine the mode for a drm_output. This way we are sure to read all inherited modes before we reconfigure a single CRTC. Enabling one output may grab the CRTC from another connector, overwriting whatever mode that connector might have had. The inherited mode is stored in drm_head, where we can keep it for the lifetime of the head, rather than relying on re-loading it from the kernel at set_mode() time. Signed-off-by: Pekka Paalanen Reviewed-by: Daniel Stone Acked-by: Derek Foreman --- libweston/compositor-drm.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 65f4378d..f54257cd 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -416,6 +416,8 @@ struct drm_head { struct drm_property_info props_conn[WDRM_CONNECTOR__COUNT]; struct backlight *backlight; + + drmModeModeInfo inherited_mode; /**< Original mode on the connector */ }; struct drm_output { @@ -4560,12 +4562,9 @@ drm_output_set_mode(struct weston_output *base, struct drm_head *head = to_drm_head(weston_output_get_first_head(base)); struct drm_mode *current; - drmModeModeInfo crtc_mode; - - if (connector_get_current_mode(head->connector, b->drm.fd, &crtc_mode) < 0) - return -1; - current = drm_output_choose_initial_mode(b, output, mode, modeline, &crtc_mode); + current = drm_output_choose_initial_mode(b, output, mode, modeline, + &head->inherited_mode); if (!current) return -1; @@ -5079,6 +5078,13 @@ drm_head_create(struct drm_backend *backend, uint32_t connector_id, head->connector->connector_type == DRM_MODE_CONNECTOR_eDP) weston_head_set_internal(&head->base); + if (connector_get_current_mode(head->connector, backend->drm.fd, + &head->inherited_mode) < 0) { + weston_log("Failed to retrieve current mode from connector %d.\n", + head->connector_id); + /* Continue, inherited_mode was memset to zero. */ + } + weston_compositor_add_head(backend->compositor, &head->base); weston_log("DRM: found head '%s', connector %d %s.\n",