diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-09-13 17:38:16 +0100 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-11-22 11:17:48 +0000 |
commit | a688deceae195aec863d8de45bdaefb251927c89 (patch) | |
tree | 80f916af851ea53ad295a525efa58e8661e176d1 /lib/igt_perf.c | |
parent | 42ee3f94f2c5c3258930c22da7c1b497dd635346 (diff) |
intel-gpu-overlay: Move local perf implementation to a library
Idea is to avoid duplication across multiple users in
upcoming patches.
v2: Commit message and use a separate library instead of piggy-
backing to libintel_tools. (Chris Wilson)
v3: Add Petri's meson build recipe.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_perf.c')
-rw-r--r-- | lib/igt_perf.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/igt_perf.c b/lib/igt_perf.c new file mode 100644 index 00000000..45cccff0 --- /dev/null +++ b/lib/igt_perf.c @@ -0,0 +1,26 @@ +#include <stdint.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> + +#include "igt_perf.h" + +uint64_t i915_type_id(void) +{ + char buf[1024]; + int fd, n; + + fd = open("/sys/bus/event_source/devices/i915/type", 0); + if (fd < 0) { + n = -1; + } else { + n = read(fd, buf, sizeof(buf)-1); + close(fd); + } + if (n < 0) + return 0; + + buf[n] = '\0'; + return strtoull(buf, 0, 0); +} + |