[PATCH weston v6 53/73] compositor-drm: get current mode on head discovery
Pekka Paalanen
ppaalanen at gmail.com
Fri Feb 16 14:57:38 UTC 2018
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
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 <pekka.paalanen at collabora.co.uk>
---
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 c816d008..5e459380 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -417,6 +417,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 {
@@ -4578,12 +4580,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;
@@ -5097,6 +5096,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",
--
2.13.6
More information about the wayland-devel
mailing list