Blob Blame History Raw
From ae0394e687f1a77e966cf72f895da91840dffb8f Mon Sep 17 00:00:00 2001
From: Rob Clark <rob@ti.com>
Date: Tue, 23 Oct 2012 16:01:37 -0500
Subject: [PATCH] fix issue on pre-rotation kernel

If kernel does not support rotation, then we should simply not use
rotation, rather than just failing.

Signed-off-by: Rob Clark <rob@ti.com>
---
 src/drmmode_display.c | 7 ++++++-
 src/omap_driver.h     | 6 ++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 91c48c5..c3cf4f8 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -225,9 +225,11 @@ drmmode_set_rotation(xf86CrtcPtr crtc, Rotation rotation)
 {
 #if XF86_CRTC_VERSION >= 4
 	ScrnInfoPtr pScrn = crtc->scrn;
+	OMAPPtr pOMAP = OMAPPTR(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-	if (!(rotation & ~SUPPORTED_ROTATIONS)) {
+	if (has_rotation(pOMAP) &&
+			!(rotation & ~SUPPORTED_ROTATIONS)) {
 		int ret;
 
 		ret = drmModeObjectSetProperty(drmmode_crtc->drmmode->fd,
@@ -616,6 +618,7 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
 static void
 drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 {
+	OMAPPtr pOMAP = OMAPPTR(pScrn);
 	drmModeObjectPropertiesPtr props;
 	xf86CrtcPtr crtc;
 	drmmode_crtc_private_ptr drmmode_crtc;
@@ -631,6 +634,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 			drmmode->mode_res->crtcs[num]);
 	drmmode_crtc->drmmode = drmmode;
 	drmmode_crtc->rotation = RR_Rotate_0;
+	drmmode_crtc->prop_rotation = 0;
 
 	/* find properties that we care about: */
 	props = drmModeObjectGetProperties(drmmode->fd,
@@ -642,6 +646,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 			prop = drmModeGetProperty(drmmode->fd, props->props[i]);
 			if (!strcmp(prop->name, "rotation")) {
 				drmmode_crtc->prop_rotation = prop->prop_id;
+				pOMAP->rotation_supported = TRUE;
 			}
 			drmModeFreeProperty(prop);
 		}
diff --git a/src/omap_driver.h b/src/omap_driver.h
index 850515d..6d2517e 100644
--- a/src/omap_driver.h
+++ b/src/omap_driver.h
@@ -149,6 +149,9 @@ typedef struct _OMAPRec
 	int					scanout_w, scanout_h;
 	Bool				scanout_rotate;
 
+	/** Does kernel support rotation? */
+	Bool				rotation_supported;
+
 	/** Pointer to the options for this screen. */
 	OptionInfoPtr		pOptionInfo;
 
@@ -187,8 +190,7 @@ static inline Bool has_dmm(OMAPPtr pOMAP)
 static inline Bool has_rotation(OMAPPtr pOMAP)
 {
 #if XF86_CRTC_VERSION >= 4
-	// TODO .. should somehow check if driver has rotation property..
-	return has_dmm(pOMAP);
+	return has_dmm(pOMAP) && pOMAP->rotation_supported;
 #else
 	return FALSE;
 #endif
-- 
1.7.11.7