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