drm_hwcomposer: Rename DrmDisplayCompositor->DrmAtomicStateManager
Primary responsibilities of this class are:
1. Send composition/mode/active state over DRM atomic commit IOCTL
to the kernel
2. Track commit state and keep planes owned by the Pipeline while they
are either displayed or staged for displaying.
3. Keep framebuffers alive while they are in use or staged.
Not much related to composition itself, therefore rename it to
DrmAtomicStateManager and move it to drm folder.
Bump clang-tidy level of DrmAtomicStateManager.c to normal by fixing
minor clang-tidy findings.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/.ci/Makefile b/.ci/Makefile
index a9b96d3..cadbde6 100644
--- a/.ci/Makefile
+++ b/.ci/Makefile
@@ -21,7 +21,6 @@
bufferinfo/legacy/BufferInfoMaliMediatek.cpp:COARSE \
bufferinfo/legacy/BufferInfoMaliMeson.cpp:COARSE \
bufferinfo/legacy/BufferInfoMinigbm.cpp:COARSE \
- compositor/DrmDisplayCompositor.cpp:COARSE \
drm/DrmFbImporter.h:FINE \
drm/DrmMode.h:COARSE \
drm/DrmProperty.h:COARSE \
diff --git a/Android.bp b/Android.bp
index 77a2644..8b6d295 100644
--- a/Android.bp
+++ b/Android.bp
@@ -84,9 +84,9 @@
"bufferinfo/BufferInfoGetter.cpp",
"bufferinfo/BufferInfoMapperMetadata.cpp",
- "compositor/DrmDisplayCompositor.cpp",
"compositor/DrmKmsPlan.cpp",
+ "drm/DrmAtomicStateManager.cpp",
"drm/DrmConnector.cpp",
"drm/DrmCrtc.cpp",
"drm/DrmDevice.cpp",
diff --git a/compositor/DrmDisplayCompositor.cpp b/drm/DrmAtomicStateManager.cpp
similarity index 90%
rename from compositor/DrmDisplayCompositor.cpp
rename to drm/DrmAtomicStateManager.cpp
index e588b7f..65fb19e 100644
--- a/compositor/DrmDisplayCompositor.cpp
+++ b/drm/DrmAtomicStateManager.cpp
@@ -15,9 +15,9 @@
*/
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
-#define LOG_TAG "hwc-drm-display-compositor"
+#define LOG_TAG "hwc-drm-atomic-state-manager"
-#include "DrmDisplayCompositor.h"
+#include "DrmAtomicStateManager.h"
#include <drm/drm_mode.h>
#include <pthread.h>
@@ -40,7 +40,7 @@
namespace android {
// NOLINTNEXTLINE (readability-function-cognitive-complexity): Fixme
-auto DrmDisplayCompositor::CommitFrame(AtomicCommitArgs &args) -> int {
+auto DrmAtomicStateManager::CommitFrame(AtomicCommitArgs &args) -> int {
ATRACE_CALL();
if (args.active && *args.active == active_frame_state_.crtc_active_state) {
@@ -72,13 +72,13 @@
int64_t out_fence = -1;
if (crtc->GetOutFencePtrProperty() &&
- !crtc->GetOutFencePtrProperty().AtomicSet(*pset, (uint64_t)&out_fence)) {
+ !crtc->GetOutFencePtrProperty().AtomicSet(*pset, uint64_t(&out_fence))) {
return -EINVAL;
}
if (args.active) {
new_frame_state.crtc_active_state = *args.active;
- if (!crtc->GetActiveProperty().AtomicSet(*pset, *args.active) ||
+ if (!crtc->GetActiveProperty().AtomicSet(*pset, *args.active ? 1 : 0) ||
!connector->GetCrtcIdProperty().AtomicSet(*pset, crtc->GetId())) {
return -EINVAL;
}
@@ -134,7 +134,7 @@
flags |= DRM_MODE_ATOMIC_TEST_ONLY;
int err = drmModeAtomicCommit(drm->GetFd(), pset.get(), flags, drm);
- if (err) {
+ if (err != 0) {
if (!args.test_only)
ALOGE("Failed to commit pset ret=%d\n", err);
return err;
@@ -157,18 +157,18 @@
return 0;
}
-auto DrmDisplayCompositor::ExecuteAtomicCommit(AtomicCommitArgs &args) -> int {
+auto DrmAtomicStateManager::ExecuteAtomicCommit(AtomicCommitArgs &args) -> int {
int err = CommitFrame(args);
if (!args.test_only) {
- if (err) {
+ if (err != 0) {
ALOGE("Composite failed for pipeline %s",
pipe_->connector->Get()->GetName().c_str());
// Disable the hw used by the last active composition. This allows us to
// signal the release fences from that composition to avoid hanging.
AtomicCommitArgs cl_args{};
cl_args.composition = std::make_shared<DrmKmsPlan>();
- if (CommitFrame(cl_args)) {
+ if (CommitFrame(cl_args) != 0) {
ALOGE("Failed to clean-up active composition for pipeline %s",
pipe_->connector->Get()->GetName().c_str());
}
@@ -179,7 +179,7 @@
return err;
} // namespace android
-auto DrmDisplayCompositor::ActivateDisplayUsingDPMS() -> int {
+auto DrmAtomicStateManager::ActivateDisplayUsingDPMS() -> int {
return drmModeConnectorSetProperty(pipe_->device->GetFd(),
pipe_->connector->Get()->GetId(),
pipe_->connector->Get()
diff --git a/compositor/DrmDisplayCompositor.h b/drm/DrmAtomicStateManager.h
similarity index 86%
rename from compositor/DrmDisplayCompositor.h
rename to drm/DrmAtomicStateManager.h
index 7e39eef..08a1c13 100644
--- a/compositor/DrmDisplayCompositor.h
+++ b/drm/DrmAtomicStateManager.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ANDROID_DRM_DISPLAY_COMPOSITOR_H_
-#define ANDROID_DRM_DISPLAY_COMPOSITOR_H_
+#ifndef ANDROID_DRM_ATOMIC_STATE_MANAGER_H_
+#define ANDROID_DRM_ATOMIC_STATE_MANAGER_H_
#include <pthread.h>
@@ -25,7 +25,7 @@
#include <sstream>
#include <tuple>
-#include "DrmKmsPlan.h"
+#include "compositor/DrmKmsPlan.h"
#include "drm/DrmPlane.h"
#include "drm/ResourceManager.h"
#include "drm/VSyncWorker.h"
@@ -49,15 +49,13 @@
}
};
-class DrmDisplayCompositor {
+class DrmAtomicStateManager {
public:
- explicit DrmDisplayCompositor(DrmDisplayPipeline *pipe) : pipe_(pipe){};
- ~DrmDisplayCompositor() = default;
+ explicit DrmAtomicStateManager(DrmDisplayPipeline *pipe) : pipe_(pipe){};
+ DrmAtomicStateManager(const DrmAtomicStateManager &) = delete;
+ ~DrmAtomicStateManager() = default;
auto ExecuteAtomicCommit(AtomicCommitArgs &args) -> int;
-
- DrmDisplayCompositor(const DrmDisplayCompositor &) = delete;
-
auto ActivateDisplayUsingDPMS() -> int;
private:
diff --git a/drm/DrmDevice.cpp b/drm/DrmDevice.cpp
index e5f41e8..fd4589e 100644
--- a/drm/DrmDevice.cpp
+++ b/drm/DrmDevice.cpp
@@ -26,7 +26,7 @@
#include <cstdint>
#include <string>
-#include "compositor/DrmDisplayCompositor.h"
+#include "drm/DrmAtomicStateManager.h"
#include "drm/DrmPlane.h"
#include "utils/log.h"
#include "utils/properties.h"
diff --git a/drm/DrmDisplayPipeline.cpp b/drm/DrmDisplayPipeline.cpp
index 31bc764..f993d28 100644
--- a/drm/DrmDisplayPipeline.cpp
+++ b/drm/DrmDisplayPipeline.cpp
@@ -18,12 +18,12 @@
#include "DrmDisplayPipeline.h"
+#include "DrmAtomicStateManager.h"
#include "DrmConnector.h"
#include "DrmCrtc.h"
#include "DrmDevice.h"
#include "DrmEncoder.h"
#include "DrmPlane.h"
-#include "compositor/DrmDisplayCompositor.h"
#include "utils/log.h"
#include "utils/properties.h"
@@ -98,7 +98,8 @@
return {};
}
- pipe->compositor = std::make_unique<DrmDisplayCompositor>(pipe.get());
+ pipe->atomic_state_manager = std::make_unique<DrmAtomicStateManager>(
+ pipe.get());
return pipe;
}
diff --git a/drm/DrmDisplayPipeline.h b/drm/DrmDisplayPipeline.h
index f055c85..7ec619e 100644
--- a/drm/DrmDisplayPipeline.h
+++ b/drm/DrmDisplayPipeline.h
@@ -27,7 +27,7 @@
class DrmPlane;
class DrmCrtc;
class DrmEncoder;
-class DrmDisplayCompositor;
+class DrmAtomicStateManager;
struct DrmDisplayPipeline;
@@ -82,7 +82,7 @@
std::shared_ptr<BindingOwner<DrmCrtc>> crtc;
std::shared_ptr<BindingOwner<DrmPlane>> primary_plane;
- std::unique_ptr<DrmDisplayCompositor> compositor;
+ std::unique_ptr<DrmAtomicStateManager> atomic_state_manager;
};
} // namespace android
diff --git a/drm/ResourceManager.cpp b/drm/ResourceManager.cpp
index b294180..c8235e9 100644
--- a/drm/ResourceManager.cpp
+++ b/drm/ResourceManager.cpp
@@ -25,7 +25,7 @@
#include <sstream>
#include "bufferinfo/BufferInfoGetter.h"
-#include "compositor/DrmDisplayCompositor.h"
+#include "drm/DrmAtomicStateManager.h"
#include "drm/DrmDevice.h"
#include "drm/DrmDisplayPipeline.h"
#include "drm/DrmPlane.h"
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index e02019d..3f00fbf 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -501,7 +501,7 @@
a_args.composition = current_plan_;
- int ret = GetPipe().compositor->ExecuteAtomicCommit(a_args);
+ int ret = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
if (ret) {
if (!a_args.test_only)
@@ -655,7 +655,7 @@
* true, as the next composition frame will implicitly activate
* the display
*/
- return GetPipe().compositor->ActivateDisplayUsingDPMS() == 0
+ return GetPipe().atomic_state_manager->ActivateDisplayUsingDPMS() == 0
? HWC2::Error::None
: HWC2::Error::BadParameter;
break;
@@ -667,7 +667,7 @@
return HWC2::Error::BadParameter;
};
- int err = GetPipe().compositor->ExecuteAtomicCommit(a_args);
+ int err = GetPipe().atomic_state_manager->ExecuteAtomicCommit(a_args);
if (err) {
ALOGE("Failed to apply the dpms composition err=%d", err);
return HWC2::Error::BadParameter;
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index ed29da6..ae5d980 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -22,7 +22,7 @@
#include <optional>
#include "HwcDisplayConfigs.h"
-#include "compositor/DrmDisplayCompositor.h"
+#include "drm/DrmAtomicStateManager.h"
#include "drm/ResourceManager.h"
#include "drm/VSyncWorker.h"
#include "drmhwcomposer.h"