mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2026-08-23 06:13:04 +00:00
Search for the first Intel dri device.
This is vital in a multi-GPU system so that we only test the Intel card and not the discrete GPUs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
+28
-1
@@ -29,6 +29,23 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "drmtest.h"
|
||||
#include "i915_drm.h"
|
||||
#include "intel_chipset.h"
|
||||
|
||||
static int
|
||||
is_intel(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 IS_INTEL(devid);
|
||||
}
|
||||
|
||||
/** Open the first DRM device we can find, searching up to 16 device nodes */
|
||||
int drm_open_any(void)
|
||||
@@ -39,8 +56,13 @@ int drm_open_any(void)
|
||||
for (i = 0; i < 16; i++) {
|
||||
sprintf(name, "/dev/dri/card%d", i);
|
||||
fd = open(name, O_RDWR);
|
||||
if (fd != -1)
|
||||
if (fd == -1)
|
||||
continue;
|
||||
|
||||
if (is_intel(fd))
|
||||
return fd;
|
||||
|
||||
close(fd);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
@@ -63,6 +85,11 @@ int drm_open_any_master(void)
|
||||
if (fd == -1)
|
||||
continue;
|
||||
|
||||
if (!is_intel(fd)) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check that we're the only opener and authed. */
|
||||
client.idx = 0;
|
||||
ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
|
||||
|
||||
Reference in New Issue
Block a user