Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44a56de2 authored by Chia-I Wu's avatar Chia-I Wu Committed by android-build-merger
Browse files

Merge "graphics: add RenderIntent and better HDR support" into pi-dev

am: aa6eca99

Change-Id: Ib3624e7188420ed9c538cd096627e93657001d90
parents f0670459 aa6eca99
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -323,9 +323,9 @@ be794f5df97f134d6dcabb866b250d1305100e7ae07fb253b7841df890b931bb android.hardwar
3c5183d7506010be57e0f748e3640fc2ded1ba955784b6256ba427f4c399591c android.hardware.gnss@1.1::IGnssConfiguration
b054af24fbb70d54cde1fb5cba126809e7c4e863e8f9115dc492321dfbcbc993 android.hardware.gnss@1.1::IGnssMeasurement
83e7a10ff3702147bd7ffa04567b20d407a3b16bbb7705644af44d919afe9103 android.hardware.gnss@1.1::IGnssMeasurementCallback
82da7e7624f72ff1927f48738913e20bee3a513adfe5dc7c4f888176e20376e6 android.hardware.graphics.common@1.1::types
0b96e0254e2168cfecb30c1ed5fb42681652cc00faa68c6e07568fafe64d1d50 android.hardware.graphics.common@1.1::types
d9b40a5b09962a5a0780b10fe33a4e607e69e2e088fc83de88a584115b7cb1c0 android.hardware.graphics.composer@2.2::IComposer
d6ce042995239712bc1d0970fa9d512c15c0b1ac9bcb048bd8b69f617b45c25e android.hardware.graphics.composer@2.2::IComposerClient
da3979dd97093cdc4ffc2e2427e848f4ba07ddcd181f31f2cb494ad0d2fa58ad android.hardware.graphics.composer@2.2::IComposerClient
dd83be076b6b3f10ed62ab34d8c8b95f2415961fb785200eb842e7bfb2b0ee92 android.hardware.graphics.mapper@2.1::IMapper
675682dd3007805c985eaaec91612abc88f4c25b3431fb84070b7584a1a741fb android.hardware.health@2.0::IHealth
434c4c32c00b0e54bb05e40c79503208b40f786a318029a2a4f66e34f10f2a76 android.hardware.health@2.0::IHealthInfoCallback
+2 −0
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@ hidl_interface {
    ],
    types: [
        "BufferUsage",
        "ColorMode",
        "Dataspace",
        "PixelFormat",
        "RenderIntent",
    ],
    gen_java: true,
    gen_java_constants: true,
+154 −3
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

package android.hardware.graphics.common@1.1;

import @1.0::PixelFormat;
import @1.0::BufferUsage;
import @1.0::ColorMode;
import @1.0::Dataspace;
import @1.0::PixelFormat;

/**
 * Pixel formats for graphics buffers.
@@ -129,15 +130,165 @@ enum BufferUsage : @1.0::BufferUsage {
@export(name="android_dataspace_v1_1_t", value_prefix="HAL_DATASPACE_",
        export_parent="false")
enum Dataspace : @1.0::Dataspace {
    /*
     * @1.0::Dataspace defines six legacy dataspaces
     *
     *   SRGB_LINEAR = 0x200, // deprecated, use V0_SRGB_LINEAR
     *   SRGB = 0x201, // deprecated, use V0_SRGB
     *   JFIF = 0x101, // deprecated, use V0_JFIF
     *   BT601_625 = 0x102, // deprecated, use V0_BT601_625
     *   BT601_525 = 0x103, // deprecated, use V0_BT601_525
     *   BT709 = 0x104, // deprecated, use V0_BT709
     *
     * The difference between the legacy dataspaces and their modern
     * counterparts is that, with legacy dataspaces, the pixel values may have
     * been desaturated by the content creator in an unspecified way.
     *
     * When colorimetric mapping is required, the legacy dataspaces must be
     * treated as their modern counterparts (e.g., SRGB must be treated as
     * V0_SRGB) and no re-saturation is allowed. When non-colorimetric mapping
     * is allowed, the pixel values can be interpreted freely by
     * implementations for the purpose of re-saturation, and the re-saturated
     * pixel values are in the respective modern dataspaces.
     *
     * This is also true when UNKNOWN is treated as a legacy dataspace.
     */

    /**
     * ITU-R Recommendation 2020 (BT.2020)
     *
     * Ultra High-definition television
     *
     * Use limited range, SMPTE 2084 (PQ) transfer and BT2020 standard
     * limited range is the preferred / normative definition for BT.2020
     * Use limited range, BT.709 transfer and BT2020 standard
     */
    BT2020_ITU = STANDARD_BT2020 | TRANSFER_SMPTE_170M | RANGE_LIMITED,

    /**
     * ITU-R Recommendation 2100 (BT.2100)
     *
     * High dynamic range television
     *
     * Use limited/full range, PQ/HLG transfer, and BT2020 standard
     * limited range is the preferred / normative definition for BT.2100
     */
    BT2020_ITU_PQ = STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_LIMITED,
    BT2020_ITU_HLG = STANDARD_BT2020 | TRANSFER_HLG | RANGE_LIMITED,
    BT2020_HLG = STANDARD_BT2020 | TRANSFER_HLG | RANGE_FULL,
};

