diff --git a/display/buffer/v1_2/IMapper.idl b/display/buffer/v1_2/IMapper.idl index fe01d210d560418d165fe7d9eab51b50b509cd36..eadb5a709091116ad3def6a1dd251feb2c84a1a1 100644 --- a/display/buffer/v1_2/IMapper.idl +++ b/display/buffer/v1_2/IMapper.idl @@ -14,6 +14,7 @@ */ package ohos.hdi.display.buffer.v1_2; +import ohos.hdi.display.buffer.v1_0.DisplayBufferType; import ohos.hdi.display.buffer.v1_2.DisplayBufferType; import ohos.hdi.display.buffer.v1_0.IMapper; diff --git a/display/buffer/v1_3/BUILD.gn b/display/buffer/v1_3/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5d69e281fe0c0099c186fad31d305e29e739ba82 --- /dev/null +++ b/display/buffer/v1_3/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/config/components/hdi/hdi.gni") + +hdi("display_buffer") { + module_name = "display_buffer" + + proxy_deps = [ + "//drivers/interface/display/buffer/v1_0:libdisplay_buffer_proxy_1.0", + "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_proxy_1.1", + "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_proxy_1.2" + ] + stub_deps = [ + "//drivers/interface/display/buffer/v1_0:libdisplay_buffer_stub_1.0", + "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_stub_1.1", + "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_stub_1.2" + ] + + sources = [ + "IMapper.idl", + ] + innerapi_tags = [ + "chipsetsdk_indirect", + "platformsdk_indirect", + ] + + branch_protector_ret = "pac_ret" + + language = "cpp" + subsystem_name = "hdf" + part_name = "drivers_interface_display" +} + +config("libdisplay_buffer_hdi_impl_config") { + include_dirs = [ "./../" ] +} + +ohos_shared_library("libdisplay_buffer_hdi_impl_v1_3") { + sources = [ + "../v1_0/hdi_impl/display_buffer_hdi_impl.cpp", + "../v1_1/hdi_impl/display_buffer_hdi_impl.cpp", + "../v1_2/hdi_impl/display_buffer_hdi_impl.cpp", + "./hdi_impl/display_buffer_hdi_impl.cpp", + ] + + public_configs = [ ":libdisplay_buffer_hdi_impl_config" ] + + deps = [ + ":libdisplay_buffer_proxy_1.3", + "../v1_0:libdisplay_buffer_proxy_1.0", + "../v1_1:libdisplay_buffer_proxy_1.1", + "../v1_2:libdisplay_buffer_proxy_1.2", + ] + + external_deps = [ + "c_utils:utils", + "graphic_surface:buffer_handle", + "hdf_core:libhdi", + "hdf_core:libpub_utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_single", + ] + + install_images = [ "system" ] + subsystem_name = "hdf" + innerapi_tags = [ + "chipsetsdk", + "platformsdk_indirect", + ] + + branch_protector_ret = "pac_ret" + + part_name = "drivers_interface_display" +} diff --git a/display/buffer/v1_3/IMapper.idl b/display/buffer/v1_3/IMapper.idl new file mode 100644 index 0000000000000000000000000000000000000000..318ce3049e3bfb377da2b30fc735237b14732ad0 --- /dev/null +++ b/display/buffer/v1_3/IMapper.idl @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ohos.hdi.display.buffer.v1_3; +import ohos.hdi.display.buffer.v1_0.DisplayBufferType; +import ohos.hdi.display.buffer.v1_2.DisplayBufferType; +import ohos.hdi.display.buffer.v1_2.IMapper; + +interface IMapper extends ohos.hdi.display.buffer.v1_2.IMapper { + /** + * @brief get iamge position + * + * @param handle The input buffer handle + * @param layout the iamge position data + * + * @return Returns 0 if the operation is successful; returns an error code defined + * in {@link DispErrCode} otherwise. + * @since 6.0 + * @version 1.3 + */ + AllocMem([in] struct AllocInfo info, [out] NativeBuffer handle); + IsSupportAllocPassthrough([in] struct AllocInfo info); +} diff --git a/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cc8c3954f07a1bfc9d65c491dd1f67f8b5343b1a --- /dev/null +++ b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "display_buffer_hdi_impl.h" +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +using namespace OHOS::HDI::Display::Buffer::V1_3; +IDisplayBuffer *IDisplayBuffer::Get() +{ + IDisplayBuffer *instance = new V1_3::HdiDisplayBufferImpl(); + if (instance == nullptr) { + return nullptr; + } + return instance; +} + +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS diff --git a/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..bba4ccb8f36f39f2dc96e36bcbb1db4ee2c0a14c --- /dev/null +++ b/display/buffer/v1_3/hdi_impl/display_buffer_hdi_impl.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H +#define OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H + +#include +#include +#include "hdf_log.h" +#include "hilog/log.h" +#include "v1_0/imapper.h" +#include "v1_2/imapper.h" +#include "v1_3/imapper.h" +#include "v1_1/include/idisplay_buffer.h" +#include "v1_2/include/idisplay_buffer.h" +#include "v1_3/include/idisplay_buffer.h" +#include "v1_0/hdi_impl/display_buffer_hdi_impl.h" +#include "v1_1/hdi_impl/display_buffer_hdi_impl.h" +#include "v1_2/hdi_impl/display_buffer_hdi_impl.h" + +#undef LOG_TAG +#define LOG_TAG "DISP_HDI_BUFF" +#undef LOG_DOMAIN +#define LOG_DOMAIN 0xD002515 + +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +template +class DisplayBufferHdiImpl : public V1_2::DisplayBufferHdiImpl { +public: + explicit DisplayBufferHdiImpl(bool isAllocLocal = false) : BaseType3_0(isAllocLocal), mapper_v1_3_(nullptr) + { + while ((mapper_v1_3_ = IMapper::Get(true)) == nullptr) { + // Waiting for metadata service ready + usleep(WAIT_TIME_INTERVAL); + } + } + + virtual ~DisplayBufferHdiImpl() {}; + + int32_t AllocMemPassThrough(const AllocInfo& info, BufferHandle*& handle) const + { + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(mapper_v1_3_, HDF_FAILURE); + sptr hdiBuffer; + int32_t ret = mapper_v1_3_->AllocMem(info, hdiBuffer); + if ((ret == HDF_SUCCESS) && (hdiBuffer != nullptr)) { + handle = hdiBuffer->Move(); + } else { + handle = nullptr; + if (ret == HDF_SUCCESS) { + ret = HDF_FAILURE; + } + HDF_LOGE("%{public}s: AllocMem error", __func__); + } + return ret; + } + + int32_t AllocMemIpc(const AllocInfo& info, BufferHandle*& handle) const + { + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(allocator_, HDF_FAILURE); + sptr hdiBuffer; + int32_t ret = allocator_->AllocMem(info, hdiBuffer); + if ((ret == HDF_SUCCESS) && (hdiBuffer != nullptr)) { + handle = hdiBuffer->Move(); + } else { + handle = nullptr; + if (ret == HDF_SUCCESS) { + ret = HDF_FAILURE; + } + HDF_LOGE("%{public}s: AllocMem error", __func__); + } + return ret; + } + + int32_t AllocMem(const AllocInfo& info, BufferHandle*& handle) const override + { + DISPLAY_TRACE; + CHECK_NULLPOINTER_RETURN_VALUE(mapper_v1_3_, HDF_FAILURE); + + //Step1. check is support alloc passthrough + if (mapper_v1_3_->IsSupportAllocPassthrough(info) == HDF_SUCCESS) { + int32_t ret = AllocMemPassThrough(info, handle); + if (ret != HDF_SUCCESS) { + HDF_LOGW("%{public}s: AllocMem Passthrough mode failed, use allocator_host", __func__); + return AllocMemIpc(info, handle); + } + return ret; + } else { + return AllocMemIpc(info, handle); + } + } + +private: + using BaseType3_0 = V1_2::DisplayBufferHdiImpl; +protected: + using BaseType3_0::WAIT_TIME_INTERVAL; + using BaseType3_0::allocator_; + sptr mapper_v1_3_; +}; +using HdiDisplayBufferImpl = DisplayBufferHdiImpl; +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS + +#endif // OHOS_HDI_DISPLAY_V1_3_DISPLAY_BUFFER_HDI_IMPL_H diff --git a/display/buffer/v1_3/include/idisplay_buffer.h b/display/buffer/v1_3/include/idisplay_buffer.h new file mode 100644 index 0000000000000000000000000000000000000000..881ddf9379ff441da928c5a8642d1120c857d834 --- /dev/null +++ b/display/buffer/v1_3/include/idisplay_buffer.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H +#define OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H + +#include "v1_0/include/idisplay_buffer.h" +#include "v1_1/include/idisplay_buffer.h" +#include "v1_2/include/idisplay_buffer.h" + +namespace OHOS { +namespace HDI { +namespace Display { +namespace Buffer { +namespace V1_3 { +class IDisplayBuffer : public V1_2::IDisplayBuffer { +public: + virtual ~IDisplayBuffer() = default; + + /** + * @brief Obtains all interfaces of IDisplayBuffer. + * + * @return Returns IDisplayBuffer* if the operation is successful; returns an null point otherwise. + * @since 5.0 + * @version 1.2 + */ + static IDisplayBuffer *Get(); + virtual int32_t AllocMem(const V1_0::AllocInfo& info, BufferHandle*& handle) const = 0; +}; +} // namespace V1_3 +} // namespace Buffer +} // namespace Display +} // namespace HDI +} // namespace OHOS + +#endif // OHOS_HDI_DISPLAY_V1_3_IDISPLAY_BUFFER_H diff --git a/display/bundle.json b/display/bundle.json index 7643e8326e8a80a61ae71b4b4c3d8bd3fa5e4416..300344cc98792f115fad1df3b2b348cd04748b33 100644 --- a/display/bundle.json +++ b/display/bundle.json @@ -46,6 +46,8 @@ "//drivers/interface/display/buffer/v1_1:libdisplay_buffer_hdi_impl_v1_1", "//drivers/interface/display/buffer/v1_2:display_buffer_idl_target", "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_hdi_impl_v1_2", + "//drivers/interface/display/buffer/v1_3:display_buffer_idl_target", + "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_hdi_impl_v1_3", "//drivers/interface/display/composer/cache_manager:libcomposer_buffer_cache", "//drivers/interface/display/composer/v1_0:display_composer_idl_target", "//drivers/interface/display/composer/v1_1:display_composer_idl_target", @@ -131,7 +133,7 @@ "header_base": "//drivers/interface/display/buffer" } }, - { + { "name": "//drivers/interface/display/buffer/v1_2:libdisplay_buffer_proxy_1.2", "header": { "header_files": [ @@ -163,6 +165,38 @@ "header_base": "//drivers/interface/display/buffer" } }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_proxy_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_stub_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:display_buffer_idl_headers_1.3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, + { + "name": "//drivers/interface/display/buffer/v1_3:libdisplay_buffer_hdi_impl_v1_3", + "header": { + "header_files": [ + ], + "header_base": "//drivers/interface/display/buffer" + } + }, { "name": "//drivers/interface/display/composer/cache_manager:libcomposer_buffer_cache", "header": {