blob: ec0ef608a3bf1e59e8c042007421485d1eafdfb2 [file] [log] [blame]
Dan Stoza4e9221b2015-09-02 15:43:39 -07001/*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_HWCOMPOSER2_H
18#define ANDROID_HARDWARE_HWCOMPOSER2_H
19
Colin Cross248ec3d2016-10-06 16:53:00 -070020#include <sys/cdefs.h>
21
Dan Stoza4e9221b2015-09-02 15:43:39 -070022#include <hardware/hardware.h>
23
24#include "hwcomposer_defs.h"
25
26__BEGIN_DECLS
27
28/*
29 * Enums
30 *
31 * For most of these enums, there is an invalid value defined to be 0. This is
32 * an attempt to catch uninitialized fields, and these values should not be
33 * used.
34 */
35
36/* Display attributes queryable through getDisplayAttribute */
37typedef enum {
38 HWC2_ATTRIBUTE_INVALID = 0,
39
40 /* Dimensions in pixels */
41 HWC2_ATTRIBUTE_WIDTH = 1,
42 HWC2_ATTRIBUTE_HEIGHT = 2,
43
44 /* Vsync period in nanoseconds */
45 HWC2_ATTRIBUTE_VSYNC_PERIOD = 3,
46
47 /* Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
48 * numbers to be stored in an int32_t without losing too much precision. If
49 * the DPI for a configuration is unavailable or is considered unreliable,
50 * the device may return -1 instead */
51 HWC2_ATTRIBUTE_DPI_X = 4,
52 HWC2_ATTRIBUTE_DPI_Y = 5,
53} hwc2_attribute_t;
54
55/* Blend modes, settable per layer */
56typedef enum {
57 HWC2_BLEND_MODE_INVALID = 0,
58
59 /* colorOut = colorSrc */
60 HWC2_BLEND_MODE_NONE = 1,
61
62 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
63 HWC2_BLEND_MODE_PREMULTIPLIED = 2,
64
65 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
66 HWC2_BLEND_MODE_COVERAGE = 3,
67} hwc2_blend_mode_t;
68
69/* See the 'Callbacks' section for more detailed descriptions of what these
70 * functions do */
71typedef enum {
72 HWC2_CALLBACK_INVALID = 0,
73 HWC2_CALLBACK_HOTPLUG = 1,
74 HWC2_CALLBACK_REFRESH = 2,
75 HWC2_CALLBACK_VSYNC = 3,
76} hwc2_callback_descriptor_t;
77
78/* Optional capabilities which may be supported by some devices. The particular
79 * set of supported capabilities for a given device may be retrieved using
80 * getCapabilities. */
81typedef enum {
82 HWC2_CAPABILITY_INVALID = 0,
83
84 /* Specifies that the device supports sideband stream layers, for which
85 * buffer content updates and other synchronization will not be provided
86 * through the usual validate/present cycle and must be handled by an
87 * external implementation-defined mechanism. Only changes to layer state
88 * (such as position, size, etc.) need to be performed through the
89 * validate/present cycle. */
90 HWC2_CAPABILITY_SIDEBAND_STREAM = 1,
Dan Stozad2168f72016-07-14 11:48:16 -070091
92 /* Specifies that the device will apply a color transform even when either
93 * the client or the device has chosen that all layers should be composed by
94 * the client. This will prevent the client from applying the color
95 * transform during its composition step. */
96 HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2,
Brian Anderson49018a52017-04-04 16:43:11 -070097
98 /* Specifies that the present fence must not be used as an accurate
99 * representation of the actual present time of a frame.
100 * This capability must never be set by HWC2 devices.
101 * This capability may be set for HWC1 devices that use the
102 * HWC2On1Adapter where emulation of the present fence using the retire
103 * fence is not feasible.
104 * In the future, CTS tests will require present time to be reliable.
105 */
106 HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE = 3,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700107
108 /* Specifies that a device is able to skip the validateDisplay call before
109 * receiving a call to presentDisplay. The client will always skip
110 * validateDisplay and try to call presentDisplay regardless of the changes
111 * in the properties of the layers. If the device returns anything else than
112 * HWC2_ERROR_NONE, it will call validateDisplay then presentDisplay again.
113 * For this capability to be worthwhile the device implementation of
114 * presentDisplay should fail as fast as possible in the case a
115 * validateDisplay step is needed.
116 */
Peiyong Linfd05d132018-01-22 12:23:25 -0800117 HWC2_CAPABILITY_SKIP_VALIDATE = 4,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700118} hwc2_capability_t;
119
120/* Possible composition types for a given layer */
121typedef enum {
122 HWC2_COMPOSITION_INVALID = 0,
123
124 /* The client will composite this layer into the client target buffer
125 * (provided to the device through setClientTarget).
126 *
127 * The device must not request any composition type changes for layers of
128 * this type. */
129 HWC2_COMPOSITION_CLIENT = 1,
130
131 /* The device will handle the composition of this layer through a hardware
132 * overlay or other similar means.
133 *
134 * Upon validateDisplay, the device may request a change from this type to
135 * HWC2_COMPOSITION_CLIENT. */
136 HWC2_COMPOSITION_DEVICE = 2,
137
138 /* The device will render this layer using the color set through
139 * setLayerColor. If this functionality is not supported on a layer that the
140 * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
141 * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
142 * upon the next call to validateDisplay.
143 *
144 * Upon validateDisplay, the device may request a change from this type to
145 * HWC2_COMPOSITION_CLIENT. */
146 HWC2_COMPOSITION_SOLID_COLOR = 3,
147
148 /* Similar to DEVICE, but the position of this layer may also be set
149 * asynchronously through setCursorPosition. If this functionality is not
150 * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
151 * device must request that the composition type of that layer is changed to
152 * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
153 *
154 * Upon validateDisplay, the device may request a change from this type to
155 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
156 * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
157 * still permit the device to composite the layer. */
158 HWC2_COMPOSITION_CURSOR = 4,
159
160 /* The device will handle the composition of this layer, as well as its
161 * buffer updates and content synchronization. Only supported on devices
162 * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
163 *
164 * Upon validateDisplay, the device may request a change from this type to
165 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
166 * unlikely that content will display correctly in these cases. */
167 HWC2_COMPOSITION_SIDEBAND = 5,
168} hwc2_composition_t;
169
170/* Possible connection options from the hotplug callback */
171typedef enum {
172 HWC2_CONNECTION_INVALID = 0,
173
174 /* The display has been connected */
175 HWC2_CONNECTION_CONNECTED = 1,
176
177 /* The display has been disconnected */
178 HWC2_CONNECTION_DISCONNECTED = 2,
179} hwc2_connection_t;
180
181/* Display requests returned by getDisplayRequests */
182typedef enum {
183 /* Instructs the client to provide a new client target buffer, even if no
184 * layers are marked for client composition. */
185 HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
186
187 /* Instructs the client to write the result of client composition directly
188 * into the virtual display output buffer. If any of the layers are not
189 * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
190 * display, this request has no effect. */
191 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
192} hwc2_display_request_t;
193
194/* Display types returned by getDisplayType */
195typedef enum {
196 HWC2_DISPLAY_TYPE_INVALID = 0,
197
198 /* All physical displays, including both internal displays and hotpluggable
199 * external displays */
200 HWC2_DISPLAY_TYPE_PHYSICAL = 1,
201
202 /* Virtual displays created by createVirtualDisplay */
203 HWC2_DISPLAY_TYPE_VIRTUAL = 2,
204} hwc2_display_type_t;
205
206/* Return codes from all functions */
207typedef enum {
208 HWC2_ERROR_NONE = 0,
209 HWC2_ERROR_BAD_CONFIG,
210 HWC2_ERROR_BAD_DISPLAY,
211 HWC2_ERROR_BAD_LAYER,
212 HWC2_ERROR_BAD_PARAMETER,
213 HWC2_ERROR_HAS_CHANGES,
214 HWC2_ERROR_NO_RESOURCES,
215 HWC2_ERROR_NOT_VALIDATED,
216 HWC2_ERROR_UNSUPPORTED,
217} hwc2_error_t;
218
219/* Function descriptors for use with getFunction */
220typedef enum {
221 HWC2_FUNCTION_INVALID = 0,
222 HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
223 HWC2_FUNCTION_CREATE_LAYER,
224 HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
225 HWC2_FUNCTION_DESTROY_LAYER,
226 HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
227 HWC2_FUNCTION_DUMP,
228 HWC2_FUNCTION_GET_ACTIVE_CONFIG,
229 HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
230 HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
231 HWC2_FUNCTION_GET_COLOR_MODES,
232 HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
233 HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
234 HWC2_FUNCTION_GET_DISPLAY_NAME,
235 HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
236 HWC2_FUNCTION_GET_DISPLAY_TYPE,
237 HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700238 HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700239 HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
240 HWC2_FUNCTION_GET_RELEASE_FENCES,
241 HWC2_FUNCTION_PRESENT_DISPLAY,
242 HWC2_FUNCTION_REGISTER_CALLBACK,
243 HWC2_FUNCTION_SET_ACTIVE_CONFIG,
244 HWC2_FUNCTION_SET_CLIENT_TARGET,
245 HWC2_FUNCTION_SET_COLOR_MODE,
246 HWC2_FUNCTION_SET_COLOR_TRANSFORM,
247 HWC2_FUNCTION_SET_CURSOR_POSITION,
248 HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
249 HWC2_FUNCTION_SET_LAYER_BUFFER,
250 HWC2_FUNCTION_SET_LAYER_COLOR,
251 HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
252 HWC2_FUNCTION_SET_LAYER_DATASPACE,
253 HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
254 HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
255 HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
256 HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
257 HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
258 HWC2_FUNCTION_SET_LAYER_TRANSFORM,
259 HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
260 HWC2_FUNCTION_SET_LAYER_Z_ORDER,
261 HWC2_FUNCTION_SET_OUTPUT_BUFFER,
262 HWC2_FUNCTION_SET_POWER_MODE,
263 HWC2_FUNCTION_SET_VSYNC_ENABLED,
264 HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800265 HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700266 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700267 HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
268 HWC2_FUNCTION_SET_READBACK_BUFFER,
269 HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700270 HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
271 HWC2_FUNCTION_GET_RENDER_INTENTS,
272 HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700273 HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700274
275 // composer 2.3
276 HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
277 HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700278 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
279 HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
280 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700281} hwc2_function_descriptor_t;
282
Dan Stozaf601e972016-03-16 09:54:40 -0700283/* Layer requests returned from getDisplayRequests */
Dan Stoza4e9221b2015-09-02 15:43:39 -0700284typedef enum {
285 /* The client should clear its target with transparent pixels where this
286 * layer would be. The client may ignore this request if the layer must be
287 * blended. */
288 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
289} hwc2_layer_request_t;
290
291/* Power modes for use with setPowerMode */
292typedef enum {
293 /* The display is fully off (blanked) */
294 HWC2_POWER_MODE_OFF = 0,
295
296 /* These are optional low power modes. getDozeSupport may be called to
297 * determine whether a given display supports these modes. */
298
299 /* The display is turned on and configured in a low power state that is
300 * suitable for presenting ambient information to the user, possibly with
301 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
302 HWC2_POWER_MODE_DOZE = 1,
303
304 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
305 * applying display updates from the client. This is effectively a hint to
306 * the device that drawing to the display has been suspended and that the
307 * the device should remain on in a low power state and continue displaying
308 * its current contents indefinitely until the power mode changes.
309 *
310 * This mode may also be used as a signal to enable hardware-based doze
311 * functionality. In this case, the device is free to take over the display
312 * and manage it autonomously to implement a low power always-on display. */
313 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
314
315 /* The display is fully on */
316 HWC2_POWER_MODE_ON = 2,
317} hwc2_power_mode_t;
318
319/* Vsync values passed to setVsyncEnabled */
320typedef enum {
321 HWC2_VSYNC_INVALID = 0,
322
323 /* Enable vsync */
324 HWC2_VSYNC_ENABLE = 1,
325
326 /* Disable vsync */
327 HWC2_VSYNC_DISABLE = 2,
328} hwc2_vsync_t;
329
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700330/* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */
331typedef enum {
332 /* SMPTE ST 2084:2014.
333 * Coordinates defined in CIE 1931 xy chromaticity space
334 */
335 HWC2_DISPLAY_RED_PRIMARY_X = 0,
336 HWC2_DISPLAY_RED_PRIMARY_Y = 1,
337 HWC2_DISPLAY_GREEN_PRIMARY_X = 2,
338 HWC2_DISPLAY_GREEN_PRIMARY_Y = 3,
339 HWC2_DISPLAY_BLUE_PRIMARY_X = 4,
340 HWC2_DISPLAY_BLUE_PRIMARY_Y = 5,
341 HWC2_WHITE_POINT_X = 6,
342 HWC2_WHITE_POINT_Y = 7,
343 /* SMPTE ST 2084:2014.
344 * Units: nits
345 * max as defined by ST 2048: 10,000 nits
346 */
347 HWC2_MAX_LUMINANCE = 8,
348 HWC2_MIN_LUMINANCE = 9,
349
350 /* CTA 861.3
351 * Units: nits
352 */
353 HWC2_MAX_CONTENT_LIGHT_LEVEL = 10,
354 HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
355} hwc2_per_frame_metadata_key_t;
356
Kevin DuBois13458872018-09-10 09:09:12 -0700357/* SetDisplayedContentSampling values passed to setDisplayedContentSamplingEnabled */
358typedef enum {
359 HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID = 0,
360
361 /* Enable displayed content sampling */
362 HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE = 1,
363
364 /* Disable displayed content sampling */
365 HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE = 2,
366} hwc2_displayed_content_sampling_t;
367
368typedef enum {
369 HWC2_FORMAT_COMPONENT_0 = 1 << 0, /* The first component (eg, for RGBA_8888, this is R) */
370 HWC2_FORMAT_COMPONENT_1 = 1 << 1, /* The second component (eg, for RGBA_8888, this is G) */
371 HWC2_FORMAT_COMPONENT_2 = 1 << 2, /* The third component (eg, for RGBA_8888, this is B) */
372 HWC2_FORMAT_COMPONENT_3 = 1 << 3, /* The fourth component (eg, for RGBA_8888, this is A) */
373} hwc2_format_color_component_t;
374
Dan Stoza4e9221b2015-09-02 15:43:39 -0700375/*
376 * Stringification Functions
377 */
378
379#ifdef HWC2_INCLUDE_STRINGIFICATION
380
381static inline const char* getAttributeName(hwc2_attribute_t attribute) {
382 switch (attribute) {
383 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
384 case HWC2_ATTRIBUTE_WIDTH: return "Width";
385 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
386 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
387 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
388 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
389 default: return "Unknown";
390 }
391}
392
393static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
394 switch (mode) {
395 case HWC2_BLEND_MODE_INVALID: return "Invalid";
396 case HWC2_BLEND_MODE_NONE: return "None";
397 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
398 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
399 default: return "Unknown";
400 }
401}
402
403static inline const char* getCallbackDescriptorName(
404 hwc2_callback_descriptor_t desc) {
405 switch (desc) {
406 case HWC2_CALLBACK_INVALID: return "Invalid";
407 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
408 case HWC2_CALLBACK_REFRESH: return "Refresh";
409 case HWC2_CALLBACK_VSYNC: return "Vsync";
410 default: return "Unknown";
411 }
412}
413
414static inline const char* getCapabilityName(hwc2_capability_t capability) {
415 switch (capability) {
416 case HWC2_CAPABILITY_INVALID: return "Invalid";
417 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
Dan Stozad2168f72016-07-14 11:48:16 -0700418 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
419 return "SkipClientColorTransform";
Brian Anderson49018a52017-04-04 16:43:11 -0700420 case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
421 return "PresentFenceIsNotReliable";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700422 default: return "Unknown";
423 }
424}
425
426static inline const char* getCompositionName(hwc2_composition_t composition) {
427 switch (composition) {
428 case HWC2_COMPOSITION_INVALID: return "Invalid";
429 case HWC2_COMPOSITION_CLIENT: return "Client";
430 case HWC2_COMPOSITION_DEVICE: return "Device";
431 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
432 case HWC2_COMPOSITION_CURSOR: return "Cursor";
433 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
434 default: return "Unknown";
435 }
436}
437
438static inline const char* getConnectionName(hwc2_connection_t connection) {
439 switch (connection) {
440 case HWC2_CONNECTION_INVALID: return "Invalid";
441 case HWC2_CONNECTION_CONNECTED: return "Connected";
442 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
443 default: return "Unknown";
444 }
445}
446
447static inline const char* getDisplayRequestName(
448 hwc2_display_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700449 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700450 case 0: return "None";
451 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
452 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
453 return "WriteClientTargetToOutput";
454 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
455 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
456 return "FlipClientTarget|WriteClientTargetToOutput";
457 default: return "Unknown";
458 }
459}
460
461static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
462 switch (type) {
463 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
464 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
465 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
466 default: return "Unknown";
467 }
468}
469
470static inline const char* getErrorName(hwc2_error_t error) {
471 switch (error) {
472 case HWC2_ERROR_NONE: return "None";
473 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
474 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
475 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
476 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
477 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
478 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
479 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
480 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
481 default: return "Unknown";
482 }
483}
484
485static inline const char* getFunctionDescriptorName(
486 hwc2_function_descriptor_t desc) {
487 switch (desc) {
488 case HWC2_FUNCTION_INVALID: return "Invalid";
489 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
490 return "AcceptDisplayChanges";
491 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
492 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
493 return "CreateVirtualDisplay";
494 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
495 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
496 return "DestroyVirtualDisplay";
497 case HWC2_FUNCTION_DUMP: return "Dump";
498 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
499 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
500 return "GetChangedCompositionTypes";
501 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
502 return "GetClientTargetSupport";
503 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
504 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
505 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
506 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
507 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
508 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
509 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
Dan Stozaf601e972016-03-16 09:54:40 -0700510 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700511 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
512 return "GetMaxVirtualDisplayCount";
513 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
514 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
515 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
516 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
517 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
518 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
519 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
520 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
521 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
522 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
523 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
524 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
525 return "SetLayerCompositionType";
526 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
527 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
528 return "SetLayerDisplayFrame";
529 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
530 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
531 return "SetLayerSidebandStream";
532 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
533 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
534 return "SetLayerSurfaceDamage";
535 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
536 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
537 return "SetLayerVisibleRegion";
538 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
539 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
540 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
541 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
542 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
Peiyong Linfd05d132018-01-22 12:23:25 -0800543 case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700544 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata";
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700545 case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys";
546 case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer";
547 case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes";
548 case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700549 case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents";
550 case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent";
551 case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix";
Peiyong Lin44819b92018-09-13 16:20:08 -0700552
553 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700554 case HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA: return "GetDisplayIdentificationData";
Peiyong Lin44819b92018-09-13 16:20:08 -0700555 case HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM: return "SetLayerColorTransform";
Kevin DuBois13458872018-09-10 09:09:12 -0700556 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: return "GetDisplayedContentSamplingAttributes";
557 case HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED: return "SetDisplayedContentSamplingEnabled";
558 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE: return "GetDisplayedContentSample";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700559 default: return "Unknown";
560 }
561}
562
563static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700564 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700565 case 0: return "None";
566 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
567 default: return "Unknown";
568 }
569}
570
571static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
572 switch (mode) {
573 case HWC2_POWER_MODE_OFF: return "Off";
574 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
575 case HWC2_POWER_MODE_DOZE: return "Doze";
576 case HWC2_POWER_MODE_ON: return "On";
577 default: return "Unknown";
578 }
579}
580
581static inline const char* getTransformName(hwc_transform_t transform) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700582 switch (__BIONIC_CAST(static_cast, int, transform)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700583 case 0: return "None";
584 case HWC_TRANSFORM_FLIP_H: return "FlipH";
585 case HWC_TRANSFORM_FLIP_V: return "FlipV";
586 case HWC_TRANSFORM_ROT_90: return "Rotate90";
587 case HWC_TRANSFORM_ROT_180: return "Rotate180";
588 case HWC_TRANSFORM_ROT_270: return "Rotate270";
589 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
590 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
591 default: return "Unknown";
592 }
593}
594
595static inline const char* getVsyncName(hwc2_vsync_t vsync) {
596 switch (vsync) {
597 case HWC2_VSYNC_INVALID: return "Invalid";
598 case HWC2_VSYNC_ENABLE: return "Enable";
599 case HWC2_VSYNC_DISABLE: return "Disable";
600 default: return "Unknown";
601 }
602}
603
Kevin DuBois13458872018-09-10 09:09:12 -0700604static inline const char* getDisplayedContentSamplingName(
605 hwc2_displayed_content_sampling_t sampling) {
606 switch (sampling) {
607 case HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID: return "Invalid";
608 case HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE: return "Enable";
609 case HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE: return "Disable";
610 default: return "Unknown";
611 }
612}
613
614static inline const char* getFormatColorComponentName(hwc2_format_color_component_t component) {
615 switch (component) {
616 case HWC2_FORMAT_COMPONENT_0: return "FirstComponent";
617 case HWC2_FORMAT_COMPONENT_1: return "SecondComponent";
618 case HWC2_FORMAT_COMPONENT_2: return "ThirdComponent";
619 case HWC2_FORMAT_COMPONENT_3: return "FourthComponent";
620 default: return "Unknown";
621 }
622}
623
Dan Stoza4e9221b2015-09-02 15:43:39 -0700624#define TO_STRING(E, T, printer) \
625 inline std::string to_string(E value) { return printer(value); } \
626 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
627#else // !HWC2_INCLUDE_STRINGIFICATION
628#define TO_STRING(name, printer)
629#endif // HWC2_INCLUDE_STRINGIFICATION
630
631/*
632 * C++11 features
633 */
634
635#ifdef HWC2_USE_CPP11
636__END_DECLS
637
638#ifdef HWC2_INCLUDE_STRINGIFICATION
639#include <string>
640#endif
641
642namespace HWC2 {
643
644enum class Attribute : int32_t {
645 Invalid = HWC2_ATTRIBUTE_INVALID,
646 Width = HWC2_ATTRIBUTE_WIDTH,
647 Height = HWC2_ATTRIBUTE_HEIGHT,
648 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
649 DpiX = HWC2_ATTRIBUTE_DPI_X,
650 DpiY = HWC2_ATTRIBUTE_DPI_Y,
651};
652TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
653
654enum class BlendMode : int32_t {
655 Invalid = HWC2_BLEND_MODE_INVALID,
656 None = HWC2_BLEND_MODE_NONE,
657 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
658 Coverage = HWC2_BLEND_MODE_COVERAGE,
659};
660TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
661
662enum class Callback : int32_t {
663 Invalid = HWC2_CALLBACK_INVALID,
664 Hotplug = HWC2_CALLBACK_HOTPLUG,
665 Refresh = HWC2_CALLBACK_REFRESH,
666 Vsync = HWC2_CALLBACK_VSYNC,
667};
668TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
669
670enum class Capability : int32_t {
671 Invalid = HWC2_CAPABILITY_INVALID,
672 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
Dan Stozad2168f72016-07-14 11:48:16 -0700673 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
Brian Anderson49018a52017-04-04 16:43:11 -0700674 PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700675 SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700676};
677TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
678
679enum class Composition : int32_t {
680 Invalid = HWC2_COMPOSITION_INVALID,
681 Client = HWC2_COMPOSITION_CLIENT,
682 Device = HWC2_COMPOSITION_DEVICE,
683 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
684 Cursor = HWC2_COMPOSITION_CURSOR,
685 Sideband = HWC2_COMPOSITION_SIDEBAND,
686};
687TO_STRING(hwc2_composition_t, Composition, getCompositionName)
688
689enum class Connection : int32_t {
690 Invalid = HWC2_CONNECTION_INVALID,
691 Connected = HWC2_CONNECTION_CONNECTED,
692 Disconnected = HWC2_CONNECTION_DISCONNECTED,
693};
694TO_STRING(hwc2_connection_t, Connection, getConnectionName)
695
696enum class DisplayRequest : int32_t {
697 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
698 WriteClientTargetToOutput =
699 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
700};
701TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
702
703enum class DisplayType : int32_t {
704 Invalid = HWC2_DISPLAY_TYPE_INVALID,
705 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
706 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
707};
708TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
709
710enum class Error : int32_t {
711 None = HWC2_ERROR_NONE,
712 BadConfig = HWC2_ERROR_BAD_CONFIG,
713 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
714 BadLayer = HWC2_ERROR_BAD_LAYER,
715 BadParameter = HWC2_ERROR_BAD_PARAMETER,
716 HasChanges = HWC2_ERROR_HAS_CHANGES,
717 NoResources = HWC2_ERROR_NO_RESOURCES,
718 NotValidated = HWC2_ERROR_NOT_VALIDATED,
719 Unsupported = HWC2_ERROR_UNSUPPORTED,
720};
721TO_STRING(hwc2_error_t, Error, getErrorName)
722
723enum class FunctionDescriptor : int32_t {
724 Invalid = HWC2_FUNCTION_INVALID,
725 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
726 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
727 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
728 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
729 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
730 Dump = HWC2_FUNCTION_DUMP,
731 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
732 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
733 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
734 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
735 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
736 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
737 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
738 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
739 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
740 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700741 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700742 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
743 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
744 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
745 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
746 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
747 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
748 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
749 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
750 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
751 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
752 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
753 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
754 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
755 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
756 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
757 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
758 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
759 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
760 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
761 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
762 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
763 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
764 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
765 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
766 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
767 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800768 SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700769 SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700770 GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
771 SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER,
772 GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
773 GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700774 GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS,
775 SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
776 GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700777
778 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700779 GetDisplayIdentificationData = HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Peiyong Lin44819b92018-09-13 16:20:08 -0700780 SetLayerColorTransform = HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700781 GetDisplayedContentSamplingAttributes = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
782 SetDisplayedContentSamplingEnabled = HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
783 GetDisplayedContentSample = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700784};
785TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
786 getFunctionDescriptorName)
787
788enum class LayerRequest : int32_t {
789 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
790};
791TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
792
793enum class PowerMode : int32_t {
794 Off = HWC2_POWER_MODE_OFF,
795 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
796 Doze = HWC2_POWER_MODE_DOZE,
797 On = HWC2_POWER_MODE_ON,
798};
799TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
800
801enum class Transform : int32_t {
802 None = 0,
803 FlipH = HWC_TRANSFORM_FLIP_H,
804 FlipV = HWC_TRANSFORM_FLIP_V,
805 Rotate90 = HWC_TRANSFORM_ROT_90,
806 Rotate180 = HWC_TRANSFORM_ROT_180,
807 Rotate270 = HWC_TRANSFORM_ROT_270,
808 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
809 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
810};
811TO_STRING(hwc_transform_t, Transform, getTransformName)
812
813enum class Vsync : int32_t {
814 Invalid = HWC2_VSYNC_INVALID,
815 Enable = HWC2_VSYNC_ENABLE,
816 Disable = HWC2_VSYNC_DISABLE,
817};
818TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
819
820} // namespace HWC2
821
822__BEGIN_DECLS
823#endif // HWC2_USE_CPP11
824
825/*
826 * Typedefs
827 */
828
829typedef void (*hwc2_function_pointer_t)();
830
831typedef void* hwc2_callback_data_t;
832typedef uint32_t hwc2_config_t;
833typedef uint64_t hwc2_display_t;
834typedef uint64_t hwc2_layer_t;
835
836/*
837 * Device Struct
838 */
839
840typedef struct hwc2_device {
841 /* Must be the first member of this struct, since a pointer to this struct
842 * will be generated by casting from a hw_device_t* */
843 struct hw_device_t common;
844
845 /* getCapabilities(..., outCount, outCapabilities)
846 *
847 * Provides a list of capabilities (described in the definition of
848 * hwc2_capability_t above) supported by this device. This list must
849 * not change after the device has been loaded.
850 *
851 * Parameters:
852 * outCount - if outCapabilities was NULL, the number of capabilities
853 * which would have been returned; if outCapabilities was not NULL,
854 * the number of capabilities returned, which must not exceed the
855 * value stored in outCount prior to the call
856 * outCapabilities - a list of capabilities supported by this device; may
857 * be NULL, in which case this function must write into outCount the
858 * number of capabilities which would have been written into
859 * outCapabilities
860 */
861 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
862 int32_t* /*hwc2_capability_t*/ outCapabilities);
863
864 /* getFunction(..., descriptor)
865 *
866 * Returns a function pointer which implements the requested description.
867 *
868 * Parameters:
869 * descriptor - the function to return
870 *
871 * Returns either a function pointer implementing the requested descriptor
872 * or NULL if the described function is not supported by this device.
873 */
874 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
875 int32_t /*hwc2_function_descriptor_t*/ descriptor);
876} hwc2_device_t;
877
878static inline int hwc2_open(const struct hw_module_t* module,
879 hwc2_device_t** device) {
880 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
Colin Crosscc8d9f92016-10-06 16:44:23 -0700881 TO_HW_DEVICE_T_OPEN(device));
Dan Stoza4e9221b2015-09-02 15:43:39 -0700882}
883
884static inline int hwc2_close(hwc2_device_t* device) {
885 return device->common.close(&device->common);
886}
887
888/*
889 * Callbacks
890 *
891 * All of these callbacks take as their first parameter the callbackData which
892 * was provided at the time of callback registration, so this parameter is
893 * omitted from the described parameter lists.
894 */
895
896/* hotplug(..., display, connected)
897 * Descriptor: HWC2_CALLBACK_HOTPLUG
898 * Will be provided to all HWC2 devices
899 *
900 * Notifies the client that the given display has either been connected or
901 * disconnected. Every active display (even a built-in physical display) must
902 * trigger at least one hotplug notification, even if it only occurs immediately
903 * after callback registration.
904 *
905 * The client may call back into the device on the same thread to query display
906 * properties (such as width, height, and vsync period), and other threads may
907 * call into the device while the callback is in progress. The device must
908 * serialize calls to this callback such that only one thread is calling it at a
909 * time.
910 *
911 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
912 * and the vsync callback should not be called for a display until vsync has
913 * been enabled with setVsyncEnabled.
914 *
915 * Parameters:
916 * display - the display which has been hotplugged
917 * connected - whether the display has been connected or disconnected
918 */
919typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
920 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
921
922/* refresh(..., display)
923 * Descriptor: HWC2_CALLBACK_REFRESH
924 * Will be provided to all HWC2 devices
925 *
926 * Notifies the client to trigger a screen refresh. This forces all layer state
927 * for this display to be resent, and the display to be validated and presented,
928 * even if there have been no changes.
929 *
930 * This refresh will occur some time after the callback is initiated, but not
931 * necessarily before it returns. This thread, however, is guaranteed not to
932 * call back into the device, thus it is safe to trigger this callback from
933 * other functions which call into the device.
934 *
935 * Parameters:
936 * display - the display to refresh
937 */
938typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
939 hwc2_display_t display);
940
941/* vsync(..., display, timestamp)
942 * Descriptor: HWC2_CALLBACK_VSYNC
943 * Will be provided to all HWC2 devices
944 *
945 * Notifies the client that a vsync event has occurred. This callback must
946 * only be triggered when vsync is enabled for this display (through
947 * setVsyncEnabled).
948 *
949 * This callback should be triggered from a thread of at least
950 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
951 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
952 *
953 * Parameters:
954 * display - the display which has received a vsync event
955 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
956 * nanoseconds
957 */
958typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
959 hwc2_display_t display, int64_t timestamp);
960
961/*
962 * Device Functions
963 *
964 * All of these functions take as their first parameter a device pointer, so
965 * this parameter is omitted from the described parameter lists.
966 */
967
Dan Stoza68cd3752016-05-20 13:30:42 -0700968/* createVirtualDisplay(..., width, height, format, outDisplay)
Dan Stoza4e9221b2015-09-02 15:43:39 -0700969 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
970 * Must be provided by all HWC2 devices
971 *
Dan Stoza68cd3752016-05-20 13:30:42 -0700972 * Creates a new virtual display with the given width and height. The format
973 * passed into this function is the default format requested by the consumer of
974 * the virtual display output buffers. If a different format will be returned by
975 * the device, it should be returned in this parameter so it can be set properly
976 * when handing the buffers to the consumer.
977 *
978 * The display will be assumed to be on from the time the first frame is
979 * presented until the display is destroyed.
Dan Stoza4e9221b2015-09-02 15:43:39 -0700980 *
981 * Parameters:
982 * width - width in pixels
983 * height - height in pixels
Dan Stoza68cd3752016-05-20 13:30:42 -0700984 * format - prior to the call, the default output buffer format selected by
985 * the consumer; after the call, the format the device will produce
Dan Stoza4e9221b2015-09-02 15:43:39 -0700986 * outDisplay - the newly-created virtual display; pointer will be non-NULL
987 *
988 * Returns HWC2_ERROR_NONE or one of the following errors:
989 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
990 * be able to create a virtual display
991 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
992 * display at this time
993 */
994typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
995 hwc2_device_t* device, uint32_t width, uint32_t height,
Dan Stoza68cd3752016-05-20 13:30:42 -0700996 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
Dan Stoza4e9221b2015-09-02 15:43:39 -0700997
998/* destroyVirtualDisplay(..., display)
999 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
1000 * Must be provided by all HWC2 devices
1001 *
1002 * Destroys a virtual display. After this call all resources consumed by this
1003 * display may be freed by the device and any operations performed on this
1004 * display should fail.
1005 *
1006 * Parameters:
1007 * display - the virtual display to destroy
1008 *
1009 * Returns HWC2_ERROR_NONE or one of the following errors:
1010 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1011 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
1012 * refer to a virtual display
1013 */
1014typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
1015 hwc2_device_t* device, hwc2_display_t display);
1016
1017/* dump(..., outSize, outBuffer)
1018 * Descriptor: HWC2_FUNCTION_DUMP
1019 * Must be provided by all HWC2 devices
1020 *
1021 * Retrieves implementation-defined debug information, which will be displayed
1022 * during, for example, `dumpsys SurfaceFlinger`.
1023 *
1024 * If called with outBuffer == NULL, the device should store a copy of the
1025 * desired output and return its length in bytes in outSize. If the device
1026 * already has a stored copy, that copy should be purged and replaced with a
1027 * fresh copy.
1028 *
1029 * If called with outBuffer != NULL, the device should copy its stored version
1030 * of the output into outBuffer and store how many bytes of data it copied into
1031 * outSize. Prior to this call, the client will have populated outSize with the
1032 * maximum number of bytes outBuffer can hold. The device must not write more
1033 * than this amount into outBuffer. If the device does not currently have a
1034 * stored copy, then it should return 0 in outSize.
1035 *
1036 * Any data written into outBuffer need not be null-terminated.
1037 *
1038 * Parameters:
1039 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
1040 * device's stored output; if outBuffer was not NULL, the number of bytes
1041 * written into it, which must not exceed the value stored in outSize
1042 * prior to the call; pointer will be non-NULL
1043 * outBuffer - the buffer to write the dump output into; may be NULL as
1044 * described above; data written into this buffer need not be
1045 * null-terminated
1046 */
1047typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
1048 char* outBuffer);
1049
1050/* getMaxVirtualDisplayCount(...)
1051 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
1052 * Must be provided by all HWC2 devices
1053 *
1054 * Returns the maximum number of virtual displays supported by this device
1055 * (which may be 0). The client will not attempt to create more than this many
1056 * virtual displays on this device. This number must not change for the lifetime
1057 * of the device.
1058 */
1059typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
1060 hwc2_device_t* device);
1061
1062/* registerCallback(..., descriptor, callbackData, pointer)
1063 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
1064 * Must be provided by all HWC2 devices
1065 *
1066 * Provides a callback for the device to call. All callbacks take a callbackData
1067 * item as the first parameter, so this value should be stored with the callback
1068 * for later use. The callbackData may differ from one callback to another. If
1069 * this function is called multiple times with the same descriptor, later
1070 * callbacks replace earlier ones.
1071 *
1072 * Parameters:
1073 * descriptor - which callback should be set
1074 * callBackdata - opaque data which must be passed back through the callback
1075 * pointer - a non-NULL function pointer corresponding to the descriptor
1076 *
1077 * Returns HWC2_ERROR_NONE or one of the following errors:
1078 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
1079 */
1080typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
1081 hwc2_device_t* device,
1082 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
1083 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
1084
Chia-I Wu28310aa2018-03-15 21:20:55 -07001085/* getDataspaceSaturationMatrix(..., dataspace, outMatrix)
1086 * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
1087 * Provided by HWC2 devices which don't return nullptr function pointer.
1088 *
1089 * Get the saturation matrix of the specified dataspace. The saturation matrix
1090 * can be used to approximate the dataspace saturation operation performed by
1091 * the HWC2 device when non-colorimetric mapping is allowed. It is to be
1092 * applied on linear pixel values.
1093 *
1094 * Parameters:
1095 * dataspace - the dataspace to query for
1096 * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity
1097 * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR.
1098 *
1099 * Returns HWC2_ERROR_NONE or one of the following errors:
1100 * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid
1101 */
1102typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)(
1103 hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace,
1104 float* outMatrix);
1105
Dan Stoza4e9221b2015-09-02 15:43:39 -07001106/*
1107 * Display Functions
1108 *
1109 * All of these functions take as their first two parameters a device pointer
1110 * and a display handle, so these parameters are omitted from the described
1111 * parameter lists.
1112 */
1113
1114/* acceptDisplayChanges(...)
1115 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
1116 * Must be provided by all HWC2 devices
1117 *
1118 * Accepts the changes required by the device from the previous validateDisplay
1119 * call (which may be queried using getChangedCompositionTypes) and revalidates
1120 * the display. This function is equivalent to requesting the changed types from
1121 * getChangedCompositionTypes, setting those types on the corresponding layers,
1122 * and then calling validateDisplay again.
1123 *
1124 * After this call it must be valid to present this display. Calling this after
1125 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
1126 * should have no other effect.
1127 *
1128 * Returns HWC2_ERROR_NONE or one of the following errors:
1129 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1130 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
1131 */
1132typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
1133 hwc2_device_t* device, hwc2_display_t display);
1134
1135/* createLayer(..., outLayer)
1136 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
1137 * Must be provided by all HWC2 devices
1138 *
1139 * Creates a new layer on the given display.
1140 *
1141 * Parameters:
1142 * outLayer - the handle of the new layer; pointer will be non-NULL
1143 *
1144 * Returns HWC2_ERROR_NONE or one of the following errors:
1145 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1146 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
1147 */
1148typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
1149 hwc2_display_t display, hwc2_layer_t* outLayer);
1150
1151/* destroyLayer(..., layer)
1152 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
1153 * Must be provided by all HWC2 devices
1154 *
1155 * Destroys the given layer.
1156 *
1157 * Parameters:
1158 * layer - the handle of the layer to destroy
1159 *
1160 * Returns HWC2_ERROR_NONE or one of the following errors:
1161 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1162 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1163 */
1164typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1165 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1166
1167/* getActiveConfig(..., outConfig)
1168 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1169 * Must be provided by all HWC2 devices
1170 *
1171 * Retrieves which display configuration is currently active.
1172 *
1173 * If no display configuration is currently active, this function must return
1174 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1175 * the responsibility of the client to call setActiveConfig with a valid
1176 * configuration before attempting to present anything on the display.
1177 *
1178 * Parameters:
1179 * outConfig - the currently active display configuration; pointer will be
1180 * non-NULL
1181 *
1182 * Returns HWC2_ERROR_NONE or one of the following errors:
1183 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1184 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1185 */
1186typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1187 hwc2_device_t* device, hwc2_display_t display,
1188 hwc2_config_t* outConfig);
1189
1190/* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1191 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1192 * Must be provided by all HWC2 devices
1193 *
1194 * Retrieves the layers for which the device requires a different composition
1195 * type than had been set prior to the last call to validateDisplay. The client
1196 * will either update its state with these types and call acceptDisplayChanges,
1197 * or will set new types and attempt to validate the display again.
1198 *
1199 * outLayers and outTypes may be NULL to retrieve the number of elements which
1200 * will be returned. The number of elements returned must be the same as the
1201 * value returned in outNumTypes from the last call to validateDisplay.
1202 *
1203 * Parameters:
1204 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1205 * and types which would have been returned; if both were non-NULL, the
1206 * number of elements returned in outLayers and outTypes, which must not
1207 * exceed the value stored in outNumElements prior to the call; pointer
1208 * will be non-NULL
1209 * outLayers - an array of layer handles
1210 * outTypes - an array of composition types, each corresponding to an element
1211 * of outLayers
1212 *
1213 * Returns HWC2_ERROR_NONE or one of the following errors:
1214 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1215 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1216 * display
1217 */
1218typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1219 hwc2_device_t* device, hwc2_display_t display,
1220 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1221 int32_t* /*hwc2_composition_t*/ outTypes);
1222
1223/* getClientTargetSupport(..., width, height, format, dataspace)
1224 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1225 * Must be provided by all HWC2 devices
1226 *
1227 * Returns whether a client target with the given properties can be handled by
1228 * the device.
1229 *
1230 * The valid formats can be found in android_pixel_format_t in
1231 * <system/graphics.h>.
1232 *
1233 * For more about dataspaces, see setLayerDataspace.
1234 *
1235 * This function must return true for a client target with width and height
1236 * equal to the active display configuration dimensions,
1237 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1238 * return true for any other configuration.
1239 *
1240 * Parameters:
1241 * width - client target width in pixels
1242 * height - client target height in pixels
1243 * format - client target format
1244 * dataspace - client target dataspace, as described in setLayerDataspace
1245 *
1246 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1247 * following errors:
1248 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1249 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1250 */
1251typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1252 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1253 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1254 int32_t /*android_dataspace_t*/ dataspace);
1255
1256/* getColorModes(..., outNumModes, outModes)
1257 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1258 * Must be provided by all HWC2 devices
1259 *
1260 * Returns the color modes supported on this display.
1261 *
1262 * The valid color modes can be found in android_color_mode_t in
1263 * <system/graphics.h>. All HWC2 devices must support at least
1264 * HAL_COLOR_MODE_NATIVE.
1265 *
1266 * outNumModes may be NULL to retrieve the number of modes which will be
1267 * returned.
1268 *
1269 * Parameters:
1270 * outNumModes - if outModes was NULL, the number of modes which would have
1271 * been returned; if outModes was not NULL, the number of modes returned,
1272 * which must not exceed the value stored in outNumModes prior to the
1273 * call; pointer will be non-NULL
1274 * outModes - an array of color modes
1275 *
1276 * Returns HWC2_ERROR_NONE or one of the following errors:
1277 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1278 */
1279typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1280 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1281 int32_t* /*android_color_mode_t*/ outModes);
1282
Chia-I Wu28310aa2018-03-15 21:20:55 -07001283/* getRenderIntents(..., mode, outNumIntents, outIntents)
1284 * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS
1285 * Provided by HWC2 devices which don't return nullptr function pointer.
1286 *
1287 * Returns the render intents supported on this display.
1288 *
1289 * The valid render intents can be found in android_render_intent_v1_1_t in
1290 * <system/graphics.h>. All HWC2 devices must support at least
1291 * HAL_RENDER_INTENT_COLORIMETRIC.
1292 *
1293 * outNumIntents may be NULL to retrieve the number of intents which will be
1294 * returned.
1295 *
1296 * Parameters:
1297 * mode - the color mode to query the render intents for
1298 * outNumIntents - if outIntents was NULL, the number of intents which would
1299 * have been returned; if outIntents was not NULL, the number of intents
1300 * returned, which must not exceed the value stored in outNumIntents
1301 * prior to the call; pointer will be non-NULL
1302 * outIntents - an array of render intents
1303 *
1304 * Returns HWC2_ERROR_NONE or one of the following errors:
1305 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1306 */
1307typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)(
1308 hwc2_device_t* device, hwc2_display_t display, int32_t mode,
1309 uint32_t* outNumIntents,
1310 int32_t* /*android_render_intent_v1_1_t*/ outIntents);
1311
Dan Stoza4e9221b2015-09-02 15:43:39 -07001312/* getDisplayAttribute(..., config, attribute, outValue)
1313 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1314 * Must be provided by all HWC2 devices
1315 *
1316 * Returns a display attribute value for a particular display configuration.
1317 *
1318 * Any attribute which is not supported or for which the value is unknown by the
1319 * device must return a value of -1.
1320 *
1321 * Parameters:
1322 * config - the display configuration for which to return attribute values
1323 * attribute - the attribute to query
1324 * outValue - the value of the attribute; the pointer will be non-NULL
1325 *
1326 * Returns HWC2_ERROR_NONE or one of the following errors:
1327 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1328 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1329 * display
1330 */
1331typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1332 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1333 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1334
1335/* getDisplayConfigs(..., outNumConfigs, outConfigs)
1336 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1337 * Must be provided by all HWC2 devices
1338 *
1339 * Returns handles for all of the valid display configurations on this display.
1340 *
1341 * outConfigs may be NULL to retrieve the number of elements which will be
1342 * returned.
1343 *
1344 * Parameters:
1345 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1346 * would have been returned; if outConfigs was not NULL, the number of
1347 * configurations returned, which must not exceed the value stored in
1348 * outNumConfigs prior to the call; pointer will be non-NULL
1349 * outConfigs - an array of configuration handles
1350 *
1351 * Returns HWC2_ERROR_NONE or one of the following errors:
1352 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1353 */
1354typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1355 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1356 hwc2_config_t* outConfigs);
1357
1358/* getDisplayName(..., outSize, outName)
1359 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1360 * Must be provided by all HWC2 devices
1361 *
1362 * Returns a human-readable version of the display's name.
1363 *
1364 * outName may be NULL to retrieve the length of the name.
1365 *
1366 * Parameters:
1367 * outSize - if outName was NULL, the number of bytes needed to return the
1368 * name if outName was not NULL, the number of bytes written into it,
1369 * which must not exceed the value stored in outSize prior to the call;
1370 * pointer will be non-NULL
1371 * outName - the display's name
1372 *
1373 * Returns HWC2_ERROR_NONE or one of the following errors:
1374 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1375 */
1376typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1377 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1378 char* outName);
1379
1380/* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1381 * outLayerRequests)
1382 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1383 * Must be provided by all HWC2 devices
1384 *
1385 * Returns the display requests and the layer requests required for the last
1386 * validated configuration.
1387 *
1388 * Display requests provide information about how the client should handle the
1389 * client target. Layer requests provide information about how the client
1390 * should handle an individual layer.
1391 *
1392 * If outLayers or outLayerRequests is NULL, the required number of layers and
1393 * requests must be returned in outNumElements, but this number may also be
1394 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1395 * to the value returned in outNumRequests from the last call to
1396 * validateDisplay).
1397 *
1398 * Parameters:
1399 * outDisplayRequests - the display requests for the current validated state
1400 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1401 * elements which would have been returned, which must be equal to the
1402 * value returned in outNumRequests from the last validateDisplay call on
1403 * this display; if both were not NULL, the number of elements in
1404 * outLayers and outLayerRequests, which must not exceed the value stored
1405 * in outNumElements prior to the call; pointer will be non-NULL
1406 * outLayers - an array of layers which all have at least one request
1407 * outLayerRequests - the requests corresponding to each element of outLayers
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_NOT_VALIDATED - validateDisplay has not been called for this
1412 * display
1413 */
1414typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1415 hwc2_device_t* device, hwc2_display_t display,
1416 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1417 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1418 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1419
1420/* getDisplayType(..., outType)
1421 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1422 * Must be provided by all HWC2 devices
1423 *
1424 * Returns whether the given display is a physical or virtual display.
1425 *
1426 * Parameters:
1427 * outType - the type of the display; pointer will be non-NULL
1428 *
1429 * Returns HWC2_ERROR_NONE or one of the following errors:
1430 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1431 */
1432typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1433 hwc2_device_t* device, hwc2_display_t display,
1434 int32_t* /*hwc2_display_type_t*/ outType);
1435
Dominik Laskowski55cf6f02018-03-25 15:12:04 -07001436/* getDisplayIdentificationData(..., outPort, outDataSize, outData)
1437 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
1438 * Optional for HWC2 devices
1439 *
1440 * If supported, getDisplayIdentificationData returns the port and data that
1441 * describe a physical display. The port is a unique number that identifies a
1442 * physical connector (e.g. eDP, HDMI) for display output. The data blob is
1443 * parsed to determine its format, typically EDID 1.3 as specified in VESA
1444 * E-EDID Standard Release A Revision 1.
1445 *
1446 * Devices for which display identification is unsupported must return null when
1447 * getFunction is called with HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA.
1448 *
1449 * Parameters:
1450 * outPort - the connector to which the display is connected;
1451 * pointer will be non-NULL
1452 * outDataSize - if outData is NULL, the size in bytes of the data which would
1453 * have been returned; if outData is not NULL, the size of outData, which
1454 * must not exceed the value stored in outDataSize prior to the call;
1455 * pointer will be non-NULL
1456 * outData - the EDID 1.3 blob identifying the display
1457 *
1458 * Returns HWC2_ERROR_NONE or one of the following errors:
1459 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1460 */
1461typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA)(
1462 hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
1463 uint32_t* outDataSize, uint8_t* outData);
1464
Dan Stoza4e9221b2015-09-02 15:43:39 -07001465/* getDozeSupport(..., outSupport)
1466 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1467 * Must be provided by all HWC2 devices
1468 *
1469 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1470 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1471 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1472 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1473 * device should not claim support.
1474 *
1475 * Parameters:
1476 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1477 * pointer will be non-NULL
1478 *
1479 * Returns HWC2_ERROR_NONE or one of the following errors:
1480 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1481 */
1482typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1483 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1484
Dan Stozaf601e972016-03-16 09:54:40 -07001485/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1486 * outMaxAverageLuminance, outMinLuminance)
1487 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1488 * Must be provided by all HWC2 devices
1489 *
1490 * Returns the high dynamic range (HDR) capabilities of the given display, which
1491 * are invariant with regard to the active configuration.
1492 *
1493 * Displays which are not HDR-capable must return no types in outTypes and set
1494 * outNumTypes to 0.
1495 *
1496 * If outTypes is NULL, the required number of HDR types must be returned in
1497 * outNumTypes.
1498 *
1499 * Parameters:
1500 * outNumTypes - if outTypes was NULL, the number of types which would have
1501 * been returned; if it was not NULL, the number of types stored in
1502 * outTypes, which must not exceed the value stored in outNumTypes prior
1503 * to the call; pointer will be non-NULL
1504 * outTypes - an array of HDR types, may have 0 elements if the display is not
1505 * HDR-capable
1506 * outMaxLuminance - the desired content maximum luminance for this display in
1507 * cd/m^2; pointer will be non-NULL
1508 * outMaxAverageLuminance - the desired content maximum frame-average
1509 * luminance for this display in cd/m^2; pointer will be non-NULL
1510 * outMinLuminance - the desired content minimum luminance for this display in
1511 * cd/m^2; pointer will be non-NULL
1512 *
1513 * Returns HWC2_ERROR_NONE or one of the following errors:
1514 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1515 */
1516typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1517 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1518 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1519 float* outMaxAverageLuminance, float* outMinLuminance);
1520
Dan Stoza4e9221b2015-09-02 15:43:39 -07001521/* getReleaseFences(..., outNumElements, outLayers, outFences)
1522 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1523 * Must be provided by all HWC2 devices
1524 *
1525 * Retrieves the release fences for device layers on this display which will
1526 * receive new buffer contents this frame.
1527 *
1528 * A release fence is a file descriptor referring to a sync fence object which
1529 * will be signaled after the device has finished reading from the buffer
1530 * presented in the prior frame. This indicates that it is safe to start writing
1531 * to the buffer again. If a given layer's fence is not returned from this
1532 * function, it will be assumed that the buffer presented on the previous frame
1533 * is ready to be written.
1534 *
1535 * The fences returned by this function should be unique for each layer (even if
1536 * they point to the same underlying sync object), and ownership of the fences
1537 * is transferred to the client, which is responsible for closing them.
1538 *
1539 * If outLayers or outFences is NULL, the required number of layers and fences
1540 * must be returned in outNumElements.
1541 *
1542 * Parameters:
1543 * outNumElements - if outLayers or outFences were NULL, the number of
1544 * elements which would have been returned; if both were not NULL, the
1545 * number of elements in outLayers and outFences, which must not exceed
1546 * the value stored in outNumElements prior to the call; pointer will be
1547 * non-NULL
1548 * outLayers - an array of layer handles
1549 * outFences - an array of sync fence file descriptors as described above,
1550 * each corresponding to an element of outLayers
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 */
1555typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
1556 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1557 hwc2_layer_t* outLayers, int32_t* outFences);
1558
Dan Stozaef264822016-07-13 14:51:09 -07001559/* presentDisplay(..., outPresentFence)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001560 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1561 * Must be provided by all HWC2 devices
1562 *
1563 * Presents the current display contents on the screen (or in the case of
1564 * virtual displays, into the output buffer).
1565 *
1566 * Prior to calling this function, the display must be successfully validated
1567 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1568 * specifically do not count as layer state, so if there are no other changes
1569 * to the layer state (or to the buffer's properties as described in
1570 * setLayerBuffer), then it is safe to call this function without first
1571 * validating the display.
1572 *
Dan Stozaef264822016-07-13 14:51:09 -07001573 * If this call succeeds, outPresentFence will be populated with a file
1574 * descriptor referring to a present sync fence object. For physical displays,
1575 * this fence will be signaled at the vsync when the result of composition of
1576 * this frame starts to appear (for video-mode panels) or starts to transfer to
1577 * panel memory (for command-mode panels). For virtual displays, this fence will
1578 * be signaled when writes to the output buffer have completed and it is safe to
1579 * read from it.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001580 *
1581 * Parameters:
Dan Stozaef264822016-07-13 14:51:09 -07001582 * outPresentFence - a sync fence file descriptor as described above; pointer
Dan Stoza4e9221b2015-09-02 15:43:39 -07001583 * will be non-NULL
1584 *
1585 * Returns HWC2_ERROR_NONE or one of the following errors:
1586 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1587 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1588 * display
1589 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1590 * for this display
1591 */
1592typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
Dan Stozaef264822016-07-13 14:51:09 -07001593 hwc2_device_t* device, hwc2_display_t display,
1594 int32_t* outPresentFence);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001595
1596/* setActiveConfig(..., config)
1597 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1598 * Must be provided by all HWC2 devices
1599 *
1600 * Sets the active configuration for this display. Upon returning, the given
1601 * display configuration should be active and remain so until either this
1602 * function is called again or the display is disconnected.
1603 *
1604 * Parameters:
1605 * config - the new display configuration
1606 *
1607 * Returns HWC2_ERROR_NONE or one of the following errors:
1608 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1609 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1610 * this display
1611 */
1612typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1613 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1614
Dan Stoza68cd3752016-05-20 13:30:42 -07001615/* setClientTarget(..., target, acquireFence, dataspace, damage)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001616 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1617 * Must be provided by all HWC2 devices
1618 *
1619 * Sets the buffer handle which will receive the output of client composition.
1620 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1621 * prior to the call to presentDisplay, and layers not marked as
1622 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1623 *
Dan Stoza3abcfa52016-05-04 12:21:06 -07001624 * The buffer handle provided may be null if no layers are being composited by
1625 * the client. This must not result in an error (unless an invalid display
1626 * handle is also provided).
1627 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001628 * Also provides a file descriptor referring to an acquire sync fence object,
1629 * which will be signaled when it is safe to read from the client target buffer.
1630 * If it is already safe to read from this buffer, -1 may be passed instead.
1631 * The device must ensure that it is safe for the client to close this file
1632 * descriptor at any point after this function is called.
1633 *
1634 * For more about dataspaces, see setLayerDataspace.
1635 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001636 * The damage parameter describes a surface damage region as defined in the
1637 * description of setLayerSurfaceDamage.
1638 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001639 * Will be called before presentDisplay if any of the layers are marked as
1640 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1641 * necessary to call this function. It is not necessary to call validateDisplay
1642 * after changing the target through this function.
1643 *
1644 * Parameters:
1645 * target - the new target buffer
1646 * acquireFence - a sync fence file descriptor as described above
1647 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
Dan Stoza68cd3752016-05-20 13:30:42 -07001648 * damage - the surface damage region
Dan Stoza4e9221b2015-09-02 15:43:39 -07001649 *
1650 * Returns HWC2_ERROR_NONE or one of the following errors:
1651 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1652 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1653 */
1654typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1655 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
Dan Stoza68cd3752016-05-20 13:30:42 -07001656 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1657 hwc_region_t damage);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001658
Dan Stozac46e96a2016-03-24 10:12:15 -07001659/* setColorMode(..., mode)
1660 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1661 * Must be provided by all HWC2 devices
1662 *
1663 * Sets the color mode of the given display.
1664 *
Chia-I Wu28310aa2018-03-15 21:20:55 -07001665 * This must be called outside of validateDisplay/presentDisplay, and it takes
1666 * effect on next presentDisplay.
Dan Stozac46e96a2016-03-24 10:12:15 -07001667 *
1668 * The valid color modes can be found in android_color_mode_t in
1669 * <system/graphics.h>. All HWC2 devices must support at least
1670 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1671 * hotplug.
1672 *
1673 * Parameters:
1674 * mode - the mode to set
1675 *
1676 * Returns HWC2_ERROR_NONE or one of the following errors:
1677 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1678 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1679 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1680 */
1681typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1682 hwc2_device_t* device, hwc2_display_t display,
1683 int32_t /*android_color_mode_t*/ mode);
1684
Chia-I Wu28310aa2018-03-15 21:20:55 -07001685/* setColorModeWithIntent(..., mode, intent)
1686 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
1687 * Provided by HWC2 devices which don't return nullptr function pointer.
1688 *
1689 * This must be called outside of validateDisplay/presentDisplay, and it takes
1690 * effect on next presentDisplay.
1691 *
1692 * The valid color modes and render intents can be found in
1693 * android_color_mode_t and android_render_intent_v1_1_t in
1694 * <system/graphics.h>. All HWC2 devices must support at least
1695 * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are
1696 * assumed to be in this mode and intent upon hotplug.
1697 *
1698 * Parameters:
1699 * mode - the mode to set
1700 * intent - the intent to set
1701 *
1702 * Returns HWC2_ERROR_NONE or one of the following errors:
1703 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1704 * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or
1705 * render intent
1706 * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display
1707 */
1708typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)(
1709 hwc2_device_t* device, hwc2_display_t display,
1710 int32_t /*android_color_mode_t*/ mode,
1711 int32_t /*android_render_intent_v1_1_t */ intent);
1712
Dan Stoza4e9221b2015-09-02 15:43:39 -07001713/* setColorTransform(..., matrix, hint)
1714 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1715 * Must be provided by all HWC2 devices
1716 *
1717 * Sets a color transform which will be applied after composition.
1718 *
1719 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1720 * hint to apply the desired color transform instead of using the color matrix
1721 * directly.
1722 *
1723 * If the device is not capable of either using the hint or the matrix to apply
1724 * the desired color transform, it should force all layers to client composition
1725 * during validateDisplay.
1726 *
Dan Stozad2168f72016-07-14 11:48:16 -07001727 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1728 * will never apply the color transform during client composition, even if all
1729 * layers are being composed by the client.
1730 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001731 * The matrix provided is an affine color transformation of the following form:
1732 *
1733 * |r.r r.g r.b 0|
1734 * |g.r g.g g.b 0|
1735 * |b.r b.g b.b 0|
1736 * |Tr Tg Tb 1|
1737 *
1738 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1739 *
1740 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1741 * color [R_out, G_out, B_out] will be:
1742 *
1743 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
Dan Stoza5dfbe332016-03-24 09:23:11 -07001744 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1745 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
Dan Stoza4e9221b2015-09-02 15:43:39 -07001746 *
1747 * Parameters:
1748 * matrix - a 4x4 transform matrix (16 floats) as described above
1749 * hint - a hint value which may be used instead of the given matrix unless it
1750 * is HAL_COLOR_TRANSFORM_ARBITRARY
1751 *
1752 * Returns HWC2_ERROR_NONE or one of the following errors:
1753 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1754 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
1755 */
1756typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
Dan Stozac46e96a2016-03-24 10:12:15 -07001757 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
Dan Stoza4e9221b2015-09-02 15:43:39 -07001758 int32_t /*android_color_transform_t*/ hint);
1759
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001760/* getPerFrameMetadataKeys(..., outKeys)
1761 * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
1762 * Optional for HWC2 devices
1763 *
1764 * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null),
1765 * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys
1766 * which are invariant with regard to the active configuration.
1767 *
1768 * Devices which are not HDR-capable, must return null when getFunction is called
1769 * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS.
1770 *
1771 * If outKeys is NULL, the required number of PerFrameMetadataKey keys
1772 * must be returned in outNumKeys.
1773 *
1774 * Parameters:
1775 * outNumKeys - if outKeys is NULL, the number of keys which would have
1776 * been returned; if outKeys is not NULL, the number of keys stored in
1777 * outKeys, which must not exceed the value stored in outNumKeys prior
1778 * to the call; pointer will be non-NULL
1779 * outKeys - an array of hwc2_per_frame_metadata_key_t keys
1780 *
1781 * Returns HWC2_ERROR_NONE or one of the following errors:
1782 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1783 */
1784typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)(
1785 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys,
1786 int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
1787
Dan Stoza4e9221b2015-09-02 15:43:39 -07001788/* setOutputBuffer(..., buffer, releaseFence)
1789 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
1790 * Must be provided by all HWC2 devices
1791 *
1792 * Sets the output buffer for a virtual display. That is, the buffer to which
1793 * the composition result will be written.
1794 *
1795 * Also provides a file descriptor referring to a release sync fence object,
1796 * which will be signaled when it is safe to write to the output buffer. If it
1797 * is already safe to write to the output buffer, -1 may be passed instead. The
1798 * device must ensure that it is safe for the client to close this file
1799 * descriptor at any point after this function is called.
1800 *
1801 * Must be called at least once before presentDisplay, but does not have any
1802 * interaction with layer state or display validation.
1803 *
1804 * Parameters:
1805 * buffer - the new output buffer
1806 * releaseFence - a sync fence file descriptor as described above
1807 *
1808 * Returns HWC2_ERROR_NONE or one of the following errors:
1809 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1810 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
1811 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
1812 */
1813typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
1814 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
1815 int32_t releaseFence);
1816
1817/* setPowerMode(..., mode)
1818 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
1819 * Must be provided by all HWC2 devices
1820 *
1821 * Sets the power mode of the given display. The transition must be complete
1822 * when this function returns. It is valid to call this function multiple times
1823 * with the same power mode.
1824 *
1825 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
1826 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
1827 * be queried using getDozeSupport.
1828 *
1829 * Parameters:
1830 * mode - the new power mode
1831 *
1832 * Returns HWC2_ERROR_NONE or one of the following errors:
1833 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1834 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
1835 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1836 * on this display
1837 */
1838typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
1839 hwc2_device_t* device, hwc2_display_t display,
1840 int32_t /*hwc2_power_mode_t*/ mode);
1841
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001842/* getReadbackBufferAttributes(..., outFormat, outDataspace)
1843 * Optional for HWC2 devices
1844 *
1845 * Returns the format which should be used when allocating a buffer for use by
1846 * device readback as well as the dataspace in which its contents should be
1847 * interpreted.
1848 *
1849 * If readback is not supported by this HWC implementation, this call will also
1850 * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method.
1851 * Returning NULL to a getFunction request for this function will also indicate
1852 * that readback is not supported.
1853 *
1854 * The width and height of this buffer will be those of the currently-active
1855 * display configuration, and the usage flags will consist of the following:
1856 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
1857 * BufferUsage::COMPOSER_OUTPUT
1858 *
1859 * The format and dataspace provided must be sufficient such that if a
1860 * correctly-configured buffer is passed into setReadbackBuffer, filled by
1861 * the device, and then displayed by the client as a full-screen buffer, the
1862 * output of the display remains the same (subject to the note about protected
1863 * content in the description of setReadbackBuffer).
1864 *
Dan Stozaaf153e02018-05-15 13:09:51 -07001865 * If the active configuration or color mode of this display has changed since
1866 * the previous call to this function, it will be called again prior to setting
1867 * a readback buffer such that the returned format and dataspace can be updated
1868 * accordingly.
1869 *
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001870 * Parameters:
1871 * outFormat - the format the client should use when allocating a device
Dan Stozaaf153e02018-05-15 13:09:51 -07001872 * readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001873 * outDataspace - the dataspace the client will use when interpreting the
Dan Stozaaf153e02018-05-15 13:09:51 -07001874 * contents of a device readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001875 *
1876 * Returns HWC2_ERROR_NONE or one of the following errors:
1877 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001878 *
1879 * See also:
1880 * setReadbackBuffer
1881 * getReadbackBufferFence
1882 */
1883typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)(
1884 hwc2_device_t* device, hwc2_display_t display,
1885 int32_t* /*android_pixel_format_t*/ outFormat,
1886 int32_t* /*android_dataspace_t*/ outDataspace);
1887
1888/* getReadbackBufferFence(..., outFence)
1889 * Optional for HWC2 devices
1890 *
1891 * Returns an acquire sync fence file descriptor which will signal when the
1892 * buffer provided to setReadbackBuffer has been filled by the device and is
1893 * safe for the client to read.
1894 *
1895 * If it is already safe to read from this buffer, -1 may be returned instead.
1896 * The client takes ownership of this file descriptor and is responsible for
1897 * closing it when it is no longer needed.
1898 *
1899 * This function will be called immediately after the composition cycle being
1900 * captured into the readback buffer. The complete ordering of a readback buffer
1901 * capture is as follows:
1902 *
1903 * getReadbackBufferAttributes
1904 * // Readback buffer is allocated
1905 * // Many frames may pass
1906 *
1907 * setReadbackBuffer
1908 * validateDisplay
1909 * presentDisplay
1910 * getReadbackBufferFence
1911 * // Implicitly wait on the acquire fence before accessing the buffer
1912 *
1913 * Parameters:
1914 * outFence - a sync fence file descriptor as described above; pointer
1915 * will be non-NULL
1916 *
1917 * Returns HWC2_ERROR_NONE or one of the following errors:
1918 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Dan Stozaaf153e02018-05-15 13:09:51 -07001919 * HWC2_ERROR_NO_RESOURCES - the readback operation was successful, but
1920 * resulted in a different validate result than would have occurred
1921 * without readback
1922 * HWC2_ERROR_UNSUPPORTED - the readback operation was unsuccessful because
1923 * of resource constraints, the presence of protected content, or other
1924 * reasons; -1 must be returned in outFence
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001925 */
1926typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)(
1927 hwc2_device_t* device, hwc2_display_t display,
1928 int32_t* outFence);
1929
1930/* setReadbackBuffer(..., buffer, releaseFence)
1931 * Optional for HWC2 devices
1932 *
1933 * Sets the readback buffer to be filled with the contents of the next
1934 * composition performed for this display (i.e., the contents present at the
1935 * time of the next validateDisplay/presentDisplay cycle).
1936 *
1937 * This buffer will have been allocated as described in
1938 * getReadbackBufferAttributes and will be interpreted as being in the dataspace
1939 * provided by the same.
1940 *
1941 * If there is hardware protected content on the display at the time of the next
1942 * composition, the area of the readback buffer covered by such content must be
1943 * completely black. Any areas of the buffer not covered by such content may
1944 * optionally be black as well.
1945 *
1946 * The release fence file descriptor provided works identically to the one
1947 * described for setOutputBuffer.
1948 *
1949 * This function will not be called between any call to validateDisplay and a
1950 * subsequent call to presentDisplay.
1951 *
1952 * Parameters:
1953 * buffer - the new readback buffer
1954 * releaseFence - a sync fence file descriptor as described in setOutputBuffer
1955 *
1956 * Returns HWC2_ERROR_NONE or one of the following errors:
1957 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1958 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
1959 *
1960 * See also:
1961 * getReadbackBufferAttributes
1962 * getReadbackBufferFence
1963 */
1964typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)(
1965 hwc2_device_t* device, hwc2_display_t display,
1966 buffer_handle_t buffer, int32_t releaseFence);
1967
Dan Stoza4e9221b2015-09-02 15:43:39 -07001968/* setVsyncEnabled(..., enabled)
1969 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
1970 * Must be provided by all HWC2 devices
1971 *
1972 * Enables or disables the vsync signal for the given display. Virtual displays
1973 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
1974 * display though this function must return HWC2_ERROR_NONE and have no other
1975 * effect.
1976 *
1977 * Parameters:
1978 * enabled - whether to enable or disable vsync
1979 *
1980 * Returns HWC2_ERROR_NONE or one of the following errors:
1981 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1982 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
1983 */
1984typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
1985 hwc2_device_t* device, hwc2_display_t display,
1986 int32_t /*hwc2_vsync_t*/ enabled);
1987
1988/* validateDisplay(..., outNumTypes, outNumRequests)
1989 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
1990 * Must be provided by all HWC2 devices
1991 *
1992 * Instructs the device to inspect all of the layer state and determine if
1993 * there are any composition type changes necessary before presenting the
1994 * display. Permitted changes are described in the definition of
1995 * hwc2_composition_t above.
1996 *
1997 * Also returns the number of layer requests required
1998 * by the given layer configuration.
1999 *
2000 * Parameters:
2001 * outNumTypes - the number of composition type changes required by the
2002 * device; if greater than 0, the client must either set and validate new
2003 * types, or call acceptDisplayChanges to accept the changes returned by
2004 * getChangedCompositionTypes; must be the same as the number of changes
2005 * returned by getChangedCompositionTypes (see the declaration of that
2006 * function for more information); pointer will be non-NULL
2007 * outNumRequests - the number of layer requests required by this layer
2008 * configuration; must be equal to the number of layer requests returned
2009 * by getDisplayRequests (see the declaration of that function for
2010 * more information); pointer will be non-NULL
2011 *
2012 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
2013 * the display using the current layer state. Otherwise returns one of the
2014 * following errors:
2015 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2016 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
2017 * for more information)
2018 */
2019typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
2020 hwc2_device_t* device, hwc2_display_t display,
2021 uint32_t* outNumTypes, uint32_t* outNumRequests);
2022
2023/*
2024 * Layer Functions
2025 *
2026 * These are functions which operate on layers, but which do not modify state
2027 * that must be validated before use. See also 'Layer State Functions' below.
2028 *
2029 * All of these functions take as their first three parameters a device pointer,
2030 * a display handle for the display which contains the layer, and a layer
2031 * handle, so these parameters are omitted from the described parameter lists.
2032 */
2033
2034/* setCursorPosition(..., x, y)
2035 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
2036 * Must be provided by all HWC2 devices
2037 *
2038 * Asynchonously sets the position of a cursor layer.
2039 *
2040 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
2041 * If validation succeeds (i.e., the device does not request a composition
2042 * change for that layer), then once a buffer has been set for the layer and it
2043 * has been presented, its position may be set by this function at any time
2044 * between presentDisplay and any subsequent validateDisplay calls for this
2045 * display.
2046 *
2047 * Once validateDisplay is called, this function will not be called again until
2048 * the validate/present sequence is completed.
2049 *
2050 * May be called from any thread so long as it is not interleaved with the
2051 * validate/present sequence as described above.
2052 *
2053 * Parameters:
2054 * x - the new x coordinate (in pixels from the left of the screen)
2055 * y - the new y coordinate (in pixels from the top of the screen)
2056 *
2057 * Returns HWC2_ERROR_NONE or one of the following errors:
2058 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2059 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
2060 * HWC2_COMPOSITION_CURSOR
2061 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
2062 * validate/present sequence
2063 */
2064typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
2065 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2066 int32_t x, int32_t y);
2067
2068/* setLayerBuffer(..., buffer, acquireFence)
2069 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
2070 * Must be provided by all HWC2 devices
2071 *
2072 * Sets the buffer handle to be displayed for this layer. If the buffer
2073 * properties set at allocation time (width, height, format, and usage) have not
2074 * changed since the previous frame, it is not necessary to call validateDisplay
2075 * before calling presentDisplay unless new state needs to be validated in the
2076 * interim.
2077 *
2078 * Also provides a file descriptor referring to an acquire sync fence object,
2079 * which will be signaled when it is safe to read from the given buffer. If it
2080 * is already safe to read from the buffer, -1 may be passed instead. The
2081 * device must ensure that it is safe for the client to close this file
2082 * descriptor at any point after this function is called.
2083 *
2084 * This function must return HWC2_ERROR_NONE and have no other effect if called
2085 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
2086 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
2087 * (because synchronization and buffer updates for these layers are handled
2088 * elsewhere).
2089 *
2090 * Parameters:
2091 * buffer - the buffer handle to set
2092 * acquireFence - a sync fence file descriptor as described above
2093 *
2094 * Returns HWC2_ERROR_NONE or one of the following errors:
2095 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2096 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
2097 */
2098typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
2099 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2100 buffer_handle_t buffer, int32_t acquireFence);
2101
2102/* setLayerSurfaceDamage(..., damage)
2103 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
2104 * Must be provided by all HWC2 devices
2105 *
2106 * Provides the region of the source buffer which has been modified since the
2107 * last frame. This region does not need to be validated before calling
2108 * presentDisplay.
2109 *
2110 * Once set through this function, the damage region remains the same until a
2111 * subsequent call to this function.
2112 *
2113 * If damage.numRects > 0, then it may be assumed that any portion of the source
2114 * buffer not covered by one of the rects has not been modified this frame. If
2115 * damage.numRects == 0, then the whole source buffer must be treated as if it
2116 * has been modified.
2117 *
2118 * If the layer's contents are not modified relative to the prior frame, damage
2119 * will contain exactly one empty rect([0, 0, 0, 0]).
2120 *
2121 * The damage rects are relative to the pre-transformed buffer, and their origin
2122 * is the top-left corner. They will not exceed the dimensions of the latched
2123 * buffer.
2124 *
2125 * Parameters:
2126 * damage - the new surface damage region
2127 *
2128 * Returns HWC2_ERROR_NONE or one of the following errors:
2129 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2130 */
2131typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
2132 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2133 hwc_region_t damage);
2134
Chia-I Wu28310aa2018-03-15 21:20:55 -07002135/* setLayerPerFrameMetadata(..., numMetadata, metadata)
2136 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
2137 * Optional for HWC2 devices
2138 *
2139 * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is
2140 * non-null), sets the metadata for the given display for all following
2141 * frames.
2142 *
2143 * Upon returning from this function, the metadata change must have
2144 * fully taken effect.
2145 *
2146 * This function will only be called if getPerFrameMetadataKeys is non-NULL
2147 * and returns at least one key.
2148 *
2149 * Parameters:
2150 * numElements is the number of elements in each of the keys and metadata arrays
2151 * keys is a pointer to the array of keys.
2152 * outMetadata is a pointer to the corresponding array of metadata.
2153 *
2154 * Returns HWC2_ERROR_NONE or one of the following errors:
2155 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2156 * HWC2_ERROR_BAD_PARAMETER - metadata is not valid
2157 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2158 */
2159typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)(
2160 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2161 uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
2162 const float* metadata);
2163
Dan Stoza4e9221b2015-09-02 15:43:39 -07002164/*
2165 * Layer State Functions
2166 *
2167 * These functions modify the state of a given layer. They do not take effect
2168 * until the display configuration is successfully validated with
2169 * validateDisplay and the display contents are presented with presentDisplay.
2170 *
2171 * All of these functions take as their first three parameters a device pointer,
2172 * a display handle for the display which contains the layer, and a layer
2173 * handle, so these parameters are omitted from the described parameter lists.
2174 */
2175
2176/* setLayerBlendMode(..., mode)
2177 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
2178 * Must be provided by all HWC2 devices
2179 *
2180 * Sets the blend mode of the given layer.
2181 *
2182 * Parameters:
2183 * mode - the new blend mode
2184 *
2185 * Returns HWC2_ERROR_NONE or one of the following errors:
2186 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2187 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
2188 */
2189typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
2190 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2191 int32_t /*hwc2_blend_mode_t*/ mode);
2192
2193/* setLayerColor(..., color)
2194 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
2195 * Must be provided by all HWC2 devices
2196 *
2197 * Sets the color of the given layer. If the composition type of the layer is
2198 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2199 * have no other effect.
2200 *
2201 * Parameters:
2202 * color - the new color
2203 *
2204 * Returns HWC2_ERROR_NONE or one of the following errors:
2205 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2206 */
2207typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
2208 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2209 hwc_color_t color);
2210
Peiyong Linfd05d132018-01-22 12:23:25 -08002211/* setLayerFloatColor(..., color)
2212 * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
2213 * Provided by HWC2 devices which don't return nullptr function pointer.
2214 *
2215 * Sets the color of the given layer. If the composition type of the layer is
2216 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2217 * have no other effect.
2218 *
2219 * Parameters:
2220 * color - the new color in float type, rage is [0.0, 1.0], the colorspace is
2221 * defined by the dataspace that gets set by calling setLayerDataspace.
2222 *
2223 * Returns HWC2_ERROR_NONE or one of the following errors:
2224 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2225 */
2226typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)(
2227 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2228 hwc_float_color_t color);
2229
Dan Stoza4e9221b2015-09-02 15:43:39 -07002230/* setLayerCompositionType(..., type)
2231 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
2232 * Must be provided by all HWC2 devices
2233 *
2234 * Sets the desired composition type of the given layer. During validateDisplay,
2235 * the device may request changes to the composition types of any of the layers
2236 * as described in the definition of hwc2_composition_t above.
2237 *
2238 * Parameters:
2239 * type - the new composition type
2240 *
2241 * Returns HWC2_ERROR_NONE or one of the following errors:
2242 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2243 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
2244 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
2245 * not supported by this device
2246 */
2247typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
2248 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2249 int32_t /*hwc2_composition_t*/ type);
2250
2251/* setLayerDataspace(..., dataspace)
2252 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
2253 * Must be provided by all HWC2 devices
2254 *
2255 * Sets the dataspace that the current buffer on this layer is in.
2256 *
2257 * The dataspace provides more information about how to interpret the buffer
2258 * contents, such as the encoding standard and color transform.
2259 *
2260 * See the values of android_dataspace_t in <system/graphics.h> for more
2261 * information.
2262 *
2263 * Parameters:
2264 * dataspace - the new dataspace
2265 *
2266 * Returns HWC2_ERROR_NONE or one of the following errors:
2267 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2268 */
2269typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
2270 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2271 int32_t /*android_dataspace_t*/ dataspace);
2272
2273/* setLayerDisplayFrame(..., frame)
2274 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
2275 * Must be provided by all HWC2 devices
2276 *
2277 * Sets the display frame (the portion of the display covered by a layer) of the
2278 * given layer. This frame will not exceed the display dimensions.
2279 *
2280 * Parameters:
2281 * frame - the new display frame
2282 *
2283 * Returns HWC2_ERROR_NONE or one of the following errors:
2284 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2285 */
2286typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
2287 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2288 hwc_rect_t frame);
2289
2290/* setLayerPlaneAlpha(..., alpha)
2291 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
2292 * Must be provided by all HWC2 devices
2293 *
2294 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
2295 * will be applied to the whole layer. It can be conceptualized as a
2296 * preprocessing step which applies the following function:
2297 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
2298 * out.rgb = in.rgb * planeAlpha
2299 * out.a = in.a * planeAlpha
2300 *
2301 * If the device does not support this operation on a layer which is marked
2302 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
2303 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
2304 *
2305 * Parameters:
2306 * alpha - the plane alpha value to apply
2307 *
2308 * Returns HWC2_ERROR_NONE or one of the following errors:
2309 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2310 */
2311typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
2312 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2313 float alpha);
2314
2315/* setLayerSidebandStream(..., stream)
2316 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
2317 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
2318 *
2319 * Sets the sideband stream for this layer. If the composition type of the given
2320 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
2321 * and have no other effect.
2322 *
2323 * Parameters:
2324 * stream - the new sideband stream
2325 *
2326 * Returns HWC2_ERROR_NONE or one of the following errors:
2327 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2328 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
2329 */
2330typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
2331 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2332 const native_handle_t* stream);
2333
2334/* setLayerSourceCrop(..., crop)
2335 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
2336 * Must be provided by all HWC2 devices
2337 *
2338 * Sets the source crop (the portion of the source buffer which will fill the
2339 * display frame) of the given layer. This crop rectangle will not exceed the
2340 * dimensions of the latched buffer.
2341 *
2342 * If the device is not capable of supporting a true float source crop (i.e., it
2343 * will truncate or round the floats to integers), it should set this layer to
2344 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
2345 * rendering.
2346 *
2347 * If the device cannot support float source crops, but still wants to handle
2348 * the layer, it should use the following code (or similar) to convert to
2349 * an integer crop:
2350 * intCrop.left = (int) ceilf(crop.left);
2351 * intCrop.top = (int) ceilf(crop.top);
2352 * intCrop.right = (int) floorf(crop.right);
2353 * intCrop.bottom = (int) floorf(crop.bottom);
2354 *
2355 * Parameters:
2356 * crop - the new source crop
2357 *
2358 * Returns HWC2_ERROR_NONE or one of the following errors:
2359 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2360 */
2361typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
2362 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2363 hwc_frect_t crop);
2364
2365/* setLayerTransform(..., transform)
2366 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
2367 * Must be provided by all HWC2 devices
2368 *
2369 * Sets the transform (rotation/flip) of the given layer.
2370 *
2371 * Parameters:
2372 * transform - the new transform
2373 *
2374 * Returns HWC2_ERROR_NONE or one of the following errors:
2375 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2376 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
2377 */
2378typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
2379 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2380 int32_t /*hwc_transform_t*/ transform);
2381
2382/* setLayerVisibleRegion(..., visible)
2383 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
2384 * Must be provided by all HWC2 devices
2385 *
2386 * Specifies the portion of the layer that is visible, including portions under
2387 * translucent areas of other layers. The region is in screen space, and will
2388 * not exceed the dimensions of the screen.
2389 *
2390 * Parameters:
2391 * visible - the new visible region, in screen space
2392 *
2393 * Returns HWC2_ERROR_NONE or one of the following errors:
2394 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2395 */
2396typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
2397 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2398 hwc_region_t visible);
2399
2400/* setLayerZOrder(..., z)
2401 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
2402 * Must be provided by all HWC2 devices
2403 *
2404 * Sets the desired Z order (height) of the given layer. A layer with a greater
2405 * Z value occludes a layer with a lesser Z value.
2406 *
2407 * Parameters:
2408 * z - the new Z order
2409 *
2410 * Returns HWC2_ERROR_NONE or one of the following errors:
2411 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2412 */
2413typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
2414 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2415 uint32_t z);
2416
Peiyong Lin44819b92018-09-13 16:20:08 -07002417/* setLayerColorTransform(..., matrix)
2418 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM
2419 * Optional by all HWC2 devices
2420 *
2421 * Sets a matrix for color transform which will be applied on this layer
2422 * before composition.
2423 *
2424 * If the device is not capable of apply the matrix on this layer, it must force
2425 * this layer to client composition during VALIDATE_DISPLAY.
2426 *
2427 * The matrix provided is an affine color transformation of the following form:
2428 *
2429 * |r.r r.g r.b 0|
2430 * |g.r g.g g.b 0|
2431 * |b.r b.g b.b 0|
2432 * |Tr Tg Tb 1|
2433 *
2434 * This matrix must be provided in row-major form:
2435 *
2436 * {r.r, r.g, r.b, 0, g.r, ...}.
2437 *
2438 * Given a matrix of this form and an input color [R_in, G_in, B_in],
2439 * the input color must first be converted to linear space
2440 * [R_linear, G_linear, B_linear], then the output linear color
2441 * [R_out_linear, G_out_linear, B_out_linear] will be:
2442 *
2443 * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
2444 * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
2445 * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
2446 *
2447 * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
2448 * gamma space: [R_out, G_out, B_out] before blending.
2449 *
2450 * Parameters:
2451 * matrix - a 4x4 transform matrix (16 floats) as described above
2452 *
2453 * Returns HWC2_ERROR_NONE or one of the following errors:
2454 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2455 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2456 */
2457typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR_TRANSFORM)(
2458 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2459 const float* matrix);
2460
Kevin DuBois13458872018-09-10 09:09:12 -07002461/* getDisplayedContentSamplingAttributes(...,
2462 * format, dataspace, supported_components, max_frames)
2463 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES
2464 * Optional by all HWC2 devices
2465 *
2466 * Query for what types of color sampling the hardware supports.
2467 *
2468 * Parameters:
2469 * format - The format of the sampled pixels; pointer will be non-NULL
2470 * dataspace - The dataspace of the sampled pixels; pointer will be non-NULL
2471 * supported_components - The mask of which components can be sampled; pointer
2472 * will be non-NULL
2473 *
2474 * Returns HWC2_ERROR_NONE or one of the following errors:
2475 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2476 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2477 */
2478typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES)(
2479 hwc2_device_t* device, hwc2_display_t display,
2480 int32_t* /* android_pixel_format_t */ format,
2481 int32_t* /* android_dataspace_t */ dataspace,
2482 uint8_t* /* mask of android_component_t */ supported_components);
2483
2484/* setDisplayedContentSamplingEnabled(..., enabled)
2485 * Descriptor: HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED
2486 * Optional by all HWC2 devices
2487 *
2488 * Enables or disables the collection of color content statistics
2489 * on this display.
2490 *
2491 * Sampling occurs on the contents of the final composition on this display
2492 * (i.e., the contents presented on screen).
2493 *
2494 * Sampling support is optional, and is set to DISABLE by default.
2495 * On each call to ENABLE, all collected statistics will be reset.
2496 *
2497 * Sample data can be queried via getDisplayedContentSample().
2498 *
2499 * Parameters:
2500 * enabled - indicates whether to enable or disable sampling.
2501 * component_mask - The mask of which components should be sampled.
2502 * If zero, all supported components are to be enabled.
2503 * max_frames - is the maximum number of frames that should be stored before
2504 * discard. The sample represents the most-recently posted frames.
2505 *
2506 * Returns HWC2_ERROR_NONE or one of the following errors:
2507 * HWC2_ERROR_BAD_DISPLAY when an invalid display handle was passed in,
2508 * HWC2_ERROR_BAD_PARAMETER when enabled was an invalid value, or
2509 * HWC2_ERROR_NO_RESOURCES when the requested ringbuffer size via max_frames
2510 * was not available.
2511 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2512 */
2513typedef int32_t (*HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED)(
2514 hwc2_device_t* device, hwc2_display_t display,
2515 int32_t /*hwc2_displayed_content_sampling_t*/ enabled,
2516 uint8_t /* mask of android_component_t */ component_mask,
2517 uint64_t max_frames);
2518
2519/* getDisplayedContentSample(..., component, max_frames, timestamp,
2520 * samples_size, samples, frame_count)
2521 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE
2522 * Optional by all HWC2 devices
2523 *
2524 * Collects the results of display content color sampling for display.
2525 *
2526 * Collection of data can occur whether the sampling is in ENABLE or
2527 * DISABLE state.
2528 *
2529 * Parameters:
2530 * max_frames - is the maximum number of frames that should be represented in
2531 * the sample. The sample represents the most-recently posted frames.
2532 * If max_frames is 0, all frames are to be represented by the sample.
2533 * timestamp - is the timestamp after which any frames were posted that should
2534 * be included in the sample. Timestamp is CLOCK_MONOTONIC.
2535 * If timestamp is 0, do not filter from the sample by time.
2536 * frame_count - The number of frames represented by this sample; pointer will
2537 * be non-NULL.
2538 * samples_size - The sizes of the color histogram representing the color
2539 * sampling. Sample_sizes are indexed in the same order as
2540 * HWC2_FORMAT_COMPONENT_.
2541 * samples - The arrays of data corresponding to the sampling data. Samples are
2542 * indexed in the same order as HWC2_FORMAT_COMPONENT_.
2543 * The size of each sample is the samples_size for the same index.
2544 * Each components sample is an array that is to be filled with the
2545 * evenly-weighted buckets of a histogram counting how many times a pixel
2546 * of the given component was displayed onscreen. Caller owns the data and
2547 * pointer may be NULL to query samples_size.
2548 *
2549 * Returns HWC2_ERROR_NONE or one of the following errors:
2550 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2551 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample, or
2552 * HWC2_ERROR_BAD_PARAMETER when the component is not supported by the hardware.
2553 */
2554typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE)(
2555 hwc2_device_t* device, hwc2_display_t display,
2556 uint64_t max_frames, uint64_t timestamp,
2557 uint64_t* frame_count, int32_t samples_size[4], uint64_t* samples[4]);
2558
Dan Stoza4e9221b2015-09-02 15:43:39 -07002559__END_DECLS
2560
2561#endif