@export(name="android_color_mode_v1_1_t", value_prefix="HAL_COLOR_MODE_",
        export_parent="false")
enum ColorMode : @1.0::ColorMode {
    /**
     * BT2020 corresponds with display settings that implement the ITU-R
     * Recommendation BT.2020 / Rec. 2020 for UHDTV.
     *
     * Primaries:
     *                  x       y
     *  green           0.170   0.797
     *  blue            0.131   0.046
     *  red             0.708   0.292
     *  white (D65)     0.3127  0.3290
     *
     * Inverse Gamma Correction (IGC): V represents normalized (with [0 to 1]
     * range) value of R, G, or B.
     *
     *  if Vnonlinear < b * 4.5
     *    Vlinear = Vnonlinear / 4.5
     *  else
     *    Vlinear = ((Vnonlinear + (a - 1)) / a) ^ (1/0.45)
     *
     * Gamma Correction (GC):
     *
     *  if Vlinear < b
     *    Vnonlinear = 4.5 * Vlinear
     *  else
     *    Vnonlinear = a * Vlinear ^ 0.45 - (a - 1)
     *
     * where
     *
     *   a = 1.09929682680944, b = 0.018053968510807
     *
     * For practical purposes, these a/b values can be used instead
     *
     *   a = 1.099, b = 0.018 for 10-bit display systems
     *   a = 1.0993, b = 0.0181 for 12-bit display systems
     */
    BT2020 = 10,

    /**
     * BT2100_PQ and BT2100_HLG correspond with display settings that
     * implement the ITU-R Recommendation BT.2100 / Rec. 2100 for HDR TV.
     *
     * Primaries:
     *                  x       y
     *  green           0.170   0.797
     *  blue            0.131   0.046
     *  red             0.708   0.292
     *  white (D65)     0.3127  0.3290
     *
     * For BT2100_PQ, the transfer function is Perceptual Quantizer (PQ). For
     * BT2100_HLG, the transfer function is Hybrid Log-Gamma (HLG).
     */
    BT2100_PQ = 11,
    BT2100_HLG = 12,
};

/**
 * RenderIntent defines the mapping from color mode colors to display colors.
 *
 * A render intent must not change how it maps colors when the color mode
 * changes. That is to say that when a render intent maps color C to color C',
 * the fact that color C can have different pixel values in different color
 * modes should not affect the mapping.
 *
 * RenderIntent overrides the render intents defined for individual color
 * modes. It is ignored when the color mode is ColorMode::NATIVE, because
 * ColorMode::NATIVE colors are already display colors.
 */
@export(name="android_render_intent_v1_1_t", value_prefix="HAL_RENDER_INTENT_",
        export_parent="false")
enum RenderIntent : int32_t {
    /**
     * Colors in the display gamut are unchanged. Colors out of the display
     * gamut are hard-clipped.
     *
     * This implies that the display must have been calibrated unless
     * ColorMode::NATIVE is the only supported color mode.
     */
    COLORIMETRIC = 0,

    /**
     * Enhance colors that are in the display gamut. Colors out of the display
     * gamut are hard-clipped.
     *
     * The enhancement typically picks the biggest standard color space (e.g.
     * DCI-P3) that is narrower than the display gamut and stretches it to the
     * display gamut. The stretching is recommended to preserve skin tones.
     */
    ENHANCE = 1,

    /**
     * Tone map high-dynamic-range colors to the display's dynamic range. The
     * dynamic range of the colors are communicated separately. After tone
     * mapping, the mapping to the display gamut is as defined in
     * COLORIMETRIC.
     */
    TONE_MAP_COLORIMETRIC = 2,

    /**
     * Tone map high-dynamic-range colors to the display's dynamic range. The
     * dynamic range of the colors are communicated separately. After tone
     * mapping, the mapping to the display gamut is as defined in ENHANCE.
     *
     * The tone mapping step and the enhancing step must match
     * TONE_MAP_COLORIMETRIC and ENHANCE respectively when they are also
     * supported.
     */
    TONE_MAP_ENHANCE = 3,

    /*
     * Vendors are recommended to use 0x100 - 0x1FF for their own values, and
     * that must be done with subtypes defined by vendor extensions.
     */
};
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ hidl_interface {
    ],
    interfaces: [
        "android.hardware.graphics.common@1.0",
        "android.hardware.graphics.common@1.1",
        "android.hardware.graphics.composer@2.1",
        "android.hidl.base@1.0",
    ],
+124 −4
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@

package android.hardware.graphics.composer@2.2;

