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 DISPLAY_ADAPTER_H 20 #define DISPLAY_ADAPTER_H 21 #include <memory> 22 #include <mutex> 23 #include <string> 24 #include "display_adapter_interface.h" 25 #include "display_module_loader.h" 26 27 namespace OHOS { 28 namespace HDI { 29 namespace DISPLAY { 30 using AdapterInitFunc = int32_t (*)(DisplayAdapterFuncs **funcs); 31 using AdapterDeInitFunc = int32_t (*)(DisplayAdapterFuncs *funcs); 32 33 class DisplayAdapter { 34 public: 35 static std::unique_ptr<DisplayAdapter> &GetInstance(); 36 virtual ~DisplayAdapter(); 37 38 int32_t Init(); 39 int32_t OpenDevice(const std::string &pathName, int32_t flags, mode_t mode); 40 int32_t CloseDevice(int32_t devFd); 41 int32_t Ioctl(int32_t devFd, uint32_t cmd, void *args); 42 int32_t FbGetDmaBuffer(int32_t devFd); 43 int32_t FbFresh(int32_t devFd, DisplayFrameInfo &frame); 44 45 private: 46 static constexpr const char *LIB_NAME_ADAPTER = "libdisplay_adapter_impl.z.so"; 47 static constexpr const char *INIT_FUNCTION_NAME = "DisplayAdapaterInitialize"; 48 static constexpr const char *DEINIT_FUNCTION_NAME = "DisplayAdapaterUninitialize"; 49 50 std::unique_ptr<DisplayModuleLoader> loader_; 51 DisplayAdapterFuncs *funcs_ = nullptr; 52 AdapterInitFunc initFunc_ = nullptr; 53 AdapterDeInitFunc deInitFunc_ = nullptr; 54 }; 55 } // namespace DISPLAY 56 } // namespace HDI 57 } // namespace OHOS 58 #endif // DISPLAY_ADAPTER_INTERFACE_H