blob: 35eedb088abe277bfc9e644c2c36d797c1a42406 [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,
Dan Stoza4e9221b2015-09-02 15:43:39 -070097} hwc2_capability_t;
98
99/* Possible composition types for a given layer */
100typedef enum {
101 HWC2_COMPOSITION_INVALID = 0,
102
103 /* The client will composite this layer into the client target buffer
104 * (provided to the device through setClientTarget).
105 *
106 * The device must not request any composition type changes for layers of
107 * this type. */
108 HWC2_COMPOSITION_CLIENT = 1,
109
110 /* The device will handle the composition of this layer through a hardware
111 * overlay or other similar means.
112 *
113 * Upon validateDisplay, the device may request a change from this type to
114 * HWC2_COMPOSITION_CLIENT. */
115 HWC2_COMPOSITION_DEVICE = 2,
116
117 /* The device will render this layer using the color set through
118 * setLayerColor. If this functionality is not supported on a layer that the
119 * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
120 * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
121 * upon the next call to validateDisplay.
122 *
123 * Upon validateDisplay, the device may request a change from this type to
124 * HWC2_COMPOSITION_CLIENT. */
125 HWC2_COMPOSITION_SOLID_COLOR = 3,
126
127 /* Similar to DEVICE, but the position of this layer may also be set
128 * asynchronously through setCursorPosition. If this functionality is not
129 * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
130 * device must request that the composition type of that layer is changed to
131 * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
132 *
133 * Upon validateDisplay, the device may request a change from this type to
134 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
135 * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
136 * still permit the device to composite the layer. */
137 HWC2_COMPOSITION_CURSOR = 4,
138
139 /* The device will handle the composition of this layer, as well as its
140 * buffer updates and content synchronization. Only supported on devices
141 * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
142 *
143 * Upon validateDisplay, the device may request a change from this type to
144 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
145 * unlikely that content will display correctly in these cases. */
146 HWC2_COMPOSITION_SIDEBAND = 5,
147} hwc2_composition_t;
148
149/* Possible connection options from the hotplug callback */
150typedef enum {
151 HWC2_CONNECTION_INVALID = 0,
152
153 /* The display has been connected */
154 HWC2_CONNECTION_CONNECTED = 1,
155
156 /* The display has been disconnected */
157 HWC2_CONNECTION_DISCONNECTED = 2,
158} hwc2_connection_t;
159
160/* Display requests returned by getDisplayRequests */
161typedef enum {
162 /* Instructs the client to provide a new client target buffer, even if no
163 * layers are marked for client composition. */
164 HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
165
166 /* Instructs the client to write the result of client composition directly
167 * into the virtual display output buffer. If any of the layers are not
168 * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
169 * display, this request has no effect. */
170 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
171} hwc2_display_request_t;
172
173/* Display types returned by getDisplayType */
174typedef enum {
175 HWC2_DISPLAY_TYPE_INVALID = 0,
176
177 /* All physical displays, including both internal displays and hotpluggable
178 * external displays */
179 HWC2_DISPLAY_TYPE_PHYSICAL = 1,
180
181 /* Virtual displays created by createVirtualDisplay */
182 HWC2_DISPLAY_TYPE_VIRTUAL = 2,
183} hwc2_display_type_t;
184
185/* Return codes from all functions */
186typedef enum {
187 HWC2_ERROR_NONE = 0,
188 HWC2_ERROR_BAD_CONFIG,
189 HWC2_ERROR_BAD_DISPLAY,
190 HWC2_ERROR_BAD_LAYER,
191 HWC2_ERROR_BAD_PARAMETER,
192 HWC2_ERROR_HAS_CHANGES,
193 HWC2_ERROR_NO_RESOURCES,
194 HWC2_ERROR_NOT_VALIDATED,
195 HWC2_ERROR_UNSUPPORTED,
196} hwc2_error_t;
197
198/* Function descriptors for use with getFunction */
199typedef enum {
200 HWC2_FUNCTION_INVALID = 0,
201 HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
202 HWC2_FUNCTION_CREATE_LAYER,
203 HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
204 HWC2_FUNCTION_DESTROY_LAYER,
205 HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
206 HWC2_FUNCTION_DUMP,
207 HWC2_FUNCTION_GET_ACTIVE_CONFIG,
208 HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
209 HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
210 HWC2_FUNCTION_GET_COLOR_MODES,
211 HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
212 HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
213 HWC2_FUNCTION_GET_DISPLAY_NAME,
214 HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
215 HWC2_FUNCTION_GET_DISPLAY_TYPE,
216 HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700217 HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700218 HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
219 HWC2_FUNCTION_GET_RELEASE_FENCES,
220 HWC2_FUNCTION_PRESENT_DISPLAY,
221 HWC2_FUNCTION_REGISTER_CALLBACK,
222 HWC2_FUNCTION_SET_ACTIVE_CONFIG,
223 HWC2_FUNCTION_SET_CLIENT_TARGET,
224 HWC2_FUNCTION_SET_COLOR_MODE,
225 HWC2_FUNCTION_SET_COLOR_TRANSFORM,
226 HWC2_FUNCTION_SET_CURSOR_POSITION,
227 HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
228 HWC2_FUNCTION_SET_LAYER_BUFFER,
229 HWC2_FUNCTION_SET_LAYER_COLOR,
230 HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
231 HWC2_FUNCTION_SET_LAYER_DATASPACE,
232 HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
233 HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
234 HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
235 HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
236 HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
237 HWC2_FUNCTION_SET_LAYER_TRANSFORM,
238 HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
239 HWC2_FUNCTION_SET_LAYER_Z_ORDER,
240 HWC2_FUNCTION_SET_OUTPUT_BUFFER,
241 HWC2_FUNCTION_SET_POWER_MODE,
242 HWC2_FUNCTION_SET_VSYNC_ENABLED,
243 HWC2_FUNCTION_VALIDATE_DISPLAY,
244} hwc2_function_descriptor_t;
245
Dan Stozaf601e972016-03-16 09:54:40 -0700246/* Layer requests returned from getDisplayRequests */
Dan Stoza4e9221b2015-09-02 15:43:39 -0700247typedef enum {
248 /* The client should clear its target with transparent pixels where this
249 * layer would be. The client may ignore this request if the layer must be
250 * blended. */
251 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
252} hwc2_layer_request_t;
253
254/* Power modes for use with setPowerMode */
255typedef enum {
256 /* The display is fully off (blanked) */
257 HWC2_POWER_MODE_OFF = 0,
258
259 /* These are optional low power modes. getDozeSupport may be called to
260 * determine whether a given display supports these modes. */
261
262 /* The display is turned on and configured in a low power state that is
263 * suitable for presenting ambient information to the user, possibly with
264 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
265 HWC2_POWER_MODE_DOZE = 1,
266
267 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
268 * applying display updates from the client. This is effectively a hint to
269 * the device that drawing to the display has been suspended and that the
270 * the device should remain on in a low power state and continue displaying
271 * its current contents indefinitely until the power mode changes.
272 *
273 * This mode may also be used as a signal to enable hardware-based doze
274 * functionality. In this case, the device is free to take over the display
275 * and manage it autonomously to implement a low power always-on display. */
276 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
277
278 /* The display is fully on */
279 HWC2_POWER_MODE_ON = 2,
280} hwc2_power_mode_t;
281
282/* Vsync values passed to setVsyncEnabled */
283typedef enum {
284 HWC2_VSYNC_INVALID = 0,
285
286 /* Enable vsync */
287 HWC2_VSYNC_ENABLE = 1,
288
289 /* Disable vsync */
290 HWC2_VSYNC_DISABLE = 2,
291} hwc2_vsync_t;
292
293/*
294 * Stringification Functions
295 */
296
297#ifdef HWC2_INCLUDE_STRINGIFICATION
298
299static inline const char* getAttributeName(hwc2_attribute_t attribute) {
300 switch (attribute) {
301 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
302 case HWC2_ATTRIBUTE_WIDTH: return "Width";
303 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
304 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
305 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
306 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
307 default: return "Unknown";
308 }
309}
310
311static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
312 switch (mode) {
313 case HWC2_BLEND_MODE_INVALID: return "Invalid";
314 case HWC2_BLEND_MODE_NONE: return "None";
315 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
316 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
317 default: return "Unknown";
318 }
319}
320
321static inline const char* getCallbackDescriptorName(
322 hwc2_callback_descriptor_t desc) {
323 switch (desc) {
324 case HWC2_CALLBACK_INVALID: return "Invalid";
325 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
326 case HWC2_CALLBACK_REFRESH: return "Refresh";
327 case HWC2_CALLBACK_VSYNC: return "Vsync";
328 default: return "Unknown";
329 }
330}
331
332static inline const char* getCapabilityName(hwc2_capability_t capability) {
333 switch (capability) {
334 case HWC2_CAPABILITY_INVALID: return "Invalid";
335 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
Dan Stozad2168f72016-07-14 11:48:16 -0700336 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
337 return "SkipClientColorTransform";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700338 default: return "Unknown";
339 }
340}
341
342static inline const char* getCompositionName(hwc2_composition_t composition) {
343 switch (composition) {
344 case HWC2_COMPOSITION_INVALID: return "Invalid";
345 case HWC2_COMPOSITION_CLIENT: return "Client";
346 case HWC2_COMPOSITION_DEVICE: return "Device";
347 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
348 case HWC2_COMPOSITION_CURSOR: return "Cursor";
349 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
350 default: return "Unknown";
351 }
352}
353
354static inline const char* getConnectionName(hwc2_connection_t connection) {
355 switch (connection) {
356 case HWC2_CONNECTION_INVALID: return "Invalid";
357 case HWC2_CONNECTION_CONNECTED: return "Connected";
358 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
359 default: return "Unknown";
360 }
361}
362
363static inline const char* getDisplayRequestName(
364 hwc2_display_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700365 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700366 case 0: return "None";
367 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
368 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
369 return "WriteClientTargetToOutput";
370 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
371 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
372 return "FlipClientTarget|WriteClientTargetToOutput";
373 default: return "Unknown";
374 }
375}
376
377static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
378 switch (type) {
379 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
380 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
381 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
382 default: return "Unknown";
383 }
384}
385
386static inline const char* getErrorName(hwc2_error_t error) {
387 switch (error) {
388 case HWC2_ERROR_NONE: return "None";
389 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
390 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
391 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
392 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
393 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
394 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
395 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
396 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
397 default: return "Unknown";
398 }
399}
400
401static inline const char* getFunctionDescriptorName(
402 hwc2_function_descriptor_t desc) {
403 switch (desc) {
404 case HWC2_FUNCTION_INVALID: return "Invalid";
405 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
406 return "AcceptDisplayChanges";
407 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
408 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
409 return "CreateVirtualDisplay";
410 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
411 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
412 return "DestroyVirtualDisplay";
413 case HWC2_FUNCTION_DUMP: return "Dump";
414 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
415 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
416 return "GetChangedCompositionTypes";
417 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
418 return "GetClientTargetSupport";
419 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
420 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
421 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
422 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
423 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
424 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
425 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
Dan Stozaf601e972016-03-16 09:54:40 -0700426 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700427 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
428 return "GetMaxVirtualDisplayCount";
429 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
430 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
431 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
432 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
433 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
434 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
435 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
436 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
437 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
438 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
439 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
440 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
441 return "SetLayerCompositionType";
442 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
443 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
444 return "SetLayerDisplayFrame";
445 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
446 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
447 return "SetLayerSidebandStream";
448 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
449 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
450 return "SetLayerSurfaceDamage";
451 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
452 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
453 return "SetLayerVisibleRegion";
454 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
455 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
456 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
457 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
458 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
459 default: return "Unknown";
460 }
461}
462
463static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700464 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700465 case 0: return "None";
466 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
467 default: return "Unknown";
468 }
469}
470
471static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
472 switch (mode) {
473 case HWC2_POWER_MODE_OFF: return "Off";
474 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
475 case HWC2_POWER_MODE_DOZE: return "Doze";
476 case HWC2_POWER_MODE_ON: return "On";
477 default: return "Unknown";
478 }
479}
480
481static inline const char* getTransformName(hwc_transform_t transform) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700482 switch (__BIONIC_CAST(static_cast, int, transform)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700483 case 0: return "None";
484 case HWC_TRANSFORM_FLIP_H: return "FlipH";
485 case HWC_TRANSFORM_FLIP_V: return "FlipV";
486 case HWC_TRANSFORM_ROT_90: return "Rotate90";
487 case HWC_TRANSFORM_ROT_180: return "Rotate180";
488 case HWC_TRANSFORM_ROT_270: return "Rotate270";
489 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
490 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
491 default: return "Unknown";
492 }
493}
494
495static inline const char* getVsyncName(hwc2_vsync_t vsync) {
496 switch (vsync) {
497 case HWC2_VSYNC_INVALID: return "Invalid";
498 case HWC2_VSYNC_ENABLE: return "Enable";
499 case HWC2_VSYNC_DISABLE: return "Disable";
500 default: return "Unknown";
501 }
502}
503
504#define TO_STRING(E, T, printer) \
505 inline std::string to_string(E value) { return printer(value); } \
506 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
507#else // !HWC2_INCLUDE_STRINGIFICATION
508#define TO_STRING(name, printer)
509#endif // HWC2_INCLUDE_STRINGIFICATION
510
511/*
512 * C++11 features
513 */
514
515#ifdef HWC2_USE_CPP11
516__END_DECLS
517
518#ifdef HWC2_INCLUDE_STRINGIFICATION
519#include <string>
520#endif
521
522namespace HWC2 {
523
524enum class Attribute : int32_t {
525 Invalid = HWC2_ATTRIBUTE_INVALID,
526 Width = HWC2_ATTRIBUTE_WIDTH,
527 Height = HWC2_ATTRIBUTE_HEIGHT,
528 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
529 DpiX = HWC2_ATTRIBUTE_DPI_X,
530 DpiY = HWC2_ATTRIBUTE_DPI_Y,
531};
532TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
533
534enum class BlendMode : int32_t {
535 Invalid = HWC2_BLEND_MODE_INVALID,
536 None = HWC2_BLEND_MODE_NONE,
537 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
538 Coverage = HWC2_BLEND_MODE_COVERAGE,
539};
540TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
541
542enum class Callback : int32_t {
543 Invalid = HWC2_CALLBACK_INVALID,
544 Hotplug = HWC2_CALLBACK_HOTPLUG,
545 Refresh = HWC2_CALLBACK_REFRESH,
546 Vsync = HWC2_CALLBACK_VSYNC,
547};
548TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
549
550enum class Capability : int32_t {
551 Invalid = HWC2_CAPABILITY_INVALID,
552 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
Dan Stozad2168f72016-07-14 11:48:16 -0700553 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700554};
555TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
556
557enum class Composition : int32_t {
558 Invalid = HWC2_COMPOSITION_INVALID,
559 Client = HWC2_COMPOSITION_CLIENT,
560 Device = HWC2_COMPOSITION_DEVICE,
561 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
562 Cursor = HWC2_COMPOSITION_CURSOR,
563 Sideband = HWC2_COMPOSITION_SIDEBAND,
564};
565TO_STRING(hwc2_composition_t, Composition, getCompositionName)
566
567enum class Connection : int32_t {
568 Invalid = HWC2_CONNECTION_INVALID,
569 Connected = HWC2_CONNECTION_CONNECTED,
570 Disconnected = HWC2_CONNECTION_DISCONNECTED,
571};
572TO_STRING(hwc2_connection_t, Connection, getConnectionName)
573
574enum class DisplayRequest : int32_t {
575 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
576 WriteClientTargetToOutput =
577 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
578};
579TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
580
581enum class DisplayType : int32_t {
582 Invalid = HWC2_DISPLAY_TYPE_INVALID,
583 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
584 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
585};
586TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
587
588enum class Error : int32_t {
589 None = HWC2_ERROR_NONE,
590 BadConfig = HWC2_ERROR_BAD_CONFIG,
591 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
592 BadLayer = HWC2_ERROR_BAD_LAYER,
593 BadParameter = HWC2_ERROR_BAD_PARAMETER,
594 HasChanges = HWC2_ERROR_HAS_CHANGES,
595 NoResources = HWC2_ERROR_NO_RESOURCES,
596 NotValidated = HWC2_ERROR_NOT_VALIDATED,
597 Unsupported = HWC2_ERROR_UNSUPPORTED,
598};
599TO_STRING(hwc2_error_t, Error, getErrorName)
600
601enum class FunctionDescriptor : int32_t {
602 Invalid = HWC2_FUNCTION_INVALID,
603 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
604 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
605 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
606 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
607 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
608 Dump = HWC2_FUNCTION_DUMP,
609 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
610 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
611 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
612 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
613 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
614 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
615 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
616 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
617 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
618 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700619 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700620 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
621 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
622 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
623 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
624 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
625 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
626 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
627 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
628 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
629 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
630 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
631 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
632 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
633 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
634 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
635 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
636 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
637 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
638 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
639 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
640 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
641 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
642 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
643 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
644 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
645 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
646};
647TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
648 getFunctionDescriptorName)
649
650enum class LayerRequest : int32_t {
651 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
652};
653TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
654
655enum class PowerMode : int32_t {
656 Off = HWC2_POWER_MODE_OFF,
657 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
658 Doze = HWC2_POWER_MODE_DOZE,
659 On = HWC2_POWER_MODE_ON,
660};
661TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
662
663enum class Transform : int32_t {
664 None = 0,
665 FlipH = HWC_TRANSFORM_FLIP_H,
666 FlipV = HWC_TRANSFORM_FLIP_V,
667 Rotate90 = HWC_TRANSFORM_ROT_90,
668 Rotate180 = HWC_TRANSFORM_ROT_180,
669 Rotate270 = HWC_TRANSFORM_ROT_270,
670 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
671 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
672};
673TO_STRING(hwc_transform_t, Transform, getTransformName)
674
675enum class Vsync : int32_t {
676 Invalid = HWC2_VSYNC_INVALID,
677 Enable = HWC2_VSYNC_ENABLE,
678 Disable = HWC2_VSYNC_DISABLE,
679};
680TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
681
682} // namespace HWC2
683
684__BEGIN_DECLS
685#endif // HWC2_USE_CPP11
686
687/*
688 * Typedefs
689 */
690
691typedef void (*hwc2_function_pointer_t)();
692
693typedef void* hwc2_callback_data_t;
694typedef uint32_t hwc2_config_t;
695typedef uint64_t hwc2_display_t;
696typedef uint64_t hwc2_layer_t;
697
698/*
699 * Device Struct
700 */
701
702typedef struct hwc2_device {
703 /* Must be the first member of this struct, since a pointer to this struct
704 * will be generated by casting from a hw_device_t* */
705 struct hw_device_t common;
706
707 /* getCapabilities(..., outCount, outCapabilities)
708 *
709 * Provides a list of capabilities (described in the definition of
710 * hwc2_capability_t above) supported by this device. This list must
711 * not change after the device has been loaded.
712 *
713 * Parameters:
714 * outCount - if outCapabilities was NULL, the number of capabilities
715 * which would have been returned; if outCapabilities was not NULL,
716 * the number of capabilities returned, which must not exceed the
717 * value stored in outCount prior to the call
718 * outCapabilities - a list of capabilities supported by this device; may
719 * be NULL, in which case this function must write into outCount the
720 * number of capabilities which would have been written into
721 * outCapabilities
722 */
723 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
724 int32_t* /*hwc2_capability_t*/ outCapabilities);
725
726 /* getFunction(..., descriptor)
727 *
728 * Returns a function pointer which implements the requested description.
729 *
730 * Parameters:
731 * descriptor - the function to return
732 *
733 * Returns either a function pointer implementing the requested descriptor
734 * or NULL if the described function is not supported by this device.
735 */
736 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
737 int32_t /*hwc2_function_descriptor_t*/ descriptor);
738} hwc2_device_t;
739
740static inline int hwc2_open(const struct hw_module_t* module,
741 hwc2_device_t** device) {
742 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
Colin Crosscc8d9f92016-10-06 16:44:23 -0700743 TO_HW_DEVICE_T_OPEN(device));
Dan Stoza4e9221b2015-09-02 15:43:39 -0700744}
745
746static inline int hwc2_close(hwc2_device_t* device) {
747 return device->common.close(&device->common);
748}
749
750/*
751 * Callbacks
752 *
753 * All of these callbacks take as their first parameter the callbackData which
754 * was provided at the time of callback registration, so this parameter is
755 * omitted from the described parameter lists.
756 */
757
758/* hotplug(..., display, connected)
759 * Descriptor: HWC2_CALLBACK_HOTPLUG
760 * Will be provided to all HWC2 devices
761 *
762 * Notifies the client that the given display has either been connected or
763 * disconnected. Every active display (even a built-in physical display) must
764 * trigger at least one hotplug notification, even if it only occurs immediately
765 * after callback registration.
766 *
767 * The client may call back into the device on the same thread to query display
768 * properties (such as width, height, and vsync period), and other threads may
769 * call into the device while the callback is in progress. The device must
770 * serialize calls to this callback such that only one thread is calling it at a
771 * time.
772 *
773 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
774 * and the vsync callback should not be called for a display until vsync has
775 * been enabled with setVsyncEnabled.
776 *
777 * Parameters:
778 * display - the display which has been hotplugged
779 * connected - whether the display has been connected or disconnected
780 */
781typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
782 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
783
784/* refresh(..., display)
785 * Descriptor: HWC2_CALLBACK_REFRESH
786 * Will be provided to all HWC2 devices
787 *
788 * Notifies the client to trigger a screen refresh. This forces all layer state
789 * for this display to be resent, and the display to be validated and presented,
790 * even if there have been no changes.
791 *
792 * This refresh will occur some time after the callback is initiated, but not
793 * necessarily before it returns. This thread, however, is guaranteed not to
794 * call back into the device, thus it is safe to trigger this callback from
795 * other functions which call into the device.
796 *
797 * Parameters:
798 * display - the display to refresh
799 */
800typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
801 hwc2_display_t display);
802
803/* vsync(..., display, timestamp)
804 * Descriptor: HWC2_CALLBACK_VSYNC
805 * Will be provided to all HWC2 devices
806 *
807 * Notifies the client that a vsync event has occurred. This callback must
808 * only be triggered when vsync is enabled for this display (through
809 * setVsyncEnabled).
810 *
811 * This callback should be triggered from a thread of at least
812 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
813 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
814 *
815 * Parameters:
816 * display - the display which has received a vsync event
817 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
818 * nanoseconds
819 */
820typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
821 hwc2_display_t display, int64_t timestamp);
822
823/*
824 * Device Functions
825 *
826 * All of these functions take as their first parameter a device pointer, so
827 * this parameter is omitted from the described parameter lists.
828 */
829
Dan Stoza68cd3752016-05-20 13:30:42 -0700830/* createVirtualDisplay(..., width, height, format, outDisplay)
Dan Stoza4e9221b2015-09-02 15:43:39 -0700831 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
832 * Must be provided by all HWC2 devices
833 *
Dan Stoza68cd3752016-05-20 13:30:42 -0700834 * Creates a new virtual display with the given width and height. The format
835 * passed into this function is the default format requested by the consumer of
836 * the virtual display output buffers. If a different format will be returned by
837 * the device, it should be returned in this parameter so it can be set properly
838 * when handing the buffers to the consumer.
839 *
840 * The display will be assumed to be on from the time the first frame is
841 * presented until the display is destroyed.
Dan Stoza4e9221b2015-09-02 15:43:39 -0700842 *
843 * Parameters:
844 * width - width in pixels
845 * height - height in pixels
Dan Stoza68cd3752016-05-20 13:30:42 -0700846 * format - prior to the call, the default output buffer format selected by
847 * the consumer; after the call, the format the device will produce
Dan Stoza4e9221b2015-09-02 15:43:39 -0700848 * outDisplay - the newly-created virtual display; pointer will be non-NULL
849 *
850 * Returns HWC2_ERROR_NONE or one of the following errors:
851 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
852 * be able to create a virtual display
853 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
854 * display at this time
855 */
856typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
857 hwc2_device_t* device, uint32_t width, uint32_t height,
Dan Stoza68cd3752016-05-20 13:30:42 -0700858 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
Dan Stoza4e9221b2015-09-02 15:43:39 -0700859
860/* destroyVirtualDisplay(..., display)
861 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
862 * Must be provided by all HWC2 devices
863 *
864 * Destroys a virtual display. After this call all resources consumed by this
865 * display may be freed by the device and any operations performed on this
866 * display should fail.
867 *
868 * Parameters:
869 * display - the virtual display to destroy
870 *
871 * Returns HWC2_ERROR_NONE or one of the following errors:
872 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
873 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
874 * refer to a virtual display
875 */
876typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
877 hwc2_device_t* device, hwc2_display_t display);
878
879/* dump(..., outSize, outBuffer)
880 * Descriptor: HWC2_FUNCTION_DUMP
881 * Must be provided by all HWC2 devices
882 *
883 * Retrieves implementation-defined debug information, which will be displayed
884 * during, for example, `dumpsys SurfaceFlinger`.
885 *
886 * If called with outBuffer == NULL, the device should store a copy of the
887 * desired output and return its length in bytes in outSize. If the device
888 * already has a stored copy, that copy should be purged and replaced with a
889 * fresh copy.
890 *
891 * If called with outBuffer != NULL, the device should copy its stored version
892 * of the output into outBuffer and store how many bytes of data it copied into
893 * outSize. Prior to this call, the client will have populated outSize with the
894 * maximum number of bytes outBuffer can hold. The device must not write more
895 * than this amount into outBuffer. If the device does not currently have a
896 * stored copy, then it should return 0 in outSize.
897 *
898 * Any data written into outBuffer need not be null-terminated.
899 *
900 * Parameters:
901 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
902 * device's stored output; if outBuffer was not NULL, the number of bytes
903 * written into it, which must not exceed the value stored in outSize
904 * prior to the call; pointer will be non-NULL
905 * outBuffer - the buffer to write the dump output into; may be NULL as
906 * described above; data written into this buffer need not be
907 * null-terminated
908 */
909typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
910 char* outBuffer);
911
912/* getMaxVirtualDisplayCount(...)
913 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
914 * Must be provided by all HWC2 devices
915 *
916 * Returns the maximum number of virtual displays supported by this device
917 * (which may be 0). The client will not attempt to create more than this many
918 * virtual displays on this device. This number must not change for the lifetime
919 * of the device.
920 */
921typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
922 hwc2_device_t* device);
923
924/* registerCallback(..., descriptor, callbackData, pointer)
925 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
926 * Must be provided by all HWC2 devices
927 *
928 * Provides a callback for the device to call. All callbacks take a callbackData
929 * item as the first parameter, so this value should be stored with the callback
930 * for later use. The callbackData may differ from one callback to another. If
931 * this function is called multiple times with the same descriptor, later
932 * callbacks replace earlier ones.
933 *
934 * Parameters:
935 * descriptor - which callback should be set
936 * callBackdata - opaque data which must be passed back through the callback
937 * pointer - a non-NULL function pointer corresponding to the descriptor
938 *
939 * Returns HWC2_ERROR_NONE or one of the following errors:
940 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
941 */
942typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
943 hwc2_device_t* device,
944 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
945 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
946
947/*
948 * Display Functions
949 *
950 * All of these functions take as their first two parameters a device pointer
951 * and a display handle, so these parameters are omitted from the described
952 * parameter lists.
953 */
954
955/* acceptDisplayChanges(...)
956 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
957 * Must be provided by all HWC2 devices
958 *
959 * Accepts the changes required by the device from the previous validateDisplay
960 * call (which may be queried using getChangedCompositionTypes) and revalidates
961 * the display. This function is equivalent to requesting the changed types from
962 * getChangedCompositionTypes, setting those types on the corresponding layers,
963 * and then calling validateDisplay again.
964 *
965 * After this call it must be valid to present this display. Calling this after
966 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
967 * should have no other effect.
968 *
969 * Returns HWC2_ERROR_NONE or one of the following errors:
970 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
971 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
972 */
973typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
974 hwc2_device_t* device, hwc2_display_t display);
975
976/* createLayer(..., outLayer)
977 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
978 * Must be provided by all HWC2 devices
979 *
980 * Creates a new layer on the given display.
981 *
982 * Parameters:
983 * outLayer - the handle of the new layer; pointer will be non-NULL
984 *
985 * Returns HWC2_ERROR_NONE or one of the following errors:
986 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
987 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
988 */
989typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
990 hwc2_display_t display, hwc2_layer_t* outLayer);
991
992/* destroyLayer(..., layer)
993 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
994 * Must be provided by all HWC2 devices
995 *
996 * Destroys the given layer.
997 *
998 * Parameters:
999 * layer - the handle of the layer to destroy
1000 *
1001 * Returns HWC2_ERROR_NONE or one of the following errors:
1002 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1003 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1004 */
1005typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1006 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1007
1008/* getActiveConfig(..., outConfig)
1009 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1010 * Must be provided by all HWC2 devices
1011 *
1012 * Retrieves which display configuration is currently active.
1013 *
1014 * If no display configuration is currently active, this function must return
1015 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1016 * the responsibility of the client to call setActiveConfig with a valid
1017 * configuration before attempting to present anything on the display.
1018 *
1019 * Parameters:
1020 * outConfig - the currently active display configuration; pointer will be
1021 * non-NULL
1022 *
1023 * Returns HWC2_ERROR_NONE or one of the following errors:
1024 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1025 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1026 */
1027typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1028 hwc2_device_t* device, hwc2_display_t display,
1029 hwc2_config_t* outConfig);
1030
1031/* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1032 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1033 * Must be provided by all HWC2 devices
1034 *
1035 * Retrieves the layers for which the device requires a different composition
1036 * type than had been set prior to the last call to validateDisplay. The client
1037 * will either update its state with these types and call acceptDisplayChanges,
1038 * or will set new types and attempt to validate the display again.
1039 *
1040 * outLayers and outTypes may be NULL to retrieve the number of elements which
1041 * will be returned. The number of elements returned must be the same as the
1042 * value returned in outNumTypes from the last call to validateDisplay.
1043 *
1044 * Parameters:
1045 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1046 * and types which would have been returned; if both were non-NULL, the
1047 * number of elements returned in outLayers and outTypes, which must not
1048 * exceed the value stored in outNumElements prior to the call; pointer
1049 * will be non-NULL
1050 * outLayers - an array of layer handles
1051 * outTypes - an array of composition types, each corresponding to an element
1052 * of outLayers
1053 *
1054 * Returns HWC2_ERROR_NONE or one of the following errors:
1055 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1056 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1057 * display
1058 */
1059typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1060 hwc2_device_t* device, hwc2_display_t display,
1061 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1062 int32_t* /*hwc2_composition_t*/ outTypes);
1063
1064/* getClientTargetSupport(..., width, height, format, dataspace)
1065 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1066 * Must be provided by all HWC2 devices
1067 *
1068 * Returns whether a client target with the given properties can be handled by
1069 * the device.
1070 *
1071 * The valid formats can be found in android_pixel_format_t in
1072 * <system/graphics.h>.
1073 *
1074 * For more about dataspaces, see setLayerDataspace.
1075 *
1076 * This function must return true for a client target with width and height
1077 * equal to the active display configuration dimensions,
1078 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1079 * return true for any other configuration.
1080 *
1081 * Parameters:
1082 * width - client target width in pixels
1083 * height - client target height in pixels
1084 * format - client target format
1085 * dataspace - client target dataspace, as described in setLayerDataspace
1086 *
1087 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1088 * following errors:
1089 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1090 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1091 */
1092typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1093 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1094 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1095 int32_t /*android_dataspace_t*/ dataspace);
1096
1097/* getColorModes(..., outNumModes, outModes)
1098 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1099 * Must be provided by all HWC2 devices
1100 *
1101 * Returns the color modes supported on this display.
1102 *
1103 * The valid color modes can be found in android_color_mode_t in
1104 * <system/graphics.h>. All HWC2 devices must support at least
1105 * HAL_COLOR_MODE_NATIVE.
1106 *
1107 * outNumModes may be NULL to retrieve the number of modes which will be
1108 * returned.
1109 *
1110 * Parameters:
1111 * outNumModes - if outModes was NULL, the number of modes which would have
1112 * been returned; if outModes was not NULL, the number of modes returned,
1113 * which must not exceed the value stored in outNumModes prior to the
1114 * call; pointer will be non-NULL
1115 * outModes - an array of color modes
1116 *
1117 * Returns HWC2_ERROR_NONE or one of the following errors:
1118 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1119 */
1120typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1121 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1122 int32_t* /*android_color_mode_t*/ outModes);
1123
1124/* getDisplayAttribute(..., config, attribute, outValue)
1125 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1126 * Must be provided by all HWC2 devices
1127 *
1128 * Returns a display attribute value for a particular display configuration.
1129 *
1130 * Any attribute which is not supported or for which the value is unknown by the
1131 * device must return a value of -1.
1132 *
1133 * Parameters:
1134 * config - the display configuration for which to return attribute values
1135 * attribute - the attribute to query
1136 * outValue - the value of the attribute; the pointer will be non-NULL
1137 *
1138 * Returns HWC2_ERROR_NONE or one of the following errors:
1139 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1140 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1141 * display
1142 */
1143typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1144 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1145 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1146
1147/* getDisplayConfigs(..., outNumConfigs, outConfigs)
1148 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1149 * Must be provided by all HWC2 devices
1150 *
1151 * Returns handles for all of the valid display configurations on this display.
1152 *
1153 * outConfigs may be NULL to retrieve the number of elements which will be
1154 * returned.
1155 *
1156 * Parameters:
1157 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1158 * would have been returned; if outConfigs was not NULL, the number of
1159 * configurations returned, which must not exceed the value stored in
1160 * outNumConfigs prior to the call; pointer will be non-NULL
1161 * outConfigs - an array of configuration handles
1162 *
1163 * Returns HWC2_ERROR_NONE or one of the following errors:
1164 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1165 */
1166typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1167 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1168 hwc2_config_t* outConfigs);
1169
1170/* getDisplayName(..., outSize, outName)
1171 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1172 * Must be provided by all HWC2 devices
1173 *
1174 * Returns a human-readable version of the display's name.
1175 *
1176 * outName may be NULL to retrieve the length of the name.
1177 *
1178 * Parameters:
1179 * outSize - if outName was NULL, the number of bytes needed to return the
1180 * name if outName was not NULL, the number of bytes written into it,
1181 * which must not exceed the value stored in outSize prior to the call;
1182 * pointer will be non-NULL
1183 * outName - the display's name
1184 *
1185 * Returns HWC2_ERROR_NONE or one of the following errors:
1186 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1187 */
1188typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1189 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1190 char* outName);
1191
1192/* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1193 * outLayerRequests)
1194 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1195 * Must be provided by all HWC2 devices
1196 *
1197 * Returns the display requests and the layer requests required for the last
1198 * validated configuration.
1199 *
1200 * Display requests provide information about how the client should handle the
1201 * client target. Layer requests provide information about how the client
1202 * should handle an individual layer.
1203 *
1204 * If outLayers or outLayerRequests is NULL, the required number of layers and
1205 * requests must be returned in outNumElements, but this number may also be
1206 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1207 * to the value returned in outNumRequests from the last call to
1208 * validateDisplay).
1209 *
1210 * Parameters:
1211 * outDisplayRequests - the display requests for the current validated state
1212 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1213 * elements which would have been returned, which must be equal to the
1214 * value returned in outNumRequests from the last validateDisplay call on
1215 * this display; if both were not NULL, the number of elements in
1216 * outLayers and outLayerRequests, which must not exceed the value stored
1217 * in outNumElements prior to the call; pointer will be non-NULL
1218 * outLayers - an array of layers which all have at least one request
1219 * outLayerRequests - the requests corresponding to each element of outLayers
1220 *
1221 * Returns HWC2_ERROR_NONE or one of the following errors:
1222 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1223 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1224 * display
1225 */
1226typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1227 hwc2_device_t* device, hwc2_display_t display,
1228 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1229 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1230 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1231
1232/* getDisplayType(..., outType)
1233 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1234 * Must be provided by all HWC2 devices
1235 *
1236 * Returns whether the given display is a physical or virtual display.
1237 *
1238 * Parameters:
1239 * outType - the type of the display; pointer will be non-NULL
1240 *
1241 * Returns HWC2_ERROR_NONE or one of the following errors:
1242 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1243 */
1244typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1245 hwc2_device_t* device, hwc2_display_t display,
1246 int32_t* /*hwc2_display_type_t*/ outType);
1247
1248/* getDozeSupport(..., outSupport)
1249 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1250 * Must be provided by all HWC2 devices
1251 *
1252 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1253 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1254 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1255 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1256 * device should not claim support.
1257 *
1258 * Parameters:
1259 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1260 * pointer will be non-NULL
1261 *
1262 * Returns HWC2_ERROR_NONE or one of the following errors:
1263 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1264 */
1265typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1266 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1267
Dan Stozaf601e972016-03-16 09:54:40 -07001268/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1269 * outMaxAverageLuminance, outMinLuminance)
1270 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1271 * Must be provided by all HWC2 devices
1272 *
1273 * Returns the high dynamic range (HDR) capabilities of the given display, which
1274 * are invariant with regard to the active configuration.
1275 *
1276 * Displays which are not HDR-capable must return no types in outTypes and set
1277 * outNumTypes to 0.
1278 *
1279 * If outTypes is NULL, the required number of HDR types must be returned in
1280 * outNumTypes.
1281 *
1282 * Parameters:
1283 * outNumTypes - if outTypes was NULL, the number of types which would have
1284 * been returned; if it was not NULL, the number of types stored in
1285 * outTypes, which must not exceed the value stored in outNumTypes prior
1286 * to the call; pointer will be non-NULL
1287 * outTypes - an array of HDR types, may have 0 elements if the display is not
1288 * HDR-capable
1289 * outMaxLuminance - the desired content maximum luminance for this display in
1290 * cd/m^2; pointer will be non-NULL
1291 * outMaxAverageLuminance - the desired content maximum frame-average
1292 * luminance for this display in cd/m^2; pointer will be non-NULL
1293 * outMinLuminance - the desired content minimum luminance for this display in
1294 * cd/m^2; pointer will be non-NULL
1295 *
1296 * Returns HWC2_ERROR_NONE or one of the following errors:
1297 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1298 */
1299typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1300 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1301 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1302 float* outMaxAverageLuminance, float* outMinLuminance);
1303
Dan Stoza4e9221b2015-09-02 15:43:39 -07001304/* getReleaseFences(..., outNumElements, outLayers, outFences)
1305 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1306 * Must be provided by all HWC2 devices
1307 *
1308 * Retrieves the release fences for device layers on this display which will
1309 * receive new buffer contents this frame.
1310 *
1311 * A release fence is a file descriptor referring to a sync fence object which
1312 * will be signaled after the device has finished reading from the buffer
1313 * presented in the prior frame. This indicates that it is safe to start writing
1314 * to the buffer again. If a given layer's fence is not returned from this
1315 * function, it will be assumed that the buffer presented on the previous frame
1316 * is ready to be written.
1317 *
1318 * The fences returned by this function should be unique for each layer (even if
1319 * they point to the same underlying sync object), and ownership of the fences
1320 * is transferred to the client, which is responsible for closing them.
1321 *
1322 * If outLayers or outFences is NULL, the required number of layers and fences
1323 * must be returned in outNumElements.
1324 *
1325 * Parameters:
1326 * outNumElements - if outLayers or outFences were NULL, the number of
1327 * elements which would have been returned; if both were not NULL, the
1328 * number of elements in outLayers and outFences, which must not exceed
1329 * the value stored in outNumElements prior to the call; pointer will be
1330 * non-NULL
1331 * outLayers - an array of layer handles
1332 * outFences - an array of sync fence file descriptors as described above,
1333 * each corresponding to an element of outLayers
1334 *
1335 * Returns HWC2_ERROR_NONE or one of the following errors:
1336 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1337 */
1338typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
1339 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1340 hwc2_layer_t* outLayers, int32_t* outFences);
1341
Dan Stozaef264822016-07-13 14:51:09 -07001342/* presentDisplay(..., outPresentFence)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001343 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1344 * Must be provided by all HWC2 devices
1345 *
1346 * Presents the current display contents on the screen (or in the case of
1347 * virtual displays, into the output buffer).
1348 *
1349 * Prior to calling this function, the display must be successfully validated
1350 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1351 * specifically do not count as layer state, so if there are no other changes
1352 * to the layer state (or to the buffer's properties as described in
1353 * setLayerBuffer), then it is safe to call this function without first
1354 * validating the display.
1355 *
Dan Stozaef264822016-07-13 14:51:09 -07001356 * If this call succeeds, outPresentFence will be populated with a file
1357 * descriptor referring to a present sync fence object. For physical displays,
1358 * this fence will be signaled at the vsync when the result of composition of
1359 * this frame starts to appear (for video-mode panels) or starts to transfer to
1360 * panel memory (for command-mode panels). For virtual displays, this fence will
1361 * be signaled when writes to the output buffer have completed and it is safe to
1362 * read from it.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001363 *
1364 * Parameters:
Dan Stozaef264822016-07-13 14:51:09 -07001365 * outPresentFence - a sync fence file descriptor as described above; pointer
Dan Stoza4e9221b2015-09-02 15:43:39 -07001366 * will be non-NULL
1367 *
1368 * Returns HWC2_ERROR_NONE or one of the following errors:
1369 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1370 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1371 * display
1372 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1373 * for this display
1374 */
1375typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
Dan Stozaef264822016-07-13 14:51:09 -07001376 hwc2_device_t* device, hwc2_display_t display,
1377 int32_t* outPresentFence);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001378
1379/* setActiveConfig(..., config)
1380 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1381 * Must be provided by all HWC2 devices
1382 *
1383 * Sets the active configuration for this display. Upon returning, the given
1384 * display configuration should be active and remain so until either this
1385 * function is called again or the display is disconnected.
1386 *
1387 * Parameters:
1388 * config - the new display configuration
1389 *
1390 * Returns HWC2_ERROR_NONE or one of the following errors:
1391 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1392 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1393 * this display
1394 */
1395typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1396 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1397
Dan Stoza68cd3752016-05-20 13:30:42 -07001398/* setClientTarget(..., target, acquireFence, dataspace, damage)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001399 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1400 * Must be provided by all HWC2 devices
1401 *
1402 * Sets the buffer handle which will receive the output of client composition.
1403 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1404 * prior to the call to presentDisplay, and layers not marked as
1405 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1406 *
Dan Stoza3abcfa52016-05-04 12:21:06 -07001407 * The buffer handle provided may be null if no layers are being composited by
1408 * the client. This must not result in an error (unless an invalid display
1409 * handle is also provided).
1410 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001411 * Also provides a file descriptor referring to an acquire sync fence object,
1412 * which will be signaled when it is safe to read from the client target buffer.
1413 * If it is already safe to read from this buffer, -1 may be passed instead.
1414 * The device must ensure that it is safe for the client to close this file
1415 * descriptor at any point after this function is called.
1416 *
1417 * For more about dataspaces, see setLayerDataspace.
1418 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001419 * The damage parameter describes a surface damage region as defined in the
1420 * description of setLayerSurfaceDamage.
1421 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001422 * Will be called before presentDisplay if any of the layers are marked as
1423 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1424 * necessary to call this function. It is not necessary to call validateDisplay
1425 * after changing the target through this function.
1426 *
1427 * Parameters:
1428 * target - the new target buffer
1429 * acquireFence - a sync fence file descriptor as described above
1430 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
Dan Stoza68cd3752016-05-20 13:30:42 -07001431 * damage - the surface damage region
Dan Stoza4e9221b2015-09-02 15:43:39 -07001432 *
1433 * Returns HWC2_ERROR_NONE or one of the following errors:
1434 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1435 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1436 */
1437typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1438 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
Dan Stoza68cd3752016-05-20 13:30:42 -07001439 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1440 hwc_region_t damage);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001441
Dan Stozac46e96a2016-03-24 10:12:15 -07001442/* setColorMode(..., mode)
1443 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1444 * Must be provided by all HWC2 devices
1445 *
1446 * Sets the color mode of the given display.
1447 *
1448 * Upon returning from this function, the color mode change must have fully
1449 * taken effect.
1450 *
1451 * The valid color modes can be found in android_color_mode_t in
1452 * <system/graphics.h>. All HWC2 devices must support at least
1453 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1454 * hotplug.
1455 *
1456 * Parameters:
1457 * mode - the mode to set
1458 *
1459 * Returns HWC2_ERROR_NONE or one of the following errors:
1460 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1461 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1462 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1463 */
1464typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1465 hwc2_device_t* device, hwc2_display_t display,
1466 int32_t /*android_color_mode_t*/ mode);
1467
Dan Stoza4e9221b2015-09-02 15:43:39 -07001468/* setColorTransform(..., matrix, hint)
1469 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1470 * Must be provided by all HWC2 devices
1471 *
1472 * Sets a color transform which will be applied after composition.
1473 *
1474 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1475 * hint to apply the desired color transform instead of using the color matrix
1476 * directly.
1477 *
1478 * If the device is not capable of either using the hint or the matrix to apply
1479 * the desired color transform, it should force all layers to client composition
1480 * during validateDisplay.
1481 *
Dan Stozad2168f72016-07-14 11:48:16 -07001482 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1483 * will never apply the color transform during client composition, even if all
1484 * layers are being composed by the client.
1485 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001486 * The matrix provided is an affine color transformation of the following form:
1487 *
1488 * |r.r r.g r.b 0|
1489 * |g.r g.g g.b 0|
1490 * |b.r b.g b.b 0|
1491 * |Tr Tg Tb 1|
1492 *
1493 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1494 *
1495 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1496 * color [R_out, G_out, B_out] will be:
1497 *
1498 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
Dan Stoza5dfbe332016-03-24 09:23:11 -07001499 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1500 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
Dan Stoza4e9221b2015-09-02 15:43:39 -07001501 *
1502 * Parameters:
1503 * matrix - a 4x4 transform matrix (16 floats) as described above
1504 * hint - a hint value which may be used instead of the given matrix unless it
1505 * is HAL_COLOR_TRANSFORM_ARBITRARY
1506 *
1507 * Returns HWC2_ERROR_NONE or one of the following errors:
1508 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1509 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
1510 */
1511typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
Dan Stozac46e96a2016-03-24 10:12:15 -07001512 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
Dan Stoza4e9221b2015-09-02 15:43:39 -07001513 int32_t /*android_color_transform_t*/ hint);
1514
Dan Stoza4e9221b2015-09-02 15:43:39 -07001515/* setOutputBuffer(..., buffer, releaseFence)
1516 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
1517 * Must be provided by all HWC2 devices
1518 *
1519 * Sets the output buffer for a virtual display. That is, the buffer to which
1520 * the composition result will be written.
1521 *
1522 * Also provides a file descriptor referring to a release sync fence object,
1523 * which will be signaled when it is safe to write to the output buffer. If it
1524 * is already safe to write to the output buffer, -1 may be passed instead. The
1525 * device must ensure that it is safe for the client to close this file
1526 * descriptor at any point after this function is called.
1527 *
1528 * Must be called at least once before presentDisplay, but does not have any
1529 * interaction with layer state or display validation.
1530 *
1531 * Parameters:
1532 * buffer - the new output buffer
1533 * releaseFence - a sync fence file descriptor as described above
1534 *
1535 * Returns HWC2_ERROR_NONE or one of the following errors:
1536 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1537 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
1538 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
1539 */
1540typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
1541 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
1542 int32_t releaseFence);
1543
1544/* setPowerMode(..., mode)
1545 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
1546 * Must be provided by all HWC2 devices
1547 *
1548 * Sets the power mode of the given display. The transition must be complete
1549 * when this function returns. It is valid to call this function multiple times
1550 * with the same power mode.
1551 *
1552 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
1553 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
1554 * be queried using getDozeSupport.
1555 *
1556 * Parameters:
1557 * mode - the new power mode
1558 *
1559 * Returns HWC2_ERROR_NONE or one of the following errors:
1560 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1561 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
1562 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1563 * on this display
1564 */
1565typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
1566 hwc2_device_t* device, hwc2_display_t display,
1567 int32_t /*hwc2_power_mode_t*/ mode);
1568
1569/* setVsyncEnabled(..., enabled)
1570 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
1571 * Must be provided by all HWC2 devices
1572 *
1573 * Enables or disables the vsync signal for the given display. Virtual displays
1574 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
1575 * display though this function must return HWC2_ERROR_NONE and have no other
1576 * effect.
1577 *
1578 * Parameters:
1579 * enabled - whether to enable or disable vsync
1580 *
1581 * Returns HWC2_ERROR_NONE or one of the following errors:
1582 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1583 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
1584 */
1585typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
1586 hwc2_device_t* device, hwc2_display_t display,
1587 int32_t /*hwc2_vsync_t*/ enabled);
1588
1589/* validateDisplay(..., outNumTypes, outNumRequests)
1590 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
1591 * Must be provided by all HWC2 devices
1592 *
1593 * Instructs the device to inspect all of the layer state and determine if
1594 * there are any composition type changes necessary before presenting the
1595 * display. Permitted changes are described in the definition of
1596 * hwc2_composition_t above.
1597 *
1598 * Also returns the number of layer requests required
1599 * by the given layer configuration.
1600 *
1601 * Parameters:
1602 * outNumTypes - the number of composition type changes required by the
1603 * device; if greater than 0, the client must either set and validate new
1604 * types, or call acceptDisplayChanges to accept the changes returned by
1605 * getChangedCompositionTypes; must be the same as the number of changes
1606 * returned by getChangedCompositionTypes (see the declaration of that
1607 * function for more information); pointer will be non-NULL
1608 * outNumRequests - the number of layer requests required by this layer
1609 * configuration; must be equal to the number of layer requests returned
1610 * by getDisplayRequests (see the declaration of that function for
1611 * more information); pointer will be non-NULL
1612 *
1613 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
1614 * the display using the current layer state. Otherwise returns one of the
1615 * following errors:
1616 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1617 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
1618 * for more information)
1619 */
1620typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
1621 hwc2_device_t* device, hwc2_display_t display,
1622 uint32_t* outNumTypes, uint32_t* outNumRequests);
1623
1624/*
1625 * Layer Functions
1626 *
1627 * These are functions which operate on layers, but which do not modify state
1628 * that must be validated before use. See also 'Layer State Functions' below.
1629 *
1630 * All of these functions take as their first three parameters a device pointer,
1631 * a display handle for the display which contains the layer, and a layer
1632 * handle, so these parameters are omitted from the described parameter lists.
1633 */
1634
1635/* setCursorPosition(..., x, y)
1636 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
1637 * Must be provided by all HWC2 devices
1638 *
1639 * Asynchonously sets the position of a cursor layer.
1640 *
1641 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
1642 * If validation succeeds (i.e., the device does not request a composition
1643 * change for that layer), then once a buffer has been set for the layer and it
1644 * has been presented, its position may be set by this function at any time
1645 * between presentDisplay and any subsequent validateDisplay calls for this
1646 * display.
1647 *
1648 * Once validateDisplay is called, this function will not be called again until
1649 * the validate/present sequence is completed.
1650 *
1651 * May be called from any thread so long as it is not interleaved with the
1652 * validate/present sequence as described above.
1653 *
1654 * Parameters:
1655 * x - the new x coordinate (in pixels from the left of the screen)
1656 * y - the new y coordinate (in pixels from the top of the screen)
1657 *
1658 * Returns HWC2_ERROR_NONE or one of the following errors:
1659 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1660 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
1661 * HWC2_COMPOSITION_CURSOR
1662 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
1663 * validate/present sequence
1664 */
1665typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
1666 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1667 int32_t x, int32_t y);
1668
1669/* setLayerBuffer(..., buffer, acquireFence)
1670 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
1671 * Must be provided by all HWC2 devices
1672 *
1673 * Sets the buffer handle to be displayed for this layer. If the buffer
1674 * properties set at allocation time (width, height, format, and usage) have not
1675 * changed since the previous frame, it is not necessary to call validateDisplay
1676 * before calling presentDisplay unless new state needs to be validated in the
1677 * interim.
1678 *
1679 * Also provides a file descriptor referring to an acquire sync fence object,
1680 * which will be signaled when it is safe to read from the given buffer. If it
1681 * is already safe to read from the buffer, -1 may be passed instead. The
1682 * device must ensure that it is safe for the client to close this file
1683 * descriptor at any point after this function is called.
1684 *
1685 * This function must return HWC2_ERROR_NONE and have no other effect if called
1686 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
1687 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
1688 * (because synchronization and buffer updates for these layers are handled
1689 * elsewhere).
1690 *
1691 * Parameters:
1692 * buffer - the buffer handle to set
1693 * acquireFence - a sync fence file descriptor as described above
1694 *
1695 * Returns HWC2_ERROR_NONE or one of the following errors:
1696 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1697 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
1698 */
1699typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
1700 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1701 buffer_handle_t buffer, int32_t acquireFence);
1702
1703/* setLayerSurfaceDamage(..., damage)
1704 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
1705 * Must be provided by all HWC2 devices
1706 *
1707 * Provides the region of the source buffer which has been modified since the
1708 * last frame. This region does not need to be validated before calling
1709 * presentDisplay.
1710 *
1711 * Once set through this function, the damage region remains the same until a
1712 * subsequent call to this function.
1713 *
1714 * If damage.numRects > 0, then it may be assumed that any portion of the source
1715 * buffer not covered by one of the rects has not been modified this frame. If
1716 * damage.numRects == 0, then the whole source buffer must be treated as if it
1717 * has been modified.
1718 *
1719 * If the layer's contents are not modified relative to the prior frame, damage
1720 * will contain exactly one empty rect([0, 0, 0, 0]).
1721 *
1722 * The damage rects are relative to the pre-transformed buffer, and their origin
1723 * is the top-left corner. They will not exceed the dimensions of the latched
1724 * buffer.
1725 *
1726 * Parameters:
1727 * damage - the new surface damage region
1728 *
1729 * Returns HWC2_ERROR_NONE or one of the following errors:
1730 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1731 */
1732typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
1733 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1734 hwc_region_t damage);
1735
1736/*
1737 * Layer State Functions
1738 *
1739 * These functions modify the state of a given layer. They do not take effect
1740 * until the display configuration is successfully validated with
1741 * validateDisplay and the display contents are presented with presentDisplay.
1742 *
1743 * All of these functions take as their first three parameters a device pointer,
1744 * a display handle for the display which contains the layer, and a layer
1745 * handle, so these parameters are omitted from the described parameter lists.
1746 */
1747
1748/* setLayerBlendMode(..., mode)
1749 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
1750 * Must be provided by all HWC2 devices
1751 *
1752 * Sets the blend mode of the given layer.
1753 *
1754 * Parameters:
1755 * mode - the new blend mode
1756 *
1757 * Returns HWC2_ERROR_NONE or one of the following errors:
1758 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1759 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
1760 */
1761typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
1762 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1763 int32_t /*hwc2_blend_mode_t*/ mode);
1764
1765/* setLayerColor(..., color)
1766 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
1767 * Must be provided by all HWC2 devices
1768 *
1769 * Sets the color of the given layer. If the composition type of the layer is
1770 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
1771 * have no other effect.
1772 *
1773 * Parameters:
1774 * color - the new color
1775 *
1776 * Returns HWC2_ERROR_NONE or one of the following errors:
1777 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1778 */
1779typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
1780 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1781 hwc_color_t color);
1782
1783/* setLayerCompositionType(..., type)
1784 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
1785 * Must be provided by all HWC2 devices
1786 *
1787 * Sets the desired composition type of the given layer. During validateDisplay,
1788 * the device may request changes to the composition types of any of the layers
1789 * as described in the definition of hwc2_composition_t above.
1790 *
1791 * Parameters:
1792 * type - the new composition type
1793 *
1794 * Returns HWC2_ERROR_NONE or one of the following errors:
1795 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1796 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
1797 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
1798 * not supported by this device
1799 */
1800typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
1801 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1802 int32_t /*hwc2_composition_t*/ type);
1803
1804/* setLayerDataspace(..., dataspace)
1805 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
1806 * Must be provided by all HWC2 devices
1807 *
1808 * Sets the dataspace that the current buffer on this layer is in.
1809 *
1810 * The dataspace provides more information about how to interpret the buffer
1811 * contents, such as the encoding standard and color transform.
1812 *
1813 * See the values of android_dataspace_t in <system/graphics.h> for more
1814 * information.
1815 *
1816 * Parameters:
1817 * dataspace - the new dataspace
1818 *
1819 * Returns HWC2_ERROR_NONE or one of the following errors:
1820 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1821 */
1822typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
1823 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1824 int32_t /*android_dataspace_t*/ dataspace);
1825
1826/* setLayerDisplayFrame(..., frame)
1827 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
1828 * Must be provided by all HWC2 devices
1829 *
1830 * Sets the display frame (the portion of the display covered by a layer) of the
1831 * given layer. This frame will not exceed the display dimensions.
1832 *
1833 * Parameters:
1834 * frame - the new display frame
1835 *
1836 * Returns HWC2_ERROR_NONE or one of the following errors:
1837 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1838 */
1839typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
1840 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1841 hwc_rect_t frame);
1842
1843/* setLayerPlaneAlpha(..., alpha)
1844 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
1845 * Must be provided by all HWC2 devices
1846 *
1847 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
1848 * will be applied to the whole layer. It can be conceptualized as a
1849 * preprocessing step which applies the following function:
1850 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
1851 * out.rgb = in.rgb * planeAlpha
1852 * out.a = in.a * planeAlpha
1853 *
1854 * If the device does not support this operation on a layer which is marked
1855 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
1856 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
1857 *
1858 * Parameters:
1859 * alpha - the plane alpha value to apply
1860 *
1861 * Returns HWC2_ERROR_NONE or one of the following errors:
1862 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1863 */
1864typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
1865 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1866 float alpha);
1867
1868/* setLayerSidebandStream(..., stream)
1869 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
1870 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
1871 *
1872 * Sets the sideband stream for this layer. If the composition type of the given
1873 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
1874 * and have no other effect.
1875 *
1876 * Parameters:
1877 * stream - the new sideband stream
1878 *
1879 * Returns HWC2_ERROR_NONE or one of the following errors:
1880 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1881 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
1882 */
1883typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
1884 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1885 const native_handle_t* stream);
1886
1887/* setLayerSourceCrop(..., crop)
1888 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
1889 * Must be provided by all HWC2 devices
1890 *
1891 * Sets the source crop (the portion of the source buffer which will fill the
1892 * display frame) of the given layer. This crop rectangle will not exceed the
1893 * dimensions of the latched buffer.
1894 *
1895 * If the device is not capable of supporting a true float source crop (i.e., it
1896 * will truncate or round the floats to integers), it should set this layer to
1897 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
1898 * rendering.
1899 *
1900 * If the device cannot support float source crops, but still wants to handle
1901 * the layer, it should use the following code (or similar) to convert to
1902 * an integer crop:
1903 * intCrop.left = (int) ceilf(crop.left);
1904 * intCrop.top = (int) ceilf(crop.top);
1905 * intCrop.right = (int) floorf(crop.right);
1906 * intCrop.bottom = (int) floorf(crop.bottom);
1907 *
1908 * Parameters:
1909 * crop - the new source crop
1910 *
1911 * Returns HWC2_ERROR_NONE or one of the following errors:
1912 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1913 */
1914typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
1915 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1916 hwc_frect_t crop);
1917
1918/* setLayerTransform(..., transform)
1919 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
1920 * Must be provided by all HWC2 devices
1921 *
1922 * Sets the transform (rotation/flip) of the given layer.
1923 *
1924 * Parameters:
1925 * transform - the new transform
1926 *
1927 * Returns HWC2_ERROR_NONE or one of the following errors:
1928 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1929 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
1930 */
1931typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
1932 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1933 int32_t /*hwc_transform_t*/ transform);
1934
1935/* setLayerVisibleRegion(..., visible)
1936 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
1937 * Must be provided by all HWC2 devices
1938 *
1939 * Specifies the portion of the layer that is visible, including portions under
1940 * translucent areas of other layers. The region is in screen space, and will
1941 * not exceed the dimensions of the screen.
1942 *
1943 * Parameters:
1944 * visible - the new visible region, in screen space
1945 *
1946 * Returns HWC2_ERROR_NONE or one of the following errors:
1947 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1948 */
1949typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
1950 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1951 hwc_region_t visible);
1952
1953/* setLayerZOrder(..., z)
1954 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
1955 * Must be provided by all HWC2 devices
1956 *
1957 * Sets the desired Z order (height) of the given layer. A layer with a greater
1958 * Z value occludes a layer with a lesser Z value.
1959 *
1960 * Parameters:
1961 * z - the new Z order
1962 *
1963 * Returns HWC2_ERROR_NONE or one of the following errors:
1964 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1965 */
1966typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
1967 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
1968 uint32_t z);
1969
1970__END_DECLS
1971
1972#endif