mesa/src/panfrost/ds/pan_pps_perf.cpp
Boris Brezillon 446ec05fae panfrost: Make pan_perf panfrost_device agnostic
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
2024-01-23 16:32:09 +00:00

81 lines
1.3 KiB
C++

#include "pan_pps_perf.h"
#include <lib/kmod/pan_kmod.h>
#include <perf/pan_perf.h>
#include <pps/pps.h>
#include <util/ralloc.h>
namespace pps {
PanfrostDevice::PanfrostDevice(int fd): fd(fd)
{
assert(fd >= 0);
}
PanfrostDevice::~PanfrostDevice()
{
}
PanfrostDevice::PanfrostDevice(PanfrostDevice &&o): fd{o.fd}
{
o.fd = -1;
}
PanfrostDevice &
PanfrostDevice::operator=(PanfrostDevice &&o)
{
std::swap(fd, o.fd);
return *this;
}
PanfrostPerf::PanfrostPerf(const PanfrostDevice &dev)
: perf{reinterpret_cast<struct panfrost_perf *>(
rzalloc(nullptr, struct panfrost_perf))}
{
assert(perf);
assert(dev.fd >= 0);
panfrost_perf_init(perf, dev.fd);
}
PanfrostPerf::~PanfrostPerf()
{
if (perf) {
panfrost_perf_disable(perf);
ralloc_free(perf);
}
}
PanfrostPerf::PanfrostPerf(PanfrostPerf &&o): perf{o.perf}
{
o.perf = nullptr;
}
PanfrostPerf &
PanfrostPerf::operator=(PanfrostPerf &&o)
{
std::swap(perf, o.perf);
return *this;
}
int
PanfrostPerf::enable() const
{
assert(perf);
return panfrost_perf_enable(perf);
}
void
PanfrostPerf::disable() const
{
assert(perf);
panfrost_perf_disable(perf);
}
int
PanfrostPerf::dump() const
{
assert(perf);
return panfrost_perf_dump(perf);
}
} // namespace pps