compositor-drm: Handle more than two output crtcs per card
Allow proper handling of output->pipe > 1 to support
triple-head graphics cards etc. by using the "high-crtc"
support introduced in Linux 2.6.39 and libdrm 2.4.25
around May 2011.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index ad70807..aa6d010 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -597,6 +597,17 @@
weston_log("set gamma failed: %m\n");
}
+static unsigned int drm_waitvblank_pipe(struct drm_output *output)
+{
+ if (output->pipe > 1)
+ return (output->pipe << DRM_VBLANK_HIGH_CRTC_SHIFT) &
+ DRM_VBLANK_HIGH_CRTC_MASK;
+ else if (output->pipe > 0)
+ return DRM_VBLANK_SECONDARY;
+ else
+ return 0;
+}
+
static int
drm_output_repaint(struct weston_output *output_base,
pixman_region32_t *damage)
@@ -668,8 +679,7 @@
weston_log("setplane failed: %d: %s\n",
ret, strerror(errno));
- if (output->pipe > 0)
- vbl.request.type |= DRM_VBLANK_SECONDARY;
+ vbl.request.type |= drm_waitvblank_pipe(output);
/*
* Queue a vblank signal so we know when the surface