Skip to contentSkip to conversation

Check that the drm fd is i915 before calling i915 ioctls on it

PATCH New Adam Jackson 1 participant 1 message Aug 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check that the drm fd is i915 before calling i915 ioctls on it

---
 src/intel_module.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
src/intel_module.c +10 -4
index edea48d..be9688a 100644
@@ -392,11 +392,17 @@ static Bool has_kernel_mode_setting(struct pci_device *dev)
 	ret = FALSE;
 	fd = drmOpen(NULL, id);
 	if (fd != -1) {
-		struct drm_i915_getparam gp;
+		drmVersionPtr v;
 
-		gp.param = I915_PARAM_HAS_GEM;
-		gp.value = &ret;
-		(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		v = drmGetVersion(fd);
+		if (v && !strcmp(v->name, "i915")) {
+			struct drm_i915_getparam gp;
+
+			gp.param = I915_PARAM_HAS_GEM;
+			gp.value = &ret;
+			(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		}
+		drmFreeVersion(v);
 		close(fd);
 	}
 
Signature · 1 line
1.7.7.6