From f1894f3239f417bfade0bb2bcdefc5e43701c5ec Mon Sep 17 00:00:00 2001 From: Nicholas Kazlauskas Date: Fri, 15 Mar 2019 11:04:40 -0400 Subject: lib/drmtest: Add helpers to check and require amdgpu These helpers will be used to address amdgpu specific quirks and features. They're implemented like the i915 and VC4 helpers. In order for the string comparison to pick up "amdgpu" the buffer size had to be expanded for __is_device. I've gone ahead and made it 12 bytes to cover everything that's there right now. v2: rebase Cc: Leo Li Cc: Harry Wentland Signed-off-by: Nicholas Kazlauskas Reviewed-by: Harry Wentland --- lib/drmtest.c | 12 +++++++++++- lib/drmtest.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/drmtest.c b/lib/drmtest.c index 25eeab88..d31ade3f 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -93,7 +93,7 @@ static int __get_drm_device_name(int fd, char *name, int name_size) static bool __is_device(int fd, const char *expect) { - char name[5] = ""; + char name[12] = ""; if (__get_drm_device_name(fd, name, sizeof(name) - 1)) return false; @@ -101,6 +101,11 @@ static bool __is_device(int fd, const char *expect) return strcmp(expect, name) == 0; } +bool is_amdgpu_device(int fd) +{ + return __is_device(fd, "amdgpu"); +} + bool is_i915_device(int fd) { return __is_device(fd, "i915"); @@ -445,6 +450,11 @@ int drm_open_driver_render(int chipset) return fd; } +void igt_require_amdgpu(int fd) +{ + igt_require(is_amdgpu_device(fd)); +} + void igt_require_intel(int fd) { igt_require(is_i915_device(fd) && has_known_intel_chipset(fd)); diff --git a/lib/drmtest.h b/lib/drmtest.h index f4401ac9..71d197f3 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -78,9 +78,11 @@ int __drm_open_driver(int chipset); void gem_quiescent_gpu(int fd); +void igt_require_amdgpu(int fd); void igt_require_intel(int fd); void igt_require_vc4(int fd); +bool is_amdgpu_device(int fd); bool is_i915_device(int fd); bool is_vc4_device(int fd); -- cgit v1.2.3