This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gralloc: Add allocator and mapper HALs
Implement the hidl .hal interfaces directly instead of using the default shims. This is required since new additions to .hal will no longer be added to the legacy gralloc1 C header. Change-Id: If577a14f75d7d13da0ff656c96ab451d21c910ce
- Loading branch information
Showing
29 changed files
with
1,765 additions
and
1,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,16 @@ LOCAL_MODULE := gralloc.$(TARGET_BOARD_PLATFORM) | |
LOCAL_VENDOR_MODULE := true | ||
LOCAL_MODULE_RELATIVE_PATH := hw | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_C_INCLUDES := $(common_includes) \ | ||
external/libcxx/include/ \ | ||
system/core/libion/include/ \ | ||
system/core/libion/kernel-headers/ \ | ||
$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include | ||
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes) | ||
|
||
LOCAL_HEADER_LIBRARIES := display_headers | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) libqdMetaData libsync libgrallocutils libion | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wall -std=c++11 -Werror | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) libqdMetaData libsync libgrallocutils \ | ||
libgralloccore \ | ||
[email protected] | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wall -Werror | ||
LOCAL_CLANG := true | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps) | ||
LOCAL_SRC_FILES := gr_ion_alloc.cpp \ | ||
gr_allocator.cpp \ | ||
gr_buf_mgr.cpp \ | ||
gr_device_impl.cpp | ||
LOCAL_SRC_FILES := gr_device_impl.cpp | ||
LOCAL_COPY_HEADERS_TO := $(common_header_export_path) | ||
LOCAL_COPY_HEADERS := gr_device_impl.h gralloc_priv.h gr_priv_handle.h | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
@@ -33,8 +28,85 @@ LOCAL_VENDOR_MODULE := true | |
LOCAL_MODULE_TAGS := optional | ||
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes) | ||
LOCAL_HEADER_LIBRARIES := display_headers | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) libqdMetaData libdl | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"grallocutils\" -Wno-sign-conversion | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps) | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) libqdMetaData libdl \ | ||
[email protected] | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) | ||
LOCAL_SRC_FILES := gr_utils.cpp gr_adreno_info.cpp | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
#libgralloccore | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := libgralloccore | ||
LOCAL_VENDOR_MODULE := true | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_C_INCLUDES := $(common_includes) \ | ||
system/core/libion/include \ | ||
system/core/libion/kernel-headers \ | ||
$(kernel_includes) | ||
|
||
LOCAL_HEADER_LIBRARIES := display_headers | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) libqdMetaData libdl libgrallocutils libion \ | ||
[email protected] | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) $(kernel_deps) | ||
LOCAL_SRC_FILES := gr_allocator.cpp gr_buf_mgr.cpp gr_ion_alloc.cpp | ||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
|
||
qti_mapper_version := $(shell \ | ||
if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/mapper/1.0" ];\ | ||
then echo QTI_MAPPER_1_0; fi) | ||
|
||
qti_allocator_version := $(shell \ | ||
if [ -d "$(TOP)/vendor/qcom/opensource/interfaces/display/allocator/1.0" ];\ | ||
then echo QTI_ALLOCATOR_1_0; fi) | ||
|
||
|
||
ifeq ($(qti_mapper_version), QTI_MAPPER_1_0) | ||
#mapper | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := [email protected] | ||
LOCAL_VENDOR_MODULE := true | ||
LOCAL_MODULE_RELATIVE_PATH := hw | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes) | ||
LOCAL_HEADER_LIBRARIES := display_headers | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) \ | ||
libhidlbase \ | ||
libhidltransport \ | ||
libqdMetaData \ | ||
libgrallocutils \ | ||
libgralloccore \ | ||
libsync \ | ||
[email protected] \ | ||
[email protected] | ||
LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdgralloc\" -Wno-sign-conversion | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) | ||
LOCAL_SRC_FILES := QtiMapper.cpp | ||
include $(BUILD_SHARED_LIBRARY) | ||
endif # QTI_MAPPER_1_0 | ||
|
||
ifeq ($(qti_allocator_version), QTI_ALLOCATOR_1_0) | ||
#allocator service | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := [email protected] | ||
LOCAL_VENDOR_MODULE := true | ||
LOCAL_MODULE_RELATIVE_PATH := hw | ||
LOCAL_MODULE_TAGS := optional | ||
LOCAL_HEADER_LIBRARIES := display_headers | ||
LOCAL_SHARED_LIBRARIES := $(common_libs) \ | ||
libhidlbase \ | ||
libhidltransport\ | ||
libqdMetaData \ | ||
libgrallocutils \ | ||
libgralloccore \ | ||
[email protected] \ | ||
[email protected] | ||
LOCAL_CFLAGS := -DLOG_TAG=\"qdgralloc\" $(common_flags) | ||
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) | ||
LOCAL_C_INCLUDES := $(common_includes) $(kernel_includes) | ||
LOCAL_SRC_FILES := QtiAllocator.cpp service.cpp | ||
LOCAL_INIT_RC := [email protected] | ||
include $(BUILD_EXECUTABLE) | ||
endif # QTI_ALLOCATOR_1_0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright (c) 2018, The Linux Foundation. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of The Linux Foundation. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#define DEBUG 0 | ||
#include "QtiAllocator.h" | ||
|
||
#include <log/log.h> | ||
#include <vector> | ||
|
||
#include "gr_utils.h" | ||
|
||
namespace vendor { | ||
namespace qti { | ||
namespace hardware { | ||
namespace display { | ||
namespace allocator { | ||
namespace V1_0 { | ||
namespace implementation { | ||
|
||
using android::hardware::hidl_handle; | ||
using gralloc::BufferDescriptor; | ||
|
||
QtiAllocator::QtiAllocator() { | ||
buf_mgr_ = BufferManager::GetInstance(); | ||
} | ||
|
||
// Methods from ::android::hardware::graphics::allocator::V2_0::IAllocator follow. | ||
Return<void> QtiAllocator::dumpDebugInfo(dumpDebugInfo_cb hidl_cb) { | ||
std::ostringstream os; | ||
buf_mgr_->Dump(&os); | ||
hidl_string reply; | ||
reply.setToExternal(os.str().c_str(), os.str().length()); | ||
hidl_cb(reply); | ||
return Void(); | ||
} | ||
|
||
Return<void> QtiAllocator::allocate(const hidl_vec<uint32_t> &descriptor, uint32_t count, | ||
allocate_cb hidl_cb) { | ||
ALOGD_IF(DEBUG, "Allocating buffers count: %d", count); | ||
gralloc::BufferDescriptor desc; | ||
|
||
auto err = desc.Decode(descriptor); | ||
if (err != Error::NONE) { | ||
hidl_cb(err, 0, hidl_vec<hidl_handle>()); | ||
return Void(); | ||
} | ||
|
||
std::vector<hidl_handle> buffers; | ||
buffers.reserve(count); | ||
for (uint32_t i = 0; i < count; i++) { | ||
buffer_handle_t buffer; | ||
ALOGD_IF(DEBUG, "buffer: %p", &buffer); | ||
err = buf_mgr_->AllocateBuffer(desc, &buffer); | ||
if (err != Error::NONE) { | ||
break; | ||
} | ||
buffers.emplace_back(hidl_handle(buffer)); | ||
} | ||
|
||
uint32_t stride = 0; | ||
hidl_vec<hidl_handle> hidl_buffers; | ||
if (err == Error::NONE && buffers.size() > 0) { | ||
stride = static_cast<uint32_t>(PRIV_HANDLE_CONST(buffers[0].getNativeHandle())->width); | ||
hidl_buffers.setToExternal(buffers.data(), buffers.size()); | ||
} | ||
hidl_cb(err, stride, hidl_buffers); | ||
|
||
for (const auto &b : buffers) { | ||
buf_mgr_->ReleaseBuffer(PRIV_HANDLE_CONST(b.getNativeHandle())); | ||
} | ||
|
||
return Void(); | ||
} | ||
|
||
// Methods from ::android::hidl::base::V1_0::IBase follow. | ||
|
||
IQtiAllocator *HIDL_FETCH_IQtiAllocator(const char * /* name */) { | ||
return new QtiAllocator(); | ||
} | ||
|
||
} // namespace implementation | ||
} // namespace V1_0 | ||
} // namespace allocator | ||
} // namespace display | ||
} // namespace hardware | ||
} // namespace qti | ||
} // namespace vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2018, The Linux Foundation. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of The Linux Foundation. nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED | ||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef __QTIALLOCATOR_H__ | ||
#define __QTIALLOCATOR_H__ | ||
|
||
#include <hidl/MQDescriptor.h> | ||
#include <hidl/Status.h> | ||
#include <vendor/qti/hardware/display/allocator/1.0/IQtiAllocator.h> | ||
|
||
#include "gr_buf_mgr.h" | ||
|
||
namespace vendor { | ||
namespace qti { | ||
namespace hardware { | ||
namespace display { | ||
namespace allocator { | ||
namespace V1_0 { | ||
namespace implementation { | ||
|
||
using ::android::hardware::Return; | ||
using ::android::hardware::Void; | ||
using ::android::hardware::graphics::allocator::V2_0::IAllocator; | ||
using ::android::hardware::graphics::mapper::V2_0::Error; | ||
using ::android::hardware::hidl_array; | ||
using ::android::hardware::hidl_memory; | ||
using ::android::hardware::hidl_string; | ||
using ::android::hardware::hidl_vec; | ||
using ::android::hidl::base::V1_0::DebugInfo; | ||
using ::android::hidl::base::V1_0::IBase; | ||
using ::android::sp; | ||
using ::vendor::qti::hardware::display::allocator::V1_0::IQtiAllocator; | ||
using gralloc::BufferManager; | ||
|
||
class QtiAllocator : public IQtiAllocator { | ||
public: | ||
QtiAllocator(); | ||
// Methods from ::android::hardware::graphics::allocator::V2_0::IAllocator follow. | ||
Return<void> dumpDebugInfo(dumpDebugInfo_cb _hidl_cb) override; | ||
Return<void> allocate(const hidl_vec<uint32_t> &descriptor, uint32_t count, | ||
allocate_cb _hidl_cb) override; | ||
|
||
// Methods from ::android::hidl::base::V1_0::IBase follow. | ||
private: | ||
BufferManager *buf_mgr_ = nullptr; | ||
}; | ||
|
||
extern "C" IQtiAllocator *HIDL_FETCH_IQtiAllocator(const char *name); | ||
|
||
} // namespace implementation | ||
} // namespace V1_0 | ||
} // namespace allocator | ||
} // namespace display | ||
} // namespace hardware | ||
} // namespace qti | ||
} // namespace vendor | ||
|
||
#endif // __QTIALLOCATOR_H__ |
Oops, something went wrong.