tests/intel/xe_sriov_flr: Add flr-twice subtest
[drm/igt-gpu-tools.git] / lib / igt_power.h
blob853b0fae815ab810de042a0a52c3a17f3226eb46
1 /*
2 * Copyright © 2019 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
25 #ifndef IGT_POWER_H
26 #define IGT_POWER_H
28 #include <stdbool.h>
29 #include <stdint.h>
31 struct rapl {
32 uint64_t power, type;
33 double scale;
34 int fd;
37 struct power_sample {
38 uint64_t energy;
39 uint64_t time;
42 struct igt_power {
43 struct rapl rapl;
44 int hwmon_fd;
45 int bat_fd;
48 int igt_power_open(int i915, struct igt_power *p, const char *domain);
49 void igt_power_close(struct igt_power *p);
51 int igt_power_bat_open(struct igt_power *p, int index);
53 static inline bool igt_power_valid(struct igt_power *p)
55 return p->rapl.fd >= 0 || p->hwmon_fd >= 0 || p->bat_fd >= 0;
58 void igt_power_get_energy(struct igt_power *p, struct power_sample *s);
60 double igt_power_get_mJ(const struct igt_power *power,
61 const struct power_sample *p0,
62 const struct power_sample *p1);
63 double igt_power_get_mW(const struct igt_power *power,
64 const struct power_sample *p0,
65 const struct power_sample *p1);
66 double igt_power_get_s(const struct power_sample *p0,
67 const struct power_sample *p1);
68 #endif /* IGT_POWER_H */