[LUT HAL] Interface update

- Rename Lut.aidl to Luts.aidl. In Luts.aidl structure, we provides one
  array of offsets and one array of lutProperties. `offsets` is to store
  starting point of each lut memory region of the lut buffer. That is to
  say, multiple Luts are packed into one same ashmem region, and we use
  `offsets` to know each lut buffer's position.
- change the data type of `size` to int.
- doc update: use `ashmem_create_region` instead.

Bug: 329472100
Test: builds
Change-Id: Iea38afa722a28c55f2147c67e2222fcd8323d0d7
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 327e84c..4263140 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
@@ -38,6 +38,6 @@
   android.hardware.graphics.composer3.DisplayLuts.LayerLut[] layerLuts;
   parcelable LayerLut {
     long layer;
-    android.hardware.graphics.composer3.Lut lut;
+    android.hardware.graphics.composer3.Luts luts;
   }
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
index 8b2b13c..87c0e1e 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -57,5 +57,5 @@
   @nullable int[] bufferSlotsToClear;
   android.hardware.graphics.composer3.LayerLifecycleBatchCommandType layerLifecycleBatchCommandType;
   int newBufferSlotCount;
-  @nullable android.hardware.graphics.composer3.Lut[] luts;
+  @nullable android.hardware.graphics.composer3.Luts luts;
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LutProperties.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LutProperties.aidl
index 5edceb5..6a4593a 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LutProperties.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LutProperties.aidl
@@ -35,7 +35,7 @@
 @VintfStability
 parcelable LutProperties {
   android.hardware.graphics.composer3.LutProperties.Dimension dimension;
-  long size;
+  int size;
   android.hardware.graphics.composer3.LutProperties.SamplingKey[] samplingKeys;
   @VintfStability
   enum Dimension {
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/Luts.aidl
similarity index 93%
rename from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Lut.aidl
rename to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Luts.aidl
index 5fae35b..2890365 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/Luts.aidl
@@ -33,7 +33,8 @@
 
 package android.hardware.graphics.composer3;
 @VintfStability
-parcelable Lut {
+parcelable Luts {
   @nullable ParcelFileDescriptor pfd;
-  android.hardware.graphics.composer3.LutProperties lutProperties;
+  @nullable int[] offsets;
+  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 ac0a606..6b59a6f 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayLuts.aidl
@@ -16,7 +16,7 @@
 
 package android.hardware.graphics.composer3;
 
-import android.hardware.graphics.composer3.Lut;
+import android.hardware.graphics.composer3.Luts;
 
 /**
  * LUT (Look-Up Table) Interface for Color Transformation.
@@ -37,9 +37,9 @@
          */
         long layer;
         /**
-         * A Lut specified by the HWC for given HDR layers that don't have Luts provided.
+         * Lut(s) specified by the HWC for given HDR layers that don't have Luts provided.
          */
-        Lut lut;
+        Luts luts;
     }
 
     LayerLut[] layerLuts;
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
index bf4f504..c89887d 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -24,7 +24,7 @@
 import android.hardware.graphics.composer3.Color;
 import android.hardware.graphics.composer3.LayerBrightness;
 import android.hardware.graphics.composer3.LayerLifecycleBatchCommandType;
-import android.hardware.graphics.composer3.Lut;
+import android.hardware.graphics.composer3.Luts;
 import android.hardware.graphics.composer3.ParcelableBlendMode;
 import android.hardware.graphics.composer3.ParcelableComposition;
 import android.hardware.graphics.composer3.ParcelableDataspace;
@@ -284,5 +284,5 @@
     /**
      * Sets the lut(s) for the layer.
      */
-    @nullable Lut[] luts;
+    @nullable Luts luts;
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
index 47ec390..1c6fd18 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl
@@ -32,7 +32,7 @@
      * The size of the Lut.
      * This refers to the length of a 1D Lut, or the grid size of a 3D one.
      */
-    long size;
+    int size;
 
     /**
      * SamplingKey is about how a Lut can be sampled.
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
similarity index 81%
rename from graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl
rename to graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
index abfeb14..5f55f1c 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Lut.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl
@@ -26,13 +26,13 @@
  */
 
 @VintfStability
-parcelable Lut {
+parcelable Luts {
     /**
      * A handle to a memory region.
      * If the file descriptor is not set, this means that the HWC doesn't specify a Lut.
      *
      * When specifying a Lut, the HWC is required to follow the instructions as below:
-     * 1. use `memfd_create` to create a shared memory segment
+     * 1. use `ashmem_create_region` to create a shared memory segment
      *    with the size specified in lutProperties.
      * 2. use `mmap` to map the shared memory segment into its own virtual address space.
      *    PROT_READ/PROT_WRITE recommended for prot argument.
@@ -40,6 +40,7 @@
      * 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
@@ -50,7 +51,15 @@
     @nullable ParcelFileDescriptor pfd;
 
     /**
-     * The properties of the Lut.
+     * The offsets store the starting point of each Lut memory of the Lut buffer.
+     *
+     * Multiple Luts can be packed into one same `pfd`, and `offsets` is used to pinpoint
+     * the starting point of each Lut.
      */
-    LutProperties lutProperties;
+    @nullable int[] offsets;
+
+    /**
+     * The properties list of the Luts.
+     */
+    LutProperties[] lutProperties;
 }
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 331d717..07c9c6d 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientReader.h
@@ -247,11 +247,11 @@
     void parseSetDisplayLuts(DisplayLuts&& displayLuts) {
         LOG_ALWAYS_FATAL_IF(mDisplay && displayLuts.display != *mDisplay);
         auto& data = mReturnData[displayLuts.display];
-        for (auto& layerLut : displayLuts.layerLuts) {
-            if (layerLut.lut.pfd.get() >= 0) {
+        for (auto& [layerId, luts] : displayLuts.layerLuts) {
+            if (luts.pfd.get() >= 0) {
                 data.layerLuts.push_back(
-                        {layerLut.layer, Lut{ndk::ScopedFileDescriptor(layerLut.lut.pfd.release()),
-                                             layerLut.lut.lutProperties}});
+                        {layerId, Luts{ndk::ScopedFileDescriptor(luts.pfd.release()), luts.offsets,
+                                       luts.lutProperties}});
             }
         }
     }
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 02fb3aa..036460e 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
@@ -30,7 +30,7 @@
 #include <aidl/android/hardware/graphics/composer3/DisplayBrightness.h>
 #include <aidl/android/hardware/graphics/composer3/LayerBrightness.h>
 #include <aidl/android/hardware/graphics/composer3/LayerLifecycleBatchCommandType.h>
-#include <aidl/android/hardware/graphics/composer3/Lut.h>
+#include <aidl/android/hardware/graphics/composer3/Luts.h>
 #include <aidl/android/hardware/graphics/composer3/PerFrameMetadata.h>
 #include <aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h>
 
@@ -246,13 +246,8 @@
         getLayerCommand(display, layer).blockingRegion.emplace(blocking.begin(), blocking.end());
     }
 
-    void setLayerLuts(int64_t display, int64_t layer, std::vector<Lut>& luts) {
-        std::vector<std::optional<Lut>> currentLuts;
-        for (auto& lut : luts) {
-            currentLuts.push_back(std::make_optional<Lut>(
-                    {ndk::ScopedFileDescriptor(lut.pfd.release()), lut.lutProperties}));
-        }
-        getLayerCommand(display, layer).luts.emplace(std::move(currentLuts));
+    void setLayerLuts(int64_t display, int64_t layer, Luts& luts) {
+        getLayerCommand(display, layer).luts.emplace(std::move(luts));
     }
 
     std::vector<DisplayCommand> takePendingCommands() {