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