1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- Description: Reduce error spew on unsupported or hybrid hardware
- Explicitly check if the device is i915 before calling random ioctl()s
- to avoid triggering pointless user-visible error messages if it is not.
- Origin: upstream b70d65ba25a32a965cc122bf944ba14a1aa0a095
- Author: Mark Thompson
- --- a/src/intel/intel_driver.c
- +++ b/src/intel/intel_driver.c
- @@ -312,6 +312,26 @@ return ret;
- }
- #endif
-
- +static int
- +intel_driver_check_device(int dev_fd)
- +{
- + // Ensure that this is actually an i915 DRM device.
- + drmVersion *version;
- + int ret;
- + version = drmGetVersion(dev_fd);
- + if (!version) {
- + fprintf(stderr, "drmGetVersion(%d) failed: %s\n", dev_fd, strerror(errno));
- + close(dev_fd);
- + return 0;
- + }
- + ret = !strcmp(version->name, "i915");
- + drmFreeVersion(version);
- + // Don't print an error here if this device is using a different driver,
- + // because we might be iterating over multiple devices looking for a
- + // compatible one.
- + return ret;
- +}
- +
- LOCAL int
- intel_driver_init_master(intel_driver_t *driver, const char* dev_name)
- {
- @@ -326,6 +346,11 @@ if (dev_fd == -1) {
- return 0;
- }
-
- +if (!intel_driver_check_device(dev_fd)) {
- + close(dev_fd);
- + return 0;
- +}
- +
- // Check that we're authenticated
- memset(&client, 0, sizeof(drm_client_t));
- ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client);
- @@ -356,6 +381,11 @@ dev_fd = open(dev_name, O_RDWR);
- if (dev_fd == -1)
- return 0;
-
- +if (!intel_driver_check_device(dev_fd)) {
- + close(dev_fd);
- + return 0;
- +}
- +
- ret = intel_driver_init(driver, dev_fd);
- driver->need_close = 1;
-
|