1
0
Fork 0

drm_hwcomposer: Add buildflag guards around libsync deps

This change adds the buildflag HAS_LIBSYNC for managing
availability of libsync. This is necessary for the
unittests target for which libsync doesn't provide the
necessary variant.

DrmAtomicStateManager.cpp is the only file which depends
on libsync. Guards have been added using the HAS_LIBSYNC
flag, such that any method which would depend on libsync
is now stubbed when it is unavailable.

Change-Id: I101083074a9fad98e1c40c27b55f2eddf1c53581
This commit is contained in:
Andrew Wolfers 2025-10-01 16:33:31 +00:00
parent 87ffe73cd7
commit ff954db228
3 changed files with 16 additions and 0 deletions

View file

@ -22,7 +22,9 @@
#include "DrmAtomicStateManager.h"
#include <drm/drm_mode.h>
#if HAS_LIBSYNC
#include <sync/sync.h>
#endif // HAS_LIBSYNC
#include <utils/Trace.h>
#include <cassert>
@ -52,6 +54,7 @@ DrmAtomicStateManager::~DrmAtomicStateManager() {
}
void DrmAtomicStateManager::WaitLastFrame() {
#if HAS_LIBSYNC
SharedFd present_fence;
{
std::lock_guard lock(mutex_);
@ -75,6 +78,7 @@ void DrmAtomicStateManager::WaitLastFrame() {
CleanupPriorFrameResources();
}
}
#endif // HAS_LIBSYNC
}
void DrmAtomicStateManager::CleanFailedCommit() {
@ -201,6 +205,7 @@ void DrmAtomicStateManager::CheckDoubleSettingState(
}
}
#if HAS_LIBSYNC
bool DrmAtomicStateManager::SetWriteBackFenceIfNeeded(
const AtomicCommitArgs &args, AtomicRequest &request) {
if (!pipe_->writeback_connector || !args.writeback_fb) {
@ -240,6 +245,13 @@ bool DrmAtomicStateManager::SetWriteBackFenceIfNeeded(
return true;
}
#else
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
bool DrmAtomicStateManager::SetWriteBackFenceIfNeeded(
const AtomicCommitArgs & /* args */, AtomicRequest & /* request */) {
return false;
}
#endif // HAS_LIBSYNC
bool DrmAtomicStateManager::SetOutputFence(AtomicRequest &request) {
auto *crtc = pipe_->crtc->Get();
@ -509,6 +521,7 @@ DrmAtomicStateManager::GetAtomicModeReqForArgs(AtomicCommitArgs &args) {
}
void DrmAtomicStateManager::ThreadFn() {
#if HAS_LIBSYNC
int tracking_at_the_moment = -1;
for (;;) {
@ -555,6 +568,7 @@ void DrmAtomicStateManager::ThreadFn() {
}
ALOGI("DrmAtomicStateManager thread exit");
#endif // HAS_LIBSYNC
}
void DrmAtomicStateManager::CleanupPriorFrameResources() {