1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_HDI_DISPLAY_BUFFER_V1_0_ALLOCATOR_SERVICE_H 17 #define OHOS_HDI_DISPLAY_BUFFER_V1_0_ALLOCATOR_SERVICE_H 18 19 #include "idisplay_buffer_vdi.h" 20 #include "v1_0/display_buffer_type.h" 21 #include "v1_0/iallocator.h" 22 #include <mutex> 23 24 namespace OHOS { 25 namespace HDI { 26 namespace Display { 27 namespace Buffer { 28 namespace V1_0 { 29 class AllocatorService : public IAllocator { 30 public: 31 AllocatorService(); 32 virtual ~AllocatorService(); 33 int32_t AllocMem(const AllocInfo& info, sptr<NativeBuffer>& handle) override; 34 35 private: 36 int32_t LoadVdi(); 37 void FreeMemVdi(BufferHandle* handle); 38 void WriteAllocPidToDma(int32_t fd); 39 std::mutex mutex_; 40 void *libHandle_; 41 IDisplayBufferVdi *vdiImpl_; 42 CreateDisplayBufferVdiFunc createVdi_; 43 DestroyDisplayBufferVdiFunc destroyVdi_; 44 }; 45 } // namespace V1_0 46 } // namespace Buffer 47 } // namespace Display 48 } // namespace HDI 49 } // namespace OHOS 50 #endif // OHOS_HDI_DISPLAY_BUFFER_V1_0_ALLOCATOR_SERVICE_H 51