2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-21 22:24:52 +08:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_neo.h"
|
|
|
|
#include "shared/source/os_interface/linux/os_time_linux.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "drm/i915_drm.h"
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class DrmNullDevice : public Drm {
|
|
|
|
|
|
|
|
public:
|
|
|
|
int ioctl(unsigned long request, void *arg) override {
|
|
|
|
if (request == DRM_IOCTL_I915_GETPARAM) {
|
|
|
|
return Drm::ioctl(request, arg);
|
|
|
|
} else if (request == DRM_IOCTL_I915_REG_READ) {
|
|
|
|
struct drm_i915_reg_read *regArg = static_cast<struct drm_i915_reg_read *>(arg);
|
|
|
|
|
|
|
|
// Handle only 36b timestamp
|
|
|
|
if (regArg->offset == (TIMESTAMP_LOW_REG | 1)) {
|
|
|
|
gpuTimestamp += 1000;
|
|
|
|
regArg->val = gpuTimestamp & 0x0000000FFFFFFFFF;
|
|
|
|
} else if (regArg->offset == TIMESTAMP_LOW_REG || regArg->offset == TIMESTAMP_HIGH_REG) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 00:43:02 +08:00
|
|
|
DrmNullDevice(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) : Drm(std::move(hwDeviceId), rootDeviceEnvironment), gpuTimestamp(0){};
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-01-30 18:23:22 +08:00
|
|
|
protected:
|
2017-12-21 07:45:38 +08:00
|
|
|
uint64_t gpuTimestamp;
|
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|