[PATCH weston 13/13] compositor-drm: Select stereo modes based on the configuration.

Emmanuel Gil Peyrot linkmauve at linkmauve.fr
Tue Nov 14 15:06:00 UTC 2017


From: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>

Signed-off-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
---
 libweston/compositor-drm.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 00f85e8b..eaf60132 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3024,7 +3024,8 @@ drm_output_choose_initial_mode(struct drm_backend *backend,
 			       struct drm_output *output,
 			       enum weston_drm_backend_output_mode mode,
 			       const char *modeline,
-			       const drmModeModeInfo *current_mode)
+			       const drmModeModeInfo *current_mode,
+			       uint32_t stereoscopy_layout)
 {
 	struct drm_mode *preferred = NULL;
 	struct drm_mode *current = NULL;
@@ -3054,6 +3055,28 @@ drm_output_choose_initial_mode(struct drm_backend *backend,
 	}
 
 	wl_list_for_each_reverse(drm_mode, &output->base.mode_list, base.link) {
+		uint32_t stereo_flags = drm_mode->mode_info.flags & DRM_MODE_FLAG_3D_MASK;
+		switch (output->base.stereoscopy_layout) {
+		case ZWP_STEREOSCOPY_V1_LAYOUT_NONE:
+			if (stereo_flags != 0)
+				continue;
+			break;
+		case ZWP_STEREOSCOPY_V1_LAYOUT_FRAME_PACKING:
+			if (stereo_flags != DRM_MODE_FLAG_3D_FRAME_PACKING)
+				continue;
+			break;
+		case ZWP_STEREOSCOPY_V1_LAYOUT_TOP_AND_BOTTOM:
+			if (stereo_flags != DRM_MODE_FLAG_3D_TOP_AND_BOTTOM)
+				continue;
+			break;
+		case ZWP_STEREOSCOPY_V1_LAYOUT_SIDE_BY_SIDE:
+			if (stereo_flags != DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF)
+				continue;
+			break;
+		default:
+			assert(0);
+		}
+
 		if (width == drm_mode->base.width &&
 		    height == drm_mode->base.height &&
 		    (refresh == 0 || refresh == drm_mode->mode_info.vrefresh))
@@ -3132,7 +3155,9 @@ drm_output_set_mode(struct weston_output *base,
 	if (connector_get_current_mode(output->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,
+	                                         &crtc_mode,
+	                                         output->base.stereoscopy_layout);
 	if (!current)
 		return -1;
 
-- 
2.15.0



More information about the wayland-devel mailing list