]>
Commit | Line | Data |
---|---|---|
7d3d7cb5 JB |
1 | Description: Reduce error spew on unsupported or hybrid hardware |
2 | ||
3 | Explicitly check if the device is i915 before calling random ioctl()s | |
4 | to avoid triggering pointless user-visible error messages if it is not. | |
5 | ||
6 | Origin: upstream b70d65ba25a32a965cc122bf944ba14a1aa0a095 | |
7 | Author: Mark Thompson | |
8 | ||
9 | --- a/src/intel/intel_driver.c | |
10 | +++ b/src/intel/intel_driver.c | |
11 | @@ -312,6 +312,26 @@ return ret; | |
12 | } | |
13 | #endif | |
14 | ||
15 | +static int | |
16 | +intel_driver_check_device(int dev_fd) | |
17 | +{ | |
18 | + // Ensure that this is actually an i915 DRM device. | |
19 | + drmVersion *version; | |
20 | + int ret; | |
21 | + version = drmGetVersion(dev_fd); | |
22 | + if (!version) { | |
23 | + fprintf(stderr, "drmGetVersion(%d) failed: %s\n", dev_fd, strerror(errno)); | |
24 | + close(dev_fd); | |
25 | + return 0; | |
26 | + } | |
27 | + ret = !strcmp(version->name, "i915"); | |
28 | + drmFreeVersion(version); | |
29 | + // Don't print an error here if this device is using a different driver, | |
30 | + // because we might be iterating over multiple devices looking for a | |
31 | + // compatible one. | |
32 | + return ret; | |
33 | +} | |
34 | + | |
35 | LOCAL int | |
36 | intel_driver_init_master(intel_driver_t *driver, const char* dev_name) | |
37 | { | |
38 | @@ -326,6 +346,11 @@ if (dev_fd == -1) { | |
39 | return 0; | |
40 | } | |
41 | ||
42 | +if (!intel_driver_check_device(dev_fd)) { | |
43 | + close(dev_fd); | |
44 | + return 0; | |
45 | +} | |
46 | + | |
47 | // Check that we're authenticated | |
48 | memset(&client, 0, sizeof(drm_client_t)); | |
49 | ret = ioctl(dev_fd, DRM_IOCTL_GET_CLIENT, &client); | |
50 | @@ -356,6 +381,11 @@ dev_fd = open(dev_name, O_RDWR); | |
51 | if (dev_fd == -1) | |
52 | return 0; | |
53 | ||
54 | +if (!intel_driver_check_device(dev_fd)) { | |
55 | + close(dev_fd); | |
56 | + return 0; | |
57 | +} | |
58 | + | |
59 | ret = intel_driver_init(driver, dev_fd); | |
60 | driver->need_close = 1; | |
61 |