Snap for 8005954 from 1e4511c4698f9b21d584234176efeb646b6ae779 to sdk-release
Change-Id: Id35ea11eadd7fa04ed8ef14989b882b82f5a782d
diff --git a/gralloc4/service/4.x/Android.bp b/gralloc4/service/4.x/Android.bp
index de06942..5bd81bc 100644
--- a/gralloc4/service/4.x/Android.bp
+++ b/gralloc4/service/4.x/Android.bp
@@ -29,8 +29,12 @@
init_rc: [
"android.hardware.graphics.allocator@4.0-service.rc",
],
+ header_libs: [
+ "libgralloc_headers",
+ ],
shared_libs: [
"android.hardware.graphics.allocator@4.0",
+ "android.hardware.graphics.allocator@4.0-impl",
"libhidlbase",
"liblog",
"libutils",
diff --git a/gralloc4/service/4.x/service.cpp b/gralloc4/service/4.x/service.cpp
index bd28407..d540086 100644
--- a/gralloc4/service/4.x/service.cpp
+++ b/gralloc4/service/4.x/service.cpp
@@ -16,13 +16,30 @@
*/
#define LOG_TAG "android.hardware.graphics.allocator@4.0-service"
-#include <android/hardware/graphics/allocator/4.0/IAllocator.h>
+#include <hidl/HidlTransportSupport.h>
+#include <hidl/Status.h>
+#include <utils/StrongPointer.h>
-#include <hidl/LegacySupport.h>
+#include "4.x/GrallocAllocator.h"
-using android::hardware::defaultPassthroughServiceImplementation;
-using android::hardware::graphics::allocator::V4_0::IAllocator;
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::hardware::setMinSchedulerPolicy;
+using arm::allocator::GrallocAllocator;
int main() {
- return defaultPassthroughServiceImplementation<IAllocator>(/*maxThreads*/ 4);
+ android::sp<GrallocAllocator> service = new GrallocAllocator();
+ configureRpcThreadpool(4, true /* callerWillJoin */);
+
+ if (!setMinSchedulerPolicy(service, SCHED_NORMAL, -20)) {
+ ALOGW("Cannot bump allocator priority");
+ }
+
+ if (service->registerAsService() != android::OK) {
+ ALOGE("Cannot register allocator service");
+ return -EINVAL;
+ }
+
+ joinRpcThreadpool();
+ return 0;
}
diff --git a/gralloc4/src/4.x/GrallocAllocator.cpp b/gralloc4/src/4.x/GrallocAllocator.cpp
index 4e074b5..0ac81fd 100644
--- a/gralloc4/src/4.x/GrallocAllocator.cpp
+++ b/gralloc4/src/4.x/GrallocAllocator.cpp
@@ -40,6 +40,8 @@
GrallocAllocator::GrallocAllocator()
{
+ MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR,
+ (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid());
}
GrallocAllocator::~GrallocAllocator()
@@ -64,11 +66,3 @@
} // namespace allocator
} // namespace arm
-
-extern "C" IAllocator *HIDL_FETCH_IAllocator(const char * /* name */)
-{
- MALI_GRALLOC_LOGV("Arm Module IAllocator %d.%d, pid = %d ppid = %d", GRALLOC_VERSION_MAJOR,
- (HIDL_ALLOCATOR_VERSION_SCALED - (GRALLOC_VERSION_MAJOR * 100)) / 10, getpid(), getppid());
-
- return new arm::allocator::GrallocAllocator();
-}
diff --git a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
index 53bbb6f..e928637 100644
--- a/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
+++ b/gralloc4/src/core/mali_gralloc_bufferallocation.cpp
@@ -446,22 +446,17 @@
{
if (plane == 0)
{
- /*
- * Ensure luma stride is aligned to "2*lcm(hw_align, cpu_align)" so
- * that chroma stride can satisfy both CPU and HW alignment
- * constraints when only half luma stride (as mandated for format).
- */
- *byte_stride = GRALLOC_ALIGN(luma_stride, 2 * stride_align);
+ *byte_stride = GRALLOC_ALIGN(luma_stride, GRALLOC_ALIGN(stride_align, 32));
}
else
{
/*
* Derive chroma stride from luma and verify it is:
- * 1. Aligned to lcm(hw_align, cpu_align)
+ * 1. Aligned to "1/2*lcm(hw_align, cpu_align)"
* 2. Multiple of 16px (16 bytes)
*/
*byte_stride = luma_stride / 2;
- assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, stride_align));
+ assert(*byte_stride == GRALLOC_ALIGN(*byte_stride, GRALLOC_ALIGN(stride_align / 2, 16)));
assert(*byte_stride & 15 == 0);
}
}
@@ -611,6 +606,10 @@
/*
* Update YV12 stride with both CPU & HW usage due to constraint of chroma stride.
* Width is anyway aligned to 16px for luma and chroma (has_cpu_usage).
+ *
+ * Note: To prevent luma stride misalignment with GPU stride alignment.
+ * The luma plane will maintain the same `stride` size, and the chroma plane
+ * will align to `stride/2`.
*/
if (format.id == MALI_GRALLOC_FORMAT_INTERNAL_YV12 && has_hw_usage && has_cpu_usage)
{
diff --git a/gralloc4/src/hidl_common/MapperMetadata.cpp b/gralloc4/src/hidl_common/MapperMetadata.cpp
index f722cde..ee743db 100644
--- a/gralloc4/src/hidl_common/MapperMetadata.cpp
+++ b/gralloc4/src/hidl_common/MapperMetadata.cpp
@@ -238,6 +238,20 @@
/* AFBC Only FourCC */
{.drm_fourcc = DRM_FORMAT_YUV420_8BIT, .components = { {} } },
{.drm_fourcc = DRM_FORMAT_YUV420_10BIT, .components = { {} } },
+
+ /* Google specific formats */
+ {
+ .drm_fourcc = DRM_FORMAT_R8,
+ .components = {
+ { { R, 0, 8 } }
+ }
+ },
+ {
+ .drm_fourcc = DRM_FORMAT_RG88,
+ .components = {
+ { { R, 0, 8 }, { G, 8, 8 } }
+ }
+ },
};
/* clang-format on */