1 /* 2 * Copyright (C) 2021–2022 Beijing OSWare Technology Co., Ltd 3 * This file contains confidential and proprietary information of 4 * OSWare Technology Co., Ltd 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef HDI_DRM_COMPOSITION_H 20 #define HDI_DRM_COMPOSITION_H 21 #include <vector> 22 #include <memory> 23 #include <xf86drm.h> 24 #include <xf86drmMode.h> 25 #include "drm_device.h" 26 #include "hdi_composer.h" 27 #include "hdi_device_common.h" 28 #include "hdi_drm_layer.h" 29 30 namespace OHOS { 31 namespace HDI { 32 namespace DISPLAY { 33 class AtomicReqPtr { 34 public: AtomicReqPtr(drmModeAtomicReqPtr ptr)35 explicit AtomicReqPtr(drmModeAtomicReqPtr ptr) : mPtr(ptr) {} ~AtomicReqPtr()36 virtual ~AtomicReqPtr() 37 { 38 if (mPtr != nullptr) 39 drmModeAtomicFree(mPtr); 40 } Get()41 drmModeAtomicReqPtr Get() const 42 { 43 return mPtr; 44 } 45 46 private: 47 drmModeAtomicReqPtr mPtr; 48 }; 49 50 class HdiDrmComposition : public HdiComposition { 51 public: 52 HdiDrmComposition(std::shared_ptr<DrmConnector> &connector, std::shared_ptr<DrmCrtc> &crtc, 53 std::shared_ptr<DrmDevice> &drmDevice); ~HdiDrmComposition()54 virtual ~HdiDrmComposition() {} 55 int32_t Init(); 56 int32_t SetLayers(std::vector<HdiLayer *> &layers, HdiLayer &clientLayer); 57 int32_t Apply(bool modeSet); 58 int32_t UpdateMode(std::unique_ptr<DrmModeBlock> &modeBlock, drmModeAtomicReq &pset); 59 60 private: 61 int32_t ApplyPlane(HdiDrmLayer &layer, DrmPlane &drmPlane, drmModeAtomicReqPtr pset); 62 std::shared_ptr<DrmDevice> mDrmDevice; 63 std::shared_ptr<DrmConnector> mConnector; 64 std::shared_ptr<DrmCrtc> mCrtc; 65 std::vector<std::shared_ptr<DrmPlane>> mPrimPlanes; 66 std::vector<std::shared_ptr<DrmPlane>> mOverlayPlanes; 67 std::vector<std::shared_ptr<DrmPlane>> mPlanes; 68 }; 69 } // OHOS 70 } // HDI 71 } // DISPLAY 72 73 #endif // HDI_DRM_COMPOSITION_H