[Glamor] [PATCH 15/15] glamor: check driver support GEM or not

zhigang.gong at linux.intel.com zhigang.gong at linux.intel.com
Fri Jan 20 00:52:13 PST 2012


From: Li Peng <peng.li at intel.com>

glamor calls DRM_IOCTL_GEM_FLINK to get a name for a buffer object.
It only works for driver that support GEM, such as intel i915 driver.
But for pvr driver who doesn't has GEM, we can't do it this way.

Here we check driver name to decide driver support GEM or not, if
it is pvr driver, mark it as False, otherwise it will be True.

Signed-off-by: Li Peng <peng.li at intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/glamor_egl.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/glamor_egl.c b/src/glamor_egl.c
index c273e8a..2a763f7 100644
--- a/src/glamor_egl.c
+++ b/src/glamor_egl.c
@@ -89,6 +89,7 @@ struct glamor_egl_screen_private {
 #ifdef GLAMOR_HAS_GBM
 	struct gbm_device *gbm;
 #endif
+	int has_gem;
 
 	PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
 	PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
@@ -200,12 +201,16 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
 
 	glamor_egl = glamor_egl_get_screen_private(scrn);
 
-	if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Couldn't flink pixmap handle\n");
-		glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
-		exit(1);
-	}
+	if (glamor_egl->has_gem) {
+		if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
+			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+				   "Couldn't flink pixmap handle\n");
+			glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
+			exit(1);
+		}
+	} else
+		name = handle;
+
 	image = _glamor_egl_create_image(glamor_egl,
 					 pixmap->drawable.width,
 					 pixmap->drawable.height,
@@ -312,6 +317,12 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 	glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)fd);
 #endif
 
+	if (scrn->driverName != NULL &&
+	    !strcmp(scrn->driverName, "pvr"))
+		glamor_egl->has_gem = 0;
+	else
+		glamor_egl->has_gem = 1;
+
 #ifndef GLAMOR_GLES2
 	eglBindAPI(EGL_OPENGL_API);
 #else
-- 
1.7.4.4



More information about the Glamor mailing list