[Lut HAL] add Lut VTS enforcement
Bug: 362319189
Bug: 358422255
Test: VtsHalGraphicsComposer3_TargetTest
Change-Id: I41b279d362715c32a2d0ee6021c0f1f94b612d64
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
index 1c6fd18..d3dd30e 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
@@ -36,8 +36,8 @@
/**
* SamplingKey is about how a Lut can be sampled.
- * A Lut can be sampled in more than one way,
- * but only one sampling method is used at one time.
+ * A Lut can be sampled in more than one key,
+ * but only one sampling key is used at one time.
*
* The implementations should use a sampling strategy
* at least as good as linear sampling.
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
index 5f55f1c..592ac50 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
@@ -40,13 +40,15 @@
* For data precision, 32-bit float is used to specify a Lut by both the HWC and
* the platform.
*
- *
* For unflattening/flattening 3D Lut(s), the algorithm below should be observed
* by both the HWC and the platform.
* Assuming that we have a 3D array `ORIGINAL[WIDTH, HEIGHT, DEPTH]`, we would turn it into
* `FLAT[WIDTH * HEIGHT * DEPTH]` by
*
* `FLAT[z + DEPTH * (y + HEIGHT * x)] = ORIGINAL[x, y, z]`
+ *
+ * Noted that 1D Lut(s) should be gain curve ones
+ * and 3D Lut(s) should be pure color lookup ones.
*/
@nullable ParcelFileDescriptor pfd;
@@ -60,6 +62,8 @@
/**
* The properties list of the Luts.
+ *
+ * The number of sampling key inside should only be one.
*/
LutProperties[] lutProperties;
}
diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
index 106941e..8006523 100644
--- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -28,6 +28,7 @@
#include <android/hardware/graphics/composer3/ComposerClientReader.h>
#include <android/hardware/graphics/composer3/ComposerClientWriter.h>
#include <binder/ProcessState.h>
+#include <cutils/ashmem.h>
#include <gtest/gtest.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
@@ -3324,6 +3325,54 @@
}
}
+class GraphicsComposerAidlCommandV4Test : public GraphicsComposerAidlCommandTest {
+ protected:
+ void SetUp() override {
+ GraphicsComposerAidlTest::SetUp();
+ if (getInterfaceVersion() <= 3) {
+ GTEST_SKIP() << "Device interface version is expected to be >= 4";
+ }
+ }
+};
+
+TEST_P(GraphicsComposerAidlCommandV4Test, SetUnsupportedLayerLuts) {
+ auto& writer = getWriter(getPrimaryDisplayId());
+ const auto& [layerStatus, layer] =
+ mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount, &writer);
+ EXPECT_TRUE(layerStatus.isOk());
+ const auto& [status, properties] = mComposerClient->getOverlaySupport();
+ if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC &&
+ status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) {
+ GTEST_SUCCEED() << "getOverlaySupport is not supported";
+ return;
+ }
+ ASSERT_TRUE(status.isOk());
+
+ // TODO (b/362319189): add Lut VTS enforcement
+ if (!properties.lutProperties) {
+ int32_t size = 7;
+ size_t bufferSize = static_cast<size_t>(size) * sizeof(float);
+ int32_t fd = ashmem_create_region("lut_shared_mem", bufferSize);
+ void* ptr = mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ std::vector<float> buffers = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
+ memcpy(ptr, buffers.data(), bufferSize);
+ munmap(ptr, bufferSize);
+ Luts luts;
+ luts.offsets = {0};
+ luts.lutProperties = {
+ {LutProperties::Dimension::ONE_D, size, {LutProperties::SamplingKey::RGB}}};
+ luts.pfd = ndk::ScopedFileDescriptor(fd);
+
+ writer.setLayerLuts(getPrimaryDisplayId(), layer, luts);
+ writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
+ VtsComposerClient::kNoFrameIntervalNs);
+ execute();
+ // change to client composition
+ ASSERT_FALSE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty());
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ }
+}
+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandTest);
INSTANTIATE_TEST_SUITE_P(
PerInstance, GraphicsComposerAidlCommandTest,
@@ -3354,6 +3403,11 @@
PerInstance, GraphicsComposerAidlCommandV3Test,
testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
::android::PrintInstanceNameToString);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandV4Test);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, GraphicsComposerAidlCommandV4Test,
+ testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
+ ::android::PrintInstanceNameToString);
} // namespace aidl::android::hardware::graphics::composer3::vts
int main(int argc, char** argv) {