From 577abb767e0f9afc329b220ec68a9280892b9f1a Mon Sep 17 00:00:00 2001 From: Devika Krishnadas Date: Tue, 9 Jan 2024 23:23:10 +0000 Subject: Revert^3 "gralloc4: Upgrade Allocator to AIDL2" 8e6973cbaabd9c038e69082699d330462492463d Reverting to comply with the Allocator VTS for 24Q1, do not merge to main. Bug: 310046460 Test: VtsHalGraphicsAllocatorAidl_TargetTest (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:489c3e2ea97618ab8c93b81e80c4f0ceb0851af7) Merged-In: I42820f1a2a618bd3973bbf1833996c04b43b4dbd Change-Id: I42820f1a2a618bd3973bbf1833996c04b43b4dbd --- gralloc4/service/aidl/Android.bp | 4 +- ...oid.hardware.graphics.allocator-aidl-service.rc | 2 +- gralloc4/service/aidl/manifest_gralloc_aidl.xml | 1 - gralloc4/src/aidl/Android.bp | 2 +- gralloc4/src/aidl/GrallocAllocator.cpp | 90 +--------------------- gralloc4/src/aidl/GrallocAllocator.h | 11 --- gralloc4/src/hidl_common/Allocator.cpp | 5 -- gralloc4/src/hidl_common/Allocator.h | 2 - 8 files changed, 5 insertions(+), 112 deletions(-) diff --git a/gralloc4/service/aidl/Android.bp b/gralloc4/service/aidl/Android.bp index ea6e461..a3d7a87 100644 --- a/gralloc4/service/aidl/Android.bp +++ b/gralloc4/service/aidl/Android.bp @@ -3,7 +3,7 @@ package { } cc_binary { - name: "android.hardware.graphics.allocator-V2-service", + name: "android.hardware.graphics.allocator-V1-service", proprietary: true, relative_install_path: "hw", srcs: [ @@ -17,7 +17,7 @@ cc_binary { "libgralloc_headers", ], shared_libs: [ - "android.hardware.graphics.allocator-V2-ndk", + "android.hardware.graphics.allocator-V1-ndk", "android.hardware.graphics.allocator-aidl-impl", "libbinder_ndk", "liblog", diff --git a/gralloc4/service/aidl/android.hardware.graphics.allocator-aidl-service.rc b/gralloc4/service/aidl/android.hardware.graphics.allocator-aidl-service.rc index 723fab6..e86b68d 100644 --- a/gralloc4/service/aidl/android.hardware.graphics.allocator-aidl-service.rc +++ b/gralloc4/service/aidl/android.hardware.graphics.allocator-aidl-service.rc @@ -1,4 +1,4 @@ -service vendor.graphics.allocator-default /vendor/bin/hw/android.hardware.graphics.allocator-V2-service +service vendor.graphics.allocator-default /vendor/bin/hw/android.hardware.graphics.allocator-V1-service class hal animation user system group graphics drmrpc diff --git a/gralloc4/service/aidl/manifest_gralloc_aidl.xml b/gralloc4/service/aidl/manifest_gralloc_aidl.xml index c29d370..6848a99 100644 --- a/gralloc4/service/aidl/manifest_gralloc_aidl.xml +++ b/gralloc4/service/aidl/manifest_gralloc_aidl.xml @@ -1,7 +1,6 @@ android.hardware.graphics.allocator - 2 IAllocator/default diff --git a/gralloc4/src/aidl/Android.bp b/gralloc4/src/aidl/Android.bp index 3c0fc26..e2d9d04 100644 --- a/gralloc4/src/aidl/Android.bp +++ b/gralloc4/src/aidl/Android.bp @@ -10,7 +10,7 @@ cc_library_shared { "arm_gralloc_api_4x_defaults", ], shared_libs: [ - "android.hardware.graphics.allocator-V2-ndk", + "android.hardware.graphics.allocator-V1-ndk", "android.hardware.graphics.allocator@4.0", "android.hardware.graphics.mapper@4.0", "libbinder_ndk", diff --git a/gralloc4/src/aidl/GrallocAllocator.cpp b/gralloc4/src/aidl/GrallocAllocator.cpp index 2b01b80..fb1d5b7 100644 --- a/gralloc4/src/aidl/GrallocAllocator.cpp +++ b/gralloc4/src/aidl/GrallocAllocator.cpp @@ -7,6 +7,7 @@ #include #include +#include "allocator/mali_gralloc_ion.h" #include "hidl_common/Allocator.h" namespace pixel::allocator { @@ -87,95 +88,6 @@ ndk::ScopedAStatus GrallocAllocator::allocate(const std::vector& descri return ndk::ScopedAStatus::ok(); } -buffer_descriptor_t decodeBufferDescriptorInfo( - const AidlAllocator::BufferDescriptorInfo& descriptor) { - buffer_descriptor_t bufferDescriptor; - bufferDescriptor.width = descriptor.width; - bufferDescriptor.height = descriptor.height; - bufferDescriptor.layer_count = descriptor.layerCount; - bufferDescriptor.hal_format = static_cast(descriptor.format); - bufferDescriptor.producer_usage = static_cast(descriptor.usage); - bufferDescriptor.consumer_usage = bufferDescriptor.producer_usage; - bufferDescriptor.format_type = MALI_GRALLOC_FORMAT_TYPE_USAGE; - bufferDescriptor.signature = sizeof(buffer_descriptor_t); - bufferDescriptor.reserved_size = descriptor.reservedSize; - const char *str = (const char*) descriptor.name.data(); - bufferDescriptor.name = std::string(str); - return bufferDescriptor; -} - -ndk::ScopedAStatus GrallocAllocator::allocate2( - const AidlAllocator::BufferDescriptorInfo& descriptor, int32_t count, - AidlAllocator::AllocationResult* result) { - MALI_GRALLOC_LOGV("Allocation request from process: %lu", callingPid()); - - buffer_descriptor_t bufferDescriptor = decodeBufferDescriptorInfo(descriptor); - - HidlError error = HidlError::NONE; - auto hidl_cb = [&](HidlError _error, int _stride, hidl_vec _buffers) { - if (_error != HidlError::NONE) { - error = _error; - return; - } - - const uint32_t size = _buffers.size(); - - result->stride = _stride; - result->buffers.resize(size); - for (uint32_t i = 0; i < size; i++) { - // Dup here is necessary. After this callback returns common::allocate - // will free the buffer which will destroy the older fd. - result->buffers[i] = android::dupToAidl(static_cast(_buffers[i])); - } - }; - - arm::allocator::common::allocate(bufferDescriptor, count, hidl_cb); - - switch (error) { - case HidlError::NONE: - break; - - case HidlError::BAD_DESCRIPTOR: - return ndk::ScopedAStatus::fromServiceSpecificError( - static_cast(AidlAllocator::AllocationError::BAD_DESCRIPTOR)); - - case HidlError::NO_RESOURCES: - return ndk::ScopedAStatus::fromServiceSpecificError( - static_cast(AidlAllocator::AllocationError::NO_RESOURCES)); - - case HidlError::UNSUPPORTED: - return ndk::ScopedAStatus::fromServiceSpecificError( - static_cast(AidlAllocator::AllocationError::UNSUPPORTED)); - - default: - return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_ERROR); - } - - return ndk::ScopedAStatus::ok(); -} - -// TODO(b/315883761): isSupported should return false for unknown-to-HAL usage -ndk::ScopedAStatus GrallocAllocator::isSupported( - const AidlAllocator::BufferDescriptorInfo& descriptor, bool* result) { - buffer_descriptor_t bufferDescriptor = decodeBufferDescriptorInfo(descriptor); - - int isBufferDescriptorSupported = arm::allocator::common::isSupported(&bufferDescriptor); - *result = (isBufferDescriptorSupported == 0); - - if (isBufferDescriptorSupported) { - MALI_GRALLOC_LOGV("Allocation for the given description will not succeed. error %d", - isBufferDescriptorSupported); - return ndk::ScopedAStatus::fromServiceSpecificError( - static_cast(AidlAllocator::AllocationError::UNSUPPORTED)); - } - return ndk::ScopedAStatus::ok(); -} - -ndk::ScopedAStatus GrallocAllocator::getIMapperLibrarySuffix(std::string* result) { - *result = ""; - return ndk::ScopedAStatus::fromStatus(STATUS_UNKNOWN_ERROR); -} - binder_status_t GrallocAllocator::dump(int fd, const char** /* args */, uint32_t numArgs) { if (callingUid() != AID_ROOT) { const std::string permission_denied = "Permission Denied\n"; diff --git a/gralloc4/src/aidl/GrallocAllocator.h b/gralloc4/src/aidl/GrallocAllocator.h index 91655a7..dadd4b9 100644 --- a/gralloc4/src/aidl/GrallocAllocator.h +++ b/gralloc4/src/aidl/GrallocAllocator.h @@ -2,11 +2,9 @@ #include #include -#include #include #include -#include #include namespace pixel { @@ -23,15 +21,6 @@ public: virtual ndk::ScopedAStatus allocate(const std::vector& descriptor, int32_t count, AidlAllocator::AllocationResult* result) override; - virtual ndk::ScopedAStatus allocate2(const AidlAllocator::BufferDescriptorInfo& descriptor, - int32_t count, - AidlAllocator::AllocationResult* result) override; - - virtual ndk::ScopedAStatus isSupported(const AidlAllocator::BufferDescriptorInfo& descriptor, - bool* result) override; - - virtual ndk::ScopedAStatus getIMapperLibrarySuffix(std::string* result) override; - virtual binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; }; diff --git a/gralloc4/src/hidl_common/Allocator.cpp b/gralloc4/src/hidl_common/Allocator.cpp index 08f2e8e..d854255 100644 --- a/gralloc4/src/hidl_common/Allocator.cpp +++ b/gralloc4/src/hidl_common/Allocator.cpp @@ -245,11 +245,6 @@ const std::string dump() { return ss.str(); } -int isSupported(buffer_descriptor_t *const bufDescriptor) { - // this is used as the criteria to determine which allocations succeed. - return mali_gralloc_derive_format_and_size(bufDescriptor); -} - } // namespace common } // namespace allocator } // namespace arm diff --git a/gralloc4/src/hidl_common/Allocator.h b/gralloc4/src/hidl_common/Allocator.h index e5ce174..079457c 100644 --- a/gralloc4/src/hidl_common/Allocator.h +++ b/gralloc4/src/hidl_common/Allocator.h @@ -56,8 +56,6 @@ void allocate(const buffer_descriptor_t &bufferDescriptor, uint32_t count, IAllo const std::string dump(); -int isSupported(buffer_descriptor_t *const bufDescriptor); - } // namespace common } // namespace allocator } // namespace arm -- cgit v1.2.3