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 <optional> 26 #include <unordered_map> 27 28 #include "Common.h" 29 30 namespace aidl::android::hardware::graphics::composer3::impl { 31 32 class DrmClient; 33 34 // A RAII object that will clear a drm framebuffer upon destruction. 35 class DrmBuffer { 36 public: 37 ~DrmBuffer(); 38 39 DrmBuffer(const DrmBuffer&) = delete; 40 DrmBuffer& operator=(const DrmBuffer&) = delete; 41 42 DrmBuffer(DrmBuffer&&) = delete; 43 DrmBuffer& operator=(DrmBuffer&&) = delete; 44 45 private: 46 friend class DrmClient; 47 friend class DrmDisplay; 48 DrmBuffer(DrmClient& drmClient); 49 50 DrmClient& mDrmClient; 51 52 uint32_t mWidth = 0; 53 uint32_t mHeight = 0; 54 uint32_t mDrmFormat = 0; 55 int32_t mPlaneFds[4] = {0, 0, 0, 0}; 56 uint32_t mPlaneHandles[4] = {0, 0, 0, 0}; 57 uint32_t mPlanePitches[4] = {0, 0, 0, 0}; 58 uint32_t mPlaneOffsets[4] = {0, 0, 0, 0}; 59 std::optional<uint32_t> mDrmFramebuffer; 60 }; 61 62 } // namespace aidl::android::hardware::graphics::composer3::impl 63