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