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