diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-27 11:20:43 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-27 12:31:13 +0100 |
commit | 1c3fd70357a57f823846010f59ba75f19e5d4af9 (patch) | |
tree | e3ef96d481a5c1d59782dab6c1b38c7e712adcd1 /overlay/perf.c | |
parent | 6ec1d2c0ae631a3c0af445d4baa53561228be9a5 (diff) |
overlay: Read power from perf_events
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/perf.c')
-rw-r--r-- | overlay/perf.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/overlay/perf.c b/overlay/perf.c new file mode 100644 index 00000000..b8fdc675 --- /dev/null +++ b/overlay/perf.c @@ -0,0 +1,26 @@ +#include <stdint.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> + +#include "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); +} + |