diff options
-rw-r--r-- | src/intel_device.c | 37 | ||||
-rw-r--r-- | src/intel_driver.h | 2 | ||||
-rw-r--r-- | src/intel_module.c | 16 |
3 files changed, 44 insertions, 11 deletions
diff --git a/src/intel_device.c b/src/intel_device.c index 17e00308..af1221bf 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -64,6 +64,31 @@ struct intel_device { static int intel_device_key = -1; +static int __intel_get_device_id(int fd) +{ + struct drm_i915_getparam gp; + int devid; + + gp.param = I915_PARAM_CHIPSET_ID; + gp.value = &devid; + + if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp))) + return 0; + + return devid; +} + +int intel_entity_get_devid(int index) +{ + struct intel_device *dev; + + dev = xf86GetEntityPrivate(index, intel_device_key)->ptr; + if (dev == NULL) + return 0; + + return __intel_get_device_id(dev->fd); +} + static inline struct intel_device *intel_device(ScrnInfoPtr scrn) { if (scrn->entityList == NULL) @@ -376,18 +401,8 @@ const char *intel_get_client_name(ScrnInfoPtr scrn) int intel_get_device_id(ScrnInfoPtr scrn) { struct intel_device *dev = intel_device(scrn); - struct drm_i915_getparam gp; - int devid; - assert(dev && dev->fd != -1); - - gp.param = I915_PARAM_CHIPSET_ID; - gp.value = &devid; - - if (ioctl(dev->fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp))) - return 0; - - return devid; + return __intel_get_device_id(dev->fd); } int intel_get_master(ScrnInfoPtr scrn) diff --git a/src/intel_driver.h b/src/intel_driver.h index 272f14e5..b2cb1b9f 100644 --- a/src/intel_driver.h +++ b/src/intel_driver.h @@ -118,6 +118,8 @@ struct intel_device_info { int gen; }; +int intel_entity_get_devid(int index); + void intel_detect_chipset(ScrnInfoPtr scrn, EntityInfoPtr ent); int intel_open_device(int entity_num, diff --git a/src/intel_module.c b/src/intel_module.c index e3367dce..d8cf9de6 100644 --- a/src/intel_module.c +++ b/src/intel_module.c @@ -454,6 +454,22 @@ intel_scrn_create(DriverPtr driver, { ScrnInfoPtr scrn; + if (match_data == 0) { + int devid = intel_entity_get_devid(entity_num), i; + if (devid == 0) + return FALSE; + + for (i = 0; intel_device_match[i].device_id != 0; i++) { + if (devid == intel_device_match[i].device_id) { + match_data = (intptr_t)&intel_device_match[i]; + break; + } + } + + if (match_data == 0) + return FALSE; + } + scrn = xf86AllocateScreen(driver, flags); if (scrn == NULL) return FALSE; |