From cfc2b2e60267fb4140e99c0049598752c7d8749a Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Tue, 1 Sep 2020 13:39:17 +0300 Subject: [PATCH] drm_hwcomposer: fix incorrect layer_count usage According to [1] DRM YCrCb planes is not the same as gralloc layers. DRMHWC2 has no information about number of layers used in the buffer. Also supplying value other than 1 will allways fail validation on passthrough MapperHal@2.1 and probably other passthrough implementations [2]. [1] - https://cs.android.com/android/platform/superproject/+/master:hardware/libhardware/include/hardware/gralloc1.h;l=467;drc=1155c41d016a118801fe97b55af9918e531f7f84 [2] - https://cs.android.com/android/platform/superproject/+/master:hardware/interfaces/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc0Hal.h;l=40;drc=e308ceb1e9940d1d90a11177782a7cfe8630bb95 Signed-off-by: Roman Stratiienko Change-Id: Idbfea8eaa74a557b98ecdff728e6c67aeea9cea6 --- utils/hwcutils.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/utils/hwcutils.cpp b/utils/hwcutils.cpp index 87e3c42..324d855 100644 --- a/utils/hwcutils.cpp +++ b/utils/hwcutils.cpp @@ -114,13 +114,9 @@ int DrmHwcLayer::ImportBuffer(Importer *importer) { const hwc_drm_bo *bo = buffer.operator->(); - unsigned int layer_count; - for (layer_count = 0; layer_count < HWC_DRM_BO_MAX_PLANES; ++layer_count) - if (bo->gem_handles[layer_count] == 0) - break; - - ret = handle.CopyBufferHandle(sf_handle, bo->width, bo->height, layer_count, - bo->hal_format, bo->usage, bo->pixel_stride); + ret = handle.CopyBufferHandle(sf_handle, bo->width, bo->height, + 1 /*layer_count*/, bo->hal_format, bo->usage, + bo->pixel_stride); if (ret) return ret; -- 2.11.0