import android.hardware.graphics.common@1.0::PixelFormat;
import android.hardware.graphics.common@1.0::Dataspace;
import android.hardware.graphics.common@1.0::PixelFormat;
import android.hardware.graphics.common@1.1::ColorMode;
import android.hardware.graphics.common@1.1::RenderIntent;
import @2.1::IComposerClient;
import @2.1::Display;
import @2.1::Error;
@@ -90,16 +92,20 @@ interface IComposerClient extends @2.1::IComposerClient {

    enum Command : @2.1::IComposerClient.Command {
        /**
         * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data)
         * SET_LAYER_PER_FRAME_METADATA has this pseudo prototype
         *
         *   setLayerPerFrameMetadata(Display display, Layer layer,
         *                            vec<PerFrameMetadata> data);
         *
         * Sets the PerFrameMetadata for the display. This metadata must be used
         * by the implementation to better tone map content to that display.
         *
         * This is a method that may be called every frame. Thus it's
         * implemented using buffered transport.
         * SET_PER_FRAME_METADATA is the command used by the buffered transport
         * SET_LAYER_PER_FRAME_METADATA is the command used by the buffered transport
         * mechanism.
         */
        SET_PER_FRAME_METADATA = 0x207 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
        SET_LAYER_PER_FRAME_METADATA = 0x303 << @2.1::IComposerClient.Command:OPCODE_SHIFT,

        /**
         * SET_LAYER_COLOR has this pseudo prototype
@@ -260,4 +266,118 @@ interface IComposerClient extends @2.1::IComposerClient {
     */
    setPowerMode_2_2(Display display, PowerMode mode) generates (Error error);

    /**
     * Returns the color modes supported on this display.
     *
     * All devices must support at least ColorMode::NATIVE.
     *
     * @param display is the display to query.
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     * @return modes is an array of color modes.
     */
    getColorModes_2_2(Display display)
           generates (Error error,
                      vec<ColorMode> modes);

    /**
     * Returns the render intents supported by the specified display and color
     * mode.
     *
     * RenderIntent::COLORIMETRIC is always supported.
     *
     * @param display is the display to query.
     * @param mode is the color mode to query.
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     *         BAD_PARAMETER when an invalid color mode was passed in.
     * @return intents is an array of render intents.
     */
    getRenderIntents(Display display, ColorMode mode)
          generates (Error error,
                     vec<RenderIntent> intents);

    /**
     * Sets the color mode and render intent of the given display.
     *
     * The color mode and render intent change must take effect on next
     * presentDisplay.
     *
     * All devices must support at least ColorMode::NATIVE and
     * RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode
     * upon hotplug.
     *
     * @param display is the display to which the color mode is set.
     * @param mode is the color mode to set to.
     * @param intent is the render intent to set to.
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     *         BAD_PARAMETER when mode or intent is invalid
     *         UNSUPPORTED when mode or intent is not supported on this
     *                     display.
     */
    setColorMode_2_2(Display display, ColorMode mode, RenderIntent intent)
          generates (Error error);

    /*
     * By default, layer dataspaces are mapped to the current color mode
     * colorimetrically with a few exceptions.
     *
     * When the layer dataspace is a legacy sRGB dataspace
     * (Dataspace::SRGB_LINEAR, Dataspace::SRGB, or Dataspace::UNKNOWN when
     * treated as such) and the display render intent is
     * RenderIntent::ENHANCE, the pixel values can go through an
     * implementation-defined saturation transform before being mapped to the
     * current color mode colorimetrically.
     *
     * Colors that are out of the gamut of the current color mode are
     * hard-clipped.
     */

    /**
     * Returns the saturation matrix of the specified legacy dataspace.
     *
     * The saturation matrix can be used to approximate the legacy dataspace
     * saturation transform. It is to be applied on linear pixel values like
     * this:
     *
     *   (in GLSL)
     *   linearSrgb = clamp(saturationMatrix * linearSrgb, 0.0, 1.0);
     *
     * @param dataspace must be Dataspace::SRGB_LINEAR.
     * @return error is NONE upon success. Otherwise,
     *         BAD_PARAMETER when an invalid dataspace was passed in.
     * @return matrix is the 4x4 column-major matrix used to approximate the
     *         legacy dataspace saturation operation. The last row must be
     *         [0.0, 0.0, 0.0, 1.0].
     */
    getDataspaceSaturationMatrix(Dataspace dataspace)
                      generates (Error error,
                                 float[4][4] matrix);

    /**
     * Executes commands from the input command message queue. Return values
     * generated by the input commands are written to the output command
     * message queue in the form of value commands.
     *
     * @param inLength is the length of input commands.
     * @param inHandles is an array of handles referenced by the input
     *        commands.
     * @return error is NONE upon success. Otherwise,
     *         BAD_PARAMETER when inLength is not equal to the length of
     *                       commands in the input command message queue.
     *         NO_RESOURCES when the output command message queue was not
     *                      properly drained.
     * @param outQueueChanged indicates whether the output command message
     *        queue has changed.
     * @param outLength is the length of output commands.
     * @param outHandles is an array of handles referenced by the output
     *        commands.
     */
    executeCommands_2_2(uint32_t inLength,
                        vec<handle> inHandles)
             generates (Error error,
                        bool outQueueChanged,
                        uint32_t outLength,
                        vec<handle> outHandles);
};
Loading