Home | History | Annotate | Download | only in hardware
      1 /*
      2  * Copyright 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_HARDWARE_HWCOMPOSER2_H
     18 #define ANDROID_HARDWARE_HWCOMPOSER2_H
     19 
     20 #include <hardware/hardware.h>
     21 
     22 #include "hwcomposer_defs.h"
     23 
     24 __BEGIN_DECLS
     25 
     26 /*
     27  * Enums
     28  *
     29  * For most of these enums, there is an invalid value defined to be 0. This is
     30  * an attempt to catch uninitialized fields, and these values should not be
     31  * used.
     32  */
     33 
     34 /* Display attributes queryable through getDisplayAttribute */
     35 typedef enum {
     36     HWC2_ATTRIBUTE_INVALID = 0,
     37 
     38     /* Dimensions in pixels */
     39     HWC2_ATTRIBUTE_WIDTH = 1,
     40     HWC2_ATTRIBUTE_HEIGHT = 2,
     41 
     42     /* Vsync period in nanoseconds */
     43     HWC2_ATTRIBUTE_VSYNC_PERIOD = 3,
     44 
     45     /* Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
     46      * numbers to be stored in an int32_t without losing too much precision. If
     47      * the DPI for a configuration is unavailable or is considered unreliable,
     48      * the device may return -1 instead */
     49     HWC2_ATTRIBUTE_DPI_X = 4,
     50     HWC2_ATTRIBUTE_DPI_Y = 5,
     51 } hwc2_attribute_t;
     52 
     53 /* Blend modes, settable per layer */
     54 typedef enum {
     55     HWC2_BLEND_MODE_INVALID = 0,
     56 
     57     /* colorOut = colorSrc */
     58     HWC2_BLEND_MODE_NONE = 1,
     59 
     60     /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
     61     HWC2_BLEND_MODE_PREMULTIPLIED = 2,
     62 
     63     /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
     64     HWC2_BLEND_MODE_COVERAGE = 3,
     65 } hwc2_blend_mode_t;
     66 
     67 /* See the 'Callbacks' section for more detailed descriptions of what these
     68  * functions do */
     69 typedef enum {
     70     HWC2_CALLBACK_INVALID = 0,
     71     HWC2_CALLBACK_HOTPLUG = 1,
     72     HWC2_CALLBACK_REFRESH = 2,
     73     HWC2_CALLBACK_VSYNC = 3,
     74 } hwc2_callback_descriptor_t;
     75 
     76 /* Optional capabilities which may be supported by some devices. The particular
     77  * set of supported capabilities for a given device may be retrieved using
     78  * getCapabilities. */
     79 typedef enum {
     80     HWC2_CAPABILITY_INVALID = 0,
     81 
     82     /* Specifies that the device supports sideband stream layers, for which
     83      * buffer content updates and other synchronization will not be provided
     84      * through the usual validate/present cycle and must be handled by an
     85      * external implementation-defined mechanism. Only changes to layer state
     86      * (such as position, size, etc.) need to be performed through the
     87      * validate/present cycle. */
     88     HWC2_CAPABILITY_SIDEBAND_STREAM = 1,
     89 
     90     /* Specifies that the device will apply a color transform even when either
     91      * the client or the device has chosen that all layers should be composed by
     92      * the client. This will prevent the client from applying the color
     93      * transform during its composition step. */
     94     HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2,
     95 } hwc2_capability_t;
     96 
     97 /* Possible composition types for a given layer */
     98 typedef enum {
     99     HWC2_COMPOSITION_INVALID = 0,
    100 
    101     /* The client will composite this layer into the client target buffer
    102      * (provided to the device through setClientTarget).
    103      *
    104      * The device must not request any composition type changes for layers of
    105      * this type. */
    106     HWC2_COMPOSITION_CLIENT = 1,
    107 
    108     /* The device will handle the composition of this layer through a hardware
    109      * overlay or other similar means.
    110      *
    111      * Upon validateDisplay, the device may request a change from this type to
    112      * HWC2_COMPOSITION_CLIENT. */
    113     HWC2_COMPOSITION_DEVICE = 2,
    114 
    115     /* The device will render this layer using the color set through
    116      * setLayerColor. If this functionality is not supported on a layer that the
    117      * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
    118      * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
    119      * upon the next call to validateDisplay.
    120      *
    121      * Upon validateDisplay, the device may request a change from this type to
    122      * HWC2_COMPOSITION_CLIENT. */
    123     HWC2_COMPOSITION_SOLID_COLOR = 3,
    124 
    125     /* Similar to DEVICE, but the position of this layer may also be set
    126      * asynchronously through setCursorPosition. If this functionality is not
    127      * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
    128      * device must request that the composition type of that layer is changed to
    129      * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
    130      *
    131      * Upon validateDisplay, the device may request a change from this type to
    132      * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
    133      * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
    134      * still permit the device to composite the layer. */
    135     HWC2_COMPOSITION_CURSOR = 4,
    136 
    137     /* The device will handle the composition of this layer, as well as its
    138      * buffer updates and content synchronization. Only supported on devices
    139      * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
    140      *
    141      * Upon validateDisplay, the device may request a change from this type to
    142      * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
    143      * unlikely that content will display correctly in these cases. */
    144     HWC2_COMPOSITION_SIDEBAND = 5,
    145 } hwc2_composition_t;
    146 
    147 /* Possible connection options from the hotplug callback */
    148 typedef enum {
    149     HWC2_CONNECTION_INVALID = 0,
    150 
    151     /* The display has been connected */
    152     HWC2_CONNECTION_CONNECTED = 1,
    153 
    154     /* The display has been disconnected */
    155     HWC2_CONNECTION_DISCONNECTED = 2,
    156 } hwc2_connection_t;
    157 
    158 /* Display requests returned by getDisplayRequests */
    159 typedef enum {
    160     /* Instructs the client to provide a new client target buffer, even if no
    161      * layers are marked for client composition. */
    162     HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
    163 
    164     /* Instructs the client to write the result of client composition directly
    165      * into the virtual display output buffer. If any of the layers are not
    166      * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
    167      * display, this request has no effect. */
    168     HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
    169 } hwc2_display_request_t;
    170 
    171 /* Display types returned by getDisplayType */
    172 typedef enum {
    173     HWC2_DISPLAY_TYPE_INVALID = 0,
    174 
    175     /* All physical displays, including both internal displays and hotpluggable
    176      * external displays */
    177     HWC2_DISPLAY_TYPE_PHYSICAL = 1,
    178 
    179     /* Virtual displays created by createVirtualDisplay */
    180     HWC2_DISPLAY_TYPE_VIRTUAL = 2,
    181 } hwc2_display_type_t;
    182 
    183 /* Return codes from all functions */
    184 typedef enum {
    185     HWC2_ERROR_NONE = 0,
    186     HWC2_ERROR_BAD_CONFIG,
    187     HWC2_ERROR_BAD_DISPLAY,
    188     HWC2_ERROR_BAD_LAYER,
    189     HWC2_ERROR_BAD_PARAMETER,
    190     HWC2_ERROR_HAS_CHANGES,
    191     HWC2_ERROR_NO_RESOURCES,
    192     HWC2_ERROR_NOT_VALIDATED,
    193     HWC2_ERROR_UNSUPPORTED,
    194 } hwc2_error_t;
    195 
    196 /* Function descriptors for use with getFunction */
    197 typedef enum {
    198     HWC2_FUNCTION_INVALID = 0,
    199     HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
    200     HWC2_FUNCTION_CREATE_LAYER,
    201     HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
    202     HWC2_FUNCTION_DESTROY_LAYER,
    203     HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
    204     HWC2_FUNCTION_DUMP,
    205     HWC2_FUNCTION_GET_ACTIVE_CONFIG,
    206     HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
    207     HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
    208     HWC2_FUNCTION_GET_COLOR_MODES,
    209     HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
    210     HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
    211     HWC2_FUNCTION_GET_DISPLAY_NAME,
    212     HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
    213     HWC2_FUNCTION_GET_DISPLAY_TYPE,
    214     HWC2_FUNCTION_GET_DOZE_SUPPORT,
    215     HWC2_FUNCTION_GET_HDR_CAPABILITIES,
    216     HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
    217     HWC2_FUNCTION_GET_RELEASE_FENCES,
    218     HWC2_FUNCTION_PRESENT_DISPLAY,
    219     HWC2_FUNCTION_REGISTER_CALLBACK,
    220     HWC2_FUNCTION_SET_ACTIVE_CONFIG,
    221     HWC2_FUNCTION_SET_CLIENT_TARGET,
    222     HWC2_FUNCTION_SET_COLOR_MODE,
    223     HWC2_FUNCTION_SET_COLOR_TRANSFORM,
    224     HWC2_FUNCTION_SET_CURSOR_POSITION,
    225     HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
    226     HWC2_FUNCTION_SET_LAYER_BUFFER,
    227     HWC2_FUNCTION_SET_LAYER_COLOR,
    228     HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
    229     HWC2_FUNCTION_SET_LAYER_DATASPACE,
    230     HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
    231     HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
    232     HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
    233     HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
    234     HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
    235     HWC2_FUNCTION_SET_LAYER_TRANSFORM,
    236     HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
    237     HWC2_FUNCTION_SET_LAYER_Z_ORDER,
    238     HWC2_FUNCTION_SET_OUTPUT_BUFFER,
    239     HWC2_FUNCTION_SET_POWER_MODE,
    240     HWC2_FUNCTION_SET_VSYNC_ENABLED,
    241     HWC2_FUNCTION_VALIDATE_DISPLAY,
    242 } hwc2_function_descriptor_t;
    243 
    244 /* Layer requests returned from getDisplayRequests */
    245 typedef enum {
    246     /* The client should clear its target with transparent pixels where this
    247      * layer would be. The client may ignore this request if the layer must be
    248      * blended. */
    249     HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
    250 } hwc2_layer_request_t;
    251 
    252 /* Power modes for use with setPowerMode */
    253 typedef enum {
    254     /* The display is fully off (blanked) */
    255     HWC2_POWER_MODE_OFF = 0,
    256 
    257     /* These are optional low power modes. getDozeSupport may be called to
    258      * determine whether a given display supports these modes. */
    259 
    260     /* The display is turned on and configured in a low power state that is
    261      * suitable for presenting ambient information to the user, possibly with
    262      * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
    263     HWC2_POWER_MODE_DOZE = 1,
    264 
    265     /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
    266      * applying display updates from the client. This is effectively a hint to
    267      * the device that drawing to the display has been suspended and that the
    268      * the device should remain on in a low power state and continue displaying
    269      * its current contents indefinitely until the power mode changes.
    270      *
    271      * This mode may also be used as a signal to enable hardware-based doze
    272      * functionality. In this case, the device is free to take over the display
    273      * and manage it autonomously to implement a low power always-on display. */
    274     HWC2_POWER_MODE_DOZE_SUSPEND = 3,
    275 
    276     /* The display is fully on */
    277     HWC2_POWER_MODE_ON = 2,
    278 } hwc2_power_mode_t;
    279 
    280 /* Vsync values passed to setVsyncEnabled */
    281 typedef enum {
    282     HWC2_VSYNC_INVALID = 0,
    283 
    284     /* Enable vsync */
    285     HWC2_VSYNC_ENABLE = 1,
    286 
    287     /* Disable vsync */
    288     HWC2_VSYNC_DISABLE = 2,
    289 } hwc2_vsync_t;
    290 
    291 /*
    292  * Stringification Functions
    293  */
    294 
    295 #ifdef HWC2_INCLUDE_STRINGIFICATION
    296 
    297 static inline const char* getAttributeName(hwc2_attribute_t attribute) {
    298     switch (attribute) {
    299         case HWC2_ATTRIBUTE_INVALID: return "Invalid";
    300         case HWC2_ATTRIBUTE_WIDTH: return "Width";
    301         case HWC2_ATTRIBUTE_HEIGHT: return "Height";
    302         case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
    303         case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
    304         case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
    305         default: return "Unknown";
    306     }
    307 }
    308 
    309 static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
    310     switch (mode) {
    311         case HWC2_BLEND_MODE_INVALID: return "Invalid";
    312         case HWC2_BLEND_MODE_NONE: return "None";
    313         case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
    314         case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
    315         default: return "Unknown";
    316     }
    317 }
    318 
    319 static inline const char* getCallbackDescriptorName(
    320         hwc2_callback_descriptor_t desc) {
    321     switch (desc) {
    322         case HWC2_CALLBACK_INVALID: return "Invalid";
    323         case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
    324         case HWC2_CALLBACK_REFRESH: return "Refresh";
    325         case HWC2_CALLBACK_VSYNC: return "Vsync";
    326         default: return "Unknown";
    327     }
    328 }
    329 
    330 static inline const char* getCapabilityName(hwc2_capability_t capability) {
    331     switch (capability) {
    332         case HWC2_CAPABILITY_INVALID: return "Invalid";
    333         case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
    334         case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
    335                 return "SkipClientColorTransform";
    336         default: return "Unknown";
    337     }
    338 }
    339 
    340 static inline const char* getCompositionName(hwc2_composition_t composition) {
    341     switch (composition) {
    342         case HWC2_COMPOSITION_INVALID: return "Invalid";
    343         case HWC2_COMPOSITION_CLIENT: return "Client";
    344         case HWC2_COMPOSITION_DEVICE: return "Device";
    345         case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
    346         case HWC2_COMPOSITION_CURSOR: return "Cursor";
    347         case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
    348         default: return "Unknown";
    349     }
    350 }
    351 
    352 static inline const char* getConnectionName(hwc2_connection_t connection) {
    353     switch (connection) {
    354         case HWC2_CONNECTION_INVALID: return "Invalid";
    355         case HWC2_CONNECTION_CONNECTED: return "Connected";
    356         case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
    357         default: return "Unknown";
    358     }
    359 }
    360 
    361 static inline const char* getDisplayRequestName(
    362         hwc2_display_request_t request) {
    363     switch (request) {
    364         case 0: return "None";
    365         case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
    366         case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
    367             return "WriteClientTargetToOutput";
    368         case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
    369                 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
    370             return "FlipClientTarget|WriteClientTargetToOutput";
    371         default: return "Unknown";
    372     }
    373 }
    374 
    375 static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
    376     switch (type) {
    377         case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
    378         case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
    379         case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
    380         default: return "Unknown";
    381     }
    382 }
    383 
    384 static inline const char* getErrorName(hwc2_error_t error) {
    385     switch (error) {
    386         case HWC2_ERROR_NONE: return "None";
    387         case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
    388         case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
    389         case HWC2_ERROR_BAD_LAYER: return "BadLayer";
    390         case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
    391         case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
    392         case HWC2_ERROR_NO_RESOURCES: return "NoResources";
    393         case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
    394         case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
    395         default: return "Unknown";
    396     }
    397 }
    398 
    399 static inline const char* getFunctionDescriptorName(
    400         hwc2_function_descriptor_t desc) {
    401     switch (desc) {
    402         case HWC2_FUNCTION_INVALID: return "Invalid";
    403         case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
    404             return "AcceptDisplayChanges";
    405         case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
    406         case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
    407             return "CreateVirtualDisplay";
    408         case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
    409         case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
    410             return "DestroyVirtualDisplay";
    411         case HWC2_FUNCTION_DUMP: return "Dump";
    412         case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
    413         case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
    414             return "GetChangedCompositionTypes";
    415         case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
    416             return "GetClientTargetSupport";
    417         case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
    418         case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
    419         case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
    420         case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
    421         case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
    422         case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
    423         case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
    424         case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
    425         case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
    426             return "GetMaxVirtualDisplayCount";
    427         case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
    428         case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
    429         case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
    430         case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
    431         case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
    432         case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
    433         case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
    434         case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
    435         case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
    436         case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
    437         case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
    438         case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
    439             return "SetLayerCompositionType";
    440         case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
    441         case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
    442             return "SetLayerDisplayFrame";
    443         case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
    444         case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
    445             return "SetLayerSidebandStream";
    446         case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
    447         case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
    448             return "SetLayerSurfaceDamage";
    449         case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
    450         case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
    451             return "SetLayerVisibleRegion";
    452         case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
    453         case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
    454         case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
    455         case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
    456         case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
    457         default: return "Unknown";
    458     }
    459 }
    460 
    461 static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
    462     switch (request) {
    463         case 0: return "None";
    464         case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
    465         default: return "Unknown";
    466     }
    467 }
    468 
    469 static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
    470     switch (mode) {
    471         case HWC2_POWER_MODE_OFF: return "Off";
    472         case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
    473         case HWC2_POWER_MODE_DOZE: return "Doze";
    474         case HWC2_POWER_MODE_ON: return "On";
    475         default: return "Unknown";
    476     }
    477 }
    478 
    479 static inline const char* getTransformName(hwc_transform_t transform) {
    480     switch (transform) {
    481         case 0: return "None";
    482         case HWC_TRANSFORM_FLIP_H: return "FlipH";
    483         case HWC_TRANSFORM_FLIP_V: return "FlipV";
    484         case HWC_TRANSFORM_ROT_90: return "Rotate90";
    485         case HWC_TRANSFORM_ROT_180: return "Rotate180";
    486         case HWC_TRANSFORM_ROT_270: return "Rotate270";
    487         case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
    488         case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
    489         default: return "Unknown";
    490     }
    491 }
    492 
    493 static inline const char* getVsyncName(hwc2_vsync_t vsync) {
    494     switch (vsync) {
    495         case HWC2_VSYNC_INVALID: return "Invalid";
    496         case HWC2_VSYNC_ENABLE: return "Enable";
    497         case HWC2_VSYNC_DISABLE: return "Disable";
    498         default: return "Unknown";
    499     }
    500 }
    501 
    502 #define TO_STRING(E, T, printer) \
    503     inline std::string to_string(E value) { return printer(value); } \
    504     inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
    505 #else // !HWC2_INCLUDE_STRINGIFICATION
    506 #define TO_STRING(name, printer)
    507 #endif // HWC2_INCLUDE_STRINGIFICATION
    508 
    509 /*
    510  * C++11 features
    511  */
    512 
    513 #ifdef HWC2_USE_CPP11
    514 __END_DECLS
    515 
    516 #ifdef HWC2_INCLUDE_STRINGIFICATION
    517 #include <string>
    518 #endif
    519 
    520 namespace HWC2 {
    521 
    522 enum class Attribute : int32_t {
    523     Invalid = HWC2_ATTRIBUTE_INVALID,
    524     Width = HWC2_ATTRIBUTE_WIDTH,
    525     Height = HWC2_ATTRIBUTE_HEIGHT,
    526     VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
    527     DpiX = HWC2_ATTRIBUTE_DPI_X,
    528     DpiY = HWC2_ATTRIBUTE_DPI_Y,
    529 };
    530 TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
    531 
    532 enum class BlendMode : int32_t {
    533     Invalid = HWC2_BLEND_MODE_INVALID,
    534     None = HWC2_BLEND_MODE_NONE,
    535     Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
    536     Coverage = HWC2_BLEND_MODE_COVERAGE,
    537 };
    538 TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
    539 
    540 enum class Callback : int32_t {
    541     Invalid = HWC2_CALLBACK_INVALID,
    542     Hotplug = HWC2_CALLBACK_HOTPLUG,
    543     Refresh = HWC2_CALLBACK_REFRESH,
    544     Vsync = HWC2_CALLBACK_VSYNC,
    545 };
    546 TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
    547 
    548 enum class Capability : int32_t {
    549     Invalid = HWC2_CAPABILITY_INVALID,
    550     SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
    551     SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
    552 };
    553 TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
    554 
    555 enum class Composition : int32_t {
    556     Invalid = HWC2_COMPOSITION_INVALID,
    557     Client = HWC2_COMPOSITION_CLIENT,
    558     Device = HWC2_COMPOSITION_DEVICE,
    559     SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
    560     Cursor = HWC2_COMPOSITION_CURSOR,
    561     Sideband = HWC2_COMPOSITION_SIDEBAND,
    562 };
    563 TO_STRING(hwc2_composition_t, Composition, getCompositionName)
    564 
    565 enum class Connection : int32_t {
    566     Invalid = HWC2_CONNECTION_INVALID,
    567     Connected = HWC2_CONNECTION_CONNECTED,
    568     Disconnected = HWC2_CONNECTION_DISCONNECTED,
    569 };
    570 TO_STRING(hwc2_connection_t, Connection, getConnectionName)
    571 
    572 enum class DisplayRequest : int32_t {
    573     FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
    574     WriteClientTargetToOutput =
    575         HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
    576 };
    577 TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
    578 
    579 enum class DisplayType : int32_t {
    580     Invalid = HWC2_DISPLAY_TYPE_INVALID,
    581     Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
    582     Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
    583 };
    584 TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
    585 
    586 enum class Error : int32_t {
    587     None = HWC2_ERROR_NONE,
    588     BadConfig = HWC2_ERROR_BAD_CONFIG,
    589     BadDisplay = HWC2_ERROR_BAD_DISPLAY,
    590     BadLayer = HWC2_ERROR_BAD_LAYER,
    591     BadParameter = HWC2_ERROR_BAD_PARAMETER,
    592     HasChanges = HWC2_ERROR_HAS_CHANGES,
    593     NoResources = HWC2_ERROR_NO_RESOURCES,
    594     NotValidated = HWC2_ERROR_NOT_VALIDATED,
    595     Unsupported = HWC2_ERROR_UNSUPPORTED,
    596 };
    597 TO_STRING(hwc2_error_t, Error, getErrorName)
    598 
    599 enum class FunctionDescriptor : int32_t {
    600     Invalid = HWC2_FUNCTION_INVALID,
    601     AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
    602     CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
    603     CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
    604     DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
    605     DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
    606     Dump = HWC2_FUNCTION_DUMP,
    607     GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
    608     GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
    609     GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
    610     GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
    611     GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
    612     GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
    613     GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
    614     GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
    615     GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
    616     GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
    617     GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
    618     GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
    619     GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
    620     PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
    621     RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
    622     SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
    623     SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
    624     SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
    625     SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
    626     SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
    627     SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
    628     SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
    629     SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
    630     SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
    631     SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
    632     SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
    633     SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
    634     SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
    635     SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
    636     SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
    637     SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
    638     SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
    639     SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
    640     SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
    641     SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
    642     SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
    643     ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
    644 };
    645 TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
    646         getFunctionDescriptorName)
    647 
    648 enum class LayerRequest : int32_t {
    649     ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
    650 };
    651 TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
    652 
    653 enum class PowerMode : int32_t {
    654     Off = HWC2_POWER_MODE_OFF,
    655     DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
    656     Doze = HWC2_POWER_MODE_DOZE,
    657     On = HWC2_POWER_MODE_ON,
    658 };
    659 TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
    660 
    661 enum class Transform : int32_t {
    662     None = 0,
    663     FlipH = HWC_TRANSFORM_FLIP_H,
    664     FlipV = HWC_TRANSFORM_FLIP_V,
    665     Rotate90 = HWC_TRANSFORM_ROT_90,
    666     Rotate180 = HWC_TRANSFORM_ROT_180,
    667     Rotate270 = HWC_TRANSFORM_ROT_270,
    668     FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
    669     FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
    670 };
    671 TO_STRING(hwc_transform_t, Transform, getTransformName)
    672 
    673 enum class Vsync : int32_t {
    674     Invalid = HWC2_VSYNC_INVALID,
    675     Enable = HWC2_VSYNC_ENABLE,
    676     Disable = HWC2_VSYNC_DISABLE,
    677 };
    678 TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
    679 
    680 } // namespace HWC2
    681 
    682 __BEGIN_DECLS
    683 #endif // HWC2_USE_CPP11
    684 
    685 /*
    686  * Typedefs
    687  */
    688 
    689 typedef void (*hwc2_function_pointer_t)();
    690 
    691 typedef void* hwc2_callback_data_t;
    692 typedef uint32_t hwc2_config_t;
    693 typedef uint64_t hwc2_display_t;
    694 typedef uint64_t hwc2_layer_t;
    695 
    696 /*
    697  * Device Struct
    698  */
    699 
    700 typedef struct hwc2_device {
    701     /* Must be the first member of this struct, since a pointer to this struct
    702      * will be generated by casting from a hw_device_t* */
    703     struct hw_device_t common;
    704 
    705     /* getCapabilities(..., outCount, outCapabilities)
    706      *
    707      * Provides a list of capabilities (described in the definition of
    708      * hwc2_capability_t above) supported by this device. This list must
    709      * not change after the device has been loaded.
    710      *
    711      * Parameters:
    712      *   outCount - if outCapabilities was NULL, the number of capabilities
    713      *       which would have been returned; if outCapabilities was not NULL,
    714      *       the number of capabilities returned, which must not exceed the
    715      *       value stored in outCount prior to the call
    716      *   outCapabilities - a list of capabilities supported by this device; may
    717      *       be NULL, in which case this function must write into outCount the
    718      *       number of capabilities which would have been written into
    719      *       outCapabilities
    720      */
    721     void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
    722             int32_t* /*hwc2_capability_t*/ outCapabilities);
    723 
    724     /* getFunction(..., descriptor)
    725      *
    726      * Returns a function pointer which implements the requested description.
    727      *
    728      * Parameters:
    729      *   descriptor - the function to return
    730      *
    731      * Returns either a function pointer implementing the requested descriptor
    732      *   or NULL if the described function is not supported by this device.
    733      */
    734     hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
    735             int32_t /*hwc2_function_descriptor_t*/ descriptor);
    736 } hwc2_device_t;
    737 
    738 static inline int hwc2_open(const struct hw_module_t* module,
    739         hwc2_device_t** device) {
    740     return module->methods->open(module, HWC_HARDWARE_COMPOSER,
    741             (struct hw_device_t**) device);
    742 }
    743 
    744 static inline int hwc2_close(hwc2_device_t* device) {
    745     return device->common.close(&device->common);
    746 }
    747 
    748 /*
    749  * Callbacks
    750  *
    751  * All of these callbacks take as their first parameter the callbackData which
    752  * was provided at the time of callback registration, so this parameter is
    753  * omitted from the described parameter lists.
    754  */
    755 
    756 /* hotplug(..., display, connected)
    757  * Descriptor: HWC2_CALLBACK_HOTPLUG
    758  * Will be provided to all HWC2 devices
    759  *
    760  * Notifies the client that the given display has either been connected or
    761  * disconnected. Every active display (even a built-in physical display) must
    762  * trigger at least one hotplug notification, even if it only occurs immediately
    763  * after callback registration.
    764  *
    765  * The client may call back into the device on the same thread to query display
    766  * properties (such as width, height, and vsync period), and other threads may
    767  * call into the device while the callback is in progress. The device must
    768  * serialize calls to this callback such that only one thread is calling it at a
    769  * time.
    770  *
    771  * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
    772  * and the vsync callback should not be called for a display until vsync has
    773  * been enabled with setVsyncEnabled.
    774  *
    775  * Parameters:
    776  *   display - the display which has been hotplugged
    777  *   connected - whether the display has been connected or disconnected
    778  */
    779 typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
    780         hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
    781 
    782 /* refresh(..., display)
    783  * Descriptor: HWC2_CALLBACK_REFRESH
    784  * Will be provided to all HWC2 devices
    785  *
    786  * Notifies the client to trigger a screen refresh. This forces all layer state
    787  * for this display to be resent, and the display to be validated and presented,
    788  * even if there have been no changes.
    789  *
    790  * This refresh will occur some time after the callback is initiated, but not
    791  * necessarily before it returns. This thread, however, is guaranteed not to
    792  * call back into the device, thus it is safe to trigger this callback from
    793  * other functions which call into the device.
    794  *
    795  * Parameters:
    796  *   display - the display to refresh
    797  */
    798 typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
    799         hwc2_display_t display);
    800 
    801 /* vsync(..., display, timestamp)
    802  * Descriptor: HWC2_CALLBACK_VSYNC
    803  * Will be provided to all HWC2 devices
    804  *
    805  * Notifies the client that a vsync event has occurred. This callback must
    806  * only be triggered when vsync is enabled for this display (through
    807  * setVsyncEnabled).
    808  *
    809  * This callback should be triggered from a thread of at least
    810  * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
    811  * less than 0.5 ms. This thread is guaranteed not to call back into the device.
    812  *
    813  * Parameters:
    814  *   display - the display which has received a vsync event
    815  *   timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
    816  *       nanoseconds
    817  */
    818 typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
    819         hwc2_display_t display, int64_t timestamp);
    820 
    821 /*
    822  * Device Functions
    823  *
    824  * All of these functions take as their first parameter a device pointer, so
    825  * this parameter is omitted from the described parameter lists.
    826  */
    827 
    828 /* createVirtualDisplay(..., width, height, format, outDisplay)
    829  * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
    830  * Must be provided by all HWC2 devices
    831  *
    832  * Creates a new virtual display with the given width and height. The format
    833  * passed into this function is the default format requested by the consumer of
    834  * the virtual display output buffers. If a different format will be returned by
    835  * the device, it should be returned in this parameter so it can be set properly
    836  * when handing the buffers to the consumer.
    837  *
    838  * The display will be assumed to be on from the time the first frame is
    839  * presented until the display is destroyed.
    840  *
    841  * Parameters:
    842  *   width - width in pixels
    843  *   height - height in pixels
    844  *   format - prior to the call, the default output buffer format selected by
    845  *       the consumer; after the call, the format the device will produce
    846  *   outDisplay - the newly-created virtual display; pointer will be non-NULL
    847  *
    848  * Returns HWC2_ERROR_NONE or one of the following errors:
    849  *   HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
    850  *       be able to create a virtual display
    851  *   HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
    852  *       display at this time
    853  */
    854 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
    855         hwc2_device_t* device, uint32_t width, uint32_t height,
    856         int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
    857 
    858 /* destroyVirtualDisplay(..., display)
    859  * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
    860  * Must be provided by all HWC2 devices
    861  *
    862  * Destroys a virtual display. After this call all resources consumed by this
    863  * display may be freed by the device and any operations performed on this
    864  * display should fail.
    865  *
    866  * Parameters:
    867  *   display - the virtual display to destroy
    868  *
    869  * Returns HWC2_ERROR_NONE or one of the following errors:
    870  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
    871  *   HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
    872  *       refer to a virtual display
    873  */
    874 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
    875         hwc2_device_t* device, hwc2_display_t display);
    876 
    877 /* dump(..., outSize, outBuffer)
    878  * Descriptor: HWC2_FUNCTION_DUMP
    879  * Must be provided by all HWC2 devices
    880  *
    881  * Retrieves implementation-defined debug information, which will be displayed
    882  * during, for example, `dumpsys SurfaceFlinger`.
    883  *
    884  * If called with outBuffer == NULL, the device should store a copy of the
    885  * desired output and return its length in bytes in outSize. If the device
    886  * already has a stored copy, that copy should be purged and replaced with a
    887  * fresh copy.
    888  *
    889  * If called with outBuffer != NULL, the device should copy its stored version
    890  * of the output into outBuffer and store how many bytes of data it copied into
    891  * outSize. Prior to this call, the client will have populated outSize with the
    892  * maximum number of bytes outBuffer can hold. The device must not write more
    893  * than this amount into outBuffer. If the device does not currently have a
    894  * stored copy, then it should return 0 in outSize.
    895  *
    896  * Any data written into outBuffer need not be null-terminated.
    897  *
    898  * Parameters:
    899  *   outSize - if outBuffer was NULL, the number of bytes needed to copy the
    900  *       device's stored output; if outBuffer was not NULL, the number of bytes
    901  *       written into it, which must not exceed the value stored in outSize
    902  *       prior to the call; pointer will be non-NULL
    903  *   outBuffer - the buffer to write the dump output into; may be NULL as
    904  *       described above; data written into this buffer need not be
    905  *       null-terminated
    906  */
    907 typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
    908         char* outBuffer);
    909 
    910 /* getMaxVirtualDisplayCount(...)
    911  * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
    912  * Must be provided by all HWC2 devices
    913  *
    914  * Returns the maximum number of virtual displays supported by this device
    915  * (which may be 0). The client will not attempt to create more than this many
    916  * virtual displays on this device. This number must not change for the lifetime
    917  * of the device.
    918  */
    919 typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
    920         hwc2_device_t* device);
    921 
    922 /* registerCallback(..., descriptor, callbackData, pointer)
    923  * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
    924  * Must be provided by all HWC2 devices
    925  *
    926  * Provides a callback for the device to call. All callbacks take a callbackData
    927  * item as the first parameter, so this value should be stored with the callback
    928  * for later use. The callbackData may differ from one callback to another. If
    929  * this function is called multiple times with the same descriptor, later
    930  * callbacks replace earlier ones.
    931  *
    932  * Parameters:
    933  *   descriptor - which callback should be set
    934  *   callBackdata - opaque data which must be passed back through the callback
    935  *   pointer - a non-NULL function pointer corresponding to the descriptor
    936  *
    937  * Returns HWC2_ERROR_NONE or one of the following errors:
    938  *   HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
    939  */
    940 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
    941         hwc2_device_t* device,
    942         int32_t /*hwc2_callback_descriptor_t*/ descriptor,
    943         hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
    944 
    945 /*
    946  * Display Functions
    947  *
    948  * All of these functions take as their first two parameters a device pointer
    949  * and a display handle, so these parameters are omitted from the described
    950  * parameter lists.
    951  */
    952 
    953 /* acceptDisplayChanges(...)
    954  * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
    955  * Must be provided by all HWC2 devices
    956  *
    957  * Accepts the changes required by the device from the previous validateDisplay
    958  * call (which may be queried using getChangedCompositionTypes) and revalidates
    959  * the display. This function is equivalent to requesting the changed types from
    960  * getChangedCompositionTypes, setting those types on the corresponding layers,
    961  * and then calling validateDisplay again.
    962  *
    963  * After this call it must be valid to present this display. Calling this after
    964  * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
    965  * should have no other effect.
    966  *
    967  * Returns HWC2_ERROR_NONE or one of the following errors:
    968  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
    969  *   HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
    970  */
    971 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
    972         hwc2_device_t* device, hwc2_display_t display);
    973 
    974 /* createLayer(..., outLayer)
    975  * Descriptor: HWC2_FUNCTION_CREATE_LAYER
    976  * Must be provided by all HWC2 devices
    977  *
    978  * Creates a new layer on the given display.
    979  *
    980  * Parameters:
    981  *   outLayer - the handle of the new layer; pointer will be non-NULL
    982  *
    983  * Returns HWC2_ERROR_NONE or one of the following errors:
    984  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
    985  *   HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
    986  */
    987 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
    988         hwc2_display_t display, hwc2_layer_t* outLayer);
    989 
    990 /* destroyLayer(..., layer)
    991  * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
    992  * Must be provided by all HWC2 devices
    993  *
    994  * Destroys the given layer.
    995  *
    996  * Parameters:
    997  *   layer - the handle of the layer to destroy
    998  *
    999  * Returns HWC2_ERROR_NONE or one of the following errors:
   1000  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1001  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1002  */
   1003 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
   1004         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
   1005 
   1006 /* getActiveConfig(..., outConfig)
   1007  * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
   1008  * Must be provided by all HWC2 devices
   1009  *
   1010  * Retrieves which display configuration is currently active.
   1011  *
   1012  * If no display configuration is currently active, this function must return
   1013  * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
   1014  * the responsibility of the client to call setActiveConfig with a valid
   1015  * configuration before attempting to present anything on the display.
   1016  *
   1017  * Parameters:
   1018  *   outConfig - the currently active display configuration; pointer will be
   1019  *       non-NULL
   1020  *
   1021  * Returns HWC2_ERROR_NONE or one of the following errors:
   1022  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1023  *   HWC2_ERROR_BAD_CONFIG - no configuration is currently active
   1024  */
   1025 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
   1026         hwc2_device_t* device, hwc2_display_t display,
   1027         hwc2_config_t* outConfig);
   1028 
   1029 /* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
   1030  * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
   1031  * Must be provided by all HWC2 devices
   1032  *
   1033  * Retrieves the layers for which the device requires a different composition
   1034  * type than had been set prior to the last call to validateDisplay. The client
   1035  * will either update its state with these types and call acceptDisplayChanges,
   1036  * or will set new types and attempt to validate the display again.
   1037  *
   1038  * outLayers and outTypes may be NULL to retrieve the number of elements which
   1039  * will be returned. The number of elements returned must be the same as the
   1040  * value returned in outNumTypes from the last call to validateDisplay.
   1041  *
   1042  * Parameters:
   1043  *   outNumElements - if outLayers or outTypes were NULL, the number of layers
   1044  *       and types which would have been returned; if both were non-NULL, the
   1045  *       number of elements returned in outLayers and outTypes, which must not
   1046  *       exceed the value stored in outNumElements prior to the call; pointer
   1047  *       will be non-NULL
   1048  *   outLayers - an array of layer handles
   1049  *   outTypes - an array of composition types, each corresponding to an element
   1050  *       of outLayers
   1051  *
   1052  * Returns HWC2_ERROR_NONE or one of the following errors:
   1053  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1054  *   HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
   1055  *       display
   1056  */
   1057 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
   1058         hwc2_device_t* device, hwc2_display_t display,
   1059         uint32_t* outNumElements, hwc2_layer_t* outLayers,
   1060         int32_t* /*hwc2_composition_t*/ outTypes);
   1061 
   1062 /* getClientTargetSupport(..., width, height, format, dataspace)
   1063  * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
   1064  * Must be provided by all HWC2 devices
   1065  *
   1066  * Returns whether a client target with the given properties can be handled by
   1067  * the device.
   1068  *
   1069  * The valid formats can be found in android_pixel_format_t in
   1070  * <system/graphics.h>.
   1071  *
   1072  * For more about dataspaces, see setLayerDataspace.
   1073  *
   1074  * This function must return true for a client target with width and height
   1075  * equal to the active display configuration dimensions,
   1076  * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
   1077  * return true for any other configuration.
   1078  *
   1079  * Parameters:
   1080  *   width - client target width in pixels
   1081  *   height - client target height in pixels
   1082  *   format - client target format
   1083  *   dataspace - client target dataspace, as described in setLayerDataspace
   1084  *
   1085  * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
   1086  * following errors:
   1087  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1088  *   HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
   1089  */
   1090 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
   1091         hwc2_device_t* device, hwc2_display_t display, uint32_t width,
   1092         uint32_t height, int32_t /*android_pixel_format_t*/ format,
   1093         int32_t /*android_dataspace_t*/ dataspace);
   1094 
   1095 /* getColorModes(..., outNumModes, outModes)
   1096  * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
   1097  * Must be provided by all HWC2 devices
   1098  *
   1099  * Returns the color modes supported on this display.
   1100  *
   1101  * The valid color modes can be found in android_color_mode_t in
   1102  * <system/graphics.h>. All HWC2 devices must support at least
   1103  * HAL_COLOR_MODE_NATIVE.
   1104  *
   1105  * outNumModes may be NULL to retrieve the number of modes which will be
   1106  * returned.
   1107  *
   1108  * Parameters:
   1109  *   outNumModes - if outModes was NULL, the number of modes which would have
   1110  *       been returned; if outModes was not NULL, the number of modes returned,
   1111  *       which must not exceed the value stored in outNumModes prior to the
   1112  *       call; pointer will be non-NULL
   1113  *   outModes - an array of color modes
   1114  *
   1115  * Returns HWC2_ERROR_NONE or one of the following errors:
   1116  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1117  */
   1118 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
   1119         hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
   1120         int32_t* /*android_color_mode_t*/ outModes);
   1121 
   1122 /* getDisplayAttribute(..., config, attribute, outValue)
   1123  * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
   1124  * Must be provided by all HWC2 devices
   1125  *
   1126  * Returns a display attribute value for a particular display configuration.
   1127  *
   1128  * Any attribute which is not supported or for which the value is unknown by the
   1129  * device must return a value of -1.
   1130  *
   1131  * Parameters:
   1132  *   config - the display configuration for which to return attribute values
   1133  *   attribute - the attribute to query
   1134  *   outValue - the value of the attribute; the pointer will be non-NULL
   1135  *
   1136  * Returns HWC2_ERROR_NONE or one of the following errors:
   1137  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1138  *   HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
   1139  *       display
   1140  */
   1141 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
   1142         hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
   1143         int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
   1144 
   1145 /* getDisplayConfigs(..., outNumConfigs, outConfigs)
   1146  * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
   1147  * Must be provided by all HWC2 devices
   1148  *
   1149  * Returns handles for all of the valid display configurations on this display.
   1150  *
   1151  * outConfigs may be NULL to retrieve the number of elements which will be
   1152  * returned.
   1153  *
   1154  * Parameters:
   1155  *   outNumConfigs - if outConfigs was NULL, the number of configurations which
   1156  *       would have been returned; if outConfigs was not NULL, the number of
   1157  *       configurations returned, which must not exceed the value stored in
   1158  *       outNumConfigs prior to the call; pointer will be non-NULL
   1159  *   outConfigs - an array of configuration handles
   1160  *
   1161  * Returns HWC2_ERROR_NONE or one of the following errors:
   1162  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1163  */
   1164 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
   1165         hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
   1166         hwc2_config_t* outConfigs);
   1167 
   1168 /* getDisplayName(..., outSize, outName)
   1169  * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
   1170  * Must be provided by all HWC2 devices
   1171  *
   1172  * Returns a human-readable version of the display's name.
   1173  *
   1174  * outName may be NULL to retrieve the length of the name.
   1175  *
   1176  * Parameters:
   1177  *   outSize - if outName was NULL, the number of bytes needed to return the
   1178  *       name if outName was not NULL, the number of bytes written into it,
   1179  *       which must not exceed the value stored in outSize prior to the call;
   1180  *       pointer will be non-NULL
   1181  *   outName - the display's name
   1182  *
   1183  * Returns HWC2_ERROR_NONE or one of the following errors:
   1184  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1185  */
   1186 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
   1187         hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
   1188         char* outName);
   1189 
   1190 /* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
   1191  *     outLayerRequests)
   1192  * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
   1193  * Must be provided by all HWC2 devices
   1194  *
   1195  * Returns the display requests and the layer requests required for the last
   1196  * validated configuration.
   1197  *
   1198  * Display requests provide information about how the client should handle the
   1199  * client target. Layer requests provide information about how the client
   1200  * should handle an individual layer.
   1201  *
   1202  * If outLayers or outLayerRequests is NULL, the required number of layers and
   1203  * requests must be returned in outNumElements, but this number may also be
   1204  * obtained from validateDisplay as outNumRequests (outNumElements must be equal
   1205  * to the value returned in outNumRequests from the last call to
   1206  * validateDisplay).
   1207  *
   1208  * Parameters:
   1209  *   outDisplayRequests - the display requests for the current validated state
   1210  *   outNumElements - if outLayers or outLayerRequests were NULL, the number of
   1211  *       elements which would have been returned, which must be equal to the
   1212  *       value returned in outNumRequests from the last validateDisplay call on
   1213  *       this display; if both were not NULL, the number of elements in
   1214  *       outLayers and outLayerRequests, which must not exceed the value stored
   1215  *       in outNumElements prior to the call; pointer will be non-NULL
   1216  *   outLayers - an array of layers which all have at least one request
   1217  *   outLayerRequests - the requests corresponding to each element of outLayers
   1218  *
   1219  * Returns HWC2_ERROR_NONE or one of the following errors:
   1220  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1221  *   HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
   1222  *       display
   1223  */
   1224 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
   1225         hwc2_device_t* device, hwc2_display_t display,
   1226         int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
   1227         uint32_t* outNumElements, hwc2_layer_t* outLayers,
   1228         int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
   1229 
   1230 /* getDisplayType(..., outType)
   1231  * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
   1232  * Must be provided by all HWC2 devices
   1233  *
   1234  * Returns whether the given display is a physical or virtual display.
   1235  *
   1236  * Parameters:
   1237  *   outType - the type of the display; pointer will be non-NULL
   1238  *
   1239  * Returns HWC2_ERROR_NONE or one of the following errors:
   1240  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1241  */
   1242 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
   1243         hwc2_device_t* device, hwc2_display_t display,
   1244         int32_t* /*hwc2_display_type_t*/ outType);
   1245 
   1246 /* getDozeSupport(..., outSupport)
   1247  * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
   1248  * Must be provided by all HWC2 devices
   1249  *
   1250  * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
   1251  * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
   1252  * DOZE (see the definition of hwc2_power_mode_t for more information), but if
   1253  * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
   1254  * device should not claim support.
   1255  *
   1256  * Parameters:
   1257  *   outSupport - whether the display supports doze modes (1 for yes, 0 for no);
   1258  *       pointer will be non-NULL
   1259  *
   1260  * Returns HWC2_ERROR_NONE or one of the following errors:
   1261  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1262  */
   1263 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
   1264         hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
   1265 
   1266 /* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
   1267  *     outMaxAverageLuminance, outMinLuminance)
   1268  * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
   1269  * Must be provided by all HWC2 devices
   1270  *
   1271  * Returns the high dynamic range (HDR) capabilities of the given display, which
   1272  * are invariant with regard to the active configuration.
   1273  *
   1274  * Displays which are not HDR-capable must return no types in outTypes and set
   1275  * outNumTypes to 0.
   1276  *
   1277  * If outTypes is NULL, the required number of HDR types must be returned in
   1278  * outNumTypes.
   1279  *
   1280  * Parameters:
   1281  *   outNumTypes - if outTypes was NULL, the number of types which would have
   1282  *       been returned; if it was not NULL, the number of types stored in
   1283  *       outTypes, which must not exceed the value stored in outNumTypes prior
   1284  *       to the call; pointer will be non-NULL
   1285  *   outTypes - an array of HDR types, may have 0 elements if the display is not
   1286  *       HDR-capable
   1287  *   outMaxLuminance - the desired content maximum luminance for this display in
   1288  *       cd/m^2; pointer will be non-NULL
   1289  *   outMaxAverageLuminance - the desired content maximum frame-average
   1290  *       luminance for this display in cd/m^2; pointer will be non-NULL
   1291  *   outMinLuminance - the desired content minimum luminance for this display in
   1292  *       cd/m^2; pointer will be non-NULL
   1293  *
   1294  * Returns HWC2_ERROR_NONE or one of the following errors:
   1295  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1296  */
   1297 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
   1298         hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
   1299         int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
   1300         float* outMaxAverageLuminance, float* outMinLuminance);
   1301 
   1302 /* getReleaseFences(..., outNumElements, outLayers, outFences)
   1303  * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
   1304  * Must be provided by all HWC2 devices
   1305  *
   1306  * Retrieves the release fences for device layers on this display which will
   1307  * receive new buffer contents this frame.
   1308  *
   1309  * A release fence is a file descriptor referring to a sync fence object which
   1310  * will be signaled after the device has finished reading from the buffer
   1311  * presented in the prior frame. This indicates that it is safe to start writing
   1312  * to the buffer again. If a given layer's fence is not returned from this
   1313  * function, it will be assumed that the buffer presented on the previous frame
   1314  * is ready to be written.
   1315  *
   1316  * The fences returned by this function should be unique for each layer (even if
   1317  * they point to the same underlying sync object), and ownership of the fences
   1318  * is transferred to the client, which is responsible for closing them.
   1319  *
   1320  * If outLayers or outFences is NULL, the required number of layers and fences
   1321  * must be returned in outNumElements.
   1322  *
   1323  * Parameters:
   1324  *   outNumElements - if outLayers or outFences were NULL, the number of
   1325  *       elements which would have been returned; if both were not NULL, the
   1326  *       number of elements in outLayers and outFences, which must not exceed
   1327  *       the value stored in outNumElements prior to the call; pointer will be
   1328  *       non-NULL
   1329  *   outLayers - an array of layer handles
   1330  *   outFences - an array of sync fence file descriptors as described above,
   1331  *       each corresponding to an element of outLayers
   1332  *
   1333  * Returns HWC2_ERROR_NONE or one of the following errors:
   1334  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1335  */
   1336 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
   1337         hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
   1338         hwc2_layer_t* outLayers, int32_t* outFences);
   1339 
   1340 /* presentDisplay(..., outPresentFence)
   1341  * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
   1342  * Must be provided by all HWC2 devices
   1343  *
   1344  * Presents the current display contents on the screen (or in the case of
   1345  * virtual displays, into the output buffer).
   1346  *
   1347  * Prior to calling this function, the display must be successfully validated
   1348  * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
   1349  * specifically do not count as layer state, so if there are no other changes
   1350  * to the layer state (or to the buffer's properties as described in
   1351  * setLayerBuffer), then it is safe to call this function without first
   1352  * validating the display.
   1353  *
   1354  * If this call succeeds, outPresentFence will be populated with a file
   1355  * descriptor referring to a present sync fence object. For physical displays,
   1356  * this fence will be signaled at the vsync when the result of composition of
   1357  * this frame starts to appear (for video-mode panels) or starts to transfer to
   1358  * panel memory (for command-mode panels). For virtual displays, this fence will
   1359  * be signaled when writes to the output buffer have completed and it is safe to
   1360  * read from it.
   1361  *
   1362  * Parameters:
   1363  *   outPresentFence - a sync fence file descriptor as described above; pointer
   1364  *       will be non-NULL
   1365  *
   1366  * Returns HWC2_ERROR_NONE or one of the following errors:
   1367  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1368  *   HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
   1369  *       display
   1370  *   HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
   1371  *       for this display
   1372  */
   1373 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
   1374         hwc2_device_t* device, hwc2_display_t display,
   1375         int32_t* outPresentFence);
   1376 
   1377 /* setActiveConfig(..., config)
   1378  * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
   1379  * Must be provided by all HWC2 devices
   1380  *
   1381  * Sets the active configuration for this display. Upon returning, the given
   1382  * display configuration should be active and remain so until either this
   1383  * function is called again or the display is disconnected.
   1384  *
   1385  * Parameters:
   1386  *   config - the new display configuration
   1387  *
   1388  * Returns HWC2_ERROR_NONE or one of the following errors:
   1389  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1390  *   HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
   1391  *       this display
   1392  */
   1393 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
   1394         hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
   1395 
   1396 /* setClientTarget(..., target, acquireFence, dataspace, damage)
   1397  * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
   1398  * Must be provided by all HWC2 devices
   1399  *
   1400  * Sets the buffer handle which will receive the output of client composition.
   1401  * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
   1402  * prior to the call to presentDisplay, and layers not marked as
   1403  * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
   1404  *
   1405  * The buffer handle provided may be null if no layers are being composited by
   1406  * the client. This must not result in an error (unless an invalid display
   1407  * handle is also provided).
   1408  *
   1409  * Also provides a file descriptor referring to an acquire sync fence object,
   1410  * which will be signaled when it is safe to read from the client target buffer.
   1411  * If it is already safe to read from this buffer, -1 may be passed instead.
   1412  * The device must ensure that it is safe for the client to close this file
   1413  * descriptor at any point after this function is called.
   1414  *
   1415  * For more about dataspaces, see setLayerDataspace.
   1416  *
   1417  * The damage parameter describes a surface damage region as defined in the
   1418  * description of setLayerSurfaceDamage.
   1419  *
   1420  * Will be called before presentDisplay if any of the layers are marked as
   1421  * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
   1422  * necessary to call this function. It is not necessary to call validateDisplay
   1423  * after changing the target through this function.
   1424  *
   1425  * Parameters:
   1426  *   target - the new target buffer
   1427  *   acquireFence - a sync fence file descriptor as described above
   1428  *   dataspace - the dataspace of the buffer, as described in setLayerDataspace
   1429  *   damage - the surface damage region
   1430  *
   1431  * Returns HWC2_ERROR_NONE or one of the following errors:
   1432  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1433  *   HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
   1434  */
   1435 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
   1436         hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
   1437         int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
   1438         hwc_region_t damage);
   1439 
   1440 /* setColorMode(..., mode)
   1441  * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
   1442  * Must be provided by all HWC2 devices
   1443  *
   1444  * Sets the color mode of the given display.
   1445  *
   1446  * Upon returning from this function, the color mode change must have fully
   1447  * taken effect.
   1448  *
   1449  * The valid color modes can be found in android_color_mode_t in
   1450  * <system/graphics.h>. All HWC2 devices must support at least
   1451  * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
   1452  * hotplug.
   1453  *
   1454  * Parameters:
   1455  *   mode - the mode to set
   1456  *
   1457  * Returns HWC2_ERROR_NONE or one of the following errors:
   1458  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1459  *   HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
   1460  *   HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
   1461  */
   1462 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
   1463         hwc2_device_t* device, hwc2_display_t display,
   1464         int32_t /*android_color_mode_t*/ mode);
   1465 
   1466 /* setColorTransform(..., matrix, hint)
   1467  * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
   1468  * Must be provided by all HWC2 devices
   1469  *
   1470  * Sets a color transform which will be applied after composition.
   1471  *
   1472  * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
   1473  * hint to apply the desired color transform instead of using the color matrix
   1474  * directly.
   1475  *
   1476  * If the device is not capable of either using the hint or the matrix to apply
   1477  * the desired color transform, it should force all layers to client composition
   1478  * during validateDisplay.
   1479  *
   1480  * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
   1481  * will never apply the color transform during client composition, even if all
   1482  * layers are being composed by the client.
   1483  *
   1484  * The matrix provided is an affine color transformation of the following form:
   1485  *
   1486  * |r.r r.g r.b 0|
   1487  * |g.r g.g g.b 0|
   1488  * |b.r b.g b.b 0|
   1489  * |Tr  Tg  Tb  1|
   1490  *
   1491  * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
   1492  *
   1493  * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
   1494  * color [R_out, G_out, B_out] will be:
   1495  *
   1496  * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
   1497  * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
   1498  * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
   1499  *
   1500  * Parameters:
   1501  *   matrix - a 4x4 transform matrix (16 floats) as described above
   1502  *   hint - a hint value which may be used instead of the given matrix unless it
   1503  *       is HAL_COLOR_TRANSFORM_ARBITRARY
   1504  *
   1505  * Returns HWC2_ERROR_NONE or one of the following errors:
   1506  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1507  *   HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
   1508  */
   1509 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
   1510         hwc2_device_t* device, hwc2_display_t display, const float* matrix,
   1511         int32_t /*android_color_transform_t*/ hint);
   1512 
   1513 /* setOutputBuffer(..., buffer, releaseFence)
   1514  * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
   1515  * Must be provided by all HWC2 devices
   1516  *
   1517  * Sets the output buffer for a virtual display. That is, the buffer to which
   1518  * the composition result will be written.
   1519  *
   1520  * Also provides a file descriptor referring to a release sync fence object,
   1521  * which will be signaled when it is safe to write to the output buffer. If it
   1522  * is already safe to write to the output buffer, -1 may be passed instead. The
   1523  * device must ensure that it is safe for the client to close this file
   1524  * descriptor at any point after this function is called.
   1525  *
   1526  * Must be called at least once before presentDisplay, but does not have any
   1527  * interaction with layer state or display validation.
   1528  *
   1529  * Parameters:
   1530  *   buffer - the new output buffer
   1531  *   releaseFence - a sync fence file descriptor as described above
   1532  *
   1533  * Returns HWC2_ERROR_NONE or one of the following errors:
   1534  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1535  *   HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
   1536  *   HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
   1537  */
   1538 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
   1539         hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
   1540         int32_t releaseFence);
   1541 
   1542 /* setPowerMode(..., mode)
   1543  * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
   1544  * Must be provided by all HWC2 devices
   1545  *
   1546  * Sets the power mode of the given display. The transition must be complete
   1547  * when this function returns. It is valid to call this function multiple times
   1548  * with the same power mode.
   1549  *
   1550  * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
   1551  * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
   1552  * be queried using getDozeSupport.
   1553  *
   1554  * Parameters:
   1555  *   mode - the new power mode
   1556  *
   1557  * Returns HWC2_ERROR_NONE or one of the following errors:
   1558  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1559  *   HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
   1560  *   HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
   1561  *       on this display
   1562  */
   1563 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
   1564         hwc2_device_t* device, hwc2_display_t display,
   1565         int32_t /*hwc2_power_mode_t*/ mode);
   1566 
   1567 /* setVsyncEnabled(..., enabled)
   1568  * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
   1569  * Must be provided by all HWC2 devices
   1570  *
   1571  * Enables or disables the vsync signal for the given display. Virtual displays
   1572  * never generate vsync callbacks, and any attempt to enable vsync for a virtual
   1573  * display though this function must return HWC2_ERROR_NONE and have no other
   1574  * effect.
   1575  *
   1576  * Parameters:
   1577  *   enabled - whether to enable or disable vsync
   1578  *
   1579  * Returns HWC2_ERROR_NONE or one of the following errors:
   1580  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1581  *   HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
   1582  */
   1583 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
   1584         hwc2_device_t* device, hwc2_display_t display,
   1585         int32_t /*hwc2_vsync_t*/ enabled);
   1586 
   1587 /* validateDisplay(..., outNumTypes, outNumRequests)
   1588  * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
   1589  * Must be provided by all HWC2 devices
   1590  *
   1591  * Instructs the device to inspect all of the layer state and determine if
   1592  * there are any composition type changes necessary before presenting the
   1593  * display. Permitted changes are described in the definition of
   1594  * hwc2_composition_t above.
   1595  *
   1596  * Also returns the number of layer requests required
   1597  * by the given layer configuration.
   1598  *
   1599  * Parameters:
   1600  *   outNumTypes - the number of composition type changes required by the
   1601  *       device; if greater than 0, the client must either set and validate new
   1602  *       types, or call acceptDisplayChanges to accept the changes returned by
   1603  *       getChangedCompositionTypes; must be the same as the number of changes
   1604  *       returned by getChangedCompositionTypes (see the declaration of that
   1605  *       function for more information); pointer will be non-NULL
   1606  *   outNumRequests - the number of layer requests required by this layer
   1607  *       configuration; must be equal to the number of layer requests returned
   1608  *       by getDisplayRequests (see the declaration of that function for
   1609  *       more information); pointer will be non-NULL
   1610  *
   1611  * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
   1612  * the display using the current layer state. Otherwise returns one of the
   1613  * following errors:
   1614  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1615  *   HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
   1616  *       for more information)
   1617  */
   1618 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
   1619         hwc2_device_t* device, hwc2_display_t display,
   1620         uint32_t* outNumTypes, uint32_t* outNumRequests);
   1621 
   1622 /*
   1623  * Layer Functions
   1624  *
   1625  * These are functions which operate on layers, but which do not modify state
   1626  * that must be validated before use. See also 'Layer State Functions' below.
   1627  *
   1628  * All of these functions take as their first three parameters a device pointer,
   1629  * a display handle for the display which contains the layer, and a layer
   1630  * handle, so these parameters are omitted from the described parameter lists.
   1631  */
   1632 
   1633 /* setCursorPosition(..., x, y)
   1634  * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
   1635  * Must be provided by all HWC2 devices
   1636  *
   1637  * Asynchonously sets the position of a cursor layer.
   1638  *
   1639  * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
   1640  * If validation succeeds (i.e., the device does not request a composition
   1641  * change for that layer), then once a buffer has been set for the layer and it
   1642  * has been presented, its position may be set by this function at any time
   1643  * between presentDisplay and any subsequent validateDisplay calls for this
   1644  * display.
   1645  *
   1646  * Once validateDisplay is called, this function will not be called again until
   1647  * the validate/present sequence is completed.
   1648  *
   1649  * May be called from any thread so long as it is not interleaved with the
   1650  * validate/present sequence as described above.
   1651  *
   1652  * Parameters:
   1653  *   x - the new x coordinate (in pixels from the left of the screen)
   1654  *   y - the new y coordinate (in pixels from the top of the screen)
   1655  *
   1656  * Returns HWC2_ERROR_NONE or one of the following errors:
   1657  *   HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
   1658  *   HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
   1659  *       HWC2_COMPOSITION_CURSOR
   1660  *   HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
   1661  *       validate/present sequence
   1662  */
   1663 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
   1664         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1665         int32_t x, int32_t y);
   1666 
   1667 /* setLayerBuffer(..., buffer, acquireFence)
   1668  * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
   1669  * Must be provided by all HWC2 devices
   1670  *
   1671  * Sets the buffer handle to be displayed for this layer. If the buffer
   1672  * properties set at allocation time (width, height, format, and usage) have not
   1673  * changed since the previous frame, it is not necessary to call validateDisplay
   1674  * before calling presentDisplay unless new state needs to be validated in the
   1675  * interim.
   1676  *
   1677  * Also provides a file descriptor referring to an acquire sync fence object,
   1678  * which will be signaled when it is safe to read from the given buffer. If it
   1679  * is already safe to read from the buffer, -1 may be passed instead. The
   1680  * device must ensure that it is safe for the client to close this file
   1681  * descriptor at any point after this function is called.
   1682  *
   1683  * This function must return HWC2_ERROR_NONE and have no other effect if called
   1684  * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
   1685  * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
   1686  * (because synchronization and buffer updates for these layers are handled
   1687  * elsewhere).
   1688  *
   1689  * Parameters:
   1690  *   buffer - the buffer handle to set
   1691  *   acquireFence - a sync fence file descriptor as described above
   1692  *
   1693  * Returns HWC2_ERROR_NONE or one of the following errors:
   1694  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1695  *   HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
   1696  */
   1697 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
   1698         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1699         buffer_handle_t buffer, int32_t acquireFence);
   1700 
   1701 /* setLayerSurfaceDamage(..., damage)
   1702  * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
   1703  * Must be provided by all HWC2 devices
   1704  *
   1705  * Provides the region of the source buffer which has been modified since the
   1706  * last frame. This region does not need to be validated before calling
   1707  * presentDisplay.
   1708  *
   1709  * Once set through this function, the damage region remains the same until a
   1710  * subsequent call to this function.
   1711  *
   1712  * If damage.numRects > 0, then it may be assumed that any portion of the source
   1713  * buffer not covered by one of the rects has not been modified this frame. If
   1714  * damage.numRects == 0, then the whole source buffer must be treated as if it
   1715  * has been modified.
   1716  *
   1717  * If the layer's contents are not modified relative to the prior frame, damage
   1718  * will contain exactly one empty rect([0, 0, 0, 0]).
   1719  *
   1720  * The damage rects are relative to the pre-transformed buffer, and their origin
   1721  * is the top-left corner. They will not exceed the dimensions of the latched
   1722  * buffer.
   1723  *
   1724  * Parameters:
   1725  *   damage - the new surface damage region
   1726  *
   1727  * Returns HWC2_ERROR_NONE or one of the following errors:
   1728  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1729  */
   1730 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
   1731         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1732         hwc_region_t damage);
   1733 
   1734 /*
   1735  * Layer State Functions
   1736  *
   1737  * These functions modify the state of a given layer. They do not take effect
   1738  * until the display configuration is successfully validated with
   1739  * validateDisplay and the display contents are presented with presentDisplay.
   1740  *
   1741  * All of these functions take as their first three parameters a device pointer,
   1742  * a display handle for the display which contains the layer, and a layer
   1743  * handle, so these parameters are omitted from the described parameter lists.
   1744  */
   1745 
   1746 /* setLayerBlendMode(..., mode)
   1747  * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
   1748  * Must be provided by all HWC2 devices
   1749  *
   1750  * Sets the blend mode of the given layer.
   1751  *
   1752  * Parameters:
   1753  *   mode - the new blend mode
   1754  *
   1755  * Returns HWC2_ERROR_NONE or one of the following errors:
   1756  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1757  *   HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
   1758  */
   1759 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
   1760         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1761         int32_t /*hwc2_blend_mode_t*/ mode);
   1762 
   1763 /* setLayerColor(..., color)
   1764  * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
   1765  * Must be provided by all HWC2 devices
   1766  *
   1767  * Sets the color of the given layer. If the composition type of the layer is
   1768  * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
   1769  * have no other effect.
   1770  *
   1771  * Parameters:
   1772  *   color - the new color
   1773  *
   1774  * Returns HWC2_ERROR_NONE or one of the following errors:
   1775  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1776  */
   1777 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
   1778         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1779         hwc_color_t color);
   1780 
   1781 /* setLayerCompositionType(..., type)
   1782  * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
   1783  * Must be provided by all HWC2 devices
   1784  *
   1785  * Sets the desired composition type of the given layer. During validateDisplay,
   1786  * the device may request changes to the composition types of any of the layers
   1787  * as described in the definition of hwc2_composition_t above.
   1788  *
   1789  * Parameters:
   1790  *   type - the new composition type
   1791  *
   1792  * Returns HWC2_ERROR_NONE or one of the following errors:
   1793  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1794  *   HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
   1795  *   HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
   1796  *       not supported by this device
   1797  */
   1798 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
   1799         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1800         int32_t /*hwc2_composition_t*/ type);
   1801 
   1802 /* setLayerDataspace(..., dataspace)
   1803  * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
   1804  * Must be provided by all HWC2 devices
   1805  *
   1806  * Sets the dataspace that the current buffer on this layer is in.
   1807  *
   1808  * The dataspace provides more information about how to interpret the buffer
   1809  * contents, such as the encoding standard and color transform.
   1810  *
   1811  * See the values of android_dataspace_t in <system/graphics.h> for more
   1812  * information.
   1813  *
   1814  * Parameters:
   1815  *   dataspace - the new dataspace
   1816  *
   1817  * Returns HWC2_ERROR_NONE or one of the following errors:
   1818  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1819  */
   1820 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
   1821         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1822         int32_t /*android_dataspace_t*/ dataspace);
   1823 
   1824 /* setLayerDisplayFrame(..., frame)
   1825  * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
   1826  * Must be provided by all HWC2 devices
   1827  *
   1828  * Sets the display frame (the portion of the display covered by a layer) of the
   1829  * given layer. This frame will not exceed the display dimensions.
   1830  *
   1831  * Parameters:
   1832  *   frame - the new display frame
   1833  *
   1834  * Returns HWC2_ERROR_NONE or one of the following errors:
   1835  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1836  */
   1837 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
   1838         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1839         hwc_rect_t frame);
   1840 
   1841 /* setLayerPlaneAlpha(..., alpha)
   1842  * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
   1843  * Must be provided by all HWC2 devices
   1844  *
   1845  * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
   1846  * will be applied to the whole layer. It can be conceptualized as a
   1847  * preprocessing step which applies the following function:
   1848  *   if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
   1849  *       out.rgb = in.rgb * planeAlpha
   1850  *   out.a = in.a * planeAlpha
   1851  *
   1852  * If the device does not support this operation on a layer which is marked
   1853  * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
   1854  * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
   1855  *
   1856  * Parameters:
   1857  *   alpha - the plane alpha value to apply
   1858  *
   1859  * Returns HWC2_ERROR_NONE or one of the following errors:
   1860  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1861  */
   1862 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
   1863         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1864         float alpha);
   1865 
   1866 /* setLayerSidebandStream(..., stream)
   1867  * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
   1868  * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
   1869  *
   1870  * Sets the sideband stream for this layer. If the composition type of the given
   1871  * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
   1872  * and have no other effect.
   1873  *
   1874  * Parameters:
   1875  *   stream - the new sideband stream
   1876  *
   1877  * Returns HWC2_ERROR_NONE or one of the following errors:
   1878  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1879  *   HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
   1880  */
   1881 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
   1882         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1883         const native_handle_t* stream);
   1884 
   1885 /* setLayerSourceCrop(..., crop)
   1886  * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
   1887  * Must be provided by all HWC2 devices
   1888  *
   1889  * Sets the source crop (the portion of the source buffer which will fill the
   1890  * display frame) of the given layer. This crop rectangle will not exceed the
   1891  * dimensions of the latched buffer.
   1892  *
   1893  * If the device is not capable of supporting a true float source crop (i.e., it
   1894  * will truncate or round the floats to integers), it should set this layer to
   1895  * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
   1896  * rendering.
   1897  *
   1898  * If the device cannot support float source crops, but still wants to handle
   1899  * the layer, it should use the following code (or similar) to convert to
   1900  * an integer crop:
   1901  *   intCrop.left = (int) ceilf(crop.left);
   1902  *   intCrop.top = (int) ceilf(crop.top);
   1903  *   intCrop.right = (int) floorf(crop.right);
   1904  *   intCrop.bottom = (int) floorf(crop.bottom);
   1905  *
   1906  * Parameters:
   1907  *   crop - the new source crop
   1908  *
   1909  * Returns HWC2_ERROR_NONE or one of the following errors:
   1910  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1911  */
   1912 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
   1913         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1914         hwc_frect_t crop);
   1915 
   1916 /* setLayerTransform(..., transform)
   1917  * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
   1918  * Must be provided by all HWC2 devices
   1919  *
   1920  * Sets the transform (rotation/flip) of the given layer.
   1921  *
   1922  * Parameters:
   1923  *   transform - the new transform
   1924  *
   1925  * Returns HWC2_ERROR_NONE or one of the following errors:
   1926  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1927  *   HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
   1928  */
   1929 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
   1930         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1931         int32_t /*hwc_transform_t*/ transform);
   1932 
   1933 /* setLayerVisibleRegion(..., visible)
   1934  * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
   1935  * Must be provided by all HWC2 devices
   1936  *
   1937  * Specifies the portion of the layer that is visible, including portions under
   1938  * translucent areas of other layers. The region is in screen space, and will
   1939  * not exceed the dimensions of the screen.
   1940  *
   1941  * Parameters:
   1942  *   visible - the new visible region, in screen space
   1943  *
   1944  * Returns HWC2_ERROR_NONE or one of the following errors:
   1945  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1946  */
   1947 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
   1948         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1949         hwc_region_t visible);
   1950 
   1951 /* setLayerZOrder(..., z)
   1952  * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
   1953  * Must be provided by all HWC2 devices
   1954  *
   1955  * Sets the desired Z order (height) of the given layer. A layer with a greater
   1956  * Z value occludes a layer with a lesser Z value.
   1957  *
   1958  * Parameters:
   1959  *   z - the new Z order
   1960  *
   1961  * Returns HWC2_ERROR_NONE or one of the following errors:
   1962  *   HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
   1963  */
   1964 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
   1965         hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
   1966         uint32_t z);
   1967 
   1968 __END_DECLS
   1969 
   1970 #endif
   1971