From 027987b1fe91a496e1397d165ced6b3c7026aa06 Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Sun, 30 Jan 2022 21:06:35 +0200 Subject: drm_hwcomposer: Tidy-up DrmEncoder class Implement DrmEncoder instantiation through CreateInstance() static method, which helps to reduce complexity of DrmDevice::Init() function. Move Encoder-to-CRTC binding information to the DrmDevice class. Move drm/DrmEncoder.h to Normal clang-tidy checks list by fixing clang-tidy findings. Signed-off-by: Roman Stratiienko --- drm/DrmEncoder.h | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'drm/DrmEncoder.h') diff --git a/drm/DrmEncoder.h b/drm/DrmEncoder.h index a1f96d3..e66d6f1 100644 --- a/drm/DrmEncoder.h +++ b/drm/DrmEncoder.h @@ -29,31 +29,39 @@ namespace android { class DrmEncoder { public: - DrmEncoder(drmModeEncoderPtr e, DrmCrtc *current_crtc, - std::vector possible_crtcs); + static auto CreateInstance(DrmDevice &dev, uint32_t encoder_id, + uint32_t index) -> std::unique_ptr; + DrmEncoder(const DrmEncoder &) = delete; DrmEncoder &operator=(const DrmEncoder &) = delete; - uint32_t id() const; + auto GetId() const { + return enc_->encoder_id; + }; + + auto GetIndexInResArray() const { + return index_in_res_array_; + } - DrmCrtc *crtc() const; - void set_crtc(DrmCrtc *crtc, int display); - bool can_bind(int display) const; - int display() const; + auto CanClone(DrmEncoder &encoder) { + return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0; + } - const std::vector &possible_crtcs() const { - return possible_crtcs_; + auto SupportsCrtc(DrmCrtc &crtc) { + return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0; + } + + auto GetCurrentCrtcId() { + return enc_->crtc_id; } - bool CanClone(DrmEncoder *encoder); - void AddPossibleClone(DrmEncoder *possible_clone); private: - uint32_t id_; - DrmCrtc *crtc_; - int display_; + DrmEncoder(DrmModeEncoderUnique enc, uint32_t index) + : enc_(std::move(enc)), index_in_res_array_(index){}; + + DrmModeEncoderUnique enc_; - std::vector possible_crtcs_; - std::set possible_clones_; + const uint32_t index_in_res_array_; }; } // namespace android -- cgit v1.2.3