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