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