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