diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-20 17:03:16 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-20 17:05:14 +0100 |
commit | ae6b3c7508d570af94f172d6a91d62d2987d654b (patch) | |
tree | 80c67848f39b3d91c081c6dc5b3fddb390796ec2 | |
parent | 3c611087e8ae09fc3fe4271f16d912ac8ae89f6b (diff) |
Check that the module that indeed i915 before using custom ioctls
Thanks to Adam Jackson for pointing me towards drmGetVersion() and
Julien Cristau for saying "Yuck!"
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/intel_module.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/intel_module.c b/src/intel_module.c index edea48d8..e5f98d4c 100644 --- a/src/intel_module.c +++ b/src/intel_module.c @@ -392,11 +392,19 @@ 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 version = drmGetVersion(fd); + if (version) { + ret = strcmp ("i915", version->name) == 0; + drmFreeVersion(version); + } + if (ret) { + struct drm_i915_getparam gp; + gp.param = I915_PARAM_HAS_GEM; + gp.value = &ret; + if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) + ret = FALSE; + } - gp.param = I915_PARAM_HAS_GEM; - gp.value = &ret; - (void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); close(fd); } |