From 6cc484f5e6809366534554eb68bdfde1e4876143 Mon Sep 17 00:00:00 2001 From: Sally Qi Date: Mon, 19 Aug 2024 16:33:14 -0700 Subject: [PATCH] [Lut HAL] Move layer out of Lut interface. - Also add setLayerLuts interface. Bug: 329472100 Test: builds Change-Id: I41c36fb5baf77e3a2d111eb32e289b91274eca2a --- .../graphics/composer3/DisplayLuts.aidl | 6 +++++- .../hardware/graphics/composer3/Lut.aidl | 1 - .../graphics/composer3/DisplayLuts.aidl | 18 +++++++++++++----- .../hardware/graphics/composer3/Lut.aidl | 5 ----- .../graphics/composer3/ComposerClientReader.h | 15 ++++++++------- .../graphics/composer3/ComposerClientWriter.h | 10 ++++++++++ 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayLuts.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayLuts.aidl index 869db5b237..327e84c1d7 100644 --- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayLuts.aidl +++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayLuts.aidl @@ -35,5 +35,9 @@ package android.hardware.graphics.composer3; @VintfStability parcelable DisplayLuts { long display; - android.hardware.graphics.composer3.Lut[] luts; + android.hardware.graphics.composer3.DisplayLuts.LayerLut[] layerLuts; + parcelable LayerLut { + long layer; + android.hardware.graphics.composer3.Lut lut; + } } diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Lut.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Lut.aidl index 39245b57bf..5fae35be9d 100644 --- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Lut.aidl +++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Lut.aidl @@ -34,7 +34,6 @@ package android.hardware.graphics.composer3; @VintfStability parcelable Lut { - long layer; @nullable ParcelFileDescriptor pfd; android.hardware.graphics.composer3.LutProperties lutProperties; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl index 56381e0846..ac0a60634a 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl @@ -27,12 +27,20 @@ import android.hardware.graphics.composer3.Lut; @VintfStability parcelable DisplayLuts { /** - * The display which this commands refers to. + * The display which the layerLuts list is for. */ long display; - /** - * A Lut list specified by the HWC for given HDR layers that don't have Luts provided. - */ - Lut[] luts; + parcelable LayerLut { + /** + * The layer that the HWC is requesting a LUT to be applied during GPU composition. + */ + long layer; + /** + * A Lut specified by the HWC for given HDR layers that don't have Luts provided. + */ + Lut lut; + } + + LayerLut[] layerLuts; } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl index e4320f50d8..abfeb148e6 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl @@ -27,11 +27,6 @@ import android.hardware.graphics.composer3.LutProperties; @VintfStability parcelable Lut { - /** - * The layer which this commands refer to. - */ - long layer; - /** * A handle to a memory region. * If the file descriptor is not set, this means that the HWC doesn't specify a Lut. diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h index fc96882ac3..331d717356 100644 --- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h +++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h @@ -186,7 +186,7 @@ class ComposerClientReader { } // Get the lut(s) requested by hardware composer. - std::vector takeDisplayLuts(int64_t display) { + std::vector takeDisplayLuts(int64_t display) { LOG_ALWAYS_FATAL_IF(mDisplay && display != *mDisplay); auto found = mReturnData.find(display); @@ -196,7 +196,7 @@ class ComposerClientReader { } ReturnData& data = found->second; - return std::move(data.luts); + return std::move(data.layerLuts); } private: @@ -247,10 +247,11 @@ class ComposerClientReader { void parseSetDisplayLuts(DisplayLuts&& displayLuts) { LOG_ALWAYS_FATAL_IF(mDisplay && displayLuts.display != *mDisplay); auto& data = mReturnData[displayLuts.display]; - for (auto& lut : displayLuts.luts) { - if (lut.pfd.get() >= 0) { - data.luts.push_back({lut.layer, ndk::ScopedFileDescriptor(lut.pfd.release()), - lut.lutProperties}); + for (auto& layerLut : displayLuts.layerLuts) { + if (layerLut.lut.pfd.get() >= 0) { + data.layerLuts.push_back( + {layerLut.layer, Lut{ndk::ScopedFileDescriptor(layerLut.lut.pfd.release()), + layerLut.lut.lutProperties}}); } } } @@ -266,7 +267,7 @@ class ComposerClientReader { .clientTargetProperty = {common::PixelFormat::RGBA_8888, Dataspace::UNKNOWN}, .brightness = 1.f, }; - std::vector luts; + std::vector layerLuts; }; std::vector mErrors; diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h index a1ccbfe047..02fb3aab28 100644 --- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h +++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -245,6 +246,15 @@ class ComposerClientWriter final { getLayerCommand(display, layer).blockingRegion.emplace(blocking.begin(), blocking.end()); } + void setLayerLuts(int64_t display, int64_t layer, std::vector& luts) { + std::vector> currentLuts; + for (auto& lut : luts) { + currentLuts.push_back(std::make_optional( + {ndk::ScopedFileDescriptor(lut.pfd.release()), lut.lutProperties})); + } + getLayerCommand(display, layer).luts.emplace(std::move(currentLuts)); + } + std::vector takePendingCommands() { flushLayerCommand(); flushDisplayCommand();