blob: 093d3a006d9bf0e06bad3c6d91e75befc68f8786 [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,
274 HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
Dan Stoza4e9221b2015-09-02 15:43:39 -0700275} hwc2_function_descriptor_t;
276
Dan Stozaf601e972016-03-16 09:54:40 -0700277/* Layer requests returned from getDisplayRequests */
Dan Stoza4e9221b2015-09-02 15:43:39 -0700278typedef enum {
279 /* The client should clear its target with transparent pixels where this
280 * layer would be. The client may ignore this request if the layer must be
281 * blended. */
282 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
283} hwc2_layer_request_t;
284
285/* Power modes for use with setPowerMode */
286typedef enum {
287 /* The display is fully off (blanked) */
288 HWC2_POWER_MODE_OFF = 0,
289
290 /* These are optional low power modes. getDozeSupport may be called to
291 * determine whether a given display supports these modes. */
292
293 /* The display is turned on and configured in a low power state that is
294 * suitable for presenting ambient information to the user, possibly with
295 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
296 HWC2_POWER_MODE_DOZE = 1,
297
298 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
299 * applying display updates from the client. This is effectively a hint to
300 * the device that drawing to the display has been suspended and that the
301 * the device should remain on in a low power state and continue displaying
302 * its current contents indefinitely until the power mode changes.
303 *
304 * This mode may also be used as a signal to enable hardware-based doze
305 * functionality. In this case, the device is free to take over the display
306 * and manage it autonomously to implement a low power always-on display. */
307 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
308
309 /* The display is fully on */
310 HWC2_POWER_MODE_ON = 2,
311} hwc2_power_mode_t;
312
313/* Vsync values passed to setVsyncEnabled */
314typedef enum {
315 HWC2_VSYNC_INVALID = 0,
316
317 /* Enable vsync */
318 HWC2_VSYNC_ENABLE = 1,
319
320 /* Disable vsync */
321 HWC2_VSYNC_DISABLE = 2,
322} hwc2_vsync_t;
323
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700324/* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */
325typedef enum {
326 /* SMPTE ST 2084:2014.
327 * Coordinates defined in CIE 1931 xy chromaticity space
328 */
329 HWC2_DISPLAY_RED_PRIMARY_X = 0,
330 HWC2_DISPLAY_RED_PRIMARY_Y = 1,
331 HWC2_DISPLAY_GREEN_PRIMARY_X = 2,
332 HWC2_DISPLAY_GREEN_PRIMARY_Y = 3,
333 HWC2_DISPLAY_BLUE_PRIMARY_X = 4,
334 HWC2_DISPLAY_BLUE_PRIMARY_Y = 5,
335 HWC2_WHITE_POINT_X = 6,
336 HWC2_WHITE_POINT_Y = 7,
337 /* SMPTE ST 2084:2014.
338 * Units: nits
339 * max as defined by ST 2048: 10,000 nits
340 */
341 HWC2_MAX_LUMINANCE = 8,
342 HWC2_MIN_LUMINANCE = 9,
343
344 /* CTA 861.3
345 * Units: nits
346 */
347 HWC2_MAX_CONTENT_LIGHT_LEVEL = 10,
348 HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
349} hwc2_per_frame_metadata_key_t;
350
Dan Stoza4e9221b2015-09-02 15:43:39 -0700351/*
352 * Stringification Functions
353 */
354
355#ifdef HWC2_INCLUDE_STRINGIFICATION
356
357static inline const char* getAttributeName(hwc2_attribute_t attribute) {
358 switch (attribute) {
359 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
360 case HWC2_ATTRIBUTE_WIDTH: return "Width";
361 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
362 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
363 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
364 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
365 default: return "Unknown";
366 }
367}
368
369static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
370 switch (mode) {
371 case HWC2_BLEND_MODE_INVALID: return "Invalid";
372 case HWC2_BLEND_MODE_NONE: return "None";
373 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
374 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
375 default: return "Unknown";
376 }
377}
378
379static inline const char* getCallbackDescriptorName(
380 hwc2_callback_descriptor_t desc) {
381 switch (desc) {
382 case HWC2_CALLBACK_INVALID: return "Invalid";
383 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
384 case HWC2_CALLBACK_REFRESH: return "Refresh";
385 case HWC2_CALLBACK_VSYNC: return "Vsync";
386 default: return "Unknown";
387 }
388}
389
390static inline const char* getCapabilityName(hwc2_capability_t capability) {
391 switch (capability) {
392 case HWC2_CAPABILITY_INVALID: return "Invalid";
393 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
Dan Stozad2168f72016-07-14 11:48:16 -0700394 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
395 return "SkipClientColorTransform";
Brian Anderson49018a52017-04-04 16:43:11 -0700396 case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
397 return "PresentFenceIsNotReliable";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700398 default: return "Unknown";
399 }
400}
401
402static inline const char* getCompositionName(hwc2_composition_t composition) {
403 switch (composition) {
404 case HWC2_COMPOSITION_INVALID: return "Invalid";
405 case HWC2_COMPOSITION_CLIENT: return "Client";
406 case HWC2_COMPOSITION_DEVICE: return "Device";
407 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
408 case HWC2_COMPOSITION_CURSOR: return "Cursor";
409 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
410 default: return "Unknown";
411 }
412}
413
414static inline const char* getConnectionName(hwc2_connection_t connection) {
415 switch (connection) {
416 case HWC2_CONNECTION_INVALID: return "Invalid";
417 case HWC2_CONNECTION_CONNECTED: return "Connected";
418 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
419 default: return "Unknown";
420 }
421}
422
423static inline const char* getDisplayRequestName(
424 hwc2_display_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700425 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700426 case 0: return "None";
427 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
428 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
429 return "WriteClientTargetToOutput";
430 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
431 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
432 return "FlipClientTarget|WriteClientTargetToOutput";
433 default: return "Unknown";
434 }
435}
436
437static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
438 switch (type) {
439 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
440 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
441 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
442 default: return "Unknown";
443 }
444}
445
446static inline const char* getErrorName(hwc2_error_t error) {
447 switch (error) {
448 case HWC2_ERROR_NONE: return "None";
449 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
450 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
451 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
452 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
453 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
454 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
455 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
456 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
457 default: return "Unknown";
458 }
459}
460
461static inline const char* getFunctionDescriptorName(
462 hwc2_function_descriptor_t desc) {
463 switch (desc) {
464 case HWC2_FUNCTION_INVALID: return "Invalid";
465 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
466 return "AcceptDisplayChanges";
467 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
468 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
469 return "CreateVirtualDisplay";
470 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
471 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
472 return "DestroyVirtualDisplay";
473 case HWC2_FUNCTION_DUMP: return "Dump";
474 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
475 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
476 return "GetChangedCompositionTypes";
477 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
478 return "GetClientTargetSupport";
479 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
480 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
481 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
482 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
483 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
484 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
485 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
Dan Stozaf601e972016-03-16 09:54:40 -0700486 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700487 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
488 return "GetMaxVirtualDisplayCount";
489 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
490 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
491 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
492 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
493 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
494 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
495 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
496 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
497 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
498 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
499 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
500 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
501 return "SetLayerCompositionType";
502 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
503 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
504 return "SetLayerDisplayFrame";
505 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
506 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
507 return "SetLayerSidebandStream";
508 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
509 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
510 return "SetLayerSurfaceDamage";
511 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
512 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
513 return "SetLayerVisibleRegion";
514 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
515 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
516 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
517 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
518 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
Peiyong Linfd05d132018-01-22 12:23:25 -0800519 case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700520 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata";
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700521 case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys";
522 case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer";
523 case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes";
524 case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700525 case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents";
526 case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent";
527 case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix";
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700528 case HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA: return "GetDisplayIdentificationData";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700529 default: return "Unknown";
530 }
531}
532
533static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700534 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700535 case 0: return "None";
536 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
537 default: return "Unknown";
538 }
539}
540
541static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
542 switch (mode) {
543 case HWC2_POWER_MODE_OFF: return "Off";
544 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
545 case HWC2_POWER_MODE_DOZE: return "Doze";
546 case HWC2_POWER_MODE_ON: return "On";
547 default: return "Unknown";
548 }
549}
550
551static inline const char* getTransformName(hwc_transform_t transform) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700552 switch (__BIONIC_CAST(static_cast, int, transform)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700553 case 0: return "None";
554 case HWC_TRANSFORM_FLIP_H: return "FlipH";
555 case HWC_TRANSFORM_FLIP_V: return "FlipV";
556 case HWC_TRANSFORM_ROT_90: return "Rotate90";
557 case HWC_TRANSFORM_ROT_180: return "Rotate180";
558 case HWC_TRANSFORM_ROT_270: return "Rotate270";
559 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
560 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
561 default: return "Unknown";
562 }
563}
564
565static inline const char* getVsyncName(hwc2_vsync_t vsync) {
566 switch (vsync) {
567 case HWC2_VSYNC_INVALID: return "Invalid";
568 case HWC2_VSYNC_ENABLE: return "Enable";
569 case HWC2_VSYNC_DISABLE: return "Disable";
570 default: return "Unknown";
571 }
572}
573
574#define TO_STRING(E, T, printer) \
575 inline std::string to_string(E value) { return printer(value); } \
576 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
577#else // !HWC2_INCLUDE_STRINGIFICATION
578#define TO_STRING(name, printer)
579#endif // HWC2_INCLUDE_STRINGIFICATION
580
581/*
582 * C++11 features
583 */
584
585#ifdef HWC2_USE_CPP11
586__END_DECLS
587
588#ifdef HWC2_INCLUDE_STRINGIFICATION
589#include <string>
590#endif
591
592namespace HWC2 {
593
594enum class Attribute : int32_t {
595 Invalid = HWC2_ATTRIBUTE_INVALID,
596 Width = HWC2_ATTRIBUTE_WIDTH,
597 Height = HWC2_ATTRIBUTE_HEIGHT,
598 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
599 DpiX = HWC2_ATTRIBUTE_DPI_X,
600 DpiY = HWC2_ATTRIBUTE_DPI_Y,
601};
602TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
603
604enum class BlendMode : int32_t {
605 Invalid = HWC2_BLEND_MODE_INVALID,
606 None = HWC2_BLEND_MODE_NONE,
607 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
608 Coverage = HWC2_BLEND_MODE_COVERAGE,
609};
610TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
611
612enum class Callback : int32_t {
613 Invalid = HWC2_CALLBACK_INVALID,
614 Hotplug = HWC2_CALLBACK_HOTPLUG,
615 Refresh = HWC2_CALLBACK_REFRESH,
616 Vsync = HWC2_CALLBACK_VSYNC,
617};
618TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
619
620enum class Capability : int32_t {
621 Invalid = HWC2_CAPABILITY_INVALID,
622 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
Dan Stozad2168f72016-07-14 11:48:16 -0700623 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
Brian Anderson49018a52017-04-04 16:43:11 -0700624 PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700625 SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700626};
627TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
628
629enum class Composition : int32_t {
630 Invalid = HWC2_COMPOSITION_INVALID,
631 Client = HWC2_COMPOSITION_CLIENT,
632 Device = HWC2_COMPOSITION_DEVICE,
633 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
634 Cursor = HWC2_COMPOSITION_CURSOR,
635 Sideband = HWC2_COMPOSITION_SIDEBAND,
636};
637TO_STRING(hwc2_composition_t, Composition, getCompositionName)
638
639enum class Connection : int32_t {
640 Invalid = HWC2_CONNECTION_INVALID,
641 Connected = HWC2_CONNECTION_CONNECTED,
642 Disconnected = HWC2_CONNECTION_DISCONNECTED,
643};
644TO_STRING(hwc2_connection_t, Connection, getConnectionName)
645
646enum class DisplayRequest : int32_t {
647 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
648 WriteClientTargetToOutput =
649 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
650};
651TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
652
653enum class DisplayType : int32_t {
654 Invalid = HWC2_DISPLAY_TYPE_INVALID,
655 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
656 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
657};
658TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
659
660enum class Error : int32_t {
661 None = HWC2_ERROR_NONE,
662 BadConfig = HWC2_ERROR_BAD_CONFIG,
663 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
664 BadLayer = HWC2_ERROR_BAD_LAYER,
665 BadParameter = HWC2_ERROR_BAD_PARAMETER,
666 HasChanges = HWC2_ERROR_HAS_CHANGES,
667 NoResources = HWC2_ERROR_NO_RESOURCES,
668 NotValidated = HWC2_ERROR_NOT_VALIDATED,
669 Unsupported = HWC2_ERROR_UNSUPPORTED,
670};
671TO_STRING(hwc2_error_t, Error, getErrorName)
672
673enum class FunctionDescriptor : int32_t {
674 Invalid = HWC2_FUNCTION_INVALID,
675 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
676 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
677 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
678 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
679 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
680 Dump = HWC2_FUNCTION_DUMP,
681 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
682 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
683 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
684 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
685 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
686 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
687 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
688 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
689 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
690 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700691 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700692 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
693 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
694 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
695 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
696 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
697 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
698 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
699 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
700 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
701 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
702 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
703 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
704 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
705 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
706 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
707 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
708 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
709 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
710 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
711 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
712 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
713 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
714 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
715 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
716 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
717 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800718 SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700719 SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700720 GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
721 SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER,
722 GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
723 GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700724 GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS,
725 SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
726 GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700727 GetDisplayIdentificationData = HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700728};
729TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
730 getFunctionDescriptorName)
731
732enum class LayerRequest : int32_t {
733 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
734};
735TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
736
737enum class PowerMode : int32_t {
738 Off = HWC2_POWER_MODE_OFF,
739 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
740 Doze = HWC2_POWER_MODE_DOZE,
741 On = HWC2_POWER_MODE_ON,
742};
743TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
744
745enum class Transform : int32_t {
746 None = 0,
747 FlipH = HWC_TRANSFORM_FLIP_H,
748 FlipV = HWC_TRANSFORM_FLIP_V,
749 Rotate90 = HWC_TRANSFORM_ROT_90,
750 Rotate180 = HWC_TRANSFORM_ROT_180,
751 Rotate270 = HWC_TRANSFORM_ROT_270,
752 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
753 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
754};
755TO_STRING(hwc_transform_t, Transform, getTransformName)
756
757enum class Vsync : int32_t {
758 Invalid = HWC2_VSYNC_INVALID,
759 Enable = HWC2_VSYNC_ENABLE,
760 Disable = HWC2_VSYNC_DISABLE,
761};
762TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
763
764} // namespace HWC2
765
766__BEGIN_DECLS
767#endif // HWC2_USE_CPP11
768
769/*
770 * Typedefs
771 */
772
773typedef void (*hwc2_function_pointer_t)();
774
775typedef void* hwc2_callback_data_t;
776typedef uint32_t hwc2_config_t;
777typedef uint64_t hwc2_display_t;
778typedef uint64_t hwc2_layer_t;
779
780/*
781 * Device Struct
782 */
783
784typedef struct hwc2_device {
785 /* Must be the first member of this struct, since a pointer to this struct
786 * will be generated by casting from a hw_device_t* */
787 struct hw_device_t common;
788
789 /* getCapabilities(..., outCount, outCapabilities)
790 *
791 * Provides a list of capabilities (described in the definition of
792 * hwc2_capability_t above) supported by this device. This list must
793 * not change after the device has been loaded.
794 *
795 * Parameters:
796 * outCount - if outCapabilities was NULL, the number of capabilities
797 * which would have been returned; if outCapabilities was not NULL,
798 * the number of capabilities returned, which must not exceed the
799 * value stored in outCount prior to the call
800 * outCapabilities - a list of capabilities supported by this device; may
801 * be NULL, in which case this function must write into outCount the
802 * number of capabilities which would have been written into
803 * outCapabilities
804 */
805 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
806 int32_t* /*hwc2_capability_t*/ outCapabilities);
807
808 /* getFunction(..., descriptor)
809 *
810 * Returns a function pointer which implements the requested description.
811 *
812 * Parameters:
813 * descriptor - the function to return
814 *
815 * Returns either a function pointer implementing the requested descriptor
816 * or NULL if the described function is not supported by this device.
817 */
818 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
819 int32_t /*hwc2_function_descriptor_t*/ descriptor);
820} hwc2_device_t;
821
822static inline int hwc2_open(const struct hw_module_t* module,
823 hwc2_device_t** device) {
824 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
Colin Crosscc8d9f92016-10-06 16:44:23 -0700825 TO_HW_DEVICE_T_OPEN(device));
Dan Stoza4e9221b2015-09-02 15:43:39 -0700826}
827
828static inline int hwc2_close(hwc2_device_t* device) {
829 return device->common.close(&device->common);
830}
831
832/*
833 * Callbacks
834 *
835 * All of these callbacks take as their first parameter the callbackData which
836 * was provided at the time of callback registration, so this parameter is
837 * omitted from the described parameter lists.
838 */
839
840/* hotplug(..., display, connected)
841 * Descriptor: HWC2_CALLBACK_HOTPLUG
842 * Will be provided to all HWC2 devices
843 *
844 * Notifies the client that the given display has either been connected or
845 * disconnected. Every active display (even a built-in physical display) must
846 * trigger at least one hotplug notification, even if it only occurs immediately
847 * after callback registration.
848 *
849 * The client may call back into the device on the same thread to query display
850 * properties (such as width, height, and vsync period), and other threads may
851 * call into the device while the callback is in progress. The device must
852 * serialize calls to this callback such that only one thread is calling it at a
853 * time.
854 *
855 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
856 * and the vsync callback should not be called for a display until vsync has
857 * been enabled with setVsyncEnabled.
858 *
859 * Parameters:
860 * display - the display which has been hotplugged
861 * connected - whether the display has been connected or disconnected
862 */
863typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
864 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
865
866/* refresh(..., display)
867 * Descriptor: HWC2_CALLBACK_REFRESH
868 * Will be provided to all HWC2 devices
869 *
870 * Notifies the client to trigger a screen refresh. This forces all layer state
871 * for this display to be resent, and the display to be validated and presented,
872 * even if there have been no changes.
873 *
874 * This refresh will occur some time after the callback is initiated, but not
875 * necessarily before it returns. This thread, however, is guaranteed not to
876 * call back into the device, thus it is safe to trigger this callback from
877 * other functions which call into the device.
878 *
879 * Parameters:
880 * display - the display to refresh
881 */
882typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
883 hwc2_display_t display);
884
885/* vsync(..., display, timestamp)
886 * Descriptor: HWC2_CALLBACK_VSYNC
887 * Will be provided to all HWC2 devices
888 *
889 * Notifies the client that a vsync event has occurred. This callback must
890 * only be triggered when vsync is enabled for this display (through
891 * setVsyncEnabled).
892 *
893 * This callback should be triggered from a thread of at least
894 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
895 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
896 *
897 * Parameters:
898 * display - the display which has received a vsync event
899 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
900 * nanoseconds
901 */
902typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
903 hwc2_display_t display, int64_t timestamp);
904
905/*
906 * Device Functions
907 *
908 * All of these functions take as their first parameter a device pointer, so
909 * this parameter is omitted from the described parameter lists.
910 */
911
Dan Stoza68cd3752016-05-20 13:30:42 -0700912/* createVirtualDisplay(..., width, height, format, outDisplay)
Dan Stoza4e9221b2015-09-02 15:43:39 -0700913 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
914 * Must be provided by all HWC2 devices
915 *
Dan Stoza68cd3752016-05-20 13:30:42 -0700916 * Creates a new virtual display with the given width and height. The format
917 * passed into this function is the default format requested by the consumer of
918 * the virtual display output buffers. If a different format will be returned by
919 * the device, it should be returned in this parameter so it can be set properly
920 * when handing the buffers to the consumer.
921 *
922 * The display will be assumed to be on from the time the first frame is
923 * presented until the display is destroyed.
Dan Stoza4e9221b2015-09-02 15:43:39 -0700924 *
925 * Parameters:
926 * width - width in pixels
927 * height - height in pixels
Dan Stoza68cd3752016-05-20 13:30:42 -0700928 * format - prior to the call, the default output buffer format selected by
929 * the consumer; after the call, the format the device will produce
Dan Stoza4e9221b2015-09-02 15:43:39 -0700930 * outDisplay - the newly-created virtual display; pointer will be non-NULL
931 *
932 * Returns HWC2_ERROR_NONE or one of the following errors:
933 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
934 * be able to create a virtual display
935 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
936 * display at this time
937 */
938typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
939 hwc2_device_t* device, uint32_t width, uint32_t height,
Dan Stoza68cd3752016-05-20 13:30:42 -0700940 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
Dan Stoza4e9221b2015-09-02 15:43:39 -0700941
942/* destroyVirtualDisplay(..., display)
943 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
944 * Must be provided by all HWC2 devices
945 *
946 * Destroys a virtual display. After this call all resources consumed by this
947 * display may be freed by the device and any operations performed on this
948 * display should fail.
949 *
950 * Parameters:
951 * display - the virtual display to destroy
952 *
953 * Returns HWC2_ERROR_NONE or one of the following errors:
954 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
955 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
956 * refer to a virtual display
957 */
958typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
959 hwc2_device_t* device, hwc2_display_t display);
960
961/* dump(..., outSize, outBuffer)
962 * Descriptor: HWC2_FUNCTION_DUMP
963 * Must be provided by all HWC2 devices
964 *
965 * Retrieves implementation-defined debug information, which will be displayed
966 * during, for example, `dumpsys SurfaceFlinger`.
967 *
968 * If called with outBuffer == NULL, the device should store a copy of the
969 * desired output and return its length in bytes in outSize. If the device
970 * already has a stored copy, that copy should be purged and replaced with a
971 * fresh copy.
972 *
973 * If called with outBuffer != NULL, the device should copy its stored version
974 * of the output into outBuffer and store how many bytes of data it copied into
975 * outSize. Prior to this call, the client will have populated outSize with the
976 * maximum number of bytes outBuffer can hold. The device must not write more
977 * than this amount into outBuffer. If the device does not currently have a
978 * stored copy, then it should return 0 in outSize.
979 *
980 * Any data written into outBuffer need not be null-terminated.
981 *
982 * Parameters:
983 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
984 * device's stored output; if outBuffer was not NULL, the number of bytes
985 * written into it, which must not exceed the value stored in outSize
986 * prior to the call; pointer will be non-NULL
987 * outBuffer - the buffer to write the dump output into; may be NULL as
988 * described above; data written into this buffer need not be
989 * null-terminated
990 */
991typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
992 char* outBuffer);
993
994/* getMaxVirtualDisplayCount(...)
995 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
996 * Must be provided by all HWC2 devices
997 *
998 * Returns the maximum number of virtual displays supported by this device
999 * (which may be 0). The client will not attempt to create more than this many
1000 * virtual displays on this device. This number must not change for the lifetime
1001 * of the device.
1002 */
1003typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
1004 hwc2_device_t* device);
1005
1006/* registerCallback(..., descriptor, callbackData, pointer)
1007 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
1008 * Must be provided by all HWC2 devices
1009 *
1010 * Provides a callback for the device to call. All callbacks take a callbackData
1011 * item as the first parameter, so this value should be stored with the callback
1012 * for later use. The callbackData may differ from one callback to another. If
1013 * this function is called multiple times with the same descriptor, later
1014 * callbacks replace earlier ones.
1015 *
1016 * Parameters:
1017 * descriptor - which callback should be set
1018 * callBackdata - opaque data which must be passed back through the callback
1019 * pointer - a non-NULL function pointer corresponding to the descriptor
1020 *
1021 * Returns HWC2_ERROR_NONE or one of the following errors:
1022 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
1023 */
1024typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
1025 hwc2_device_t* device,
1026 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
1027 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
1028
Chia-I Wu28310aa2018-03-15 21:20:55 -07001029/* getDataspaceSaturationMatrix(..., dataspace, outMatrix)
1030 * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
1031 * Provided by HWC2 devices which don't return nullptr function pointer.
1032 *
1033 * Get the saturation matrix of the specified dataspace. The saturation matrix
1034 * can be used to approximate the dataspace saturation operation performed by
1035 * the HWC2 device when non-colorimetric mapping is allowed. It is to be
1036 * applied on linear pixel values.
1037 *
1038 * Parameters:
1039 * dataspace - the dataspace to query for
1040 * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity
1041 * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR.
1042 *
1043 * Returns HWC2_ERROR_NONE or one of the following errors:
1044 * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid
1045 */
1046typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)(
1047 hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace,
1048 float* outMatrix);
1049
Dan Stoza4e9221b2015-09-02 15:43:39 -07001050/*
1051 * Display Functions
1052 *
1053 * All of these functions take as their first two parameters a device pointer
1054 * and a display handle, so these parameters are omitted from the described
1055 * parameter lists.
1056 */
1057
1058/* acceptDisplayChanges(...)
1059 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
1060 * Must be provided by all HWC2 devices
1061 *
1062 * Accepts the changes required by the device from the previous validateDisplay
1063 * call (which may be queried using getChangedCompositionTypes) and revalidates
1064 * the display. This function is equivalent to requesting the changed types from
1065 * getChangedCompositionTypes, setting those types on the corresponding layers,
1066 * and then calling validateDisplay again.
1067 *
1068 * After this call it must be valid to present this display. Calling this after
1069 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
1070 * should have no other effect.
1071 *
1072 * Returns HWC2_ERROR_NONE or one of the following errors:
1073 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1074 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
1075 */
1076typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
1077 hwc2_device_t* device, hwc2_display_t display);
1078
1079/* createLayer(..., outLayer)
1080 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
1081 * Must be provided by all HWC2 devices
1082 *
1083 * Creates a new layer on the given display.
1084 *
1085 * Parameters:
1086 * outLayer - the handle of the new layer; pointer will be non-NULL
1087 *
1088 * Returns HWC2_ERROR_NONE or one of the following errors:
1089 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1090 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
1091 */
1092typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
1093 hwc2_display_t display, hwc2_layer_t* outLayer);
1094
1095/* destroyLayer(..., layer)
1096 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
1097 * Must be provided by all HWC2 devices
1098 *
1099 * Destroys the given layer.
1100 *
1101 * Parameters:
1102 * layer - the handle of the layer to destroy
1103 *
1104 * Returns HWC2_ERROR_NONE or one of the following errors:
1105 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1106 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1107 */
1108typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1109 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1110
1111/* getActiveConfig(..., outConfig)
1112 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1113 * Must be provided by all HWC2 devices
1114 *
1115 * Retrieves which display configuration is currently active.
1116 *
1117 * If no display configuration is currently active, this function must return
1118 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1119 * the responsibility of the client to call setActiveConfig with a valid
1120 * configuration before attempting to present anything on the display.
1121 *
1122 * Parameters:
1123 * outConfig - the currently active display configuration; pointer will be
1124 * non-NULL
1125 *
1126 * Returns HWC2_ERROR_NONE or one of the following errors:
1127 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1128 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1129 */
1130typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1131 hwc2_device_t* device, hwc2_display_t display,
1132 hwc2_config_t* outConfig);
1133
1134/* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1135 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1136 * Must be provided by all HWC2 devices
1137 *
1138 * Retrieves the layers for which the device requires a different composition
1139 * type than had been set prior to the last call to validateDisplay. The client
1140 * will either update its state with these types and call acceptDisplayChanges,
1141 * or will set new types and attempt to validate the display again.
1142 *
1143 * outLayers and outTypes may be NULL to retrieve the number of elements which
1144 * will be returned. The number of elements returned must be the same as the
1145 * value returned in outNumTypes from the last call to validateDisplay.
1146 *
1147 * Parameters:
1148 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1149 * and types which would have been returned; if both were non-NULL, the
1150 * number of elements returned in outLayers and outTypes, which must not
1151 * exceed the value stored in outNumElements prior to the call; pointer
1152 * will be non-NULL
1153 * outLayers - an array of layer handles
1154 * outTypes - an array of composition types, each corresponding to an element
1155 * of outLayers
1156 *
1157 * Returns HWC2_ERROR_NONE or one of the following errors:
1158 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1159 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1160 * display
1161 */
1162typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1163 hwc2_device_t* device, hwc2_display_t display,
1164 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1165 int32_t* /*hwc2_composition_t*/ outTypes);
1166
1167/* getClientTargetSupport(..., width, height, format, dataspace)
1168 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1169 * Must be provided by all HWC2 devices
1170 *
1171 * Returns whether a client target with the given properties can be handled by
1172 * the device.
1173 *
1174 * The valid formats can be found in android_pixel_format_t in
1175 * <system/graphics.h>.
1176 *
1177 * For more about dataspaces, see setLayerDataspace.
1178 *
1179 * This function must return true for a client target with width and height
1180 * equal to the active display configuration dimensions,
1181 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1182 * return true for any other configuration.
1183 *
1184 * Parameters:
1185 * width - client target width in pixels
1186 * height - client target height in pixels
1187 * format - client target format
1188 * dataspace - client target dataspace, as described in setLayerDataspace
1189 *
1190 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1191 * following errors:
1192 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1193 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1194 */
1195typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1196 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1197 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1198 int32_t /*android_dataspace_t*/ dataspace);
1199
1200/* getColorModes(..., outNumModes, outModes)
1201 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1202 * Must be provided by all HWC2 devices
1203 *
1204 * Returns the color modes supported on this display.
1205 *
1206 * The valid color modes can be found in android_color_mode_t in
1207 * <system/graphics.h>. All HWC2 devices must support at least
1208 * HAL_COLOR_MODE_NATIVE.
1209 *
1210 * outNumModes may be NULL to retrieve the number of modes which will be
1211 * returned.
1212 *
1213 * Parameters:
1214 * outNumModes - if outModes was NULL, the number of modes which would have
1215 * been returned; if outModes was not NULL, the number of modes returned,
1216 * which must not exceed the value stored in outNumModes prior to the
1217 * call; pointer will be non-NULL
1218 * outModes - an array of color modes
1219 *
1220 * Returns HWC2_ERROR_NONE or one of the following errors:
1221 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1222 */
1223typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1224 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1225 int32_t* /*android_color_mode_t*/ outModes);
1226
Chia-I Wu28310aa2018-03-15 21:20:55 -07001227/* getRenderIntents(..., mode, outNumIntents, outIntents)
1228 * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS
1229 * Provided by HWC2 devices which don't return nullptr function pointer.
1230 *
1231 * Returns the render intents supported on this display.
1232 *
1233 * The valid render intents can be found in android_render_intent_v1_1_t in
1234 * <system/graphics.h>. All HWC2 devices must support at least
1235 * HAL_RENDER_INTENT_COLORIMETRIC.
1236 *
1237 * outNumIntents may be NULL to retrieve the number of intents which will be
1238 * returned.
1239 *
1240 * Parameters:
1241 * mode - the color mode to query the render intents for
1242 * outNumIntents - if outIntents was NULL, the number of intents which would
1243 * have been returned; if outIntents was not NULL, the number of intents
1244 * returned, which must not exceed the value stored in outNumIntents
1245 * prior to the call; pointer will be non-NULL
1246 * outIntents - an array of render intents
1247 *
1248 * Returns HWC2_ERROR_NONE or one of the following errors:
1249 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1250 */
1251typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)(
1252 hwc2_device_t* device, hwc2_display_t display, int32_t mode,
1253 uint32_t* outNumIntents,
1254 int32_t* /*android_render_intent_v1_1_t*/ outIntents);
1255
Dan Stoza4e9221b2015-09-02 15:43:39 -07001256/* getDisplayAttribute(..., config, attribute, outValue)
1257 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1258 * Must be provided by all HWC2 devices
1259 *
1260 * Returns a display attribute value for a particular display configuration.
1261 *
1262 * Any attribute which is not supported or for which the value is unknown by the
1263 * device must return a value of -1.
1264 *
1265 * Parameters:
1266 * config - the display configuration for which to return attribute values
1267 * attribute - the attribute to query
1268 * outValue - the value of the attribute; the pointer will be non-NULL
1269 *
1270 * Returns HWC2_ERROR_NONE or one of the following errors:
1271 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1272 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1273 * display
1274 */
1275typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1276 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1277 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1278
1279/* getDisplayConfigs(..., outNumConfigs, outConfigs)
1280 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1281 * Must be provided by all HWC2 devices
1282 *
1283 * Returns handles for all of the valid display configurations on this display.
1284 *
1285 * outConfigs may be NULL to retrieve the number of elements which will be
1286 * returned.
1287 *
1288 * Parameters:
1289 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1290 * would have been returned; if outConfigs was not NULL, the number of
1291 * configurations returned, which must not exceed the value stored in
1292 * outNumConfigs prior to the call; pointer will be non-NULL
1293 * outConfigs - an array of configuration handles
1294 *
1295 * Returns HWC2_ERROR_NONE or one of the following errors:
1296 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1297 */
1298typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1299 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1300 hwc2_config_t* outConfigs);
1301
1302/* getDisplayName(..., outSize, outName)
1303 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1304 * Must be provided by all HWC2 devices
1305 *
1306 * Returns a human-readable version of the display's name.
1307 *
1308 * outName may be NULL to retrieve the length of the name.
1309 *
1310 * Parameters:
1311 * outSize - if outName was NULL, the number of bytes needed to return the
1312 * name if outName was not NULL, the number of bytes written into it,
1313 * which must not exceed the value stored in outSize prior to the call;
1314 * pointer will be non-NULL
1315 * outName - the display's name
1316 *
1317 * Returns HWC2_ERROR_NONE or one of the following errors:
1318 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1319 */
1320typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1321 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1322 char* outName);
1323
1324/* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1325 * outLayerRequests)
1326 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1327 * Must be provided by all HWC2 devices
1328 *
1329 * Returns the display requests and the layer requests required for the last
1330 * validated configuration.
1331 *
1332 * Display requests provide information about how the client should handle the
1333 * client target. Layer requests provide information about how the client
1334 * should handle an individual layer.
1335 *
1336 * If outLayers or outLayerRequests is NULL, the required number of layers and
1337 * requests must be returned in outNumElements, but this number may also be
1338 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1339 * to the value returned in outNumRequests from the last call to
1340 * validateDisplay).
1341 *
1342 * Parameters:
1343 * outDisplayRequests - the display requests for the current validated state
1344 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1345 * elements which would have been returned, which must be equal to the
1346 * value returned in outNumRequests from the last validateDisplay call on
1347 * this display; if both were not NULL, the number of elements in
1348 * outLayers and outLayerRequests, which must not exceed the value stored
1349 * in outNumElements prior to the call; pointer will be non-NULL
1350 * outLayers - an array of layers which all have at least one request
1351 * outLayerRequests - the requests corresponding to each element of outLayers
1352 *
1353 * Returns HWC2_ERROR_NONE or one of the following errors:
1354 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1355 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1356 * display
1357 */
1358typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1359 hwc2_device_t* device, hwc2_display_t display,
1360 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1361 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1362 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1363
1364/* getDisplayType(..., outType)
1365 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1366 * Must be provided by all HWC2 devices
1367 *
1368 * Returns whether the given display is a physical or virtual display.
1369 *
1370 * Parameters:
1371 * outType - the type of the display; pointer will be non-NULL
1372 *
1373 * Returns HWC2_ERROR_NONE or one of the following errors:
1374 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1375 */
1376typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1377 hwc2_device_t* device, hwc2_display_t display,
1378 int32_t* /*hwc2_display_type_t*/ outType);
1379
Dominik Laskowski55cf6f02018-03-25 15:12:04 -07001380/* getDisplayIdentificationData(..., outPort, outDataSize, outData)
1381 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
1382 * Optional for HWC2 devices
1383 *
1384 * If supported, getDisplayIdentificationData returns the port and data that
1385 * describe a physical display. The port is a unique number that identifies a
1386 * physical connector (e.g. eDP, HDMI) for display output. The data blob is
1387 * parsed to determine its format, typically EDID 1.3 as specified in VESA
1388 * E-EDID Standard Release A Revision 1.
1389 *
1390 * Devices for which display identification is unsupported must return null when
1391 * getFunction is called with HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA.
1392 *
1393 * Parameters:
1394 * outPort - the connector to which the display is connected;
1395 * pointer will be non-NULL
1396 * outDataSize - if outData is NULL, the size in bytes of the data which would
1397 * have been returned; if outData is not NULL, the size of outData, which
1398 * must not exceed the value stored in outDataSize prior to the call;
1399 * pointer will be non-NULL
1400 * outData - the EDID 1.3 blob identifying the display
1401 *
1402 * Returns HWC2_ERROR_NONE or one of the following errors:
1403 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1404 */
1405typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA)(
1406 hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
1407 uint32_t* outDataSize, uint8_t* outData);
1408
Dan Stoza4e9221b2015-09-02 15:43:39 -07001409/* getDozeSupport(..., outSupport)
1410 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1411 * Must be provided by all HWC2 devices
1412 *
1413 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1414 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1415 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1416 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1417 * device should not claim support.
1418 *
1419 * Parameters:
1420 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1421 * pointer will be non-NULL
1422 *
1423 * Returns HWC2_ERROR_NONE or one of the following errors:
1424 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1425 */
1426typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1427 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1428
Dan Stozaf601e972016-03-16 09:54:40 -07001429/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1430 * outMaxAverageLuminance, outMinLuminance)
1431 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1432 * Must be provided by all HWC2 devices
1433 *
1434 * Returns the high dynamic range (HDR) capabilities of the given display, which
1435 * are invariant with regard to the active configuration.
1436 *
1437 * Displays which are not HDR-capable must return no types in outTypes and set
1438 * outNumTypes to 0.
1439 *
1440 * If outTypes is NULL, the required number of HDR types must be returned in
1441 * outNumTypes.
1442 *
1443 * Parameters:
1444 * outNumTypes - if outTypes was NULL, the number of types which would have
1445 * been returned; if it was not NULL, the number of types stored in
1446 * outTypes, which must not exceed the value stored in outNumTypes prior
1447 * to the call; pointer will be non-NULL
1448 * outTypes - an array of HDR types, may have 0 elements if the display is not
1449 * HDR-capable
1450 * outMaxLuminance - the desired content maximum luminance for this display in
1451 * cd/m^2; pointer will be non-NULL
1452 * outMaxAverageLuminance - the desired content maximum frame-average
1453 * luminance for this display in cd/m^2; pointer will be non-NULL
1454 * outMinLuminance - the desired content minimum luminance for this display in
1455 * cd/m^2; pointer will be non-NULL
1456 *
1457 * Returns HWC2_ERROR_NONE or one of the following errors:
1458 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1459 */
1460typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1461 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1462 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1463 float* outMaxAverageLuminance, float* outMinLuminance);
1464
Dan Stoza4e9221b2015-09-02 15:43:39 -07001465/* getReleaseFences(..., outNumElements, outLayers, outFences)
1466 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1467 * Must be provided by all HWC2 devices
1468 *
1469 * Retrieves the release fences for device layers on this display which will
1470 * receive new buffer contents this frame.
1471 *
1472 * A release fence is a file descriptor referring to a sync fence object which
1473 * will be signaled after the device has finished reading from the buffer
1474 * presented in the prior frame. This indicates that it is safe to start writing
1475 * to the buffer again. If a given layer's fence is not returned from this
1476 * function, it will be assumed that the buffer presented on the previous frame
1477 * is ready to be written.
1478 *
1479 * The fences returned by this function should be unique for each layer (even if
1480 * they point to the same underlying sync object), and ownership of the fences
1481 * is transferred to the client, which is responsible for closing them.
1482 *
1483 * If outLayers or outFences is NULL, the required number of layers and fences
1484 * must be returned in outNumElements.
1485 *
1486 * Parameters:
1487 * outNumElements - if outLayers or outFences were NULL, the number of
1488 * elements which would have been returned; if both were not NULL, the
1489 * number of elements in outLayers and outFences, which must not exceed
1490 * the value stored in outNumElements prior to the call; pointer will be
1491 * non-NULL
1492 * outLayers - an array of layer handles
1493 * outFences - an array of sync fence file descriptors as described above,
1494 * each corresponding to an element of outLayers
1495 *
1496 * Returns HWC2_ERROR_NONE or one of the following errors:
1497 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1498 */
1499typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
1500 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1501 hwc2_layer_t* outLayers, int32_t* outFences);
1502
Dan Stozaef264822016-07-13 14:51:09 -07001503/* presentDisplay(..., outPresentFence)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001504 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1505 * Must be provided by all HWC2 devices
1506 *
1507 * Presents the current display contents on the screen (or in the case of
1508 * virtual displays, into the output buffer).
1509 *
1510 * Prior to calling this function, the display must be successfully validated
1511 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1512 * specifically do not count as layer state, so if there are no other changes
1513 * to the layer state (or to the buffer's properties as described in
1514 * setLayerBuffer), then it is safe to call this function without first
1515 * validating the display.
1516 *
Dan Stozaef264822016-07-13 14:51:09 -07001517 * If this call succeeds, outPresentFence will be populated with a file
1518 * descriptor referring to a present sync fence object. For physical displays,
1519 * this fence will be signaled at the vsync when the result of composition of
1520 * this frame starts to appear (for video-mode panels) or starts to transfer to
1521 * panel memory (for command-mode panels). For virtual displays, this fence will
1522 * be signaled when writes to the output buffer have completed and it is safe to
1523 * read from it.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001524 *
1525 * Parameters:
Dan Stozaef264822016-07-13 14:51:09 -07001526 * outPresentFence - a sync fence file descriptor as described above; pointer
Dan Stoza4e9221b2015-09-02 15:43:39 -07001527 * will be non-NULL
1528 *
1529 * Returns HWC2_ERROR_NONE or one of the following errors:
1530 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1531 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1532 * display
1533 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1534 * for this display
1535 */
1536typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
Dan Stozaef264822016-07-13 14:51:09 -07001537 hwc2_device_t* device, hwc2_display_t display,
1538 int32_t* outPresentFence);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001539
1540/* setActiveConfig(..., config)
1541 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1542 * Must be provided by all HWC2 devices
1543 *
1544 * Sets the active configuration for this display. Upon returning, the given
1545 * display configuration should be active and remain so until either this
1546 * function is called again or the display is disconnected.
1547 *
1548 * Parameters:
1549 * config - the new display configuration
1550 *
1551 * Returns HWC2_ERROR_NONE or one of the following errors:
1552 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1553 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1554 * this display
1555 */
1556typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1557 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1558
Dan Stoza68cd3752016-05-20 13:30:42 -07001559/* setClientTarget(..., target, acquireFence, dataspace, damage)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001560 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1561 * Must be provided by all HWC2 devices
1562 *
1563 * Sets the buffer handle which will receive the output of client composition.
1564 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1565 * prior to the call to presentDisplay, and layers not marked as
1566 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1567 *
Dan Stoza3abcfa52016-05-04 12:21:06 -07001568 * The buffer handle provided may be null if no layers are being composited by
1569 * the client. This must not result in an error (unless an invalid display
1570 * handle is also provided).
1571 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001572 * Also provides a file descriptor referring to an acquire sync fence object,
1573 * which will be signaled when it is safe to read from the client target buffer.
1574 * If it is already safe to read from this buffer, -1 may be passed instead.
1575 * The device must ensure that it is safe for the client to close this file
1576 * descriptor at any point after this function is called.
1577 *
1578 * For more about dataspaces, see setLayerDataspace.
1579 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001580 * The damage parameter describes a surface damage region as defined in the
1581 * description of setLayerSurfaceDamage.
1582 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001583 * Will be called before presentDisplay if any of the layers are marked as
1584 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1585 * necessary to call this function. It is not necessary to call validateDisplay
1586 * after changing the target through this function.
1587 *
1588 * Parameters:
1589 * target - the new target buffer
1590 * acquireFence - a sync fence file descriptor as described above
1591 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
Dan Stoza68cd3752016-05-20 13:30:42 -07001592 * damage - the surface damage region
Dan Stoza4e9221b2015-09-02 15:43:39 -07001593 *
1594 * Returns HWC2_ERROR_NONE or one of the following errors:
1595 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1596 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1597 */
1598typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1599 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
Dan Stoza68cd3752016-05-20 13:30:42 -07001600 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1601 hwc_region_t damage);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001602
Dan Stozac46e96a2016-03-24 10:12:15 -07001603/* setColorMode(..., mode)
1604 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1605 * Must be provided by all HWC2 devices
1606 *
1607 * Sets the color mode of the given display.
1608 *
Chia-I Wu28310aa2018-03-15 21:20:55 -07001609 * This must be called outside of validateDisplay/presentDisplay, and it takes
1610 * effect on next presentDisplay.
Dan Stozac46e96a2016-03-24 10:12:15 -07001611 *
1612 * The valid color modes can be found in android_color_mode_t in
1613 * <system/graphics.h>. All HWC2 devices must support at least
1614 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1615 * hotplug.
1616 *
1617 * Parameters:
1618 * mode - the mode to set
1619 *
1620 * Returns HWC2_ERROR_NONE or one of the following errors:
1621 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1622 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1623 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1624 */
1625typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1626 hwc2_device_t* device, hwc2_display_t display,
1627 int32_t /*android_color_mode_t*/ mode);
1628
Chia-I Wu28310aa2018-03-15 21:20:55 -07001629/* setColorModeWithIntent(..., mode, intent)
1630 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
1631 * Provided by HWC2 devices which don't return nullptr function pointer.
1632 *
1633 * This must be called outside of validateDisplay/presentDisplay, and it takes
1634 * effect on next presentDisplay.
1635 *
1636 * The valid color modes and render intents can be found in
1637 * android_color_mode_t and android_render_intent_v1_1_t in
1638 * <system/graphics.h>. All HWC2 devices must support at least
1639 * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are
1640 * assumed to be in this mode and intent upon hotplug.
1641 *
1642 * Parameters:
1643 * mode - the mode to set
1644 * intent - the intent to set
1645 *
1646 * Returns HWC2_ERROR_NONE or one of the following errors:
1647 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1648 * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or
1649 * render intent
1650 * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display
1651 */
1652typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)(
1653 hwc2_device_t* device, hwc2_display_t display,
1654 int32_t /*android_color_mode_t*/ mode,
1655 int32_t /*android_render_intent_v1_1_t */ intent);
1656
Dan Stoza4e9221b2015-09-02 15:43:39 -07001657/* setColorTransform(..., matrix, hint)
1658 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1659 * Must be provided by all HWC2 devices
1660 *
1661 * Sets a color transform which will be applied after composition.
1662 *
1663 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1664 * hint to apply the desired color transform instead of using the color matrix
1665 * directly.
1666 *
1667 * If the device is not capable of either using the hint or the matrix to apply
1668 * the desired color transform, it should force all layers to client composition
1669 * during validateDisplay.
1670 *
Dan Stozad2168f72016-07-14 11:48:16 -07001671 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1672 * will never apply the color transform during client composition, even if all
1673 * layers are being composed by the client.
1674 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001675 * The matrix provided is an affine color transformation of the following form:
1676 *
1677 * |r.r r.g r.b 0|
1678 * |g.r g.g g.b 0|
1679 * |b.r b.g b.b 0|
1680 * |Tr Tg Tb 1|
1681 *
1682 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1683 *
1684 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1685 * color [R_out, G_out, B_out] will be:
1686 *
1687 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
Dan Stoza5dfbe332016-03-24 09:23:11 -07001688 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1689 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
Dan Stoza4e9221b2015-09-02 15:43:39 -07001690 *
1691 * Parameters:
1692 * matrix - a 4x4 transform matrix (16 floats) as described above
1693 * hint - a hint value which may be used instead of the given matrix unless it
1694 * is HAL_COLOR_TRANSFORM_ARBITRARY
1695 *
1696 * Returns HWC2_ERROR_NONE or one of the following errors:
1697 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1698 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
1699 */
1700typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
Dan Stozac46e96a2016-03-24 10:12:15 -07001701 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
Dan Stoza4e9221b2015-09-02 15:43:39 -07001702 int32_t /*android_color_transform_t*/ hint);
1703
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001704/* getPerFrameMetadataKeys(..., outKeys)
1705 * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
1706 * Optional for HWC2 devices
1707 *
1708 * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null),
1709 * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys
1710 * which are invariant with regard to the active configuration.
1711 *
1712 * Devices which are not HDR-capable, must return null when getFunction is called
1713 * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS.
1714 *
1715 * If outKeys is NULL, the required number of PerFrameMetadataKey keys
1716 * must be returned in outNumKeys.
1717 *
1718 * Parameters:
1719 * outNumKeys - if outKeys is NULL, the number of keys which would have
1720 * been returned; if outKeys is not NULL, the number of keys stored in
1721 * outKeys, which must not exceed the value stored in outNumKeys prior
1722 * to the call; pointer will be non-NULL
1723 * outKeys - an array of hwc2_per_frame_metadata_key_t keys
1724 *
1725 * Returns HWC2_ERROR_NONE or one of the following errors:
1726 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1727 */
1728typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)(
1729 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys,
1730 int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
1731
Dan Stoza4e9221b2015-09-02 15:43:39 -07001732/* setOutputBuffer(..., buffer, releaseFence)
1733 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
1734 * Must be provided by all HWC2 devices
1735 *
1736 * Sets the output buffer for a virtual display. That is, the buffer to which
1737 * the composition result will be written.
1738 *
1739 * Also provides a file descriptor referring to a release sync fence object,
1740 * which will be signaled when it is safe to write to the output buffer. If it
1741 * is already safe to write to the output buffer, -1 may be passed instead. The
1742 * device must ensure that it is safe for the client to close this file
1743 * descriptor at any point after this function is called.
1744 *
1745 * Must be called at least once before presentDisplay, but does not have any
1746 * interaction with layer state or display validation.
1747 *
1748 * Parameters:
1749 * buffer - the new output buffer
1750 * releaseFence - a sync fence file descriptor as described above
1751 *
1752 * Returns HWC2_ERROR_NONE or one of the following errors:
1753 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1754 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
1755 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
1756 */
1757typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
1758 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
1759 int32_t releaseFence);
1760
1761/* setPowerMode(..., mode)
1762 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
1763 * Must be provided by all HWC2 devices
1764 *
1765 * Sets the power mode of the given display. The transition must be complete
1766 * when this function returns. It is valid to call this function multiple times
1767 * with the same power mode.
1768 *
1769 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
1770 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
1771 * be queried using getDozeSupport.
1772 *
1773 * Parameters:
1774 * mode - the new power mode
1775 *
1776 * Returns HWC2_ERROR_NONE or one of the following errors:
1777 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1778 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
1779 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1780 * on this display
1781 */
1782typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
1783 hwc2_device_t* device, hwc2_display_t display,
1784 int32_t /*hwc2_power_mode_t*/ mode);
1785
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001786/* getReadbackBufferAttributes(..., outFormat, outDataspace)
1787 * Optional for HWC2 devices
1788 *
1789 * Returns the format which should be used when allocating a buffer for use by
1790 * device readback as well as the dataspace in which its contents should be
1791 * interpreted.
1792 *
1793 * If readback is not supported by this HWC implementation, this call will also
1794 * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method.
1795 * Returning NULL to a getFunction request for this function will also indicate
1796 * that readback is not supported.
1797 *
1798 * The width and height of this buffer will be those of the currently-active
1799 * display configuration, and the usage flags will consist of the following:
1800 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
1801 * BufferUsage::COMPOSER_OUTPUT
1802 *
1803 * The format and dataspace provided must be sufficient such that if a
1804 * correctly-configured buffer is passed into setReadbackBuffer, filled by
1805 * the device, and then displayed by the client as a full-screen buffer, the
1806 * output of the display remains the same (subject to the note about protected
1807 * content in the description of setReadbackBuffer).
1808 *
1809 * Parameters:
1810 * outFormat - the format the client should use when allocating a device
1811 * readback buffer
1812 * outDataspace - the dataspace the client will use when interpreting the
1813 * contents of a device readback buffer
1814 *
1815 * Returns HWC2_ERROR_NONE or one of the following errors:
1816 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1817 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1818 *
1819 * See also:
1820 * setReadbackBuffer
1821 * getReadbackBufferFence
1822 */
1823typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)(
1824 hwc2_device_t* device, hwc2_display_t display,
1825 int32_t* /*android_pixel_format_t*/ outFormat,
1826 int32_t* /*android_dataspace_t*/ outDataspace);
1827
1828/* getReadbackBufferFence(..., outFence)
1829 * Optional for HWC2 devices
1830 *
1831 * Returns an acquire sync fence file descriptor which will signal when the
1832 * buffer provided to setReadbackBuffer has been filled by the device and is
1833 * safe for the client to read.
1834 *
1835 * If it is already safe to read from this buffer, -1 may be returned instead.
1836 * The client takes ownership of this file descriptor and is responsible for
1837 * closing it when it is no longer needed.
1838 *
1839 * This function will be called immediately after the composition cycle being
1840 * captured into the readback buffer. The complete ordering of a readback buffer
1841 * capture is as follows:
1842 *
1843 * getReadbackBufferAttributes
1844 * // Readback buffer is allocated
1845 * // Many frames may pass
1846 *
1847 * setReadbackBuffer
1848 * validateDisplay
1849 * presentDisplay
1850 * getReadbackBufferFence
1851 * // Implicitly wait on the acquire fence before accessing the buffer
1852 *
1853 * Parameters:
1854 * outFence - a sync fence file descriptor as described above; pointer
1855 * will be non-NULL
1856 *
1857 * Returns HWC2_ERROR_NONE or one of the following errors:
1858 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1859 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1860 *
1861 */
1862typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)(
1863 hwc2_device_t* device, hwc2_display_t display,
1864 int32_t* outFence);
1865
1866/* setReadbackBuffer(..., buffer, releaseFence)
1867 * Optional for HWC2 devices
1868 *
1869 * Sets the readback buffer to be filled with the contents of the next
1870 * composition performed for this display (i.e., the contents present at the
1871 * time of the next validateDisplay/presentDisplay cycle).
1872 *
1873 * This buffer will have been allocated as described in
1874 * getReadbackBufferAttributes and will be interpreted as being in the dataspace
1875 * provided by the same.
1876 *
1877 * If there is hardware protected content on the display at the time of the next
1878 * composition, the area of the readback buffer covered by such content must be
1879 * completely black. Any areas of the buffer not covered by such content may
1880 * optionally be black as well.
1881 *
1882 * The release fence file descriptor provided works identically to the one
1883 * described for setOutputBuffer.
1884 *
1885 * This function will not be called between any call to validateDisplay and a
1886 * subsequent call to presentDisplay.
1887 *
1888 * Parameters:
1889 * buffer - the new readback buffer
1890 * releaseFence - a sync fence file descriptor as described in setOutputBuffer
1891 *
1892 * Returns HWC2_ERROR_NONE or one of the following errors:
1893 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1894 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
1895 *
1896 * See also:
1897 * getReadbackBufferAttributes
1898 * getReadbackBufferFence
1899 */
1900typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)(
1901 hwc2_device_t* device, hwc2_display_t display,
1902 buffer_handle_t buffer, int32_t releaseFence);
1903
Dan Stoza4e9221b2015-09-02 15:43:39 -07001904/* setVsyncEnabled(..., enabled)
1905 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
1906 * Must be provided by all HWC2 devices
1907 *
1908 * Enables or disables the vsync signal for the given display. Virtual displays
1909 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
1910 * display though this function must return HWC2_ERROR_NONE and have no other
1911 * effect.
1912 *
1913 * Parameters:
1914 * enabled - whether to enable or disable vsync
1915 *
1916 * Returns HWC2_ERROR_NONE or one of the following errors:
1917 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1918 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
1919 */
1920typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
1921 hwc2_device_t* device, hwc2_display_t display,
1922 int32_t /*hwc2_vsync_t*/ enabled);
1923
1924/* validateDisplay(..., outNumTypes, outNumRequests)
1925 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
1926 * Must be provided by all HWC2 devices
1927 *
1928 * Instructs the device to inspect all of the layer state and determine if
1929 * there are any composition type changes necessary before presenting the
1930 * display. Permitted changes are described in the definition of
1931 * hwc2_composition_t above.
1932 *
1933 * Also returns the number of layer requests required
1934 * by the given layer configuration.
1935 *
1936 * Parameters:
1937 * outNumTypes - the number of composition type changes required by the
1938 * device; if greater than 0, the client must either set and validate new
1939 * types, or call acceptDisplayChanges to accept the changes returned by
1940 * getChangedCompositionTypes; must be the same as the number of changes
1941 * returned by getChangedCompositionTypes (see the declaration of that
1942 * function for more information); pointer will be non-NULL
1943 * outNumRequests - the number of layer requests required by this layer
1944 * configuration; must be equal to the number of layer requests returned
1945 * by getDisplayRequests (see the declaration of that function for
1946 * more information); pointer will be non-NULL
1947 *
1948 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
1949 * the display using the current layer state. Otherwise returns one of the
1950 * following errors:
1951 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1952 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
1953 * for more information)
1954 */
1955typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
1956 hwc2_device_t* device, hwc2_display_t display,
1957 uint32_t* outNumTypes, uint32_t* outNumRequests);
1958
1959/*
1960 * Layer Functions
1961 *
1962 * These are functions which operate on layers, but which do not modify state
1963 * that must be validated before use. See also 'Layer State Functions' below.
1964 *
1965 * All of these functions take as their first three parameters a device pointer,
1966 * a display handle for the display which contains the layer, and a layer
1967 * handle, so these parameters are omitted from the described parameter lists.
1968 */
1969
1970/* setCursorPosition(..., x, y)
1971 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
1972 * Must be provided by all HWC2 devices
1973 *
1974 * Asynchonously sets the position of a cursor layer.
1975 *
1976 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
1977 * If validation succeeds (i.e., the device does not request a composition
1978 * change for that layer), then once a buffer has been set for the layer and it
1979 * has been presented, its position may be set by this function at any time
1980 * between presentDisplay and any subsequent validateDisplay calls for this
1981 * display.
1982 *
1983 * Once validateDisplay is called, this function will not be called again until
1984 * the validate/present sequence is completed.
1985 *
1986 * May be called from any thread so long as it is not interleaved with the
1987 * validate/present sequence as described above.
1988 *
1989 * Parameters:
1990 * x - the new x coordinate (in pixels from the left of the screen)
1991 * y - the new y coordinate (in pixels from the top of the screen)
1992 *
1993 * Returns HWC2_ERROR_NONE or one of the following errors:
1994 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1995 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
1996 * HWC2_COMPOSITION_CURSOR
1997 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
1998 * validate/present sequence
1999 */
2000typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
2001 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2002 int32_t x, int32_t y);
2003
2004/* setLayerBuffer(..., buffer, acquireFence)
2005 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
2006 * Must be provided by all HWC2 devices
2007 *
2008 * Sets the buffer handle to be displayed for this layer. If the buffer
2009 * properties set at allocation time (width, height, format, and usage) have not
2010 * changed since the previous frame, it is not necessary to call validateDisplay
2011 * before calling presentDisplay unless new state needs to be validated in the
2012 * interim.
2013 *
2014 * Also provides a file descriptor referring to an acquire sync fence object,
2015 * which will be signaled when it is safe to read from the given buffer. If it
2016 * is already safe to read from the buffer, -1 may be passed instead. The
2017 * device must ensure that it is safe for the client to close this file
2018 * descriptor at any point after this function is called.
2019 *
2020 * This function must return HWC2_ERROR_NONE and have no other effect if called
2021 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
2022 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
2023 * (because synchronization and buffer updates for these layers are handled
2024 * elsewhere).
2025 *
2026 * Parameters:
2027 * buffer - the buffer handle to set
2028 * acquireFence - a sync fence file descriptor as described above
2029 *
2030 * Returns HWC2_ERROR_NONE or one of the following errors:
2031 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2032 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
2033 */
2034typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
2035 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2036 buffer_handle_t buffer, int32_t acquireFence);
2037
2038/* setLayerSurfaceDamage(..., damage)
2039 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
2040 * Must be provided by all HWC2 devices
2041 *
2042 * Provides the region of the source buffer which has been modified since the
2043 * last frame. This region does not need to be validated before calling
2044 * presentDisplay.
2045 *
2046 * Once set through this function, the damage region remains the same until a
2047 * subsequent call to this function.
2048 *
2049 * If damage.numRects > 0, then it may be assumed that any portion of the source
2050 * buffer not covered by one of the rects has not been modified this frame. If
2051 * damage.numRects == 0, then the whole source buffer must be treated as if it
2052 * has been modified.
2053 *
2054 * If the layer's contents are not modified relative to the prior frame, damage
2055 * will contain exactly one empty rect([0, 0, 0, 0]).
2056 *
2057 * The damage rects are relative to the pre-transformed buffer, and their origin
2058 * is the top-left corner. They will not exceed the dimensions of the latched
2059 * buffer.
2060 *
2061 * Parameters:
2062 * damage - the new surface damage region
2063 *
2064 * Returns HWC2_ERROR_NONE or one of the following errors:
2065 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2066 */
2067typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
2068 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2069 hwc_region_t damage);
2070
Chia-I Wu28310aa2018-03-15 21:20:55 -07002071/* setLayerPerFrameMetadata(..., numMetadata, metadata)
2072 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
2073 * Optional for HWC2 devices
2074 *
2075 * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is
2076 * non-null), sets the metadata for the given display for all following
2077 * frames.
2078 *
2079 * Upon returning from this function, the metadata change must have
2080 * fully taken effect.
2081 *
2082 * This function will only be called if getPerFrameMetadataKeys is non-NULL
2083 * and returns at least one key.
2084 *
2085 * Parameters:
2086 * numElements is the number of elements in each of the keys and metadata arrays
2087 * keys is a pointer to the array of keys.
2088 * outMetadata is a pointer to the corresponding array of metadata.
2089 *
2090 * Returns HWC2_ERROR_NONE or one of the following errors:
2091 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2092 * HWC2_ERROR_BAD_PARAMETER - metadata is not valid
2093 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2094 */
2095typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)(
2096 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2097 uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
2098 const float* metadata);
2099
Dan Stoza4e9221b2015-09-02 15:43:39 -07002100/*
2101 * Layer State Functions
2102 *
2103 * These functions modify the state of a given layer. They do not take effect
2104 * until the display configuration is successfully validated with
2105 * validateDisplay and the display contents are presented with presentDisplay.
2106 *
2107 * All of these functions take as their first three parameters a device pointer,
2108 * a display handle for the display which contains the layer, and a layer
2109 * handle, so these parameters are omitted from the described parameter lists.
2110 */
2111
2112/* setLayerBlendMode(..., mode)
2113 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
2114 * Must be provided by all HWC2 devices
2115 *
2116 * Sets the blend mode of the given layer.
2117 *
2118 * Parameters:
2119 * mode - the new blend mode
2120 *
2121 * Returns HWC2_ERROR_NONE or one of the following errors:
2122 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2123 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
2124 */
2125typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
2126 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2127 int32_t /*hwc2_blend_mode_t*/ mode);
2128
2129/* setLayerColor(..., color)
2130 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
2131 * Must be provided by all HWC2 devices
2132 *
2133 * Sets the color of the given layer. If the composition type of the layer is
2134 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2135 * have no other effect.
2136 *
2137 * Parameters:
2138 * color - the new color
2139 *
2140 * Returns HWC2_ERROR_NONE or one of the following errors:
2141 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2142 */
2143typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
2144 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2145 hwc_color_t color);
2146
Peiyong Linfd05d132018-01-22 12:23:25 -08002147/* setLayerFloatColor(..., color)
2148 * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
2149 * Provided by HWC2 devices which don't return nullptr function pointer.
2150 *
2151 * Sets the color of the given layer. If the composition type of the layer is
2152 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2153 * have no other effect.
2154 *
2155 * Parameters:
2156 * color - the new color in float type, rage is [0.0, 1.0], the colorspace is
2157 * defined by the dataspace that gets set by calling setLayerDataspace.
2158 *
2159 * Returns HWC2_ERROR_NONE or one of the following errors:
2160 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2161 */
2162typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)(
2163 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2164 hwc_float_color_t color);
2165
Dan Stoza4e9221b2015-09-02 15:43:39 -07002166/* setLayerCompositionType(..., type)
2167 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
2168 * Must be provided by all HWC2 devices
2169 *
2170 * Sets the desired composition type of the given layer. During validateDisplay,
2171 * the device may request changes to the composition types of any of the layers
2172 * as described in the definition of hwc2_composition_t above.
2173 *
2174 * Parameters:
2175 * type - the new composition type
2176 *
2177 * Returns HWC2_ERROR_NONE or one of the following errors:
2178 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2179 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
2180 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
2181 * not supported by this device
2182 */
2183typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
2184 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2185 int32_t /*hwc2_composition_t*/ type);
2186
2187/* setLayerDataspace(..., dataspace)
2188 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
2189 * Must be provided by all HWC2 devices
2190 *
2191 * Sets the dataspace that the current buffer on this layer is in.
2192 *
2193 * The dataspace provides more information about how to interpret the buffer
2194 * contents, such as the encoding standard and color transform.
2195 *
2196 * See the values of android_dataspace_t in <system/graphics.h> for more
2197 * information.
2198 *
2199 * Parameters:
2200 * dataspace - the new dataspace
2201 *
2202 * Returns HWC2_ERROR_NONE or one of the following errors:
2203 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2204 */
2205typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
2206 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2207 int32_t /*android_dataspace_t*/ dataspace);
2208
2209/* setLayerDisplayFrame(..., frame)
2210 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
2211 * Must be provided by all HWC2 devices
2212 *
2213 * Sets the display frame (the portion of the display covered by a layer) of the
2214 * given layer. This frame will not exceed the display dimensions.
2215 *
2216 * Parameters:
2217 * frame - the new display frame
2218 *
2219 * Returns HWC2_ERROR_NONE or one of the following errors:
2220 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2221 */
2222typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
2223 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2224 hwc_rect_t frame);
2225
2226/* setLayerPlaneAlpha(..., alpha)
2227 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
2228 * Must be provided by all HWC2 devices
2229 *
2230 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
2231 * will be applied to the whole layer. It can be conceptualized as a
2232 * preprocessing step which applies the following function:
2233 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
2234 * out.rgb = in.rgb * planeAlpha
2235 * out.a = in.a * planeAlpha
2236 *
2237 * If the device does not support this operation on a layer which is marked
2238 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
2239 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
2240 *
2241 * Parameters:
2242 * alpha - the plane alpha value to apply
2243 *
2244 * Returns HWC2_ERROR_NONE or one of the following errors:
2245 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2246 */
2247typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
2248 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2249 float alpha);
2250
2251/* setLayerSidebandStream(..., stream)
2252 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
2253 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
2254 *
2255 * Sets the sideband stream for this layer. If the composition type of the given
2256 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
2257 * and have no other effect.
2258 *
2259 * Parameters:
2260 * stream - the new sideband stream
2261 *
2262 * Returns HWC2_ERROR_NONE or one of the following errors:
2263 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2264 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
2265 */
2266typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
2267 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2268 const native_handle_t* stream);
2269
2270/* setLayerSourceCrop(..., crop)
2271 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
2272 * Must be provided by all HWC2 devices
2273 *
2274 * Sets the source crop (the portion of the source buffer which will fill the
2275 * display frame) of the given layer. This crop rectangle will not exceed the
2276 * dimensions of the latched buffer.
2277 *
2278 * If the device is not capable of supporting a true float source crop (i.e., it
2279 * will truncate or round the floats to integers), it should set this layer to
2280 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
2281 * rendering.
2282 *
2283 * If the device cannot support float source crops, but still wants to handle
2284 * the layer, it should use the following code (or similar) to convert to
2285 * an integer crop:
2286 * intCrop.left = (int) ceilf(crop.left);
2287 * intCrop.top = (int) ceilf(crop.top);
2288 * intCrop.right = (int) floorf(crop.right);
2289 * intCrop.bottom = (int) floorf(crop.bottom);
2290 *
2291 * Parameters:
2292 * crop - the new source crop
2293 *
2294 * Returns HWC2_ERROR_NONE or one of the following errors:
2295 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2296 */
2297typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
2298 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2299 hwc_frect_t crop);
2300
2301/* setLayerTransform(..., transform)
2302 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
2303 * Must be provided by all HWC2 devices
2304 *
2305 * Sets the transform (rotation/flip) of the given layer.
2306 *
2307 * Parameters:
2308 * transform - the new transform
2309 *
2310 * Returns HWC2_ERROR_NONE or one of the following errors:
2311 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2312 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
2313 */
2314typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
2315 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2316 int32_t /*hwc_transform_t*/ transform);
2317
2318/* setLayerVisibleRegion(..., visible)
2319 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
2320 * Must be provided by all HWC2 devices
2321 *
2322 * Specifies the portion of the layer that is visible, including portions under
2323 * translucent areas of other layers. The region is in screen space, and will
2324 * not exceed the dimensions of the screen.
2325 *
2326 * Parameters:
2327 * visible - the new visible region, in screen space
2328 *
2329 * Returns HWC2_ERROR_NONE or one of the following errors:
2330 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2331 */
2332typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
2333 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2334 hwc_region_t visible);
2335
2336/* setLayerZOrder(..., z)
2337 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
2338 * Must be provided by all HWC2 devices
2339 *
2340 * Sets the desired Z order (height) of the given layer. A layer with a greater
2341 * Z value occludes a layer with a lesser Z value.
2342 *
2343 * Parameters:
2344 * z - the new Z order
2345 *
2346 * Returns HWC2_ERROR_NONE or one of the following errors:
2347 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2348 */
2349typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
2350 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2351 uint32_t z);
2352
2353__END_DECLS
2354
2355#endif