From 10be875de071672e61a52ab0679bbc6803df8c51 Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Sun, 30 Jan 2022 20:28:46 +0200 Subject: drm_hwcomposer: Tidy-up DrmCrtc class Implement DrmCrtc instantiation through CreateInstance() static method, which helps to reduce complexity of DrmDevice::Init() function. Move CRTC-to-Display binding information to the DrmDevice class. Move drm/DrmCrtc.h to Normal clang-tidy checks list by fixing clang-tidy findings. Signed-off-by: Roman Stratiienko --- drm/DrmCrtc.h | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'drm/DrmCrtc.h') diff --git a/drm/DrmCrtc.h b/drm/DrmCrtc.h index 85e067a..42fc9f9 100644 --- a/drm/DrmCrtc.h +++ b/drm/DrmCrtc.h @@ -23,6 +23,7 @@ #include "DrmMode.h" #include "DrmProperty.h" +#include "DrmUnique.h" namespace android { @@ -30,32 +31,40 @@ class DrmDevice; class DrmCrtc { public: - DrmCrtc(DrmDevice *drm, drmModeCrtcPtr c, unsigned pipe); + static auto CreateInstance(DrmDevice &dev, uint32_t crtc_id, uint32_t index) + -> std::unique_ptr; + + DrmCrtc() = delete; DrmCrtc(const DrmCrtc &) = delete; DrmCrtc &operator=(const DrmCrtc &) = delete; - int Init(); + auto GetId() const { + return crtc_->crtc_id; + } - uint32_t id() const; - unsigned pipe() const; + auto GetIndexInResArray() const { + return index_in_res_array_; + } - int display() const; - void set_display(int display); + auto &GetActiveProperty() const { + return active_property_; + } - bool can_bind(int display) const; + auto &GetModeProperty() const { + return mode_property_; + } - const DrmProperty &active_property() const; - const DrmProperty &mode_property() const; - const DrmProperty &out_fence_ptr_property() const; + auto &GetOutFencePtrProperty() const { + return out_fence_ptr_property_; + } private: - DrmDevice *drm_; + DrmCrtc(DrmModeCrtcUnique crtc, uint32_t index) + : crtc_(std::move(crtc)), index_in_res_array_(index){}; - uint32_t id_; - unsigned pipe_; - int display_; + DrmModeCrtcUnique crtc_; - DrmMode mode_; + const uint32_t index_in_res_array_; DrmProperty active_property_; DrmProperty mode_property_; -- cgit v1.2.3