Commit 13d233ed authored by Pekka Paalanen's avatar Pekka Paalanen

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's avatarPekka Paalanen <>
Reviewed-by: Daniel Stone's avatarDaniel Stone <>
Acked-by: default avatarDerek Foreman <>
parent f8570465
......@@ -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,
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)
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",
/* 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",
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment