1 // clang-format off
2 /*
3 * Copyright 2015 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 #ifndef ANDROID_HARDWARE_HWCOMPOSER2_H
19 #define ANDROID_HARDWARE_HWCOMPOSER2_H
20
21 #include <sys/cdefs.h>
22
23 #include <hardware/hardware.h>
24
25 #include "hwcomposer_defs.h"
26
27 /* Missing in glibc, pull from BIONIC */
28 #if defined(__cplusplus)
29 #define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
30 #else
31 #define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
32 #endif
33
34 __BEGIN_DECLS
35
36 /*
37 * Enums
38 *
39 * For most of these enums, there is an invalid value defined to be 0. This is
40 * an attempt to catch uninitialized fields, and these values should not be
41 * used.
42 */
43
44 /* Display attributes queryable through getDisplayAttribute */
45 typedef enum {
46 HWC2_ATTRIBUTE_INVALID = 0,
47
48 /* Dimensions in pixels */
49 HWC2_ATTRIBUTE_WIDTH = 1,
50 HWC2_ATTRIBUTE_HEIGHT = 2,
51
52 /* Vsync period in nanoseconds */
53 HWC2_ATTRIBUTE_VSYNC_PERIOD = 3,
54
55 /* Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
56 * numbers to be stored in an int32_t without losing too much precision. If
57 * the DPI for a configuration is unavailable or is considered unreliable,
58 * the device may return -1 instead */
59 HWC2_ATTRIBUTE_DPI_X = 4,
60 HWC2_ATTRIBUTE_DPI_Y = 5,
61
62 /* The configuration group this config is associated to.
63 * Switching between configurations within the same group may be done seamlessly
64 * in some conditions via setActiveConfigWithConstraints. */
65 HWC2_ATTRIBUTE_CONFIG_GROUP = 7,
66 } hwc2_attribute_t;
67
68 /* Blend modes, settable per layer */
69 typedef enum {
70 HWC2_BLEND_MODE_INVALID = 0,
71
72 /* colorOut = colorSrc */
73 HWC2_BLEND_MODE_NONE = 1,
74
75 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
76 HWC2_BLEND_MODE_PREMULTIPLIED = 2,
77
78 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
79 HWC2_BLEND_MODE_COVERAGE = 3,
80 } hwc2_blend_mode_t;
81
82 /* See the 'Callbacks' section for more detailed descriptions of what these
83 * functions do */
84 typedef enum {
85 HWC2_CALLBACK_INVALID = 0,
86 HWC2_CALLBACK_HOTPLUG = 1,
87 HWC2_CALLBACK_REFRESH = 2,
88 HWC2_CALLBACK_VSYNC = 3,
89 HWC2_CALLBACK_VSYNC_2_4 = 4,
90 HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED = 5,
91 HWC2_CALLBACK_SEAMLESS_POSSIBLE = 6,
92 } hwc2_callback_descriptor_t;
93
94 /* Optional capabilities which may be supported by some devices. The particular
95 * set of supported capabilities for a given device may be retrieved using
96 * getCapabilities. */
97 typedef enum {
98 HWC2_CAPABILITY_INVALID = 0,
99
100 /* Specifies that the device supports sideband stream layers, for which
101 * buffer content updates and other synchronization will not be provided
102 * through the usual validate/present cycle and must be handled by an
103 * external implementation-defined mechanism. Only changes to layer state
104 * (such as position, size, etc.) need to be performed through the
105 * validate/present cycle. */
106 HWC2_CAPABILITY_SIDEBAND_STREAM = 1,
107
108 /* Specifies that the device will apply a color transform even when either
109 * the client or the device has chosen that all layers should be composed by
110 * the client. This will prevent the client from applying the color
111 * transform during its composition step. */
112 HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2,
113
114 /* Specifies that the present fence must not be used as an accurate
115 * representation of the actual present time of a frame.
116 * This capability must never be set by HWC2 devices.
117 * This capability may be set for HWC1 devices that use the
118 * HWC2On1Adapter where emulation of the present fence using the retire
119 * fence is not feasible.
120 * In the future, CTS tests will require present time to be reliable.
121 */
122 HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE = 3,
123
124 /* Specifies that a device is able to skip the validateDisplay call before
125 * receiving a call to presentDisplay. The client will always skip
126 * validateDisplay and try to call presentDisplay regardless of the changes
127 * in the properties of the layers. If the device returns anything else than
128 * HWC2_ERROR_NONE, it will call validateDisplay then presentDisplay again.
129 * For this capability to be worthwhile the device implementation of
130 * presentDisplay should fail as fast as possible in the case a
131 * validateDisplay step is needed.
132 */
133 HWC2_CAPABILITY_SKIP_VALIDATE = 4,
134 } hwc2_capability_t;
135
136 /* Possible composition types for a given layer */
137 typedef enum {
138 HWC2_COMPOSITION_INVALID = 0,
139
140 /* The client will composite this layer into the client target buffer
141 * (provided to the device through setClientTarget).
142 *
143 * The device must not request any composition type changes for layers of
144 * this type. */
145 HWC2_COMPOSITION_CLIENT = 1,
146
147 /* The device will handle the composition of this layer through a hardware
148 * overlay or other similar means.
149 *
150 * Upon validateDisplay, the device may request a change from this type to
151 * HWC2_COMPOSITION_CLIENT. */
152 HWC2_COMPOSITION_DEVICE = 2,
153
154 /* The device will render this layer using the color set through
155 * setLayerColor. If this functionality is not supported on a layer that the
156 * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
157 * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
158 * upon the next call to validateDisplay.
159 *
160 * Upon validateDisplay, the device may request a change from this type to
161 * HWC2_COMPOSITION_CLIENT. */
162 HWC2_COMPOSITION_SOLID_COLOR = 3,
163
164 /* Similar to DEVICE, but the position of this layer may also be set
165 * asynchronously through setCursorPosition. If this functionality is not
166 * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
167 * device must request that the composition type of that layer is changed to
168 * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
169 *
170 * Upon validateDisplay, the device may request a change from this type to
171 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
172 * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
173 * still permit the device to composite the layer. */
174 HWC2_COMPOSITION_CURSOR = 4,
175
176 /* The device will handle the composition of this layer, as well as its
177 * buffer updates and content synchronization. Only supported on devices
178 * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
179 *
180 * Upon validateDisplay, the device may request a change from this type to
181 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
182 * unlikely that content will display correctly in these cases. */
183 HWC2_COMPOSITION_SIDEBAND = 5,
184 } hwc2_composition_t;
185
186 /* Possible connection options from the hotplug callback */
187 typedef enum {
188 HWC2_CONNECTION_INVALID = 0,
189
190 /* The display has been connected */
191 HWC2_CONNECTION_CONNECTED = 1,
192
193 /* The display has been disconnected */
194 HWC2_CONNECTION_DISCONNECTED = 2,
195 } hwc2_connection_t;
196
197 /* Display requests returned by getDisplayRequests */
198 typedef enum {
199 /* Instructs the client to provide a new client target buffer, even if no
200 * layers are marked for client composition. */
201 HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
202
203 /* Instructs the client to write the result of client composition directly
204 * into the virtual display output buffer. If any of the layers are not
205 * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
206 * display, this request has no effect. */
207 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
208 } hwc2_display_request_t;
209
210 /* Display types returned by getDisplayType */
211 typedef enum {
212 HWC2_DISPLAY_TYPE_INVALID = 0,
213
214 /* All physical displays, including both internal displays and hotpluggable
215 * external displays */
216 HWC2_DISPLAY_TYPE_PHYSICAL = 1,
217
218 /* Virtual displays created by createVirtualDisplay */
219 HWC2_DISPLAY_TYPE_VIRTUAL = 2,
220 } hwc2_display_type_t;
221
222 /* Physical display types returned by getDisplayConnectionType */
223 typedef enum {
224 HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL = 0,
225 HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL = 1,
226 } hwc2_display_connection_type_t;
227
228 /* Return codes from all functions */
229 typedef enum {
230 HWC2_ERROR_NONE = 0,
231 HWC2_ERROR_BAD_CONFIG,
232 HWC2_ERROR_BAD_DISPLAY,
233 HWC2_ERROR_BAD_LAYER,
234 HWC2_ERROR_BAD_PARAMETER,
235 HWC2_ERROR_HAS_CHANGES,
236 HWC2_ERROR_NO_RESOURCES,
237 HWC2_ERROR_NOT_VALIDATED,
238 HWC2_ERROR_UNSUPPORTED,
239 HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
240 HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
241 } hwc2_error_t;
242
243 /* Function descriptors for use with getFunction */
244 typedef enum {
245 HWC2_FUNCTION_INVALID = 0,
246 HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
247 HWC2_FUNCTION_CREATE_LAYER,
248 HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
249 HWC2_FUNCTION_DESTROY_LAYER,
250 HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
251 HWC2_FUNCTION_DUMP,
252 HWC2_FUNCTION_GET_ACTIVE_CONFIG,
253 HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
254 HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
255 HWC2_FUNCTION_GET_COLOR_MODES,
256 HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
257 HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
258 HWC2_FUNCTION_GET_DISPLAY_NAME,
259 HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
260 HWC2_FUNCTION_GET_DISPLAY_TYPE,
261 HWC2_FUNCTION_GET_DOZE_SUPPORT,
262 HWC2_FUNCTION_GET_HDR_CAPABILITIES,
263 HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
264 HWC2_FUNCTION_GET_RELEASE_FENCES,
265 HWC2_FUNCTION_PRESENT_DISPLAY,
266 HWC2_FUNCTION_REGISTER_CALLBACK,
267 HWC2_FUNCTION_SET_ACTIVE_CONFIG,
268 HWC2_FUNCTION_SET_CLIENT_TARGET,
269 HWC2_FUNCTION_SET_COLOR_MODE,
270 HWC2_FUNCTION_SET_COLOR_TRANSFORM,
271 HWC2_FUNCTION_SET_CURSOR_POSITION,
272 HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
273 HWC2_FUNCTION_SET_LAYER_BUFFER,
274 HWC2_FUNCTION_SET_LAYER_COLOR,
275 HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
276 HWC2_FUNCTION_SET_LAYER_DATASPACE,
277 HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
278 HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
279 HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
280 HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
281 HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
282 HWC2_FUNCTION_SET_LAYER_TRANSFORM,
283 HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
284 HWC2_FUNCTION_SET_LAYER_Z_ORDER,
285 HWC2_FUNCTION_SET_OUTPUT_BUFFER,
286 HWC2_FUNCTION_SET_POWER_MODE,
287 HWC2_FUNCTION_SET_VSYNC_ENABLED,
288 HWC2_FUNCTION_VALIDATE_DISPLAY,
289 HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
290 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
291 HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
292 HWC2_FUNCTION_SET_READBACK_BUFFER,
293 HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
294 HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
295 HWC2_FUNCTION_GET_RENDER_INTENTS,
296 HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
297 HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
298
299 // composer 2.3
300 HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
301 HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
302 HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
303 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
304 HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
305 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
306 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
307 HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
308 HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
309
310 // composer 2.4
311 HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
312 HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
313 HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
314 HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE,
315 HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES,
316 HWC2_FUNCTION_SET_CONTENT_TYPE,
317 HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY,
318 HWC2_FUNCTION_SET_LAYER_GENERIC_METADATA,
319 HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY,
320 } hwc2_function_descriptor_t;
321
322 /* Layer requests returned from getDisplayRequests */
323 typedef enum {
324 /* The client should clear its target with transparent pixels where this
325 * layer would be. The client may ignore this request if the layer must be
326 * blended. */
327 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
328 } hwc2_layer_request_t;
329
330 /* Power modes for use with setPowerMode */
331 typedef enum {
332 /* The display is fully off (blanked) */
333 HWC2_POWER_MODE_OFF = 0,
334
335 /* These are optional low power modes. getDozeSupport may be called to
336 * determine whether a given display supports these modes. */
337
338 /* The display is turned on and configured in a low power state that is
339 * suitable for presenting ambient information to the user, possibly with
340 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
341 HWC2_POWER_MODE_DOZE = 1,
342
343 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
344 * applying display updates from the client. This is effectively a hint to
345 * the device that drawing to the display has been suspended and that the
346 * the device should remain on in a low power state and continue displaying
347 * its current contents indefinitely until the power mode changes.
348 *
349 * This mode may also be used as a signal to enable hardware-based doze
350 * functionality. In this case, the device is free to take over the display
351 * and manage it autonomously to implement a low power always-on display. */
352 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
353
354 /* The display is fully on */
355 HWC2_POWER_MODE_ON = 2,
356 } hwc2_power_mode_t;
357
358 typedef enum {
359 HWC2_CONTENT_TYPE_NONE = 0,
360 HWC2_CONTENT_TYPE_GRAPHICS = 1,
361 HWC2_CONTENT_TYPE_PHOTO = 2,
362 HWC2_CONTENT_TYPE_CINEMA = 3,
363 HWC2_CONTENT_TYPE_GAME = 4,
364 } hwc2_content_type_t;
365
366 /* Vsync values passed to setVsyncEnabled */
367 typedef enum {
368 HWC2_VSYNC_INVALID = 0,
369
370 /* Enable vsync */
371 HWC2_VSYNC_ENABLE = 1,
372
373 /* Disable vsync */
374 HWC2_VSYNC_DISABLE = 2,
375 } hwc2_vsync_t;
376
377 /* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */
378 typedef enum {
379 /* SMPTE ST 2084:2014.
380 * Coordinates defined in CIE 1931 xy chromaticity space
381 */
382 HWC2_DISPLAY_RED_PRIMARY_X = 0,
383 HWC2_DISPLAY_RED_PRIMARY_Y = 1,
384 HWC2_DISPLAY_GREEN_PRIMARY_X = 2,
385 HWC2_DISPLAY_GREEN_PRIMARY_Y = 3,
386 HWC2_DISPLAY_BLUE_PRIMARY_X = 4,
387 HWC2_DISPLAY_BLUE_PRIMARY_Y = 5,
388 HWC2_WHITE_POINT_X = 6,
389 HWC2_WHITE_POINT_Y = 7,
390 /* SMPTE ST 2084:2014.
391 * Units: nits
392 * max as defined by ST 2048: 10,000 nits
393 */
394 HWC2_MAX_LUMINANCE = 8,
395 HWC2_MIN_LUMINANCE = 9,
396
397 /* CTA 861.3
398 * Units: nits
399 */
400 HWC2_MAX_CONTENT_LIGHT_LEVEL = 10,
401 HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
402 } hwc2_per_frame_metadata_key_t;
403
404 /* SetDisplayedContentSampling values passed to setDisplayedContentSamplingEnabled */
405 typedef enum {
406 HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID = 0,
407
408 /* Enable displayed content sampling */
409 HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE = 1,
410
411 /* Disable displayed content sampling */
412 HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE = 2,
413 } hwc2_displayed_content_sampling_t;
414
415 typedef enum {
416 HWC2_FORMAT_COMPONENT_0 = 1 << 0, /* The first component (eg, for RGBA_8888, this is R) */
417 HWC2_FORMAT_COMPONENT_1 = 1 << 1, /* The second component (eg, for RGBA_8888, this is G) */
418 HWC2_FORMAT_COMPONENT_2 = 1 << 2, /* The third component (eg, for RGBA_8888, this is B) */
419 HWC2_FORMAT_COMPONENT_3 = 1 << 3, /* The fourth component (eg, for RGBA_8888, this is A) */
420 } hwc2_format_color_component_t;
421
422 /* Optional display capabilities which may be supported by some displays.
423 * The particular set of supported capabilities for a given display may be
424 * retrieved using getDisplayCapabilities. */
425 typedef enum {
426 HWC2_DISPLAY_CAPABILITY_INVALID = 0,
427
428 /**
429 * Specifies that the display must apply a color transform even when either
430 * the client or the device has chosen that all layers should be composed by
431 * the client. This prevents the client from applying the color transform
432 * during its composition step.
433 * If getDisplayCapabilities is supported, the global capability
434 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is ignored.
435 * If getDisplayCapabilities is not supported, and the global capability
436 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
437 * then all displays must be treated as having
438 * HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM.
439 */
440 HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 1,
441
442 /**
443 * Specifies that the display supports PowerMode::DOZE and
444 * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
445 * over DOZE (see the definition of PowerMode for more information),
446 * but if both DOZE and DOZE_SUSPEND are no different from
447 * PowerMode::ON, the device must not claim support.
448 * HWC2_DISPLAY_CAPABILITY_DOZE must be returned by getDisplayCapabilities
449 * when getDozeSupport indicates the display supports PowerMode::DOZE and
450 * PowerMode::DOZE_SUSPEND.
451 */
452 HWC2_DISPLAY_CAPABILITY_DOZE = 2,
453
454 /**
455 * Specified that the display supports brightness operations.
456 */
457 HWC2_DISPLAY_CAPABILITY_BRIGHTNESS = 3,
458
459 /**
460 * Specifies that the display supports a low latency mode. If the connection
461 * to the display is via HDMI, this specifies whether Auto Low Latency Mode
462 * is supported. If, instead, there is an internal connection to the display,
463 * then this specifies that the display has some other custom low latency
464 * mode.
465 */
466 HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE = 5,
467 } hwc2_display_capability_t;
468
469 /*
470 * Stringification Functions
471 */
472
473 #ifdef HWC2_INCLUDE_STRINGIFICATION
474
getAttributeName(hwc2_attribute_t attribute)475 static inline const char* getAttributeName(hwc2_attribute_t attribute) {
476 switch (attribute) {
477 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
478 case HWC2_ATTRIBUTE_WIDTH: return "Width";
479 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
480 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
481 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
482 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
483 case HWC2_ATTRIBUTE_CONFIG_GROUP: return "ConfigGroup";
484 default: return "Unknown";
485 }
486 }
487
getBlendModeName(hwc2_blend_mode_t mode)488 static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
489 switch (mode) {
490 case HWC2_BLEND_MODE_INVALID: return "Invalid";
491 case HWC2_BLEND_MODE_NONE: return "None";
492 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
493 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
494 default: return "Unknown";
495 }
496 }
497
getCallbackDescriptorName(hwc2_callback_descriptor_t desc)498 static inline const char* getCallbackDescriptorName(
499 hwc2_callback_descriptor_t desc) {
500 switch (desc) {
501 case HWC2_CALLBACK_INVALID: return "Invalid";
502 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
503 case HWC2_CALLBACK_REFRESH: return "Refresh";
504 case HWC2_CALLBACK_VSYNC: return "Vsync";
505 case HWC2_CALLBACK_VSYNC_2_4: return "Vsync2.4";
506 case HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED: return "VsyncPeriodTimingChanged";
507 case HWC2_CALLBACK_SEAMLESS_POSSIBLE: return "SeamlessPossible";
508 default: return "Unknown";
509 }
510 }
511
getCapabilityName(hwc2_capability_t capability)512 static inline const char* getCapabilityName(hwc2_capability_t capability) {
513 switch (capability) {
514 case HWC2_CAPABILITY_INVALID: return "Invalid";
515 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
516 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
517 return "SkipClientColorTransform";
518 case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
519 return "PresentFenceIsNotReliable";
520 default: return "Unknown";
521 }
522 }
523
getCompositionName(hwc2_composition_t composition)524 static inline const char* getCompositionName(hwc2_composition_t composition) {
525 switch (composition) {
526 case HWC2_COMPOSITION_INVALID: return "Invalid";
527 case HWC2_COMPOSITION_CLIENT: return "Client";
528 case HWC2_COMPOSITION_DEVICE: return "Device";
529 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
530 case HWC2_COMPOSITION_CURSOR: return "Cursor";
531 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
532 default: return "Unknown";
533 }
534 }
535
getConnectionName(hwc2_connection_t connection)536 static inline const char* getConnectionName(hwc2_connection_t connection) {
537 switch (connection) {
538 case HWC2_CONNECTION_INVALID: return "Invalid";
539 case HWC2_CONNECTION_CONNECTED: return "Connected";
540 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
541 default: return "Unknown";
542 }
543 }
544
getDisplayRequestName(hwc2_display_request_t request)545 static inline const char* getDisplayRequestName(
546 hwc2_display_request_t request) {
547 switch (__BIONIC_CAST(static_cast, int, request)) {
548 case 0: return "None";
549 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
550 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
551 return "WriteClientTargetToOutput";
552 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
553 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
554 return "FlipClientTarget|WriteClientTargetToOutput";
555 default: return "Unknown";
556 }
557 }
558
getDisplayTypeName(hwc2_display_type_t type)559 static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
560 switch (type) {
561 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
562 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
563 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
564 default: return "Unknown";
565 }
566 }
567
getDisplayConnectionTypeName(hwc2_display_connection_type_t type)568 static inline const char* getDisplayConnectionTypeName(hwc2_display_connection_type_t type) {
569 switch (type) {
570 case HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL: return "Internal";
571 case HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL: return "External";
572 default: return "Unknown";
573 }
574 }
575
getErrorName(hwc2_error_t error)576 static inline const char* getErrorName(hwc2_error_t error) {
577 switch (error) {
578 case HWC2_ERROR_NONE: return "None";
579 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
580 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
581 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
582 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
583 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
584 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
585 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
586 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
587 case HWC2_ERROR_SEAMLESS_NOT_ALLOWED: return "SeamlessNotAllowed";
588 case HWC2_ERROR_SEAMLESS_NOT_POSSIBLE: return "SeamlessNotPossible";
589 default: return "Unknown";
590 }
591 }
592
getFunctionDescriptorName(hwc2_function_descriptor_t desc)593 static inline const char* getFunctionDescriptorName(
594 hwc2_function_descriptor_t desc) {
595 switch (desc) {
596 case HWC2_FUNCTION_INVALID: return "Invalid";
597 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
598 return "AcceptDisplayChanges";
599 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
600 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
601 return "CreateVirtualDisplay";
602 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
603 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
604 return "DestroyVirtualDisplay";
605 case HWC2_FUNCTION_DUMP: return "Dump";
606 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
607 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
608 return "GetChangedCompositionTypes";
609 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
610 return "GetClientTargetSupport";
611 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
612 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
613 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
614 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
615 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
616 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
617 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
618 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
619 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
620 return "GetMaxVirtualDisplayCount";
621 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
622 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
623 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
624 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
625 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
626 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
627 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
628 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
629 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
630 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
631 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
632 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
633 return "SetLayerCompositionType";
634 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
635 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
636 return "SetLayerDisplayFrame";
637 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
638 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
639 return "SetLayerSidebandStream";
640 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
641 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
642 return "SetLayerSurfaceDamage";
643 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
644 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
645 return "SetLayerVisibleRegion";
646 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
647 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
648 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
649 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
650 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
651 case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor";
652 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata";
653 case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys";
654 case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer";
655 case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes";
656 case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence";
657 case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents";
658 case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent";
659 case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix";
660
661 // composer 2.3
662 case HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA: return "GetDisplayIdentificationData";
663 case HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES: return "GetDisplayCapabilities";
664 case HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM: return "SetLayerColorTransform";
665 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: return "GetDisplayedContentSamplingAttributes";
666 case HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED: return "SetDisplayedContentSamplingEnabled";
667 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE: return "GetDisplayedContentSample";
668 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS: return "SetLayerPerFrameMetadataBlobs";
669 case HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT: return "GetDisplayBrightnessSupport";
670 case HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS: return "SetDisplayBrightness";
671
672 // composer 2.4
673 case HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE: return "GetDisplayConnectionType";
674 case HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD: return "GetDisplayVsyncPeriod";
675 case HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS: return "SetActiveConfigWithConstraints";
676 case HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE: return "SetAutoLowLatencyMode";
677 case HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES: return "GetSupportedContentTypes";
678 case HWC2_FUNCTION_SET_CONTENT_TYPE: return "SetContentType";
679 case HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY: return "GetClientTargetProperty";
680 case HWC2_FUNCTION_SET_LAYER_GENERIC_METADATA: return "SetLayerGenericMetadata";
681 case HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY: return "GetLayerGenericMetadataKey";
682
683 default: return "Unknown";
684 }
685 }
686
getLayerRequestName(hwc2_layer_request_t request)687 static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
688 switch (__BIONIC_CAST(static_cast, int, request)) {
689 case 0: return "None";
690 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
691 default: return "Unknown";
692 }
693 }
694
getPowerModeName(hwc2_power_mode_t mode)695 static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
696 switch (mode) {
697 case HWC2_POWER_MODE_OFF: return "Off";
698 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
699 case HWC2_POWER_MODE_DOZE: return "Doze";
700 case HWC2_POWER_MODE_ON: return "On";
701 default: return "Unknown";
702 }
703 }
704
getContentTypeName(hwc2_content_type_t contentType)705 static inline const char* getContentTypeName(hwc2_content_type_t contentType) {
706 switch(contentType) {
707 case HWC2_CONTENT_TYPE_NONE: return "None";
708 case HWC2_CONTENT_TYPE_GRAPHICS: return "Graphics";
709 case HWC2_CONTENT_TYPE_PHOTO: return "Photo";
710 case HWC2_CONTENT_TYPE_CINEMA: return "Cinema";
711 case HWC2_CONTENT_TYPE_GAME: return "Game";
712 default: return "Unknown";
713 }
714 }
715
getTransformName(hwc_transform_t transform)716 static inline const char* getTransformName(hwc_transform_t transform) {
717 switch (__BIONIC_CAST(static_cast, int, transform)) {
718 case 0: return "None";
719 case HWC_TRANSFORM_FLIP_H: return "FlipH";
720 case HWC_TRANSFORM_FLIP_V: return "FlipV";
721 case HWC_TRANSFORM_ROT_90: return "Rotate90";
722 case HWC_TRANSFORM_ROT_180: return "Rotate180";
723 case HWC_TRANSFORM_ROT_270: return "Rotate270";
724 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
725 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
726 default: return "Unknown";
727 }
728 }
729
getVsyncName(hwc2_vsync_t vsync)730 static inline const char* getVsyncName(hwc2_vsync_t vsync) {
731 switch (vsync) {
732 case HWC2_VSYNC_INVALID: return "Invalid";
733 case HWC2_VSYNC_ENABLE: return "Enable";
734 case HWC2_VSYNC_DISABLE: return "Disable";
735 default: return "Unknown";
736 }
737 }
738
getDisplayedContentSamplingName(hwc2_displayed_content_sampling_t sampling)739 static inline const char* getDisplayedContentSamplingName(
740 hwc2_displayed_content_sampling_t sampling) {
741 switch (sampling) {
742 case HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID: return "Invalid";
743 case HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE: return "Enable";
744 case HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE: return "Disable";
745 default: return "Unknown";
746 }
747 }
748
getFormatColorComponentName(hwc2_format_color_component_t component)749 static inline const char* getFormatColorComponentName(hwc2_format_color_component_t component) {
750 switch (component) {
751 case HWC2_FORMAT_COMPONENT_0: return "FirstComponent";
752 case HWC2_FORMAT_COMPONENT_1: return "SecondComponent";
753 case HWC2_FORMAT_COMPONENT_2: return "ThirdComponent";
754 case HWC2_FORMAT_COMPONENT_3: return "FourthComponent";
755 default: return "Unknown";
756 }
757 }
758
getDisplayCapabilityName(hwc2_display_capability_t capability)759 static inline const char* getDisplayCapabilityName(hwc2_display_capability_t capability) {
760 switch (capability) {
761 case HWC2_DISPLAY_CAPABILITY_INVALID: return "Invalid";
762 case HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
763 return "SkipClientColorTransform";
764 case HWC2_DISPLAY_CAPABILITY_DOZE:
765 return "Doze";
766 case HWC2_DISPLAY_CAPABILITY_BRIGHTNESS:
767 return "Brightness";
768 case HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE:
769 return "AutoLowLatencyMode";
770 default:
771 return "Unknown";
772 }
773 }
774
775 #define TO_STRING(E, T, printer) \
776 inline std::string to_string(E value) { return printer(value); } \
777 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
778 #else // !HWC2_INCLUDE_STRINGIFICATION
779 #define TO_STRING(name, printer)
780 #endif // HWC2_INCLUDE_STRINGIFICATION
781
782 /*
783 * C++11 features
784 */
785
786 #ifdef HWC2_USE_CPP11
787 __END_DECLS
788
789 #ifdef HWC2_INCLUDE_STRINGIFICATION
790 #include <string>
791 #endif
792
793 namespace HWC2 {
794
795 enum class Attribute : int32_t {
796 Invalid = HWC2_ATTRIBUTE_INVALID,
797 Width = HWC2_ATTRIBUTE_WIDTH,
798 Height = HWC2_ATTRIBUTE_HEIGHT,
799 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
800 DpiX = HWC2_ATTRIBUTE_DPI_X,
801 DpiY = HWC2_ATTRIBUTE_DPI_Y,
802 ConfigGroup = HWC2_ATTRIBUTE_CONFIG_GROUP,
803 };
804 TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
805
806 enum class BlendMode : int32_t {
807 Invalid = HWC2_BLEND_MODE_INVALID,
808 None = HWC2_BLEND_MODE_NONE,
809 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
810 Coverage = HWC2_BLEND_MODE_COVERAGE,
811 };
812 TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
813
814 enum class Callback : int32_t {
815 Invalid = HWC2_CALLBACK_INVALID,
816 Hotplug = HWC2_CALLBACK_HOTPLUG,
817 Refresh = HWC2_CALLBACK_REFRESH,
818 Vsync = HWC2_CALLBACK_VSYNC,
819 Vsync_2_4 = HWC2_CALLBACK_VSYNC_2_4,
820 VsyncPeriodTimingChanged = HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED,
821 SeamlessPossible = HWC2_CALLBACK_SEAMLESS_POSSIBLE,
822 };
823 TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
824
825 enum class Capability : int32_t {
826 Invalid = HWC2_CAPABILITY_INVALID,
827 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
828 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
829 PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE,
830 SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE,
831 };
832 TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
833
834 enum class Composition : int32_t {
835 Invalid = HWC2_COMPOSITION_INVALID,
836 Client = HWC2_COMPOSITION_CLIENT,
837 Device = HWC2_COMPOSITION_DEVICE,
838 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
839 Cursor = HWC2_COMPOSITION_CURSOR,
840 Sideband = HWC2_COMPOSITION_SIDEBAND,
841 };
842 TO_STRING(hwc2_composition_t, Composition, getCompositionName)
843
844 enum class Connection : int32_t {
845 Invalid = HWC2_CONNECTION_INVALID,
846 Connected = HWC2_CONNECTION_CONNECTED,
847 Disconnected = HWC2_CONNECTION_DISCONNECTED,
848 };
849 TO_STRING(hwc2_connection_t, Connection, getConnectionName)
850
851 enum class DisplayRequest : int32_t {
852 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
853 WriteClientTargetToOutput =
854 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
855 };
856 TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
857
858 enum class DisplayType : int32_t {
859 Invalid = HWC2_DISPLAY_TYPE_INVALID,
860 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
861 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
862 };
863 TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
864
865 enum class DisplayConnectionType : uint32_t {
866 Internal = HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL,
867 External = HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL,
868 };
869 TO_STRING(hwc2_display_connection_type_t, DisplayConnectionType, getDisplayConnectionTypeName)
870
871 enum class Error : int32_t {
872 None = HWC2_ERROR_NONE,
873 BadConfig = HWC2_ERROR_BAD_CONFIG,
874 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
875 BadLayer = HWC2_ERROR_BAD_LAYER,
876 BadParameter = HWC2_ERROR_BAD_PARAMETER,
877 HasChanges = HWC2_ERROR_HAS_CHANGES,
878 NoResources = HWC2_ERROR_NO_RESOURCES,
879 NotValidated = HWC2_ERROR_NOT_VALIDATED,
880 Unsupported = HWC2_ERROR_UNSUPPORTED,
881 SeamlessNotAllowed = HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
882 SeamlessNotPossible = HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
883 };
884 TO_STRING(hwc2_error_t, Error, getErrorName)
885
886 enum class FunctionDescriptor : int32_t {
887 Invalid = HWC2_FUNCTION_INVALID,
888 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
889 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
890 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
891 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
892 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
893 Dump = HWC2_FUNCTION_DUMP,
894 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
895 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
896 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
897 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
898 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
899 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
900 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
901 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
902 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
903 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
904 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
905 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
906 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
907 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
908 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
909 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
910 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
911 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
912 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
913 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
914 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
915 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
916 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
917 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
918 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
919 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
920 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
921 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
922 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
923 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
924 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
925 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
926 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
927 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
928 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
929 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
930 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
931 SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
932 SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
933 GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
934 SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER,
935 GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
936 GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
937 GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS,
938 SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
939 GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
940
941 // composer 2.3
942 GetDisplayIdentificationData = HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
943 GetDisplayCapabilities = HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
944 SetLayerColorTransform = HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
945 GetDisplayedContentSamplingAttributes = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
946 SetDisplayedContentSamplingEnabled = HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
947 GetDisplayedContentSample = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
948 SetLayerPerFrameMetadataBlobs = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
949 GetDisplayBrightnessSupport = HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
950 SetDisplayBrightness = HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
951
952 // composer 2.4
953 GetDisplayConnectionType = HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
954 GetDisplayVsyncPeriod = HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
955 SetActiveConfigWithConstraints = HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
956 SetAutoLowLatencyMode = HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE,
957 GetSupportedContentTypes = HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES,
958 SetContentType = HWC2_FUNCTION_SET_CONTENT_TYPE,
959 GetClientTargetProperty = HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY,
960 SetLayerGenericMetadata = HWC2_FUNCTION_SET_LAYER_GENERIC_METADATA,
961 GetLayerGenericMetadataKey = HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY,
962 };
963 TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
964 getFunctionDescriptorName)
965
966 enum class LayerRequest : int32_t {
967 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
968 };
969 TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
970
971 enum class PowerMode : int32_t {
972 Off = HWC2_POWER_MODE_OFF,
973 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
974 Doze = HWC2_POWER_MODE_DOZE,
975 On = HWC2_POWER_MODE_ON,
976 };
977 TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
978
979 enum class ContentType : int32_t {
980 None = HWC2_CONTENT_TYPE_NONE,
981 Graphics = HWC2_CONTENT_TYPE_GRAPHICS,
982 Photo = HWC2_CONTENT_TYPE_PHOTO,
983 Cinema = HWC2_CONTENT_TYPE_CINEMA,
984 Game = HWC2_CONTENT_TYPE_GAME,
985 };
986 TO_STRING(hwc2_content_type_t, ContentType, getContentTypeName)
987
988 enum class Transform : int32_t {
989 None = 0,
990 FlipH = HWC_TRANSFORM_FLIP_H,
991 FlipV = HWC_TRANSFORM_FLIP_V,
992 Rotate90 = HWC_TRANSFORM_ROT_90,
993 Rotate180 = HWC_TRANSFORM_ROT_180,
994 Rotate270 = HWC_TRANSFORM_ROT_270,
995 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
996 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
997 };
998 TO_STRING(hwc_transform_t, Transform, getTransformName)
999
1000 enum class Vsync : int32_t {
1001 Invalid = HWC2_VSYNC_INVALID,
1002 Enable = HWC2_VSYNC_ENABLE,
1003 Disable = HWC2_VSYNC_DISABLE,
1004 };
1005 TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
1006
1007 enum class DisplayCapability : int32_t {
1008 Invalid = HWC2_DISPLAY_CAPABILITY_INVALID,
1009 SkipClientColorTransform = HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
1010 Doze = HWC2_DISPLAY_CAPABILITY_DOZE,
1011 Brightness = HWC2_DISPLAY_CAPABILITY_BRIGHTNESS,
1012 AutoLowLatencyMode = HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE,
1013 };
1014 TO_STRING(hwc2_display_capability_t, DisplayCapability, getDisplayCapabilityName)
1015
1016 } // namespace HWC2
1017
1018 __BEGIN_DECLS
1019 #endif // HWC2_USE_CPP11
1020
1021 /*
1022 * Typedefs
1023 */
1024
1025 typedef void (*hwc2_function_pointer_t)();
1026
1027 typedef void* hwc2_callback_data_t;
1028 typedef uint32_t hwc2_config_t;
1029 typedef uint64_t hwc2_display_t;
1030 typedef uint64_t hwc2_layer_t;
1031 typedef uint32_t hwc2_vsync_period_t;
1032
1033 /*
1034 * Device Struct
1035 */
1036
1037 typedef struct hwc2_device {
1038 /* Must be the first member of this struct, since a pointer to this struct
1039 * will be generated by casting from a hw_device_t* */
1040 struct hw_device_t common;
1041
1042 /* getCapabilities(..., outCount, outCapabilities)
1043 *
1044 * Provides a list of capabilities (described in the definition of
1045 * hwc2_capability_t above) supported by this device. This list must
1046 * not change after the device has been loaded.
1047 *
1048 * Parameters:
1049 * outCount - if outCapabilities was NULL, the number of capabilities
1050 * which would have been returned; if outCapabilities was not NULL,
1051 * the number of capabilities returned, which must not exceed the
1052 * value stored in outCount prior to the call
1053 * outCapabilities - a list of capabilities supported by this device; may
1054 * be NULL, in which case this function must write into outCount the
1055 * number of capabilities which would have been written into
1056 * outCapabilities
1057 */
1058 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
1059 int32_t* /*hwc2_capability_t*/ outCapabilities);
1060
1061 /* getFunction(..., descriptor)
1062 *
1063 * Returns a function pointer which implements the requested description.
1064 *
1065 * Parameters:
1066 * descriptor - the function to return
1067 *
1068 * Returns either a function pointer implementing the requested descriptor
1069 * or NULL if the described function is not supported by this device.
1070 */
1071 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
1072 int32_t /*hwc2_function_descriptor_t*/ descriptor);
1073 } hwc2_device_t;
1074
hwc2_open(const struct hw_module_t * module,hwc2_device_t ** device)1075 static inline int hwc2_open(const struct hw_module_t* module,
1076 hwc2_device_t** device) {
1077 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
1078 TO_HW_DEVICE_T_OPEN(device));
1079 }
1080
hwc2_close(hwc2_device_t * device)1081 static inline int hwc2_close(hwc2_device_t* device) {
1082 return device->common.close(&device->common);
1083 }
1084
1085 /*
1086 * Callbacks
1087 *
1088 * All of these callbacks take as their first parameter the callbackData which
1089 * was provided at the time of callback registration, so this parameter is
1090 * omitted from the described parameter lists.
1091 */
1092
1093 /* hotplug(..., display, connected)
1094 * Descriptor: HWC2_CALLBACK_HOTPLUG
1095 * Will be provided to all HWC2 devices
1096 *
1097 * Notifies the client that the given display has either been connected or
1098 * disconnected. Every active display (even a built-in physical display) must
1099 * trigger at least one hotplug notification, even if it only occurs immediately
1100 * after callback registration.
1101 *
1102 * The client may call back into the device on the same thread to query display
1103 * properties (such as width, height, and vsync period), and other threads may
1104 * call into the device while the callback is in progress. The device must
1105 * serialize calls to this callback such that only one thread is calling it at a
1106 * time.
1107 *
1108 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
1109 * and the vsync callback should not be called for a display until vsync has
1110 * been enabled with setVsyncEnabled.
1111 *
1112 * Parameters:
1113 * display - the display which has been hotplugged
1114 * connected - whether the display has been connected or disconnected
1115 */
1116 typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
1117 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
1118
1119 /* refresh(..., display)
1120 * Descriptor: HWC2_CALLBACK_REFRESH
1121 * Will be provided to all HWC2 devices
1122 *
1123 * Notifies the client to trigger a screen refresh. This forces all layer state
1124 * for this display to be resent, and the display to be validated and presented,
1125 * even if there have been no changes.
1126 *
1127 * This refresh will occur some time after the callback is initiated, but not
1128 * necessarily before it returns. This thread, however, is guaranteed not to
1129 * call back into the device, thus it is safe to trigger this callback from
1130 * other functions which call into the device.
1131 *
1132 * Parameters:
1133 * display - the display to refresh
1134 */
1135 typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
1136 hwc2_display_t display);
1137
1138 /* vsync(..., display, timestamp)
1139 * Descriptor: HWC2_CALLBACK_VSYNC
1140 * Will be provided to all HWC2 devices
1141 *
1142 * Notifies the client that a vsync event has occurred. This callback must
1143 * only be triggered when vsync is enabled for this display (through
1144 * setVsyncEnabled).
1145 *
1146 * This callback should be triggered from a thread of at least
1147 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1148 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1149 *
1150 * Parameters:
1151 * display - the display which has received a vsync event
1152 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1153 * nanoseconds
1154 */
1155 typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
1156 hwc2_display_t display, int64_t timestamp);
1157
1158 /* vsync_2_4(..., display, timestamp, vsyncPeriodNanos)
1159 * Descriptor: HWC2_CALLBACK_VSYNC_2_4
1160 * Required for HWC2 devices for composer 2.4
1161 *
1162 * Notifies the client that a vsync event has occurred. This callback must
1163 * only be triggered when vsync is enabled for this display (through
1164 * setVsyncEnabled).
1165 *
1166 * This callback should be triggered from a thread of at least
1167 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1168 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1169 *
1170 * Parameters:
1171 * display - the display which has received a vsync event
1172 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1173 * nanoseconds
1174 * vsyncPeriodNanos - the display vsync period in nanoseconds i.e. the next onVsync2_4 is
1175 * expected to be called vsyncPeriod nanoseconds after this call.
1176 */
1177 typedef void (*HWC2_PFN_VSYNC_2_4)(hwc2_callback_data_t callbackData,
1178 hwc2_display_t display, int64_t timestamp, hwc2_vsync_period_t vsyncPeriodNanos);
1179
1180 /* vsyncPeriodTimingChanged(..., display, updated_timeline)
1181 * Descriptor: HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED
1182 * Optional for HWC2 devices for composer 2.4
1183 *
1184 * Notifies the client that the previously reported timing for vsync period change has been
1185 * updated. This may occur if the composer missed the deadline for changing the vsync period
1186 * or the client submitted a refresh frame too late.
1187 *
1188 * This callback should be triggered from a thread of at least
1189 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1190 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1191 *
1192 * Parameters:
1193 * display - the display which has received a vsync event
1194 * updated_timeline - new timeline for the vsync period change
1195 */
1196 typedef void (*HWC2_PFN_VSYNC_PERIOD_TIMING_CHANGED)(hwc2_callback_data_t callbackData,
1197 hwc2_display_t display, hwc_vsync_period_change_timeline_t* updated_timeline);
1198
1199 /* SeamlessPossible(..., display)
1200 * Descriptor: HWC2_CALLBACK_SEAMLESS_POSSIBLE
1201 * Optional for HWC2 devices for composer 2.4
1202 *
1203 * Notifies the client that the conditions which previously led to returning SEAMLESS_NOT_POSSIBLE
1204 * from setActiveConfigWithConstraints have changed and now seamless may be possible. Client should
1205 * retry calling setActiveConfigWithConstraints.
1206 *
1207 *
1208 * Parameters:
1209 * display - a display setActiveConfigWithConstraints previously failed with
1210 * SEAMLESS_NOT_POSSIBLE.
1211 */
1212 typedef void (*HWC2_PFN_SEAMLESS_POSSIBLE)(hwc2_callback_data_t callbackData,
1213 hwc2_display_t display);
1214
1215 /*
1216 * Device Functions
1217 *
1218 * All of these functions take as their first parameter a device pointer, so
1219 * this parameter is omitted from the described parameter lists.
1220 */
1221
1222 /* createVirtualDisplay(..., width, height, format, outDisplay)
1223 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
1224 * Must be provided by all HWC2 devices
1225 *
1226 * Creates a new virtual display with the given width and height. The format
1227 * passed into this function is the default format requested by the consumer of
1228 * the virtual display output buffers. If a different format will be returned by
1229 * the device, it should be returned in this parameter so it can be set properly
1230 * when handing the buffers to the consumer.
1231 *
1232 * The display will be assumed to be on from the time the first frame is
1233 * presented until the display is destroyed.
1234 *
1235 * Parameters:
1236 * width - width in pixels
1237 * height - height in pixels
1238 * format - prior to the call, the default output buffer format selected by
1239 * the consumer; after the call, the format the device will produce
1240 * outDisplay - the newly-created virtual display; pointer will be non-NULL
1241 *
1242 * Returns HWC2_ERROR_NONE or one of the following errors:
1243 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
1244 * be able to create a virtual display
1245 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
1246 * display at this time
1247 */
1248 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
1249 hwc2_device_t* device, uint32_t width, uint32_t height,
1250 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
1251
1252 /* destroyVirtualDisplay(..., display)
1253 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
1254 * Must be provided by all HWC2 devices
1255 *
1256 * Destroys a virtual display. After this call all resources consumed by this
1257 * display may be freed by the device and any operations performed on this
1258 * display should fail.
1259 *
1260 * Parameters:
1261 * display - the virtual display to destroy
1262 *
1263 * Returns HWC2_ERROR_NONE or one of the following errors:
1264 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1265 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
1266 * refer to a virtual display
1267 */
1268 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
1269 hwc2_device_t* device, hwc2_display_t display);
1270
1271 /* dump(..., outSize, outBuffer)
1272 * Descriptor: HWC2_FUNCTION_DUMP
1273 * Must be provided by all HWC2 devices
1274 *
1275 * Retrieves implementation-defined debug information, which will be displayed
1276 * during, for example, `dumpsys SurfaceFlinger`.
1277 *
1278 * If called with outBuffer == NULL, the device should store a copy of the
1279 * desired output and return its length in bytes in outSize. If the device
1280 * already has a stored copy, that copy should be purged and replaced with a
1281 * fresh copy.
1282 *
1283 * If called with outBuffer != NULL, the device should copy its stored version
1284 * of the output into outBuffer and store how many bytes of data it copied into
1285 * outSize. Prior to this call, the client will have populated outSize with the
1286 * maximum number of bytes outBuffer can hold. The device must not write more
1287 * than this amount into outBuffer. If the device does not currently have a
1288 * stored copy, then it should return 0 in outSize.
1289 *
1290 * Any data written into outBuffer need not be null-terminated.
1291 *
1292 * Parameters:
1293 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
1294 * device's stored output; if outBuffer was not NULL, the number of bytes
1295 * written into it, which must not exceed the value stored in outSize
1296 * prior to the call; pointer will be non-NULL
1297 * outBuffer - the buffer to write the dump output into; may be NULL as
1298 * described above; data written into this buffer need not be
1299 * null-terminated
1300 */
1301 typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
1302 char* outBuffer);
1303
1304 /* getMaxVirtualDisplayCount(...)
1305 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
1306 * Must be provided by all HWC2 devices
1307 *
1308 * Returns the maximum number of virtual displays supported by this device
1309 * (which may be 0). The client will not attempt to create more than this many
1310 * virtual displays on this device. This number must not change for the lifetime
1311 * of the device.
1312 */
1313 typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
1314 hwc2_device_t* device);
1315
1316 /* registerCallback(..., descriptor, callbackData, pointer)
1317 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
1318 * Must be provided by all HWC2 devices
1319 *
1320 * Provides a callback for the device to call. All callbacks take a callbackData
1321 * item as the first parameter, so this value should be stored with the callback
1322 * for later use. The callbackData may differ from one callback to another. If
1323 * this function is called multiple times with the same descriptor, later
1324 * callbacks replace earlier ones.
1325 *
1326 * Parameters:
1327 * descriptor - which callback should be set
1328 * callBackdata - opaque data which must be passed back through the callback
1329 * pointer - a non-NULL function pointer corresponding to the descriptor
1330 *
1331 * Returns HWC2_ERROR_NONE or one of the following errors:
1332 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
1333 */
1334 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
1335 hwc2_device_t* device,
1336 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
1337 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
1338
1339 /* getDataspaceSaturationMatrix(..., dataspace, outMatrix)
1340 * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
1341 * Provided by HWC2 devices which don't return nullptr function pointer.
1342 *
1343 * Get the saturation matrix of the specified dataspace. The saturation matrix
1344 * can be used to approximate the dataspace saturation operation performed by
1345 * the HWC2 device when non-colorimetric mapping is allowed. It is to be
1346 * applied on linear pixel values.
1347 *
1348 * Parameters:
1349 * dataspace - the dataspace to query for
1350 * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity
1351 * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR.
1352 *
1353 * Returns HWC2_ERROR_NONE or one of the following errors:
1354 * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid
1355 */
1356 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)(
1357 hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace,
1358 float* outMatrix);
1359
1360 /*
1361 * Display Functions
1362 *
1363 * All of these functions take as their first two parameters a device pointer
1364 * and a display handle, so these parameters are omitted from the described
1365 * parameter lists.
1366 */
1367
1368 /* acceptDisplayChanges(...)
1369 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
1370 * Must be provided by all HWC2 devices
1371 *
1372 * Accepts the changes required by the device from the previous validateDisplay
1373 * call (which may be queried using getChangedCompositionTypes) and revalidates
1374 * the display. This function is equivalent to requesting the changed types from
1375 * getChangedCompositionTypes, setting those types on the corresponding layers,
1376 * and then calling validateDisplay again.
1377 *
1378 * After this call it must be valid to present this display. Calling this after
1379 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
1380 * should have no other effect.
1381 *
1382 * Returns HWC2_ERROR_NONE or one of the following errors:
1383 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1384 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
1385 */
1386 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
1387 hwc2_device_t* device, hwc2_display_t display);
1388
1389 /* createLayer(..., outLayer)
1390 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
1391 * Must be provided by all HWC2 devices
1392 *
1393 * Creates a new layer on the given display.
1394 *
1395 * Parameters:
1396 * outLayer - the handle of the new layer; pointer will be non-NULL
1397 *
1398 * Returns HWC2_ERROR_NONE or one of the following errors:
1399 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1400 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
1401 */
1402 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
1403 hwc2_display_t display, hwc2_layer_t* outLayer);
1404
1405 /* destroyLayer(..., layer)
1406 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
1407 * Must be provided by all HWC2 devices
1408 *
1409 * Destroys the given layer.
1410 *
1411 * Parameters:
1412 * layer - the handle of the layer to destroy
1413 *
1414 * Returns HWC2_ERROR_NONE or one of the following errors:
1415 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1416 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1417 */
1418 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1419 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1420
1421 /* getActiveConfig(..., outConfig)
1422 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1423 * Must be provided by all HWC2 devices
1424 *
1425 * Retrieves which display configuration is currently active.
1426 *
1427 * If no display configuration is currently active, this function must return
1428 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1429 * the responsibility of the client to call setActiveConfig with a valid
1430 * configuration before attempting to present anything on the display.
1431 *
1432 * Parameters:
1433 * outConfig - the currently active display configuration; pointer will be
1434 * non-NULL
1435 *
1436 * Returns HWC2_ERROR_NONE or one of the following errors:
1437 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1438 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1439 */
1440 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1441 hwc2_device_t* device, hwc2_display_t display,
1442 hwc2_config_t* outConfig);
1443
1444 /* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1445 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1446 * Must be provided by all HWC2 devices
1447 *
1448 * Retrieves the layers for which the device requires a different composition
1449 * type than had been set prior to the last call to validateDisplay. The client
1450 * will either update its state with these types and call acceptDisplayChanges,
1451 * or will set new types and attempt to validate the display again.
1452 *
1453 * outLayers and outTypes may be NULL to retrieve the number of elements which
1454 * will be returned. The number of elements returned must be the same as the
1455 * value returned in outNumTypes from the last call to validateDisplay.
1456 *
1457 * Parameters:
1458 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1459 * and types which would have been returned; if both were non-NULL, the
1460 * number of elements returned in outLayers and outTypes, which must not
1461 * exceed the value stored in outNumElements prior to the call; pointer
1462 * will be non-NULL
1463 * outLayers - an array of layer handles
1464 * outTypes - an array of composition types, each corresponding to an element
1465 * of outLayers
1466 *
1467 * Returns HWC2_ERROR_NONE or one of the following errors:
1468 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1469 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1470 * display
1471 */
1472 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1473 hwc2_device_t* device, hwc2_display_t display,
1474 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1475 int32_t* /*hwc2_composition_t*/ outTypes);
1476
1477 /* getClientTargetSupport(..., width, height, format, dataspace)
1478 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1479 * Must be provided by all HWC2 devices
1480 *
1481 * Returns whether a client target with the given properties can be handled by
1482 * the device.
1483 *
1484 * The valid formats can be found in android_pixel_format_t in
1485 * <system/graphics.h>.
1486 *
1487 * For more about dataspaces, see setLayerDataspace.
1488 *
1489 * This function must return true for a client target with width and height
1490 * equal to the active display configuration dimensions,
1491 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1492 * return true for any other configuration.
1493 *
1494 * Parameters:
1495 * width - client target width in pixels
1496 * height - client target height in pixels
1497 * format - client target format
1498 * dataspace - client target dataspace, as described in setLayerDataspace
1499 *
1500 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1501 * following errors:
1502 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1503 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1504 */
1505 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1506 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1507 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1508 int32_t /*android_dataspace_t*/ dataspace);
1509
1510 /* getColorModes(..., outNumModes, outModes)
1511 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1512 * Must be provided by all HWC2 devices
1513 *
1514 * Returns the color modes supported on this display.
1515 *
1516 * The valid color modes can be found in android_color_mode_t in
1517 * <system/graphics.h>. All HWC2 devices must support at least
1518 * HAL_COLOR_MODE_NATIVE.
1519 *
1520 * outNumModes may be NULL to retrieve the number of modes which will be
1521 * returned.
1522 *
1523 * Parameters:
1524 * outNumModes - if outModes was NULL, the number of modes which would have
1525 * been returned; if outModes was not NULL, the number of modes returned,
1526 * which must not exceed the value stored in outNumModes prior to the
1527 * call; pointer will be non-NULL
1528 * outModes - an array of color modes
1529 *
1530 * Returns HWC2_ERROR_NONE or one of the following errors:
1531 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1532 */
1533 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1534 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1535 int32_t* /*android_color_mode_t*/ outModes);
1536
1537 /* getRenderIntents(..., mode, outNumIntents, outIntents)
1538 * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS
1539 * Provided by HWC2 devices which don't return nullptr function pointer.
1540 *
1541 * Returns the render intents supported on this display.
1542 *
1543 * The valid render intents can be found in android_render_intent_v1_1_t in
1544 * <system/graphics.h>. All HWC2 devices must support at least
1545 * HAL_RENDER_INTENT_COLORIMETRIC.
1546 *
1547 * outNumIntents may be NULL to retrieve the number of intents which will be
1548 * returned.
1549 *
1550 * Parameters:
1551 * mode - the color mode to query the render intents for
1552 * outNumIntents - if outIntents was NULL, the number of intents which would
1553 * have been returned; if outIntents was not NULL, the number of intents
1554 * returned, which must not exceed the value stored in outNumIntents
1555 * prior to the call; pointer will be non-NULL
1556 * outIntents - an array of render intents
1557 *
1558 * Returns HWC2_ERROR_NONE or one of the following errors:
1559 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1560 */
1561 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)(
1562 hwc2_device_t* device, hwc2_display_t display, int32_t mode,
1563 uint32_t* outNumIntents,
1564 int32_t* /*android_render_intent_v1_1_t*/ outIntents);
1565
1566 /* getDisplayAttribute(..., config, attribute, outValue)
1567 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1568 * Must be provided by all HWC2 devices
1569 *
1570 * Returns a display attribute value for a particular display configuration.
1571 *
1572 * Any attribute which is not supported or for which the value is unknown by the
1573 * device must return a value of -1.
1574 *
1575 * Parameters:
1576 * config - the display configuration for which to return attribute values
1577 * attribute - the attribute to query
1578 * outValue - the value of the attribute; the pointer will be non-NULL
1579 *
1580 * Returns HWC2_ERROR_NONE or one of the following errors:
1581 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1582 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1583 * display
1584 */
1585 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1586 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1587 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1588
1589 /* getDisplayConfigs(..., outNumConfigs, outConfigs)
1590 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1591 * Must be provided by all HWC2 devices
1592 *
1593 * Returns handles for all of the valid display configurations on this display.
1594 *
1595 * outConfigs may be NULL to retrieve the number of elements which will be
1596 * returned.
1597 *
1598 * Parameters:
1599 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1600 * would have been returned; if outConfigs was not NULL, the number of
1601 * configurations returned, which must not exceed the value stored in
1602 * outNumConfigs prior to the call; pointer will be non-NULL
1603 * outConfigs - an array of configuration handles
1604 *
1605 * Returns HWC2_ERROR_NONE or one of the following errors:
1606 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1607 */
1608 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1609 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1610 hwc2_config_t* outConfigs);
1611
1612 /* getDisplayName(..., outSize, outName)
1613 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1614 * Must be provided by all HWC2 devices
1615 *
1616 * Returns a human-readable version of the display's name.
1617 *
1618 * outName may be NULL to retrieve the length of the name.
1619 *
1620 * Parameters:
1621 * outSize - if outName was NULL, the number of bytes needed to return the
1622 * name if outName was not NULL, the number of bytes written into it,
1623 * which must not exceed the value stored in outSize prior to the call;
1624 * pointer will be non-NULL
1625 * outName - the display's name
1626 *
1627 * Returns HWC2_ERROR_NONE or one of the following errors:
1628 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1629 */
1630 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1631 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1632 char* outName);
1633
1634 /* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1635 * outLayerRequests)
1636 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1637 * Must be provided by all HWC2 devices
1638 *
1639 * Returns the display requests and the layer requests required for the last
1640 * validated configuration.
1641 *
1642 * Display requests provide information about how the client should handle the
1643 * client target. Layer requests provide information about how the client
1644 * should handle an individual layer.
1645 *
1646 * If outLayers or outLayerRequests is NULL, the required number of layers and
1647 * requests must be returned in outNumElements, but this number may also be
1648 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1649 * to the value returned in outNumRequests from the last call to
1650 * validateDisplay).
1651 *
1652 * Parameters:
1653 * outDisplayRequests - the display requests for the current validated state
1654 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1655 * elements which would have been returned, which must be equal to the
1656 * value returned in outNumRequests from the last validateDisplay call on
1657 * this display; if both were not NULL, the number of elements in
1658 * outLayers and outLayerRequests, which must not exceed the value stored
1659 * in outNumElements prior to the call; pointer will be non-NULL
1660 * outLayers - an array of layers which all have at least one request
1661 * outLayerRequests - the requests corresponding to each element of outLayers
1662 *
1663 * Returns HWC2_ERROR_NONE or one of the following errors:
1664 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1665 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1666 * display
1667 */
1668 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1669 hwc2_device_t* device, hwc2_display_t display,
1670 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1671 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1672 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1673
1674 /* getDisplayType(..., outType)
1675 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1676 * Must be provided by all HWC2 devices
1677 *
1678 * Returns whether the given display is a physical or virtual display.
1679 *
1680 * Parameters:
1681 * outType - the type of the display; pointer will be non-NULL
1682 *
1683 * Returns HWC2_ERROR_NONE or one of the following errors:
1684 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1685 */
1686 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1687 hwc2_device_t* device, hwc2_display_t display,
1688 int32_t* /*hwc2_display_type_t*/ outType);
1689
1690 /* getDisplayIdentificationData(..., outPort, outDataSize, outData)
1691 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
1692 * Optional for HWC2 devices
1693 *
1694 * If supported, getDisplayIdentificationData returns the port and data that
1695 * describe a physical display. The port is a unique number that identifies a
1696 * physical connector (e.g. eDP, HDMI) for display output. The data blob is
1697 * parsed to determine its format, typically EDID 1.3 as specified in VESA
1698 * E-EDID Standard Release A Revision 1.
1699 *
1700 * Devices for which display identification is unsupported must return null when
1701 * getFunction is called with HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA.
1702 *
1703 * Parameters:
1704 * outPort - the connector to which the display is connected;
1705 * pointer will be non-NULL
1706 * outDataSize - if outData is NULL, the size in bytes of the data which would
1707 * have been returned; if outData is not NULL, the size of outData, which
1708 * must not exceed the value stored in outDataSize prior to the call;
1709 * pointer will be non-NULL
1710 * outData - the EDID 1.3 blob identifying the display
1711 *
1712 * Returns HWC2_ERROR_NONE or one of the following errors:
1713 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1714 */
1715 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA)(
1716 hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
1717 uint32_t* outDataSize, uint8_t* outData);
1718
1719 /* getDozeSupport(..., outSupport)
1720 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1721 * Must be provided by all HWC2 devices
1722 *
1723 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1724 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1725 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1726 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1727 * device should not claim support.
1728 *
1729 * Parameters:
1730 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1731 * pointer will be non-NULL
1732 *
1733 * Returns HWC2_ERROR_NONE or one of the following errors:
1734 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1735 */
1736 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1737 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1738
1739 /* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1740 * outMaxAverageLuminance, outMinLuminance)
1741 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1742 * Must be provided by all HWC2 devices
1743 *
1744 * Returns the high dynamic range (HDR) capabilities of the given display, which
1745 * are invariant with regard to the active configuration.
1746 *
1747 * Displays which are not HDR-capable must return no types in outTypes and set
1748 * outNumTypes to 0.
1749 *
1750 * If outTypes is NULL, the required number of HDR types must be returned in
1751 * outNumTypes.
1752 *
1753 * Parameters:
1754 * outNumTypes - if outTypes was NULL, the number of types which would have
1755 * been returned; if it was not NULL, the number of types stored in
1756 * outTypes, which must not exceed the value stored in outNumTypes prior
1757 * to the call; pointer will be non-NULL
1758 * outTypes - an array of HDR types, may have 0 elements if the display is not
1759 * HDR-capable
1760 * outMaxLuminance - the desired content maximum luminance for this display in
1761 * cd/m^2; pointer will be non-NULL
1762 * outMaxAverageLuminance - the desired content maximum frame-average
1763 * luminance for this display in cd/m^2; pointer will be non-NULL
1764 * outMinLuminance - the desired content minimum luminance for this display in
1765 * cd/m^2; pointer will be non-NULL
1766 *
1767 * Returns HWC2_ERROR_NONE or one of the following errors:
1768 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1769 */
1770 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1771 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1772 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1773 float* outMaxAverageLuminance, float* outMinLuminance);
1774
1775 /* getReleaseFences(..., outNumElements, outLayers, outFences)
1776 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1777 * Must be provided by all HWC2 devices
1778 *
1779 * Retrieves the release fences for device layers on this display which will
1780 * receive new buffer contents this frame.
1781 *
1782 * A release fence is a file descriptor referring to a sync fence object which
1783 * will be signaled after the device has finished reading from the buffer
1784 * presented in the prior frame. This indicates that it is safe to start writing
1785 * to the buffer again. If a given layer's fence is not returned from this
1786 * function, it will be assumed that the buffer presented on the previous frame
1787 * is ready to be written.
1788 *
1789 * The fences returned by this function should be unique for each layer (even if
1790 * they point to the same underlying sync object), and ownership of the fences
1791 * is transferred to the client, which is responsible for closing them.
1792 *
1793 * If outLayers or outFences is NULL, the required number of layers and fences
1794 * must be returned in outNumElements.
1795 *
1796 * Parameters:
1797 * outNumElements - if outLayers or outFences were NULL, the number of
1798 * elements which would have been returned; if both were not NULL, the
1799 * number of elements in outLayers and outFences, which must not exceed
1800 * the value stored in outNumElements prior to the call; pointer will be
1801 * non-NULL
1802 * outLayers - an array of layer handles
1803 * outFences - an array of sync fence file descriptors as described above,
1804 * each corresponding to an element of outLayers
1805 *
1806 * Returns HWC2_ERROR_NONE or one of the following errors:
1807 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1808 */
1809 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
1810 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1811 hwc2_layer_t* outLayers, int32_t* outFences);
1812
1813 /* presentDisplay(..., outPresentFence)
1814 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1815 * Must be provided by all HWC2 devices
1816 *
1817 * Presents the current display contents on the screen (or in the case of
1818 * virtual displays, into the output buffer).
1819 *
1820 * Prior to calling this function, the display must be successfully validated
1821 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1822 * specifically do not count as layer state, so if there are no other changes
1823 * to the layer state (or to the buffer's properties as described in
1824 * setLayerBuffer), then it is safe to call this function without first
1825 * validating the display.
1826 *
1827 * If this call succeeds, outPresentFence will be populated with a file
1828 * descriptor referring to a present sync fence object. For physical displays,
1829 * this fence will be signaled at the vsync when the result of composition of
1830 * this frame starts to appear (for video-mode panels) or starts to transfer to
1831 * panel memory (for command-mode panels). For virtual displays, this fence will
1832 * be signaled when writes to the output buffer have completed and it is safe to
1833 * read from it.
1834 *
1835 * Parameters:
1836 * outPresentFence - a sync fence file descriptor as described above; pointer
1837 * will be non-NULL
1838 *
1839 * Returns HWC2_ERROR_NONE or one of the following errors:
1840 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1841 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1842 * display
1843 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1844 * for this display
1845 */
1846 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
1847 hwc2_device_t* device, hwc2_display_t display,
1848 int32_t* outPresentFence);
1849
1850 /* setActiveConfig(..., config)
1851 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1852 * Must be provided by all HWC2 devices
1853 *
1854 * Sets the active configuration for this display. Upon returning, the given
1855 * display configuration should be active and remain so until either this
1856 * function is called again or the display is disconnected.
1857 *
1858 * Parameters:
1859 * config - the new display configuration
1860 *
1861 * Returns HWC2_ERROR_NONE or one of the following errors:
1862 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1863 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1864 * this display
1865 */
1866 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1867 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1868
1869 /* setClientTarget(..., target, acquireFence, dataspace, damage)
1870 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1871 * Must be provided by all HWC2 devices
1872 *
1873 * Sets the buffer handle which will receive the output of client composition.
1874 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1875 * prior to the call to presentDisplay, and layers not marked as
1876 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1877 *
1878 * The buffer handle provided may be null if no layers are being composited by
1879 * the client. This must not result in an error (unless an invalid display
1880 * handle is also provided).
1881 *
1882 * Also provides a file descriptor referring to an acquire sync fence object,
1883 * which will be signaled when it is safe to read from the client target buffer.
1884 * If it is already safe to read from this buffer, -1 may be passed instead.
1885 * The device must ensure that it is safe for the client to close this file
1886 * descriptor at any point after this function is called.
1887 *
1888 * For more about dataspaces, see setLayerDataspace.
1889 *
1890 * The damage parameter describes a surface damage region as defined in the
1891 * description of setLayerSurfaceDamage.
1892 *
1893 * Will be called before presentDisplay if any of the layers are marked as
1894 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1895 * necessary to call this function. It is not necessary to call validateDisplay
1896 * after changing the target through this function.
1897 *
1898 * Parameters:
1899 * target - the new target buffer
1900 * acquireFence - a sync fence file descriptor as described above
1901 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
1902 * damage - the surface damage region
1903 *
1904 * Returns HWC2_ERROR_NONE or one of the following errors:
1905 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1906 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1907 */
1908 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1909 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
1910 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1911 hwc_region_t damage);
1912
1913 /* setColorMode(..., mode)
1914 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1915 * Must be provided by all HWC2 devices
1916 *
1917 * Sets the color mode of the given display.
1918 *
1919 * This must be called outside of validateDisplay/presentDisplay, and it takes
1920 * effect on next presentDisplay.
1921 *
1922 * The valid color modes can be found in android_color_mode_t in
1923 * <system/graphics.h>. All HWC2 devices must support at least
1924 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1925 * hotplug.
1926 *
1927 * Parameters:
1928 * mode - the mode to set
1929 *
1930 * Returns HWC2_ERROR_NONE or one of the following errors:
1931 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1932 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1933 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1934 */
1935 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1936 hwc2_device_t* device, hwc2_display_t display,
1937 int32_t /*android_color_mode_t*/ mode);
1938
1939 /* setColorModeWithIntent(..., mode, intent)
1940 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
1941 * Provided by HWC2 devices which don't return nullptr function pointer.
1942 *
1943 * This must be called outside of validateDisplay/presentDisplay, and it takes
1944 * effect on next presentDisplay.
1945 *
1946 * The valid color modes and render intents can be found in
1947 * android_color_mode_t and android_render_intent_v1_1_t in
1948 * <system/graphics.h>. All HWC2 devices must support at least
1949 * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are
1950 * assumed to be in this mode and intent upon hotplug.
1951 *
1952 * Parameters:
1953 * mode - the mode to set
1954 * intent - the intent to set
1955 *
1956 * Returns HWC2_ERROR_NONE or one of the following errors:
1957 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1958 * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or
1959 * render intent
1960 * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display
1961 */
1962 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)(
1963 hwc2_device_t* device, hwc2_display_t display,
1964 int32_t /*android_color_mode_t*/ mode,
1965 int32_t /*android_render_intent_v1_1_t */ intent);
1966
1967 /* setColorTransform(..., matrix, hint)
1968 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1969 * Must be provided by all HWC2 devices
1970 *
1971 * Sets a color transform which will be applied after composition.
1972 *
1973 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1974 * hint to apply the desired color transform instead of using the color matrix
1975 * directly.
1976 *
1977 * If the device is not capable of either using the hint or the matrix to apply
1978 * the desired color transform, it should force all layers to client composition
1979 * during validateDisplay.
1980 *
1981 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1982 * will never apply the color transform during client composition, even if all
1983 * layers are being composed by the client.
1984 *
1985 * The matrix provided is an affine color transformation of the following form:
1986 *
1987 * |r.r r.g r.b 0|
1988 * |g.r g.g g.b 0|
1989 * |b.r b.g b.b 0|
1990 * |Tr Tg Tb 1|
1991 *
1992 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1993 *
1994 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1995 * color [R_out, G_out, B_out] will be:
1996 *
1997 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
1998 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1999 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
2000 *
2001 * Parameters:
2002 * matrix - a 4x4 transform matrix (16 floats) as described above
2003 * hint - a hint value which may be used instead of the given matrix unless it
2004 * is HAL_COLOR_TRANSFORM_ARBITRARY
2005 *
2006 * Returns HWC2_ERROR_NONE or one of the following errors:
2007 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2008 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
2009 */
2010 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
2011 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
2012 int32_t /*android_color_transform_t*/ hint);
2013
2014 /* getPerFrameMetadataKeys(..., outKeys)
2015 * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
2016 * Optional for HWC2 devices
2017 *
2018 * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null),
2019 * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys
2020 * which are invariant with regard to the active configuration.
2021 *
2022 * Devices which are not HDR-capable, must return null when getFunction is called
2023 * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS.
2024 *
2025 * If outKeys is NULL, the required number of PerFrameMetadataKey keys
2026 * must be returned in outNumKeys.
2027 *
2028 * Parameters:
2029 * outNumKeys - if outKeys is NULL, the number of keys which would have
2030 * been returned; if outKeys is not NULL, the number of keys stored in
2031 * outKeys, which must not exceed the value stored in outNumKeys prior
2032 * to the call; pointer will be non-NULL
2033 * outKeys - an array of hwc2_per_frame_metadata_key_t keys
2034 *
2035 * Returns HWC2_ERROR_NONE or one of the following errors:
2036 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2037 */
2038 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)(
2039 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys,
2040 int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
2041
2042 /* setOutputBuffer(..., buffer, releaseFence)
2043 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
2044 * Must be provided by all HWC2 devices
2045 *
2046 * Sets the output buffer for a virtual display. That is, the buffer to which
2047 * the composition result will be written.
2048 *
2049 * Also provides a file descriptor referring to a release sync fence object,
2050 * which will be signaled when it is safe to write to the output buffer. If it
2051 * is already safe to write to the output buffer, -1 may be passed instead. The
2052 * device must ensure that it is safe for the client to close this file
2053 * descriptor at any point after this function is called.
2054 *
2055 * Must be called at least once before presentDisplay, but does not have any
2056 * interaction with layer state or display validation.
2057 *
2058 * Parameters:
2059 * buffer - the new output buffer
2060 * releaseFence - a sync fence file descriptor as described above
2061 *
2062 * Returns HWC2_ERROR_NONE or one of the following errors:
2063 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2064 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
2065 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
2066 */
2067 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
2068 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
2069 int32_t releaseFence);
2070
2071 /* setPowerMode(..., mode)
2072 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
2073 * Must be provided by all HWC2 devices
2074 *
2075 * Sets the power mode of the given display. The transition must be complete
2076 * when this function returns. It is valid to call this function multiple times
2077 * with the same power mode.
2078 *
2079 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
2080 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
2081 * be queried using getDozeSupport.
2082 *
2083 * Parameters:
2084 * mode - the new power mode
2085 *
2086 * Returns HWC2_ERROR_NONE or one of the following errors:
2087 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2088 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
2089 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
2090 * on this display
2091 */
2092 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
2093 hwc2_device_t* device, hwc2_display_t display,
2094 int32_t /*hwc2_power_mode_t*/ mode);
2095
2096 /* getReadbackBufferAttributes(..., outFormat, outDataspace)
2097 * Optional for HWC2 devices
2098 *
2099 * Returns the format which should be used when allocating a buffer for use by
2100 * device readback as well as the dataspace in which its contents should be
2101 * interpreted.
2102 *
2103 * If readback is not supported by this HWC implementation, this call will also
2104 * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method.
2105 * Returning NULL to a getFunction request for this function will also indicate
2106 * that readback is not supported.
2107 *
2108 * The width and height of this buffer will be those of the currently-active
2109 * display configuration, and the usage flags will consist of the following:
2110 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
2111 * BufferUsage::COMPOSER_OUTPUT
2112 *
2113 * The format and dataspace provided must be sufficient such that if a
2114 * correctly-configured buffer is passed into setReadbackBuffer, filled by
2115 * the device, and then displayed by the client as a full-screen buffer, the
2116 * output of the display remains the same (subject to the note about protected
2117 * content in the description of setReadbackBuffer).
2118 *
2119 * If the active configuration or color mode of this display has changed since
2120 * the previous call to this function, it will be called again prior to setting
2121 * a readback buffer such that the returned format and dataspace can be updated
2122 * accordingly.
2123 *
2124 * Parameters:
2125 * outFormat - the format the client should use when allocating a device
2126 * readback buffer; pointer will be non-NULL
2127 * outDataspace - the dataspace the client will use when interpreting the
2128 * contents of a device readback buffer; pointer will be non-NULL
2129 *
2130 * Returns HWC2_ERROR_NONE or one of the following errors:
2131 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2132 *
2133 * See also:
2134 * setReadbackBuffer
2135 * getReadbackBufferFence
2136 */
2137 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)(
2138 hwc2_device_t* device, hwc2_display_t display,
2139 int32_t* /*android_pixel_format_t*/ outFormat,
2140 int32_t* /*android_dataspace_t*/ outDataspace);
2141
2142 /* getReadbackBufferFence(..., outFence)
2143 * Optional for HWC2 devices
2144 *
2145 * Returns an acquire sync fence file descriptor which will signal when the
2146 * buffer provided to setReadbackBuffer has been filled by the device and is
2147 * safe for the client to read.
2148 *
2149 * If it is already safe to read from this buffer, -1 may be returned instead.
2150 * The client takes ownership of this file descriptor and is responsible for
2151 * closing it when it is no longer needed.
2152 *
2153 * This function will be called immediately after the composition cycle being
2154 * captured into the readback buffer. The complete ordering of a readback buffer
2155 * capture is as follows:
2156 *
2157 * getReadbackBufferAttributes
2158 * // Readback buffer is allocated
2159 * // Many frames may pass
2160 *
2161 * setReadbackBuffer
2162 * validateDisplay
2163 * presentDisplay
2164 * getReadbackBufferFence
2165 * // Implicitly wait on the acquire fence before accessing the buffer
2166 *
2167 * Parameters:
2168 * outFence - a sync fence file descriptor as described above; pointer
2169 * will be non-NULL
2170 *
2171 * Returns HWC2_ERROR_NONE or one of the following errors:
2172 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2173 * HWC2_ERROR_NO_RESOURCES - the readback operation was successful, but
2174 * resulted in a different validate result than would have occurred
2175 * without readback
2176 * HWC2_ERROR_UNSUPPORTED - the readback operation was unsuccessful because
2177 * of resource constraints, the presence of protected content, or other
2178 * reasons; -1 must be returned in outFence
2179 */
2180 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)(
2181 hwc2_device_t* device, hwc2_display_t display,
2182 int32_t* outFence);
2183
2184 /* setReadbackBuffer(..., buffer, releaseFence)
2185 * Optional for HWC2 devices
2186 *
2187 * Sets the readback buffer to be filled with the contents of the next
2188 * composition performed for this display (i.e., the contents present at the
2189 * time of the next validateDisplay/presentDisplay cycle).
2190 *
2191 * This buffer will have been allocated as described in
2192 * getReadbackBufferAttributes and will be interpreted as being in the dataspace
2193 * provided by the same.
2194 *
2195 * If there is hardware protected content on the display at the time of the next
2196 * composition, the area of the readback buffer covered by such content must be
2197 * completely black. Any areas of the buffer not covered by such content may
2198 * optionally be black as well.
2199 *
2200 * The release fence file descriptor provided works identically to the one
2201 * described for setOutputBuffer.
2202 *
2203 * This function will not be called between any call to validateDisplay and a
2204 * subsequent call to presentDisplay.
2205 *
2206 * Parameters:
2207 * buffer - the new readback buffer
2208 * releaseFence - a sync fence file descriptor as described in setOutputBuffer
2209 *
2210 * Returns HWC2_ERROR_NONE or one of the following errors:
2211 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2212 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
2213 *
2214 * See also:
2215 * getReadbackBufferAttributes
2216 * getReadbackBufferFence
2217 */
2218 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)(
2219 hwc2_device_t* device, hwc2_display_t display,
2220 buffer_handle_t buffer, int32_t releaseFence);
2221
2222 /* setVsyncEnabled(..., enabled)
2223 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
2224 * Must be provided by all HWC2 devices
2225 *
2226 * Enables or disables the vsync signal for the given display. Virtual displays
2227 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
2228 * display though this function must return HWC2_ERROR_NONE and have no other
2229 * effect.
2230 *
2231 * Parameters:
2232 * enabled - whether to enable or disable vsync
2233 *
2234 * Returns HWC2_ERROR_NONE or one of the following errors:
2235 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2236 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
2237 */
2238 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
2239 hwc2_device_t* device, hwc2_display_t display,
2240 int32_t /*hwc2_vsync_t*/ enabled);
2241
2242 /* validateDisplay(..., outNumTypes, outNumRequests)
2243 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
2244 * Must be provided by all HWC2 devices
2245 *
2246 * Instructs the device to inspect all of the layer state and determine if
2247 * there are any composition type changes necessary before presenting the
2248 * display. Permitted changes are described in the definition of
2249 * hwc2_composition_t above.
2250 *
2251 * Also returns the number of layer requests required
2252 * by the given layer configuration.
2253 *
2254 * Parameters:
2255 * outNumTypes - the number of composition type changes required by the
2256 * device; if greater than 0, the client must either set and validate new
2257 * types, or call acceptDisplayChanges to accept the changes returned by
2258 * getChangedCompositionTypes; must be the same as the number of changes
2259 * returned by getChangedCompositionTypes (see the declaration of that
2260 * function for more information); pointer will be non-NULL
2261 * outNumRequests - the number of layer requests required by this layer
2262 * configuration; must be equal to the number of layer requests returned
2263 * by getDisplayRequests (see the declaration of that function for
2264 * more information); pointer will be non-NULL
2265 *
2266 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
2267 * the display using the current layer state. Otherwise returns one of the
2268 * following errors:
2269 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2270 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
2271 * for more information)
2272 */
2273 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
2274 hwc2_device_t* device, hwc2_display_t display,
2275 uint32_t* outNumTypes, uint32_t* outNumRequests);
2276
2277 /*
2278 * Layer Functions
2279 *
2280 * These are functions which operate on layers, but which do not modify state
2281 * that must be validated before use. See also 'Layer State Functions' below.
2282 *
2283 * All of these functions take as their first three parameters a device pointer,
2284 * a display handle for the display which contains the layer, and a layer
2285 * handle, so these parameters are omitted from the described parameter lists.
2286 */
2287
2288 /* setCursorPosition(..., x, y)
2289 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
2290 * Must be provided by all HWC2 devices
2291 *
2292 * Asynchonously sets the position of a cursor layer.
2293 *
2294 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
2295 * If validation succeeds (i.e., the device does not request a composition
2296 * change for that layer), then once a buffer has been set for the layer and it
2297 * has been presented, its position may be set by this function at any time
2298 * between presentDisplay and any subsequent validateDisplay calls for this
2299 * display.
2300 *
2301 * Once validateDisplay is called, this function will not be called again until
2302 * the validate/present sequence is completed.
2303 *
2304 * May be called from any thread so long as it is not interleaved with the
2305 * validate/present sequence as described above.
2306 *
2307 * Parameters:
2308 * x - the new x coordinate (in pixels from the left of the screen)
2309 * y - the new y coordinate (in pixels from the top of the screen)
2310 *
2311 * Returns HWC2_ERROR_NONE or one of the following errors:
2312 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2313 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
2314 * HWC2_COMPOSITION_CURSOR
2315 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
2316 * validate/present sequence
2317 */
2318 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
2319 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2320 int32_t x, int32_t y);
2321
2322 /* setLayerBuffer(..., buffer, acquireFence)
2323 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
2324 * Must be provided by all HWC2 devices
2325 *
2326 * Sets the buffer handle to be displayed for this layer. If the buffer
2327 * properties set at allocation time (width, height, format, and usage) have not
2328 * changed since the previous frame, it is not necessary to call validateDisplay
2329 * before calling presentDisplay unless new state needs to be validated in the
2330 * interim.
2331 *
2332 * Also provides a file descriptor referring to an acquire sync fence object,
2333 * which will be signaled when it is safe to read from the given buffer. If it
2334 * is already safe to read from the buffer, -1 may be passed instead. The
2335 * device must ensure that it is safe for the client to close this file
2336 * descriptor at any point after this function is called.
2337 *
2338 * This function must return HWC2_ERROR_NONE and have no other effect if called
2339 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
2340 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
2341 * (because synchronization and buffer updates for these layers are handled
2342 * elsewhere).
2343 *
2344 * Parameters:
2345 * buffer - the buffer handle to set
2346 * acquireFence - a sync fence file descriptor as described above
2347 *
2348 * Returns HWC2_ERROR_NONE or one of the following errors:
2349 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2350 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
2351 */
2352 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
2353 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2354 buffer_handle_t buffer, int32_t acquireFence);
2355
2356 /* setLayerSurfaceDamage(..., damage)
2357 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
2358 * Must be provided by all HWC2 devices
2359 *
2360 * Provides the region of the source buffer which has been modified since the
2361 * last frame. This region does not need to be validated before calling
2362 * presentDisplay.
2363 *
2364 * Once set through this function, the damage region remains the same until a
2365 * subsequent call to this function.
2366 *
2367 * If damage.numRects > 0, then it may be assumed that any portion of the source
2368 * buffer not covered by one of the rects has not been modified this frame. If
2369 * damage.numRects == 0, then the whole source buffer must be treated as if it
2370 * has been modified.
2371 *
2372 * If the layer's contents are not modified relative to the prior frame, damage
2373 * will contain exactly one empty rect([0, 0, 0, 0]).
2374 *
2375 * The damage rects are relative to the pre-transformed buffer, and their origin
2376 * is the top-left corner. They will not exceed the dimensions of the latched
2377 * buffer.
2378 *
2379 * Parameters:
2380 * damage - the new surface damage region
2381 *
2382 * Returns HWC2_ERROR_NONE or one of the following errors:
2383 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2384 */
2385 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
2386 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2387 hwc_region_t damage);
2388
2389 /* setLayerPerFrameMetadata(..., numMetadata, metadata)
2390 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
2391 * Optional for HWC2 devices
2392 *
2393 * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is
2394 * non-null), sets the metadata for the given display for all following
2395 * frames.
2396 *
2397 * Upon returning from this function, the metadata change must have
2398 * fully taken effect.
2399 *
2400 * This function will only be called if getPerFrameMetadataKeys is non-NULL
2401 * and returns at least one key.
2402 *
2403 * Parameters:
2404 * numElements is the number of elements in each of the keys and metadata arrays
2405 * keys is a pointer to the array of keys.
2406 * outMetadata is a pointer to the corresponding array of metadata.
2407 *
2408 * Returns HWC2_ERROR_NONE or one of the following errors:
2409 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2410 * HWC2_ERROR_BAD_PARAMETER - metadata is not valid
2411 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2412 */
2413 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)(
2414 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2415 uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
2416 const float* metadata);
2417
2418 /* setLayerPerFrameMetadataBlobs(...,numElements, keys, sizes, blobs)
2419 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS
2420 * Optional for HWC2 devices
2421 *
2422 * If supported, (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS)
2423 * is non-null), sets the metadata for the given display and layer.
2424 *
2425 * Upon returning from this function, the metadata change must have fully taken
2426 * effect.
2427 *
2428 * This function must only be called if getPerFrameMetadataKeys is non-NULL
2429 * and returns at least one key that corresponds to a blob type.
2430 *
2431 * Current valid blob type keys are: HDR10_PLUS_SEI
2432 *
2433 * Parameters:
2434 * numElements is the number of elements in each of the keys, sizes, and
2435 * metadata arrays
2436 * keys is a pointer to an array of keys. Current valid keys are those listed
2437 * above as valid blob type keys.
2438 * sizes is a pointer to an array of unsigned ints specifying the sizes of
2439 * each metadata blob
2440 * metadata is a pointer to a blob of data holding all blobs contiguously in
2441 * memory
2442 *
2443 * Returns HWC2_ERROR_NONE or one of the following erros:
2444 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2445 * HWC2_ERROR_BAD_PARAMETER - sizes of keys and metadata parameters does
2446 * not match numElements, numElements < 0, or keys contains a
2447 * non-valid key (see above for current valid blob type keys).
2448 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2449 */
2450 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS)(
2451 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2452 uint32_t numElements, const int32_t* keys, const uint32_t* sizes,
2453 const uint8_t* metadata);
2454 /*
2455 * Layer State Functions
2456 *
2457 * These functions modify the state of a given layer. They do not take effect
2458 * until the display configuration is successfully validated with
2459 * validateDisplay and the display contents are presented with presentDisplay.
2460 *
2461 * All of these functions take as their first three parameters a device pointer,
2462 * a display handle for the display which contains the layer, and a layer
2463 * handle, so these parameters are omitted from the described parameter lists.
2464 */
2465
2466 /* setLayerBlendMode(..., mode)
2467 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
2468 * Must be provided by all HWC2 devices
2469 *
2470 * Sets the blend mode of the given layer.
2471 *
2472 * Parameters:
2473 * mode - the new blend mode
2474 *
2475 * Returns HWC2_ERROR_NONE or one of the following errors:
2476 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2477 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
2478 */
2479 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
2480 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2481 int32_t /*hwc2_blend_mode_t*/ mode);
2482
2483 /* setLayerColor(..., color)
2484 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
2485 * Must be provided by all HWC2 devices
2486 *
2487 * Sets the color of the given layer. If the composition type of the layer is
2488 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2489 * have no other effect.
2490 *
2491 * Parameters:
2492 * color - the new color
2493 *
2494 * Returns HWC2_ERROR_NONE or one of the following errors:
2495 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2496 */
2497 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
2498 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2499 hwc_color_t color);
2500
2501 /* setLayerFloatColor(..., color)
2502 * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
2503 * Provided by HWC2 devices which don't return nullptr function pointer.
2504 *
2505 * Sets the color of the given layer. If the composition type of the layer is
2506 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2507 * have no other effect.
2508 *
2509 * Parameters:
2510 * color - the new color in float type, rage is [0.0, 1.0], the colorspace is
2511 * defined by the dataspace that gets set by calling setLayerDataspace.
2512 *
2513 * Returns HWC2_ERROR_NONE or one of the following errors:
2514 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2515 */
2516 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)(
2517 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2518 hwc_float_color_t color);
2519
2520 /* setLayerCompositionType(..., type)
2521 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
2522 * Must be provided by all HWC2 devices
2523 *
2524 * Sets the desired composition type of the given layer. During validateDisplay,
2525 * the device may request changes to the composition types of any of the layers
2526 * as described in the definition of hwc2_composition_t above.
2527 *
2528 * Parameters:
2529 * type - the new composition type
2530 *
2531 * Returns HWC2_ERROR_NONE or one of the following errors:
2532 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2533 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
2534 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
2535 * not supported by this device
2536 */
2537 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
2538 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2539 int32_t /*hwc2_composition_t*/ type);
2540
2541 /* setLayerDataspace(..., dataspace)
2542 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
2543 * Must be provided by all HWC2 devices
2544 *
2545 * Sets the dataspace that the current buffer on this layer is in.
2546 *
2547 * The dataspace provides more information about how to interpret the buffer
2548 * contents, such as the encoding standard and color transform.
2549 *
2550 * See the values of android_dataspace_t in <system/graphics.h> for more
2551 * information.
2552 *
2553 * Parameters:
2554 * dataspace - the new dataspace
2555 *
2556 * Returns HWC2_ERROR_NONE or one of the following errors:
2557 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2558 */
2559 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
2560 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2561 int32_t /*android_dataspace_t*/ dataspace);
2562
2563 /* setLayerDisplayFrame(..., frame)
2564 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
2565 * Must be provided by all HWC2 devices
2566 *
2567 * Sets the display frame (the portion of the display covered by a layer) of the
2568 * given layer. This frame will not exceed the display dimensions.
2569 *
2570 * Parameters:
2571 * frame - the new display frame
2572 *
2573 * Returns HWC2_ERROR_NONE or one of the following errors:
2574 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2575 */
2576 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
2577 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2578 hwc_rect_t frame);
2579
2580 /* setLayerPlaneAlpha(..., alpha)
2581 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
2582 * Must be provided by all HWC2 devices
2583 *
2584 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
2585 * will be applied to the whole layer. It can be conceptualized as a
2586 * preprocessing step which applies the following function:
2587 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
2588 * out.rgb = in.rgb * planeAlpha
2589 * out.a = in.a * planeAlpha
2590 *
2591 * If the device does not support this operation on a layer which is marked
2592 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
2593 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
2594 *
2595 * Parameters:
2596 * alpha - the plane alpha value to apply
2597 *
2598 * Returns HWC2_ERROR_NONE or one of the following errors:
2599 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2600 */
2601 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
2602 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2603 float alpha);
2604
2605 /* setLayerSidebandStream(..., stream)
2606 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
2607 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
2608 *
2609 * Sets the sideband stream for this layer. If the composition type of the given
2610 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
2611 * and have no other effect.
2612 *
2613 * Parameters:
2614 * stream - the new sideband stream
2615 *
2616 * Returns HWC2_ERROR_NONE or one of the following errors:
2617 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2618 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
2619 */
2620 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
2621 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2622 const native_handle_t* stream);
2623
2624 /* setLayerSourceCrop(..., crop)
2625 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
2626 * Must be provided by all HWC2 devices
2627 *
2628 * Sets the source crop (the portion of the source buffer which will fill the
2629 * display frame) of the given layer. This crop rectangle will not exceed the
2630 * dimensions of the latched buffer.
2631 *
2632 * If the device is not capable of supporting a true float source crop (i.e., it
2633 * will truncate or round the floats to integers), it should set this layer to
2634 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
2635 * rendering.
2636 *
2637 * If the device cannot support float source crops, but still wants to handle
2638 * the layer, it should use the following code (or similar) to convert to
2639 * an integer crop:
2640 * intCrop.left = (int) ceilf(crop.left);
2641 * intCrop.top = (int) ceilf(crop.top);
2642 * intCrop.right = (int) floorf(crop.right);
2643 * intCrop.bottom = (int) floorf(crop.bottom);
2644 *
2645 * Parameters:
2646 * crop - the new source crop
2647 *
2648 * Returns HWC2_ERROR_NONE or one of the following errors:
2649 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2650 */
2651 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
2652 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2653 hwc_frect_t crop);
2654
2655 /* setLayerTransform(..., transform)
2656 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
2657 * Must be provided by all HWC2 devices
2658 *
2659 * Sets the transform (rotation/flip) of the given layer.
2660 *
2661 * Parameters:
2662 * transform - the new transform
2663 *
2664 * Returns HWC2_ERROR_NONE or one of the following errors:
2665 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2666 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
2667 */
2668 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
2669 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2670 int32_t /*hwc_transform_t*/ transform);
2671
2672 /* setLayerVisibleRegion(..., visible)
2673 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
2674 * Must be provided by all HWC2 devices
2675 *
2676 * Specifies the portion of the layer that is visible, including portions under
2677 * translucent areas of other layers. The region is in screen space, and will
2678 * not exceed the dimensions of the screen.
2679 *
2680 * Parameters:
2681 * visible - the new visible region, in screen space
2682 *
2683 * Returns HWC2_ERROR_NONE or one of the following errors:
2684 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2685 */
2686 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
2687 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2688 hwc_region_t visible);
2689
2690 /* setLayerZOrder(..., z)
2691 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
2692 * Must be provided by all HWC2 devices
2693 *
2694 * Sets the desired Z order (height) of the given layer. A layer with a greater
2695 * Z value occludes a layer with a lesser Z value.
2696 *
2697 * Parameters:
2698 * z - the new Z order
2699 *
2700 * Returns HWC2_ERROR_NONE or one of the following errors:
2701 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2702 */
2703 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
2704 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2705 uint32_t z);
2706
2707 /* setLayerColorTransform(..., matrix)
2708 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM
2709 * Optional by all HWC2 devices
2710 *
2711 * Sets a matrix for color transform which will be applied on this layer
2712 * before composition.
2713 *
2714 * If the device is not capable of apply the matrix on this layer, it must force
2715 * this layer to client composition during VALIDATE_DISPLAY.
2716 *
2717 * The matrix provided is an affine color transformation of the following form:
2718 *
2719 * |r.r r.g r.b 0|
2720 * |g.r g.g g.b 0|
2721 * |b.r b.g b.b 0|
2722 * |Tr Tg Tb 1|
2723 *
2724 * This matrix must be provided in row-major form:
2725 *
2726 * {r.r, r.g, r.b, 0, g.r, ...}.
2727 *
2728 * Given a matrix of this form and an input color [R_in, G_in, B_in],
2729 * the input color must first be converted to linear space
2730 * [R_linear, G_linear, B_linear], then the output linear color
2731 * [R_out_linear, G_out_linear, B_out_linear] will be:
2732 *
2733 * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
2734 * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
2735 * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
2736 *
2737 * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
2738 * gamma space: [R_out, G_out, B_out] before blending.
2739 *
2740 * Parameters:
2741 * matrix - a 4x4 transform matrix (16 floats) as described above
2742 *
2743 * Returns HWC2_ERROR_NONE or one of the following errors:
2744 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2745 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2746 */
2747 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR_TRANSFORM)(
2748 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2749 const float* matrix);
2750
2751 /* getDisplayedContentSamplingAttributes(...,
2752 * format, dataspace, supported_components, max_frames)
2753 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES
2754 * Optional by all HWC2 devices
2755 *
2756 * Query for what types of color sampling the hardware supports.
2757 *
2758 * Parameters:
2759 * format - The format of the sampled pixels; pointer will be non-NULL
2760 * dataspace - The dataspace of the sampled pixels; pointer will be non-NULL
2761 * supported_components - The mask of which components can be sampled; pointer
2762 * will be non-NULL
2763 *
2764 * Returns HWC2_ERROR_NONE or one of the following errors:
2765 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2766 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2767 */
2768 typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES)(
2769 hwc2_device_t* device, hwc2_display_t display,
2770 int32_t* /* android_pixel_format_t */ format,
2771 int32_t* /* android_dataspace_t */ dataspace,
2772 uint8_t* /* mask of android_component_t */ supported_components);
2773
2774 /* setDisplayedContentSamplingEnabled(..., enabled)
2775 * Descriptor: HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED
2776 * Optional by all HWC2 devices
2777 *
2778 * Enables or disables the collection of color content statistics
2779 * on this display.
2780 *
2781 * Sampling occurs on the contents of the final composition on this display
2782 * (i.e., the contents presented on screen).
2783 *
2784 * Sampling support is optional, and is set to DISABLE by default.
2785 * On each call to ENABLE, all collected statistics will be reset.
2786 *
2787 * Sample data can be queried via getDisplayedContentSample().
2788 *
2789 * Parameters:
2790 * enabled - indicates whether to enable or disable sampling.
2791 * component_mask - The mask of which components should be sampled.
2792 * If zero, all supported components are to be enabled.
2793 * max_frames - is the maximum number of frames that should be stored before
2794 * discard. The sample represents the most-recently posted frames.
2795 *
2796 * Returns HWC2_ERROR_NONE or one of the following errors:
2797 * HWC2_ERROR_BAD_DISPLAY when an invalid display handle was passed in,
2798 * HWC2_ERROR_BAD_PARAMETER when enabled was an invalid value, or
2799 * HWC2_ERROR_NO_RESOURCES when the requested ringbuffer size via max_frames
2800 * was not available.
2801 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2802 */
2803 typedef int32_t (*HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED)(
2804 hwc2_device_t* device, hwc2_display_t display,
2805 int32_t /*hwc2_displayed_content_sampling_t*/ enabled,
2806 uint8_t /* mask of android_component_t */ component_mask,
2807 uint64_t max_frames);
2808
2809 /* getDisplayedContentSample(..., component, max_frames, timestamp,
2810 * samples_size, samples, frame_count)
2811 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE
2812 * Optional by all HWC2 devices
2813 *
2814 * Collects the results of display content color sampling for display.
2815 *
2816 * Collection of data can occur whether the sampling is in ENABLE or
2817 * DISABLE state.
2818 *
2819 * Parameters:
2820 * max_frames - is the maximum number of frames that should be represented in
2821 * the sample. The sample represents the most-recently posted frames.
2822 * If max_frames is 0, all frames are to be represented by the sample.
2823 * timestamp - is the timestamp after which any frames were posted that should
2824 * be included in the sample. Timestamp is CLOCK_MONOTONIC.
2825 * If timestamp is 0, do not filter from the sample by time.
2826 * frame_count - The number of frames represented by this sample; pointer will
2827 * be non-NULL.
2828 * samples_size - The sizes of the color histogram representing the color
2829 * sampling. Sample_sizes are indexed in the same order as
2830 * HWC2_FORMAT_COMPONENT_.
2831 * samples - The arrays of data corresponding to the sampling data. Samples are
2832 * indexed in the same order as HWC2_FORMAT_COMPONENT_.
2833 * The size of each sample is the samples_size for the same index.
2834 * Each components sample is an array that is to be filled with the
2835 * evenly-weighted buckets of a histogram counting how many times a pixel
2836 * of the given component was displayed onscreen. Caller owns the data and
2837 * pointer may be NULL to query samples_size.
2838 *
2839 * Returns HWC2_ERROR_NONE or one of the following errors:
2840 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2841 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample, or
2842 * HWC2_ERROR_BAD_PARAMETER when the component is not supported by the hardware.
2843 */
2844 typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE)(
2845 hwc2_device_t* device, hwc2_display_t display,
2846 uint64_t max_frames, uint64_t timestamp,
2847 uint64_t* frame_count, int32_t samples_size[4], uint64_t* samples[4]);
2848
2849 /* getDisplayCapabilities(..., outCapabilities)
2850 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES
2851 * Required for HWC2 devices for composer 2.3
2852 * Optional for HWC2 devices for composer 2.1 and 2.2
2853 *
2854 * getDisplayCapabilities returns a list of supported capabilities
2855 * (as described in the definition of Capability above).
2856 * This list must not change after initialization.
2857 *
2858 * Parameters:
2859 * outNumCapabilities - if outCapabilities was nullptr, returns the number of capabilities
2860 * if outCapabilities was not nullptr, returns the number of capabilities stored in
2861 * outCapabilities, which must not exceed the value stored in outNumCapabilities prior
2862 * to the call; pointer will be non-NULL
2863 * outCapabilities - a list of supported capabilities.
2864 *
2865 * Returns HWC2_ERROR_NONE or one of the following errors:
2866 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2867 */
2868 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CAPABILITIES)(
2869 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumCapabilities,
2870 uint32_t* outCapabilities);
2871
2872 /* Use getDisplayCapabilities instead. If brightness is supported, must return
2873 * DisplayCapability::BRIGHTNESS as one of the display capabilities via getDisplayCapabilities.
2874 * Only use getDisplayCapabilities as the source of truth to query brightness support.
2875 *
2876 * getDisplayBrightnessSupport(displayToken)
2877 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT
2878 * Required for HWC2 devices for composer 2.3
2879 * Optional for HWC2 devices for composer 2.1 and 2.2
2880 *
2881 * getDisplayBrightnessSupport returns whether brightness operations are supported on a display.
2882 *
2883 * Parameters:
2884 * outSupport - whether the display supports operations.
2885 *
2886 * Returns HWC2_ERROR_NONE or one of the following errors:
2887 * HWC2_ERROR_BAD_DISPLAY when the display is invalid.
2888 */
2889 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT)(hwc2_device_t* device,
2890 hwc2_display_t display, bool* outSupport);
2891
2892 /* setDisplayBrightness(displayToken, brightnesss)
2893 * Descriptor: HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS
2894 * Required for HWC2 devices for composer 2.3
2895 * Optional for HWC2 devices for composer 2.1 and 2.2
2896 *
2897 * setDisplayBrightness sets the brightness of a display.
2898 *
2899 * Parameters:
2900 * brightness - a number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or
2901 * -1.0f to turn the backlight off.
2902 *
2903 * Returns HWC2_ERROR_NONE or one of the following errors:
2904 * HWC2_ERROR_BAD_DISPLAY when the display is invalid, or
2905 * HWC2_ERROR_UNSUPPORTED when brightness operations are not supported, or
2906 * HWC2_ERROR_BAD_PARAMETER when the brightness is invalid, or
2907 * HWC2_ERROR_NO_RESOURCES when the brightness cannot be applied.
2908 */
2909 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_DISPLAY_BRIGHTNESS)(hwc2_device_t* device,
2910 hwc2_display_t display, float brightness);
2911
2912 /* Composer 2.4 additions */
2913
2914 /* getDisplayConnectionType(..., outType)
2915 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE
2916 * Optional for all HWC2 devices
2917 *
2918 * Returns whether the given physical display is internal or external.
2919 *
2920 * Parameters:
2921 * outType - the connection type of the display; pointer will be non-NULL
2922 *
2923 * Returns HWC2_ERROR_NONE or one of the following errors:
2924 * HWC2_ERROR_BAD_DISPLAY when the display is invalid or virtual.
2925 */
2926 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE)(
2927 hwc2_device_t* device, hwc2_display_t display,
2928 uint32_t* /*hwc2_display_connection_type_t*/ outType);
2929
2930 /* getDisplayVsyncPeriod(..., outVsyncPeriods)
2931 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD
2932 * Required for HWC2 devices for composer 2.4
2933 *
2934 * Retrieves which vsync period the display is currently using.
2935 *
2936 * If no display configuration is currently active, this function must
2937 * return BAD_CONFIG. If a vsync period is about to change due to a
2938 * setActiveConfigWithConstraints call, this function must return the current vsync period
2939 * until the change has taken place.
2940 *
2941 * Parameters:
2942 * outVsyncPeriod - the current vsync period of the display.
2943 *
2944 * Returns HWC2_ERROR_NONE or one of the following errors:
2945 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2946 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
2947 */
2948 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD)(
2949 hwc2_device_t* device, hwc2_display_t display, hwc2_vsync_period_t* outVsyncPeriod);
2950
2951 /* setActiveConfigWithConstraints(...,
2952 * config,
2953 * vsyncPeriodChangeConstraints,
2954 * outTimeline)
2955 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS
2956 * Required for HWC2 devices for composer 2.4
2957 *
2958 * Sets the active configuration and the refresh rate for this display.
2959 * If the new config shares the same config group as the current config,
2960 * only the vsync period shall change.
2961 * Upon returning, the given display configuration, except vsync period, must be active and
2962 * remain so until either this function is called again or the display is disconnected.
2963 * When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
2964 * called with the new vsync period.
2965 *
2966 * Parameters:
2967 * config - the new display configuration.
2968 * vsyncPeriodChangeConstraints - constraints required for changing vsync period:
2969 * desiredTimeNanos - the time in CLOCK_MONOTONIC after
2970 * which the vsync period may change
2971 * (i.e., the vsync period must not change
2972 * before this time).
2973 * seamlessRequired - if true, requires that the vsync period
2974 * change must happen seamlessly without
2975 * a noticeable visual artifact.
2976 * When the conditions change and it may be
2977 * possible to change the vsync period
2978 * seamlessly, HWC2_CALLBACK_SEAMLESS_POSSIBLE
2979 * callback must be called to indicate that
2980 * caller should retry.
2981 * outTimeline - the timeline for the vsync period change.
2982 *
2983 * Returns HWC2_ERROR_NONE or one of the following errors:
2984 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in.
2985 * HWC2_ERROR_BAD_CONFIG - an invalid configuration handle passed in.
2986 * HWC2_ERROR_SEAMLESS_NOT_ALLOWED - when seamlessRequired was true but config provided doesn't
2987 * share the same config group as the current config.
2988 * HWC2_ERROR_SEAMLESS_NOT_POSSIBLE - when seamlessRequired was true but the display cannot
2989 * achieve the vsync period change without a noticeable
2990 * visual artifact.
2991 */
2992 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS)(
2993 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
2994 hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
2995 hwc_vsync_period_change_timeline_t* outTimeline);
2996
2997 /* setAutoLowLatencyMode(displayToken, on)
2998 * Descriptor: HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE
2999 * Optional for HWC2 devices
3000 *
3001 * setAutoLowLatencyMode requests that the display goes into low latency mode. If the display
3002 * is connected via HDMI 2.1, then Auto Low Latency Mode should be triggered. If the display is
3003 * internally connected, then a custom low latency mode should be triggered (if available).
3004 *
3005 * Parameters:
3006 * on - indicates whether to turn low latency mode on (=true) or off (=false)
3007 *
3008 * Returns HWC2_ERROR_NONE or one of the following errors:
3009 * HWC2_ERROR_BAD_DISPLAY - when the display is invalid, or
3010 * HWC2_ERROR_UNSUPPORTED - when the display does not support any low latency mode
3011 */
3012 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_AUTO_LOW_LATENCY_MODE)(hwc2_device_t* device,
3013 hwc2_display_t display, bool on);
3014
3015 /* getSupportedContentTypes(..., outSupportedContentTypes)
3016 * Descriptor: HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES
3017 * Optional for HWC2 devices
3018 *
3019 * getSupportedContentTypes returns a list of supported content types
3020 * (as described in the definition of ContentType above).
3021 * This list must not change after initialization.
3022 *
3023 * Parameters:
3024 * outNumSupportedContentTypes - if outSupportedContentTypes was nullptr, returns the number
3025 * of supported content types; if outSupportedContentTypes was not nullptr, returns the
3026 * number of capabilities stored in outSupportedContentTypes, which must not exceed the
3027 * value stored in outNumSupportedContentTypes prior to the call; pointer will be non-NULL
3028 * outSupportedContentTypes - a list of supported content types.
3029 *
3030 * Returns HWC2_ERROR_NONE or one of the following errors:
3031 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
3032 */
3033 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_GET_SUPPORTED_CONTENT_TYPES)(hwc2_device_t* device,
3034 hwc2_display_t display, uint32_t* outNumSupportedContentTypes, uint32_t* outSupportedContentTypes);
3035
3036 /* setContentType(displayToken, contentType)
3037 * Descriptor: HWC2_FUNCTION_SET_CONTENT_TYPE
3038 * Optional for HWC2 devices
3039 *
3040 * setContentType instructs the display that the content being shown is of the given contentType
3041 * (one of GRAPHICS, PHOTO, CINEMA, GAME).
3042 *
3043 * According to the HDMI 1.4 specification, supporting all content types is optional. Whether
3044 * the display supports a given content type is reported by getSupportedContentTypes.
3045 *
3046 * Parameters:
3047 * contentType - the type of content that is currently being shown on the display
3048 *
3049 * Returns HWC2_ERROR_NONE or one of the following errors:
3050 * HWC2_ERROR_BAD_DISPLAY - when the display is invalid, or
3051 * HWC2_ERROR_UNSUPPORTED - when the given content type is a valid content type, but is not
3052 * supported on this display, or
3053 * HWC2_ERROR_BAD_PARAMETER - when the given content type is invalid
3054 */
3055 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_CONTENT_TYPE)(hwc2_device_t* device,
3056 hwc2_display_t display, int32_t /* hwc2_content_type_t */ contentType);
3057
3058 /* getClientTargetProperty(..., outClientTargetProperty)
3059 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY
3060 * Optional for HWC2 devices
3061 *
3062 * Retrieves the client target properties for which the hardware composer
3063 * requests after the last call to validateDisplay. The client must set the
3064 * properties of the client target to match the returned values.
3065 * When this API is implemented, if client composition is needed, the hardware
3066 * composer must return meaningful client target property with dataspace not
3067 * setting to UNKNOWN.
3068 * When the returned dataspace is set to UNKNOWN, it means hardware composer
3069 * requests nothing, the client must ignore the returned client target property
3070 * structrue.
3071 *
3072 * Parameters:
3073 * outClientTargetProperty - the client target properties that hardware
3074 * composer requests. If dataspace field is set to UNKNOWN, it means
3075 * the hardware composer requests nothing, the client must ignore the
3076 * returned client target property structure.
3077 *
3078 * Returns HWC2_ERROR_NONE or one of the following errors:
3079 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
3080 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
3081 * display
3082 */
3083 typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_PROPERTY)(
3084 hwc2_device_t* device, hwc2_display_t display,
3085 hwc_client_target_property_t* outClientTargetProperty);
3086
3087 /* setLayerGenericMetadata(..., keyLength, key, mandatory, valueLength, value)
3088 * Descriptor: HWC2_FUNCTION_SET_LAYER_GENERIC_METADATA
3089 * Optional for HWC2 devices for composer 2.4+
3090 *
3091 * setLayerGenericMetadata sets a piece of generic metadata for the given layer.
3092 * If this function is called twice with the same key but different values, the
3093 * newer value must override the older one. Calling this function with
3094 * valueLength == 0 must reset that key's metadata as if it had not been set.
3095 *
3096 * A given piece of metadata may either be mandatory or a hint (non-mandatory)
3097 * as indicated by the `mandatory` parameter. Mandatory metadata may affect the
3098 * composition result, which is to say that it may cause a visible change in the
3099 * final image. By contrast, hints may only affect the composition strategy,
3100 * such as which layers are composited by the client, but must not cause a
3101 * visible change in the final image.
3102 *
3103 * This implies that if the device does not understand a given key:
3104 * - If the key is marked as mandatory, it must mark this layer for client
3105 * composition in order to ensure the correct composition result
3106 * - If the key is a hint, the metadata provided may be ignored
3107 *
3108 * Parameters:
3109 * keyLength - the length of the key parameter
3110 * key - the metadata key
3111 * mandatory - indicates whether this particular key represents mandatory
3112 * metadata or a hint, as described above
3113 * valueLength - the length of the value parameter
3114 * value - the metadata value
3115 *
3116 * Returns HWC2_ERROR_NONE or one of the following errors:
3117 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
3118 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
3119 * HWC2_ERROR_BAD_PARAMETER - an unsupported key was passed in, or the value
3120 * does not conform to the expected format for the key
3121 */
3122 typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_LAYER_GENERIC_METADATA)(hwc2_device_t* device,
3123 hwc2_display_t display, hwc2_layer_t layer, uint32_t keyLength, const char* key,
3124 bool mandatory, uint32_t valueLength, const uint8_t* value);
3125
3126 /* getLayerGenericMetadataKey(..., keyIndex, outKeyLength, outKey, outMandatory)
3127 * Descriptor: HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY
3128 * Optional for HWC2 devices for composer 2.4+
3129 *
3130 * getLayerGenericMetadataKey allows the client to query which metadata keys are
3131 * supported by the composer implementation. Only keys in this list will be
3132 * passed into setLayerGenericMetadata. Additionally, the key names in this list
3133 * must meet the following requirements:
3134 * - Must be specified in reverse domain name notation
3135 * - Must not start with 'com.android' or 'android'
3136 * - Must be unique within the returned list of keys
3137 * - Must correspond to a matching HIDL struct type, which defines the structure
3138 * of its values. For example, the key 'com.example.V1-3.Foo' should
3139 * correspond to a value of type com.example@1.3::Foo, which is defined in a
3140 * vendor HAL extension
3141 *
3142 * Client code which calls this function will look similar to this:
3143 *
3144 * struct Key {
3145 * std::string name;
3146 * bool mandatory;
3147 * }
3148 *
3149 * std::vector<Key> keys;
3150 * uint32_t index = 0;
3151 * uint32_t keyLength = 0;
3152 * while (true) {
3153 * getLayerGenericMetadataKey(device, index, &keyLength, nullptr, nullptr);
3154 * if (keyLength == 0) break;
3155 *
3156 * Key key;
3157 * key.name.resize(keyLength);
3158 * getLayerGenericMetadataKey(device, index, &keyLength, key.name.data(), &key.mandatory);
3159 * keys.push_back(key);
3160 *
3161 * ++index;
3162 * }
3163 *
3164 * Parameters:
3165 * keyIndex - the index of the key to retrieve. For values beyond the end of
3166 * the list of supported keys, outKeyLength should return 0, and the
3167 * client may assume that if the length is 0 for keyIndex N, then it is
3168 * also 0 for all keyIndex values > N.
3169 * outKeyLength - if outKey was nullptr, returns the length of the key to
3170 * allow the client to allocate an appropriately-sized buffer; if outKey
3171 * was not nullptr, returns the length of the returned key, which must not
3172 * exceed the value stored in outKeyLength prior to the call; pointer will
3173 * be non-null
3174 * outKey - the key at the given index, or nullptr to query the key's length
3175 * outMandatory - whether the given metadata is mandatory or not (see
3176 * setLayerGenericMetadata for more information), may be nullptr
3177 */
3178 typedef void (*HWC2_PFN_GET_LAYER_GENERIC_METADATA_KEY)(hwc2_device_t* device, uint32_t keyIndex,
3179 uint32_t* outKeyLength, char* outKey, bool* outMandatory);
3180
3181 __END_DECLS
3182
3183 #endif
3184