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