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