Add sdr white point information to composer3

* Add layer-level SDR white point. When there are mixed HDR/SDR layers
on the display, HDR layers should remain at display brightness, or
whatever the HDR standard is (e.g., keep HLG content at 1000 nits), while
SDR layers should be "dimmed" to the appropriate perceptual brightness.
* Add SDR white point to the client composited client target buffer.
When there are mixed HDR/SDR layers in client compostion, HWC must tell
SurfaceFlinger the target white point of the client target buffer so
that SurfaceFlinger-applied dimming may be atomically applied as a
brightness mode change.

Bug: 200310158
Test: builds

Change-Id: Ifbfe3125ede1a4de04978c6e644a5c911c33d3b6
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl
index 3b31149..e19105d 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl
@@ -72,4 +72,5 @@
   SET_LAYER_PER_FRAME_METADATA_BLOBS = 50593792,
   SET_CLIENT_TARGET_PROPERTY = 17104896,
   SET_LAYER_GENERIC_METADATA = 68026368,
+  SET_LAYER_WHITE_POINT_NITS = 50659328,
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
index 531fd14..8824f5a 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -40,7 +40,7 @@
   void destroyVirtualDisplay(long display);
   android.hardware.graphics.composer3.ExecuteCommandsStatus executeCommands(int inLength, in android.hardware.common.NativeHandle[] inHandles);
   int getActiveConfig(long display);
-  void getClientTargetSupport(long display, int width, int height, android.hardware.graphics.common.PixelFormat format, android.hardware.graphics.common.Dataspace dataspace);
+  void getClientTargetSupport(long display, int width, int height, in android.hardware.graphics.composer3.ClientTargetProperty clientTargetProperty);
   android.hardware.graphics.composer3.ColorMode[] getColorModes(long display);
   float[] getDataspaceSaturationMatrix(android.hardware.graphics.common.Dataspace dataspace);
   int getDisplayAttribute(long display, int config, android.hardware.graphics.composer3.DisplayAttribute attribute);
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl
index 5f987d0..95c07ac 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl
@@ -689,8 +689,16 @@
      *
      *     0 - 3: clientTargetProperty.pixelFormat
      *     4 - 7: clientTargetProperty.dataspace
+     *     8 - 11: whitePointNits
      *
-     *   setClientTargetProperty(ClientTargetProperty clientTargetProperty);
+     * The white point parameter describes the intended white point of the client target buffer.
+     * When client composition blends both HDR and SDR content, the client must composite to the
+     * brightness space as specified by the hardware composer. This is so that adjusting the real
+     * display brightness may be applied atomically with compensating the client target output. For
+     * instance, client-compositing a list of SDR layers requires dimming the brightness space of
+     * the SDR buffers when an HDR layer is simultaneously device-composited.
+     *
+     *   setClientTargetProperty(ClientTargetProperty clientTargetProperty, float whitePointNits);
      */
     SET_CLIENT_TARGET_PROPERTY = 0x105 << OPCODE_SHIFT,
 
@@ -738,4 +746,18 @@
      *        corresponding to the key as described above
      */
     SET_LAYER_GENERIC_METADATA = 0x40e << OPCODE_SHIFT,
+
+    /**
+     * SET_LAYER_WHITE_POINT_NITS has this pseudo prototype
+     *
+     *   setLayerWhitePointNits(float sdrWhitePointNits);
+     *
+     * Sets the desired white point for the layer. This is intended to be used when presenting
+     * an SDR layer alongside HDR content. The HDR content will be presented at the display
+     * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point
+     * provided.
+     *
+     * @param whitePointNits is the white point in nits.
+     */
+    SET_LAYER_WHITE_POINT_NITS = 0x305 << OPCODE_SHIFT,
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
index 9bde220..92b99d5 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -200,15 +200,12 @@
      * @param display is the display to query.
      * @param width is the client target width in pixels.
      * @param height is the client target height in pixels.
-     * @param format is the client target format.
-     * @param dataspace is the client target dataspace, as described in
-     *     setLayerDataspace.
+     * @param clientTargetProperty is the client target format and dataspace.
      * @exception EX_BAD_DISPLAY when an invalid display handle was passed in.
      * @exception EX_UNSUPPORTED when the given configuration is not supported.
      */
-    void getClientTargetSupport(long display, int width, int height,
-            android.hardware.graphics.common.PixelFormat format,
-            android.hardware.graphics.common.Dataspace dataspace);
+    void getClientTargetSupport(
+            long display, int width, int height, in ClientTargetProperty clientTargetProperty);
 
     /**
      * Returns the color modes supported on this display.