1 /* 2 * Copyright © 2021 Collabora, Ltd. 3 * Author: Antonio Caggiano <antonio.caggiano@collabora.com> 4 * 5 * SPDX-License-Identifier: MIT 6 */ 7 8 #pragma once 9 10 #include <optional> 11 #include <string> 12 #include <vector> 13 14 #include <intel/dev/intel_device_info.h> 15 #include <intel/perf/intel_perf.h> 16 #include <intel/perf/intel_perf_query.h> 17 18 namespace pps 19 { 20 int perf_ioctl(int fd, unsigned long request, void *arg); 21 22 class IntelPerf 23 { 24 public: 25 IntelPerf(int drm_fd); 26 27 IntelPerf(const IntelPerf &) = delete; 28 IntelPerf &operator=(const IntelPerf &) = delete; 29 30 IntelPerf(IntelPerf &&); 31 IntelPerf &operator=(IntelPerf &&) noexcept; 32 33 ~IntelPerf(); 34 35 std::optional<struct intel_perf_query_info> find_query_by_name(const std::string &name) const; 36 37 std::vector<struct intel_perf_query_info*> get_queries() const; 38 39 bool open(uint64_t sampling_period_ns); 40 void close(); 41 42 bool oa_stream_ready() const; 43 ssize_t read_oa_stream(void *buf, size_t bytes) const; 44 45 int drm_fd = -1; 46 47 void *ralloc_ctx = nullptr; 48 void *ralloc_cfg = nullptr; 49 50 struct intel_perf_context *ctx = nullptr; 51 struct intel_perf_config *cfg = nullptr; 52 53 struct intel_device_info devinfo = {}; 54 55 std::optional<struct intel_perf_query_info> query = std::nullopt; 56 }; 57 58 } // namespace pps 59