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