| 1 |
/* |
| 2 |
* Copyright 2023 Google |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#include "DrmSync.h" |
| 7 |
|
| 8 |
#include <unistd.h> |
| 9 |
|
| 10 |
#include "util/libsync.h" |
| 11 |
#include "util/log.h" |
| 12 |
#include "util/macros.h" |
| 13 |
#include "util/u_process.h" |
| 14 |
|
| 15 |
namespace gfxstream { |
| 16 |
|
| 17 |
DrmSyncHelper::DrmSyncHelper() {} |
| 18 |
|
| 19 |
int DrmSyncHelper::wait(int syncFd, int timeoutMilliseconds) { |
| 20 |
return sync_wait(syncFd, timeoutMilliseconds); |
| 21 |
} |
| 22 |
|
| 23 |
void DrmSyncHelper::debugPrint(int syncFd) { |
| 24 |
struct sync_file_info* info = sync_file_info(syncFd); |
| 25 |
if (!info) { |
| 26 |
mesa_loge("failed to get sync file info"); |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
struct sync_fence_info* fence_info = (struct sync_fence_info*)info->sync_fence_info; |
| 31 |
|
| 32 |
for (uint32_t i = 0; i < info->num_fences; i++) { |
| 33 |
uint64_t time_ms = DIV_ROUND_UP(fence_info[i].timestamp_ns, 1e6); |
| 34 |
mesa_logi("[%s] Fence: %s, status: %i, timestamp (ms): %llu", util_get_process_name(), |
| 35 |
info->name, fence_info[i].status, (unsigned long long)time_ms); |
| 36 |
} |
| 37 |
|
| 38 |
free(info); |
| 39 |
} |
| 40 |
|
| 41 |
int DrmSyncHelper::dup(int syncFd) { return ::dup(syncFd); } |
| 42 |
|
| 43 |
int DrmSyncHelper::close(int syncFd) { return ::close(syncFd); } |
| 44 |
|
| 45 |
SyncHelper* osCreateSyncHelper() { return new DrmSyncHelper(); } |
| 46 |
|
| 47 |
} // namespace gfxstream |