1 /* 2 * Copyright 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <android-base/logging.h> 20 #include <android-base/unique_fd.h> 21 #include <xf86drm.h> 22 #include <xf86drmMode.h> 23 24 #include <cstdint> 25 #include <memory> 26 #include <string> 27 #include <unordered_map> 28 29 #include "Common.h" 30 #include "DrmProperty.h" 31 32 namespace aidl::android::hardware::graphics::composer3::impl { 33 34 class DrmCrtc { 35 public: 36 static std::unique_ptr<DrmCrtc> create(::android::base::borrowed_fd drmFd, uint32_t crtcId, 37 uint32_t crtcIndexInResourcesArray); ~DrmCrtc()38 ~DrmCrtc() {} 39 getId()40 uint32_t getId() const { return mId; } 41 getActiveProperty()42 const DrmProperty& getActiveProperty() const { return mActive; } getModeProperty()43 const DrmProperty& getModeProperty() const { return mMode; } getOutFenceProperty()44 const DrmProperty& getOutFenceProperty() const { return mOutFence; } 45 46 private: DrmCrtc(uint32_t id,uint32_t index)47 DrmCrtc(uint32_t id, uint32_t index) : mId(id), mIndexInResourcesArray(index) {} 48 49 friend class DrmPlane; 50 51 const uint32_t mId; 52 const uint32_t mIndexInResourcesArray; 53 54 DrmProperty mActive; 55 DrmProperty mMode; 56 DrmProperty mOutFence; 57 GetPropertiesMap()58 static const auto& GetPropertiesMap() { 59 static const auto* sMap = []() { 60 return new DrmPropertyMemberMap<DrmCrtc>{ 61 {"ACTIVE", &DrmCrtc::mActive}, 62 {"MODE_ID", &DrmCrtc::mMode}, 63 {"OUT_FENCE_PTR", &DrmCrtc::mOutFence}, 64 }; 65 }(); 66 return *sMap; 67 } 68 }; 69 70 } // namespace aidl::android::hardware::graphics::composer3::impl 71