2019-03-27 19:44:49 +08:00
|
|
|
/*
|
2022-05-11 20:01:41 +08:00
|
|
|
* Copyright (C) 2019-2022 Intel Corporation
|
2019-03-27 19:44:49 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-03-17 14:26:46 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
2021-05-25 01:34:55 +08:00
|
|
|
#include "shared/source/os_interface/linux/hw_device_id.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2019-03-27 19:44:49 +08:00
|
|
|
|
2022-07-20 01:13:51 +08:00
|
|
|
#include <functional>
|
|
|
|
|
2019-03-27 19:44:49 +08:00
|
|
|
class DrmWrap : public NEO::Drm {
|
|
|
|
public:
|
2022-06-08 20:43:51 +08:00
|
|
|
using Drm::ioctlStatistics;
|
|
|
|
using Drm::queryDeviceIdAndRevision;
|
2020-07-14 10:36:16 +08:00
|
|
|
using Drm::virtualMemoryIds;
|
2022-07-20 01:13:51 +08:00
|
|
|
static std::unique_ptr<DrmWrap, std::function<void(Drm *)>> createDrm(RootDeviceEnvironment &rootDeviceEnvironment) {
|
2020-03-17 14:26:46 +08:00
|
|
|
auto hwDeviceIds = OSInterface::discoverDevices(rootDeviceEnvironment.executionEnvironment);
|
2020-02-17 23:14:22 +08:00
|
|
|
if (!hwDeviceIds.empty()) {
|
2022-07-20 01:13:51 +08:00
|
|
|
return std::unique_ptr<DrmWrap, std::function<void(Drm *)>>{static_cast<DrmWrap *>(NEO::Drm::create(std::unique_ptr<HwDeviceIdDrm>(hwDeviceIds[0].release()->as<HwDeviceIdDrm>()), rootDeviceEnvironment)), [](Drm *drm) {
|
|
|
|
drm->cleanup();
|
|
|
|
delete drm;
|
|
|
|
}};
|
2020-02-07 21:32:02 +08:00
|
|
|
}
|
|
|
|
return nullptr;
|
2019-03-27 19:44:49 +08:00
|
|
|
}
|
|
|
|
};
|
2022-06-08 20:43:51 +08:00
|
|
|
|
|
|
|
static_assert(sizeof(DrmWrap) == sizeof(NEO::Drm));
|