blob: e545e24b3cb700a5a451d1b2b3c225f003b3ecc7 [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,
Ady Abrahamb1ea4032019-10-18 18:00:01 -070053
54 /* The configuration group this config is associated to.
55 * Switching between configurations within the same group may be done seamlessly
56 * in some conditions via setActiveConfigWithConstraints. */
57 HWC2_ATTRIBUTE_CONFIG_GROUP = 7,
Dan Stoza4e9221b2015-09-02 15:43:39 -070058} hwc2_attribute_t;
59
60/* Blend modes, settable per layer */
61typedef enum {
62 HWC2_BLEND_MODE_INVALID = 0,
63
64 /* colorOut = colorSrc */
65 HWC2_BLEND_MODE_NONE = 1,
66
67 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
68 HWC2_BLEND_MODE_PREMULTIPLIED = 2,
69
70 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
71 HWC2_BLEND_MODE_COVERAGE = 3,
72} hwc2_blend_mode_t;
73
74/* See the 'Callbacks' section for more detailed descriptions of what these
75 * functions do */
76typedef enum {
77 HWC2_CALLBACK_INVALID = 0,
78 HWC2_CALLBACK_HOTPLUG = 1,
79 HWC2_CALLBACK_REFRESH = 2,
80 HWC2_CALLBACK_VSYNC = 3,
Ady Abraham8324c922019-10-10 19:14:07 -070081 HWC2_CALLBACK_VSYNC_2_4 = 4,
Ady Abrahamb1ea4032019-10-18 18:00:01 -070082 HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED = 5,
Ady Abrahamc1b2f072019-12-30 12:56:54 -080083 HWC2_CALLBACK_SEAMLESS_POSSIBLE = 6,
Dan Stoza4e9221b2015-09-02 15:43:39 -070084} hwc2_callback_descriptor_t;
85
86/* Optional capabilities which may be supported by some devices. The particular
87 * set of supported capabilities for a given device may be retrieved using
88 * getCapabilities. */
89typedef enum {
90 HWC2_CAPABILITY_INVALID = 0,
91
92 /* Specifies that the device supports sideband stream layers, for which
93 * buffer content updates and other synchronization will not be provided
94 * through the usual validate/present cycle and must be handled by an
95 * external implementation-defined mechanism. Only changes to layer state
96 * (such as position, size, etc.) need to be performed through the
97 * validate/present cycle. */
98 HWC2_CAPABILITY_SIDEBAND_STREAM = 1,
Dan Stozad2168f72016-07-14 11:48:16 -070099
100 /* Specifies that the device will apply a color transform even when either
101 * the client or the device has chosen that all layers should be composed by
102 * the client. This will prevent the client from applying the color
103 * transform during its composition step. */
104 HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2,
Brian Anderson49018a52017-04-04 16:43:11 -0700105
106 /* Specifies that the present fence must not be used as an accurate
107 * representation of the actual present time of a frame.
108 * This capability must never be set by HWC2 devices.
109 * This capability may be set for HWC1 devices that use the
110 * HWC2On1Adapter where emulation of the present fence using the retire
111 * fence is not feasible.
112 * In the future, CTS tests will require present time to be reliable.
113 */
114 HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE = 3,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700115
116 /* Specifies that a device is able to skip the validateDisplay call before
117 * receiving a call to presentDisplay. The client will always skip
118 * validateDisplay and try to call presentDisplay regardless of the changes
119 * in the properties of the layers. If the device returns anything else than
120 * HWC2_ERROR_NONE, it will call validateDisplay then presentDisplay again.
121 * For this capability to be worthwhile the device implementation of
122 * presentDisplay should fail as fast as possible in the case a
123 * validateDisplay step is needed.
124 */
Peiyong Linfd05d132018-01-22 12:23:25 -0800125 HWC2_CAPABILITY_SKIP_VALIDATE = 4,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700126} hwc2_capability_t;
127
128/* Possible composition types for a given layer */
129typedef enum {
130 HWC2_COMPOSITION_INVALID = 0,
131
132 /* The client will composite this layer into the client target buffer
133 * (provided to the device through setClientTarget).
134 *
135 * The device must not request any composition type changes for layers of
136 * this type. */
137 HWC2_COMPOSITION_CLIENT = 1,
138
139 /* The device will handle the composition of this layer through a hardware
140 * overlay or other similar means.
141 *
142 * Upon validateDisplay, the device may request a change from this type to
143 * HWC2_COMPOSITION_CLIENT. */
144 HWC2_COMPOSITION_DEVICE = 2,
145
146 /* The device will render this layer using the color set through
147 * setLayerColor. If this functionality is not supported on a layer that the
148 * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
149 * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
150 * upon the next call to validateDisplay.
151 *
152 * Upon validateDisplay, the device may request a change from this type to
153 * HWC2_COMPOSITION_CLIENT. */
154 HWC2_COMPOSITION_SOLID_COLOR = 3,
155
156 /* Similar to DEVICE, but the position of this layer may also be set
157 * asynchronously through setCursorPosition. If this functionality is not
158 * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
159 * device must request that the composition type of that layer is changed to
160 * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
161 *
162 * Upon validateDisplay, the device may request a change from this type to
163 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
164 * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
165 * still permit the device to composite the layer. */
166 HWC2_COMPOSITION_CURSOR = 4,
167
168 /* The device will handle the composition of this layer, as well as its
169 * buffer updates and content synchronization. Only supported on devices
170 * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
171 *
172 * Upon validateDisplay, the device may request a change from this type to
173 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
174 * unlikely that content will display correctly in these cases. */
175 HWC2_COMPOSITION_SIDEBAND = 5,
176} hwc2_composition_t;
177
178/* Possible connection options from the hotplug callback */
179typedef enum {
180 HWC2_CONNECTION_INVALID = 0,
181
182 /* The display has been connected */
183 HWC2_CONNECTION_CONNECTED = 1,
184
185 /* The display has been disconnected */
186 HWC2_CONNECTION_DISCONNECTED = 2,
187} hwc2_connection_t;
188
189/* Display requests returned by getDisplayRequests */
190typedef enum {
191 /* Instructs the client to provide a new client target buffer, even if no
192 * layers are marked for client composition. */
193 HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
194
195 /* Instructs the client to write the result of client composition directly
196 * into the virtual display output buffer. If any of the layers are not
197 * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
198 * display, this request has no effect. */
199 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
200} hwc2_display_request_t;
201
202/* Display types returned by getDisplayType */
203typedef enum {
204 HWC2_DISPLAY_TYPE_INVALID = 0,
205
206 /* All physical displays, including both internal displays and hotpluggable
207 * external displays */
208 HWC2_DISPLAY_TYPE_PHYSICAL = 1,
209
210 /* Virtual displays created by createVirtualDisplay */
211 HWC2_DISPLAY_TYPE_VIRTUAL = 2,
212} hwc2_display_type_t;
213
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700214/* Physical display types returned by getDisplayConnectionType */
215typedef enum {
216 HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL = 0,
217 HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL = 1,
218} hwc2_display_connection_type_t;
219
Dan Stoza4e9221b2015-09-02 15:43:39 -0700220/* Return codes from all functions */
221typedef enum {
222 HWC2_ERROR_NONE = 0,
223 HWC2_ERROR_BAD_CONFIG,
224 HWC2_ERROR_BAD_DISPLAY,
225 HWC2_ERROR_BAD_LAYER,
226 HWC2_ERROR_BAD_PARAMETER,
227 HWC2_ERROR_HAS_CHANGES,
228 HWC2_ERROR_NO_RESOURCES,
229 HWC2_ERROR_NOT_VALIDATED,
230 HWC2_ERROR_UNSUPPORTED,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700231 HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
Ady Abraham8324c922019-10-10 19:14:07 -0700232 HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700233} hwc2_error_t;
234
235/* Function descriptors for use with getFunction */
236typedef enum {
237 HWC2_FUNCTION_INVALID = 0,
238 HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
239 HWC2_FUNCTION_CREATE_LAYER,
240 HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
241 HWC2_FUNCTION_DESTROY_LAYER,
242 HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
243 HWC2_FUNCTION_DUMP,
244 HWC2_FUNCTION_GET_ACTIVE_CONFIG,
245 HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
246 HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
247 HWC2_FUNCTION_GET_COLOR_MODES,
248 HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
249 HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
250 HWC2_FUNCTION_GET_DISPLAY_NAME,
251 HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
252 HWC2_FUNCTION_GET_DISPLAY_TYPE,
253 HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700254 HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700255 HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
256 HWC2_FUNCTION_GET_RELEASE_FENCES,
257 HWC2_FUNCTION_PRESENT_DISPLAY,
258 HWC2_FUNCTION_REGISTER_CALLBACK,
259 HWC2_FUNCTION_SET_ACTIVE_CONFIG,
260 HWC2_FUNCTION_SET_CLIENT_TARGET,
261 HWC2_FUNCTION_SET_COLOR_MODE,
262 HWC2_FUNCTION_SET_COLOR_TRANSFORM,
263 HWC2_FUNCTION_SET_CURSOR_POSITION,
264 HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
265 HWC2_FUNCTION_SET_LAYER_BUFFER,
266 HWC2_FUNCTION_SET_LAYER_COLOR,
267 HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
268 HWC2_FUNCTION_SET_LAYER_DATASPACE,
269 HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
270 HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
271 HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
272 HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
273 HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
274 HWC2_FUNCTION_SET_LAYER_TRANSFORM,
275 HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
276 HWC2_FUNCTION_SET_LAYER_Z_ORDER,
277 HWC2_FUNCTION_SET_OUTPUT_BUFFER,
278 HWC2_FUNCTION_SET_POWER_MODE,
279 HWC2_FUNCTION_SET_VSYNC_ENABLED,
280 HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800281 HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700282 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700283 HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
284 HWC2_FUNCTION_SET_READBACK_BUFFER,
285 HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700286 HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
287 HWC2_FUNCTION_GET_RENDER_INTENTS,
288 HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700289 HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700290
291 // composer 2.3
292 HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Peiyong Linf09421f2018-10-26 18:31:03 -0700293 HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
Peiyong Lin44819b92018-09-13 16:20:08 -0700294 HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700295 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
296 HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
297 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Valerie Hau69c53432018-11-13 09:07:44 -0800298 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
Dan Gittik10510ff2019-01-18 19:30:24 +0000299 HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
300 HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700301
302 // composer 2.4
303 HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
Ady Abraham8324c922019-10-10 19:14:07 -0700304 HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700305 HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
Galia Peycheva038dfb12019-11-06 22:59:52 +0100306 HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE,
307 HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES,
308 HWC2_FUNCTION_SET_CONTENT_TYPE,
Peiyong Linf7775422020-01-08 15:30:52 -0800309 HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700310} hwc2_function_descriptor_t;
311
Dan Stozaf601e972016-03-16 09:54:40 -0700312/* Layer requests returned from getDisplayRequests */
Dan Stoza4e9221b2015-09-02 15:43:39 -0700313typedef enum {
314 /* The client should clear its target with transparent pixels where this
315 * layer would be. The client may ignore this request if the layer must be
316 * blended. */
317 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
318} hwc2_layer_request_t;
319
320/* Power modes for use with setPowerMode */
321typedef enum {
322 /* The display is fully off (blanked) */
323 HWC2_POWER_MODE_OFF = 0,
324
325 /* These are optional low power modes. getDozeSupport may be called to
326 * determine whether a given display supports these modes. */
327
328 /* The display is turned on and configured in a low power state that is
329 * suitable for presenting ambient information to the user, possibly with
330 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
331 HWC2_POWER_MODE_DOZE = 1,
332
333 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
334 * applying display updates from the client. This is effectively a hint to
335 * the device that drawing to the display has been suspended and that the
336 * the device should remain on in a low power state and continue displaying
337 * its current contents indefinitely until the power mode changes.
338 *
339 * This mode may also be used as a signal to enable hardware-based doze
340 * functionality. In this case, the device is free to take over the display
341 * and manage it autonomously to implement a low power always-on display. */
342 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
343
344 /* The display is fully on */
345 HWC2_POWER_MODE_ON = 2,
346} hwc2_power_mode_t;
347
Galia Peycheva038dfb12019-11-06 22:59:52 +0100348typedef enum {
349 HWC2_CONTENT_TYPE_NONE = 0,
350 HWC2_CONTENT_TYPE_GRAPHICS = 1,
351 HWC2_CONTENT_TYPE_PHOTO = 2,
352 HWC2_CONTENT_TYPE_CINEMA = 3,
353 HWC2_CONTENT_TYPE_GAME = 4,
354} hwc2_content_type_t;
355
Dan Stoza4e9221b2015-09-02 15:43:39 -0700356/* Vsync values passed to setVsyncEnabled */
357typedef enum {
358 HWC2_VSYNC_INVALID = 0,
359
360 /* Enable vsync */
361 HWC2_VSYNC_ENABLE = 1,
362
363 /* Disable vsync */
364 HWC2_VSYNC_DISABLE = 2,
365} hwc2_vsync_t;
366
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700367/* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */
368typedef enum {
369 /* SMPTE ST 2084:2014.
370 * Coordinates defined in CIE 1931 xy chromaticity space
371 */
372 HWC2_DISPLAY_RED_PRIMARY_X = 0,
373 HWC2_DISPLAY_RED_PRIMARY_Y = 1,
374 HWC2_DISPLAY_GREEN_PRIMARY_X = 2,
375 HWC2_DISPLAY_GREEN_PRIMARY_Y = 3,
376 HWC2_DISPLAY_BLUE_PRIMARY_X = 4,
377 HWC2_DISPLAY_BLUE_PRIMARY_Y = 5,
378 HWC2_WHITE_POINT_X = 6,
379 HWC2_WHITE_POINT_Y = 7,
380 /* SMPTE ST 2084:2014.
381 * Units: nits
382 * max as defined by ST 2048: 10,000 nits
383 */
384 HWC2_MAX_LUMINANCE = 8,
385 HWC2_MIN_LUMINANCE = 9,
386
387 /* CTA 861.3
388 * Units: nits
389 */
390 HWC2_MAX_CONTENT_LIGHT_LEVEL = 10,
391 HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
392} hwc2_per_frame_metadata_key_t;
393
Kevin DuBois13458872018-09-10 09:09:12 -0700394/* SetDisplayedContentSampling values passed to setDisplayedContentSamplingEnabled */
395typedef enum {
396 HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID = 0,
397
398 /* Enable displayed content sampling */
399 HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE = 1,
400
401 /* Disable displayed content sampling */
402 HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE = 2,
403} hwc2_displayed_content_sampling_t;
404
405typedef enum {
406 HWC2_FORMAT_COMPONENT_0 = 1 << 0, /* The first component (eg, for RGBA_8888, this is R) */
407 HWC2_FORMAT_COMPONENT_1 = 1 << 1, /* The second component (eg, for RGBA_8888, this is G) */
408 HWC2_FORMAT_COMPONENT_2 = 1 << 2, /* The third component (eg, for RGBA_8888, this is B) */
409 HWC2_FORMAT_COMPONENT_3 = 1 << 3, /* The fourth component (eg, for RGBA_8888, this is A) */
410} hwc2_format_color_component_t;
411
Peiyong Linf09421f2018-10-26 18:31:03 -0700412/* Optional display capabilities which may be supported by some displays.
413 * The particular set of supported capabilities for a given display may be
414 * retrieved using getDisplayCapabilities. */
415typedef enum {
416 HWC2_DISPLAY_CAPABILITY_INVALID = 0,
417
418 /**
419 * Specifies that the display must apply a color transform even when either
420 * the client or the device has chosen that all layers should be composed by
421 * the client. This prevents the client from applying the color transform
422 * during its composition step.
423 * If getDisplayCapabilities is supported, the global capability
424 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is ignored.
425 * If getDisplayCapabilities is not supported, and the global capability
426 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
427 * then all displays must be treated as having
428 * HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM.
429 */
430 HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 1,
431
432 /**
433 * Specifies that the display supports PowerMode::DOZE and
434 * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
435 * over DOZE (see the definition of PowerMode for more information),
436 * but if both DOZE and DOZE_SUSPEND are no different from
437 * PowerMode::ON, the device must not claim support.
438 * HWC2_DISPLAY_CAPABILITY_DOZE must be returned by getDisplayCapabilities
439 * when getDozeSupport indicates the display supports PowerMode::DOZE and
440 * PowerMode::DOZE_SUSPEND.
441 */
442 HWC2_DISPLAY_CAPABILITY_DOZE = 2,
Dan Gittik10510ff2019-01-18 19:30:24 +0000443
444 /**
445 * Specified that the display supports brightness operations.
446 */
447 HWC2_DISPLAY_CAPABILITY_BRIGHTNESS = 3,
Galia Peycheva038dfb12019-11-06 22:59:52 +0100448
449 /**
450 * Specifies that the display supports a low latency mode. If the connection
451 * to the display is via HDMI, this specifies whether Auto Low Latency Mode
452 * is supported. If, instead, there is an internal connection to the display,
453 * then this specifies that the display has some other custom low latency
454 * mode.
455 */
456 HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE = 5,
Peiyong Linf09421f2018-10-26 18:31:03 -0700457} hwc2_display_capability_t;
458
Dan Stoza4e9221b2015-09-02 15:43:39 -0700459/*
460 * Stringification Functions
461 */
462
463#ifdef HWC2_INCLUDE_STRINGIFICATION
464
465static inline const char* getAttributeName(hwc2_attribute_t attribute) {
466 switch (attribute) {
467 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
468 case HWC2_ATTRIBUTE_WIDTH: return "Width";
469 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
470 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
471 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
472 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700473 case HWC2_ATTRIBUTE_CONFIG_GROUP: return "ConfigGroup";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700474 default: return "Unknown";
475 }
476}
477
478static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
479 switch (mode) {
480 case HWC2_BLEND_MODE_INVALID: return "Invalid";
481 case HWC2_BLEND_MODE_NONE: return "None";
482 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
483 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
484 default: return "Unknown";
485 }
486}
487
488static inline const char* getCallbackDescriptorName(
489 hwc2_callback_descriptor_t desc) {
490 switch (desc) {
491 case HWC2_CALLBACK_INVALID: return "Invalid";
492 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
493 case HWC2_CALLBACK_REFRESH: return "Refresh";
494 case HWC2_CALLBACK_VSYNC: return "Vsync";
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700495 case HWC2_CALLBACK_VSYNC_2_4: return "Vsync2.4";
496 case HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED: return "VsyncPeriodTimingChanged";
Ady Abrahamc1b2f072019-12-30 12:56:54 -0800497 case HWC2_CALLBACK_SEAMLESS_POSSIBLE: return "SeamlessPossible";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700498 default: return "Unknown";
499 }
500}
501
502static inline const char* getCapabilityName(hwc2_capability_t capability) {
503 switch (capability) {
504 case HWC2_CAPABILITY_INVALID: return "Invalid";
505 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
Dan Stozad2168f72016-07-14 11:48:16 -0700506 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
507 return "SkipClientColorTransform";
Brian Anderson49018a52017-04-04 16:43:11 -0700508 case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
509 return "PresentFenceIsNotReliable";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700510 default: return "Unknown";
511 }
512}
513
514static inline const char* getCompositionName(hwc2_composition_t composition) {
515 switch (composition) {
516 case HWC2_COMPOSITION_INVALID: return "Invalid";
517 case HWC2_COMPOSITION_CLIENT: return "Client";
518 case HWC2_COMPOSITION_DEVICE: return "Device";
519 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
520 case HWC2_COMPOSITION_CURSOR: return "Cursor";
521 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
522 default: return "Unknown";
523 }
524}
525
526static inline const char* getConnectionName(hwc2_connection_t connection) {
527 switch (connection) {
528 case HWC2_CONNECTION_INVALID: return "Invalid";
529 case HWC2_CONNECTION_CONNECTED: return "Connected";
530 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
531 default: return "Unknown";
532 }
533}
534
535static inline const char* getDisplayRequestName(
536 hwc2_display_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700537 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700538 case 0: return "None";
539 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
540 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
541 return "WriteClientTargetToOutput";
542 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
543 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
544 return "FlipClientTarget|WriteClientTargetToOutput";
545 default: return "Unknown";
546 }
547}
548
549static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
550 switch (type) {
551 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
552 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
553 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
554 default: return "Unknown";
555 }
556}
557
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700558static inline const char* getDisplayConnectionTypeName(hwc2_display_connection_type_t type) {
559 switch (type) {
560 case HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL: return "Internal";
561 case HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL: return "External";
562 default: return "Unknown";
563 }
564}
565
Dan Stoza4e9221b2015-09-02 15:43:39 -0700566static inline const char* getErrorName(hwc2_error_t error) {
567 switch (error) {
568 case HWC2_ERROR_NONE: return "None";
569 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
570 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
571 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
572 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
573 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
574 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
575 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
576 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700577 case HWC2_ERROR_SEAMLESS_NOT_ALLOWED: return "SeamlessNotAllowed";
Ady Abraham8324c922019-10-10 19:14:07 -0700578 case HWC2_ERROR_SEAMLESS_NOT_POSSIBLE: return "SeamlessNotPossible";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700579 default: return "Unknown";
580 }
581}
582
583static inline const char* getFunctionDescriptorName(
584 hwc2_function_descriptor_t desc) {
585 switch (desc) {
586 case HWC2_FUNCTION_INVALID: return "Invalid";
587 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
588 return "AcceptDisplayChanges";
589 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
590 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
591 return "CreateVirtualDisplay";
592 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
593 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
594 return "DestroyVirtualDisplay";
595 case HWC2_FUNCTION_DUMP: return "Dump";
596 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
597 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
598 return "GetChangedCompositionTypes";
599 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
600 return "GetClientTargetSupport";
601 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
602 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
603 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
604 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
605 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
606 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
607 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
Dan Stozaf601e972016-03-16 09:54:40 -0700608 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700609 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
610 return "GetMaxVirtualDisplayCount";
611 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
612 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
613 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
614 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
615 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
616 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
617 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
618 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
619 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
620 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
621 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
622 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
623 return "SetLayerCompositionType";
624 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
625 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
626 return "SetLayerDisplayFrame";
627 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
628 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
629 return "SetLayerSidebandStream";
630 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
631 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
632 return "SetLayerSurfaceDamage";
633 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
634 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
635 return "SetLayerVisibleRegion";
636 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
637 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
638 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
639 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
640 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
Peiyong Linfd05d132018-01-22 12:23:25 -0800641 case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700642 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata";
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700643 case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys";
644 case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer";
645 case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes";
646 case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700647 case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents";
648 case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent";
649 case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix";
Peiyong Lin44819b92018-09-13 16:20:08 -0700650
651 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700652 case HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA: return "GetDisplayIdentificationData";
Peiyong Linf09421f2018-10-26 18:31:03 -0700653 case HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES: return "GetDisplayCapabilities";
Peiyong Lin44819b92018-09-13 16:20:08 -0700654 case HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM: return "SetLayerColorTransform";
Kevin DuBois13458872018-09-10 09:09:12 -0700655 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: return "GetDisplayedContentSamplingAttributes";
656 case HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED: return "SetDisplayedContentSamplingEnabled";
657 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE: return "GetDisplayedContentSample";
Valerie Hau69c53432018-11-13 09:07:44 -0800658 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS: return "SetLayerPerFrameMetadataBlobs";
Dan Gittik10510ff2019-01-18 19:30:24 +0000659 case HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT: return "GetDisplayBrightnessSupport";
660 case HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS: return "SetDisplayBrightness";
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700661
662 // composer 2.4
663 case HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE: return "GetDisplayConnectionType";
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700664 case HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD: return "GetDisplayVsyncPeriod";
665 case HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS: return "SetActiveConfigWithConstraints";
Galia Peycheva038dfb12019-11-06 22:59:52 +0100666 case HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE: return "SetAutoLowLatencyMode";
667 case HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES: return "GetSupportedContentTypes";
668 case HWC2_FUNCTION_SET_CONTENT_TYPE: return "SetContentType";
Peiyong Linf7775422020-01-08 15:30:52 -0800669 case HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY: return "GetClientTargetProperty";
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700670
Dan Stoza4e9221b2015-09-02 15:43:39 -0700671 default: return "Unknown";
672 }
673}
674
675static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700676 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700677 case 0: return "None";
678 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
679 default: return "Unknown";
680 }
681}
682
683static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
684 switch (mode) {
685 case HWC2_POWER_MODE_OFF: return "Off";
686 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
687 case HWC2_POWER_MODE_DOZE: return "Doze";
688 case HWC2_POWER_MODE_ON: return "On";
689 default: return "Unknown";
690 }
691}
692
Galia Peycheva038dfb12019-11-06 22:59:52 +0100693static inline const char* getContentTypeName(hwc2_content_type_t contentType) {
694 switch(contentType) {
695 case HWC2_CONTENT_TYPE_NONE: return "None";
696 case HWC2_CONTENT_TYPE_GRAPHICS: return "Graphics";
697 case HWC2_CONTENT_TYPE_PHOTO: return "Photo";
698 case HWC2_CONTENT_TYPE_CINEMA: return "Cinema";
699 case HWC2_CONTENT_TYPE_GAME: return "Game";
700 default: return "Unknown";
701 }
702}
703
Dan Stoza4e9221b2015-09-02 15:43:39 -0700704static inline const char* getTransformName(hwc_transform_t transform) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700705 switch (__BIONIC_CAST(static_cast, int, transform)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700706 case 0: return "None";
707 case HWC_TRANSFORM_FLIP_H: return "FlipH";
708 case HWC_TRANSFORM_FLIP_V: return "FlipV";
709 case HWC_TRANSFORM_ROT_90: return "Rotate90";
710 case HWC_TRANSFORM_ROT_180: return "Rotate180";
711 case HWC_TRANSFORM_ROT_270: return "Rotate270";
712 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
713 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
714 default: return "Unknown";
715 }
716}
717
718static inline const char* getVsyncName(hwc2_vsync_t vsync) {
719 switch (vsync) {
720 case HWC2_VSYNC_INVALID: return "Invalid";
721 case HWC2_VSYNC_ENABLE: return "Enable";
722 case HWC2_VSYNC_DISABLE: return "Disable";
723 default: return "Unknown";
724 }
725}
726
Kevin DuBois13458872018-09-10 09:09:12 -0700727static inline const char* getDisplayedContentSamplingName(
728 hwc2_displayed_content_sampling_t sampling) {
729 switch (sampling) {
730 case HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID: return "Invalid";
731 case HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE: return "Enable";
732 case HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE: return "Disable";
733 default: return "Unknown";
734 }
735}
736
737static inline const char* getFormatColorComponentName(hwc2_format_color_component_t component) {
738 switch (component) {
739 case HWC2_FORMAT_COMPONENT_0: return "FirstComponent";
740 case HWC2_FORMAT_COMPONENT_1: return "SecondComponent";
741 case HWC2_FORMAT_COMPONENT_2: return "ThirdComponent";
742 case HWC2_FORMAT_COMPONENT_3: return "FourthComponent";
743 default: return "Unknown";
744 }
745}
746
Peiyong Linf09421f2018-10-26 18:31:03 -0700747static inline const char* getDisplayCapabilityName(hwc2_display_capability_t capability) {
748 switch (capability) {
749 case HWC2_DISPLAY_CAPABILITY_INVALID: return "Invalid";
750 case HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
751 return "SkipClientColorTransform";
752 case HWC2_DISPLAY_CAPABILITY_DOZE:
753 return "Doze";
Dan Gittik10510ff2019-01-18 19:30:24 +0000754 case HWC2_DISPLAY_CAPABILITY_BRIGHTNESS:
755 return "Brightness";
Galia Peycheva038dfb12019-11-06 22:59:52 +0100756 case HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE:
757 return "AutoLowLatencyMode";
Peiyong Linf09421f2018-10-26 18:31:03 -0700758 default:
759 return "Unknown";
760 }
761}
762
Dan Stoza4e9221b2015-09-02 15:43:39 -0700763#define TO_STRING(E, T, printer) \
764 inline std::string to_string(E value) { return printer(value); } \
765 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
766#else // !HWC2_INCLUDE_STRINGIFICATION
767#define TO_STRING(name, printer)
768#endif // HWC2_INCLUDE_STRINGIFICATION
769
770/*
771 * C++11 features
772 */
773
774#ifdef HWC2_USE_CPP11
775__END_DECLS
776
777#ifdef HWC2_INCLUDE_STRINGIFICATION
778#include <string>
779#endif
780
781namespace HWC2 {
782
783enum class Attribute : int32_t {
784 Invalid = HWC2_ATTRIBUTE_INVALID,
785 Width = HWC2_ATTRIBUTE_WIDTH,
786 Height = HWC2_ATTRIBUTE_HEIGHT,
787 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
788 DpiX = HWC2_ATTRIBUTE_DPI_X,
789 DpiY = HWC2_ATTRIBUTE_DPI_Y,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700790 ConfigGroup = HWC2_ATTRIBUTE_CONFIG_GROUP,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700791};
792TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
793
794enum class BlendMode : int32_t {
795 Invalid = HWC2_BLEND_MODE_INVALID,
796 None = HWC2_BLEND_MODE_NONE,
797 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
798 Coverage = HWC2_BLEND_MODE_COVERAGE,
799};
800TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
801
802enum class Callback : int32_t {
803 Invalid = HWC2_CALLBACK_INVALID,
804 Hotplug = HWC2_CALLBACK_HOTPLUG,
805 Refresh = HWC2_CALLBACK_REFRESH,
806 Vsync = HWC2_CALLBACK_VSYNC,
Ady Abraham8324c922019-10-10 19:14:07 -0700807 Vsync_2_4 = HWC2_CALLBACK_VSYNC_2_4,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700808 VsyncPeriodTimingChanged = HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED,
Ady Abrahamc1b2f072019-12-30 12:56:54 -0800809 SeamlessPossible = HWC2_CALLBACK_SEAMLESS_POSSIBLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700810};
811TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
812
813enum class Capability : int32_t {
814 Invalid = HWC2_CAPABILITY_INVALID,
815 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
Dan Stozad2168f72016-07-14 11:48:16 -0700816 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
Brian Anderson49018a52017-04-04 16:43:11 -0700817 PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700818 SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700819};
820TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
821
822enum class Composition : int32_t {
823 Invalid = HWC2_COMPOSITION_INVALID,
824 Client = HWC2_COMPOSITION_CLIENT,
825 Device = HWC2_COMPOSITION_DEVICE,
826 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
827 Cursor = HWC2_COMPOSITION_CURSOR,
828 Sideband = HWC2_COMPOSITION_SIDEBAND,
829};
830TO_STRING(hwc2_composition_t, Composition, getCompositionName)
831
832enum class Connection : int32_t {
833 Invalid = HWC2_CONNECTION_INVALID,
834 Connected = HWC2_CONNECTION_CONNECTED,
835 Disconnected = HWC2_CONNECTION_DISCONNECTED,
836};
837TO_STRING(hwc2_connection_t, Connection, getConnectionName)
838
839enum class DisplayRequest : int32_t {
840 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
841 WriteClientTargetToOutput =
842 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
843};
844TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
845
846enum class DisplayType : int32_t {
847 Invalid = HWC2_DISPLAY_TYPE_INVALID,
848 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
849 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
850};
851TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
852
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700853enum class DisplayConnectionType : uint32_t {
854 Internal = HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL,
855 External = HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL,
856};
857TO_STRING(hwc2_display_connection_type_t, DisplayConnectionType, getDisplayConnectionTypeName)
858
Dan Stoza4e9221b2015-09-02 15:43:39 -0700859enum class Error : int32_t {
860 None = HWC2_ERROR_NONE,
861 BadConfig = HWC2_ERROR_BAD_CONFIG,
862 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
863 BadLayer = HWC2_ERROR_BAD_LAYER,
864 BadParameter = HWC2_ERROR_BAD_PARAMETER,
865 HasChanges = HWC2_ERROR_HAS_CHANGES,
866 NoResources = HWC2_ERROR_NO_RESOURCES,
867 NotValidated = HWC2_ERROR_NOT_VALIDATED,
868 Unsupported = HWC2_ERROR_UNSUPPORTED,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700869 SeamlessNotAllowed = HWC2_ERROR_SEAMLESS_NOT_ALLOWED,
Ady Abraham8324c922019-10-10 19:14:07 -0700870 SeamlessNotPossible = HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700871};
872TO_STRING(hwc2_error_t, Error, getErrorName)
873
874enum class FunctionDescriptor : int32_t {
875 Invalid = HWC2_FUNCTION_INVALID,
876 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
877 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
878 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
879 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
880 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
881 Dump = HWC2_FUNCTION_DUMP,
882 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
883 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
884 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
885 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
886 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
887 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
888 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
889 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
890 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
891 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700892 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700893 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
894 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
895 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
896 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
897 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
898 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
899 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
900 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
901 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
902 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
903 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
904 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
905 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
906 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
907 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
908 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
909 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
910 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
911 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
912 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
913 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
914 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
915 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
916 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
917 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
918 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800919 SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700920 SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700921 GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
922 SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER,
923 GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
924 GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700925 GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS,
926 SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
927 GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700928
929 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700930 GetDisplayIdentificationData = HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Peiyong Linf09421f2018-10-26 18:31:03 -0700931 GetDisplayCapabilities = HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
Peiyong Lin44819b92018-09-13 16:20:08 -0700932 SetLayerColorTransform = HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700933 GetDisplayedContentSamplingAttributes = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
934 SetDisplayedContentSamplingEnabled = HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
935 GetDisplayedContentSample = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Valerie Hau69c53432018-11-13 09:07:44 -0800936 SetLayerPerFrameMetadataBlobs = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
Dan Gittik10510ff2019-01-18 19:30:24 +0000937 GetDisplayBrightnessSupport = HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
938 SetDisplayBrightness = HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700939
940 // composer 2.4
941 GetDisplayConnectionType = HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
Ady Abrahamb1ea4032019-10-18 18:00:01 -0700942 GetDisplayVsyncPeriod = HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
943 SetActiveConfigWithConstraints = HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS,
Galia Peycheva038dfb12019-11-06 22:59:52 +0100944 SetAutoLowLatencyMode = HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE,
945 GetSupportedContentTypes = HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES,
946 SetContentType = HWC2_FUNCTION_SET_CONTENT_TYPE,
Peiyong Linf7775422020-01-08 15:30:52 -0800947 GetClientTargetProperty = HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700948};
949TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
950 getFunctionDescriptorName)
951
952enum class LayerRequest : int32_t {
953 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
954};
955TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
956
957enum class PowerMode : int32_t {
958 Off = HWC2_POWER_MODE_OFF,
959 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
960 Doze = HWC2_POWER_MODE_DOZE,
961 On = HWC2_POWER_MODE_ON,
962};
963TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
964
Galia Peycheva038dfb12019-11-06 22:59:52 +0100965enum class ContentType : int32_t {
966 None = HWC2_CONTENT_TYPE_NONE,
967 Graphics = HWC2_CONTENT_TYPE_GRAPHICS,
968 Photo = HWC2_CONTENT_TYPE_PHOTO,
969 Cinema = HWC2_CONTENT_TYPE_CINEMA,
970 Game = HWC2_CONTENT_TYPE_GAME,
971};
972TO_STRING(hwc2_content_type_t, ContentType, getContentTypeName)
973
Dan Stoza4e9221b2015-09-02 15:43:39 -0700974enum class Transform : int32_t {
975 None = 0,
976 FlipH = HWC_TRANSFORM_FLIP_H,
977 FlipV = HWC_TRANSFORM_FLIP_V,
978 Rotate90 = HWC_TRANSFORM_ROT_90,
979 Rotate180 = HWC_TRANSFORM_ROT_180,
980 Rotate270 = HWC_TRANSFORM_ROT_270,
981 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
982 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
983};
984TO_STRING(hwc_transform_t, Transform, getTransformName)
985
986enum class Vsync : int32_t {
987 Invalid = HWC2_VSYNC_INVALID,
988 Enable = HWC2_VSYNC_ENABLE,
989 Disable = HWC2_VSYNC_DISABLE,
990};
991TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
992
Peiyong Linf09421f2018-10-26 18:31:03 -0700993enum class DisplayCapability : int32_t {
994 Invalid = HWC2_DISPLAY_CAPABILITY_INVALID,
995 SkipClientColorTransform = HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
996 Doze = HWC2_DISPLAY_CAPABILITY_DOZE,
Dan Gittik10510ff2019-01-18 19:30:24 +0000997 Brightness = HWC2_DISPLAY_CAPABILITY_BRIGHTNESS,
Galia Peycheva038dfb12019-11-06 22:59:52 +0100998 AutoLowLatencyMode = HWC2_DISPLAY_CAPABILITY_AUTO_LOW_LATENCY_MODE,
Peiyong Linf09421f2018-10-26 18:31:03 -0700999};
1000TO_STRING(hwc2_display_capability_t, DisplayCapability, getDisplayCapabilityName)
1001
Dan Stoza4e9221b2015-09-02 15:43:39 -07001002} // namespace HWC2
1003
1004__BEGIN_DECLS
1005#endif // HWC2_USE_CPP11
1006
1007/*
1008 * Typedefs
1009 */
1010
1011typedef void (*hwc2_function_pointer_t)();
1012
1013typedef void* hwc2_callback_data_t;
1014typedef uint32_t hwc2_config_t;
1015typedef uint64_t hwc2_display_t;
1016typedef uint64_t hwc2_layer_t;
Ady Abraham8324c922019-10-10 19:14:07 -07001017typedef uint32_t hwc2_vsync_period_t;
Dan Stoza4e9221b2015-09-02 15:43:39 -07001018
1019/*
1020 * Device Struct
1021 */
1022
1023typedef struct hwc2_device {
1024 /* Must be the first member of this struct, since a pointer to this struct
1025 * will be generated by casting from a hw_device_t* */
1026 struct hw_device_t common;
1027
1028 /* getCapabilities(..., outCount, outCapabilities)
1029 *
1030 * Provides a list of capabilities (described in the definition of
1031 * hwc2_capability_t above) supported by this device. This list must
1032 * not change after the device has been loaded.
1033 *
1034 * Parameters:
1035 * outCount - if outCapabilities was NULL, the number of capabilities
1036 * which would have been returned; if outCapabilities was not NULL,
1037 * the number of capabilities returned, which must not exceed the
1038 * value stored in outCount prior to the call
1039 * outCapabilities - a list of capabilities supported by this device; may
1040 * be NULL, in which case this function must write into outCount the
1041 * number of capabilities which would have been written into
1042 * outCapabilities
1043 */
1044 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
1045 int32_t* /*hwc2_capability_t*/ outCapabilities);
1046
1047 /* getFunction(..., descriptor)
1048 *
1049 * Returns a function pointer which implements the requested description.
1050 *
1051 * Parameters:
1052 * descriptor - the function to return
1053 *
1054 * Returns either a function pointer implementing the requested descriptor
1055 * or NULL if the described function is not supported by this device.
1056 */
1057 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
1058 int32_t /*hwc2_function_descriptor_t*/ descriptor);
1059} hwc2_device_t;
1060
1061static inline int hwc2_open(const struct hw_module_t* module,
1062 hwc2_device_t** device) {
1063 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
Colin Crosscc8d9f92016-10-06 16:44:23 -07001064 TO_HW_DEVICE_T_OPEN(device));
Dan Stoza4e9221b2015-09-02 15:43:39 -07001065}
1066
1067static inline int hwc2_close(hwc2_device_t* device) {
1068 return device->common.close(&device->common);
1069}
1070
1071/*
1072 * Callbacks
1073 *
1074 * All of these callbacks take as their first parameter the callbackData which
1075 * was provided at the time of callback registration, so this parameter is
1076 * omitted from the described parameter lists.
1077 */
1078
1079/* hotplug(..., display, connected)
1080 * Descriptor: HWC2_CALLBACK_HOTPLUG
1081 * Will be provided to all HWC2 devices
1082 *
1083 * Notifies the client that the given display has either been connected or
1084 * disconnected. Every active display (even a built-in physical display) must
1085 * trigger at least one hotplug notification, even if it only occurs immediately
1086 * after callback registration.
1087 *
1088 * The client may call back into the device on the same thread to query display
1089 * properties (such as width, height, and vsync period), and other threads may
1090 * call into the device while the callback is in progress. The device must
1091 * serialize calls to this callback such that only one thread is calling it at a
1092 * time.
1093 *
1094 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
1095 * and the vsync callback should not be called for a display until vsync has
1096 * been enabled with setVsyncEnabled.
1097 *
1098 * Parameters:
1099 * display - the display which has been hotplugged
1100 * connected - whether the display has been connected or disconnected
1101 */
1102typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
1103 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
1104
1105/* refresh(..., display)
1106 * Descriptor: HWC2_CALLBACK_REFRESH
1107 * Will be provided to all HWC2 devices
1108 *
1109 * Notifies the client to trigger a screen refresh. This forces all layer state
1110 * for this display to be resent, and the display to be validated and presented,
1111 * even if there have been no changes.
1112 *
1113 * This refresh will occur some time after the callback is initiated, but not
1114 * necessarily before it returns. This thread, however, is guaranteed not to
1115 * call back into the device, thus it is safe to trigger this callback from
1116 * other functions which call into the device.
1117 *
1118 * Parameters:
1119 * display - the display to refresh
1120 */
1121typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
1122 hwc2_display_t display);
1123
1124/* vsync(..., display, timestamp)
1125 * Descriptor: HWC2_CALLBACK_VSYNC
1126 * Will be provided to all HWC2 devices
1127 *
1128 * Notifies the client that a vsync event has occurred. This callback must
1129 * only be triggered when vsync is enabled for this display (through
1130 * setVsyncEnabled).
1131 *
1132 * This callback should be triggered from a thread of at least
1133 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1134 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1135 *
1136 * Parameters:
1137 * display - the display which has received a vsync event
1138 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1139 * nanoseconds
1140 */
1141typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
1142 hwc2_display_t display, int64_t timestamp);
1143
Ady Abraham8324c922019-10-10 19:14:07 -07001144/* vsync_2_4(..., display, timestamp, vsyncPeriodNanos)
1145 * Descriptor: HWC2_CALLBACK_VSYNC_2_4
1146 * Required for HWC2 devices for composer 2.4
1147 *
1148 * Notifies the client that a vsync event has occurred. This callback must
1149 * only be triggered when vsync is enabled for this display (through
1150 * setVsyncEnabled).
1151 *
1152 * This callback should be triggered from a thread of at least
1153 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1154 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1155 *
1156 * Parameters:
1157 * display - the display which has received a vsync event
1158 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1159 * nanoseconds
1160 * vsyncPeriodNanos - the display vsync period in nanoseconds i.e. the next onVsync2_4 is
1161 * expected to be called vsyncPeriod nanoseconds after this call.
1162 */
1163typedef void (*HWC2_PFN_VSYNC_2_4)(hwc2_callback_data_t callbackData,
1164 hwc2_display_t display, int64_t timestamp, hwc2_vsync_period_t vsyncPeriodNanos);
1165
Ady Abrahamb1ea4032019-10-18 18:00:01 -07001166/* vsyncPeriodTimingChanged(..., display, updated_timeline)
1167 * Descriptor: HWC2_CALLBACK_VSYNC_PERIOD_TIMING_CHANGED
1168 * Optional for HWC2 devices for composer 2.4
1169 *
1170 * Notifies the client that the previously reported timing for vsync period change has been
1171 * updated. This may occur if the composer missed the deadline for changing the vsync period
1172 * or the client submitted a refresh frame too late.
1173 *
1174 * This callback should be triggered from a thread of at least
1175 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1176 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1177 *
1178 * Parameters:
1179 * display - the display which has received a vsync event
1180 * updated_timeline - new timeline for the vsync period change
1181 */
1182typedef void (*HWC2_PFN_VSYNC_PERIOD_TIMING_CHANGED)(hwc2_callback_data_t callbackData,
1183 hwc2_display_t display, hwc_vsync_period_change_timeline_t* updated_timeline);
1184
Ady Abrahamc1b2f072019-12-30 12:56:54 -08001185/* SeamlessPossible(..., display)
1186 * Descriptor: HWC2_CALLBACK_SEAMLESS_POSSIBLE
1187 * Optional for HWC2 devices for composer 2.4
1188 *
1189 * Notifies the client that the conditions which previously led to returning SEAMLESS_NOT_POSSIBLE
1190 * from setActiveConfigWithConstraints have changed and now seamless may be possible. Client should
1191 * retry calling setActiveConfigWithConstraints.
1192 *
1193 *
1194 * Parameters:
1195 * display - a display setActiveConfigWithConstraints previously failed with
1196 * SEAMLESS_NOT_POSSIBLE.
1197 */
1198typedef void (*HWC2_PFN_SEAMLESS_POSSIBLE)(hwc2_callback_data_t callbackData,
1199 hwc2_display_t display);
1200
Dan Stoza4e9221b2015-09-02 15:43:39 -07001201/*
1202 * Device Functions
1203 *
1204 * All of these functions take as their first parameter a device pointer, so
1205 * this parameter is omitted from the described parameter lists.
1206 */
1207
Dan Stoza68cd3752016-05-20 13:30:42 -07001208/* createVirtualDisplay(..., width, height, format, outDisplay)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001209 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
1210 * Must be provided by all HWC2 devices
1211 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001212 * Creates a new virtual display with the given width and height. The format
1213 * passed into this function is the default format requested by the consumer of
1214 * the virtual display output buffers. If a different format will be returned by
1215 * the device, it should be returned in this parameter so it can be set properly
1216 * when handing the buffers to the consumer.
1217 *
1218 * The display will be assumed to be on from the time the first frame is
1219 * presented until the display is destroyed.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001220 *
1221 * Parameters:
1222 * width - width in pixels
1223 * height - height in pixels
Dan Stoza68cd3752016-05-20 13:30:42 -07001224 * format - prior to the call, the default output buffer format selected by
1225 * the consumer; after the call, the format the device will produce
Dan Stoza4e9221b2015-09-02 15:43:39 -07001226 * outDisplay - the newly-created virtual display; pointer will be non-NULL
1227 *
1228 * Returns HWC2_ERROR_NONE or one of the following errors:
1229 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
1230 * be able to create a virtual display
1231 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
1232 * display at this time
1233 */
1234typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
1235 hwc2_device_t* device, uint32_t width, uint32_t height,
Dan Stoza68cd3752016-05-20 13:30:42 -07001236 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001237
1238/* destroyVirtualDisplay(..., display)
1239 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
1240 * Must be provided by all HWC2 devices
1241 *
1242 * Destroys a virtual display. After this call all resources consumed by this
1243 * display may be freed by the device and any operations performed on this
1244 * display should fail.
1245 *
1246 * Parameters:
1247 * display - the virtual display to destroy
1248 *
1249 * Returns HWC2_ERROR_NONE or one of the following errors:
1250 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1251 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
1252 * refer to a virtual display
1253 */
1254typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
1255 hwc2_device_t* device, hwc2_display_t display);
1256
1257/* dump(..., outSize, outBuffer)
1258 * Descriptor: HWC2_FUNCTION_DUMP
1259 * Must be provided by all HWC2 devices
1260 *
1261 * Retrieves implementation-defined debug information, which will be displayed
1262 * during, for example, `dumpsys SurfaceFlinger`.
1263 *
1264 * If called with outBuffer == NULL, the device should store a copy of the
1265 * desired output and return its length in bytes in outSize. If the device
1266 * already has a stored copy, that copy should be purged and replaced with a
1267 * fresh copy.
1268 *
1269 * If called with outBuffer != NULL, the device should copy its stored version
1270 * of the output into outBuffer and store how many bytes of data it copied into
1271 * outSize. Prior to this call, the client will have populated outSize with the
1272 * maximum number of bytes outBuffer can hold. The device must not write more
1273 * than this amount into outBuffer. If the device does not currently have a
1274 * stored copy, then it should return 0 in outSize.
1275 *
1276 * Any data written into outBuffer need not be null-terminated.
1277 *
1278 * Parameters:
1279 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
1280 * device's stored output; if outBuffer was not NULL, the number of bytes
1281 * written into it, which must not exceed the value stored in outSize
1282 * prior to the call; pointer will be non-NULL
1283 * outBuffer - the buffer to write the dump output into; may be NULL as
1284 * described above; data written into this buffer need not be
1285 * null-terminated
1286 */
1287typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
1288 char* outBuffer);
1289
1290/* getMaxVirtualDisplayCount(...)
1291 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
1292 * Must be provided by all HWC2 devices
1293 *
1294 * Returns the maximum number of virtual displays supported by this device
1295 * (which may be 0). The client will not attempt to create more than this many
1296 * virtual displays on this device. This number must not change for the lifetime
1297 * of the device.
1298 */
1299typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
1300 hwc2_device_t* device);
1301
1302/* registerCallback(..., descriptor, callbackData, pointer)
1303 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
1304 * Must be provided by all HWC2 devices
1305 *
1306 * Provides a callback for the device to call. All callbacks take a callbackData
1307 * item as the first parameter, so this value should be stored with the callback
1308 * for later use. The callbackData may differ from one callback to another. If
1309 * this function is called multiple times with the same descriptor, later
1310 * callbacks replace earlier ones.
1311 *
1312 * Parameters:
1313 * descriptor - which callback should be set
1314 * callBackdata - opaque data which must be passed back through the callback
1315 * pointer - a non-NULL function pointer corresponding to the descriptor
1316 *
1317 * Returns HWC2_ERROR_NONE or one of the following errors:
1318 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
1319 */
1320typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
1321 hwc2_device_t* device,
1322 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
1323 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
1324
Chia-I Wu28310aa2018-03-15 21:20:55 -07001325/* getDataspaceSaturationMatrix(..., dataspace, outMatrix)
1326 * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
1327 * Provided by HWC2 devices which don't return nullptr function pointer.
1328 *
1329 * Get the saturation matrix of the specified dataspace. The saturation matrix
1330 * can be used to approximate the dataspace saturation operation performed by
1331 * the HWC2 device when non-colorimetric mapping is allowed. It is to be
1332 * applied on linear pixel values.
1333 *
1334 * Parameters:
1335 * dataspace - the dataspace to query for
1336 * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity
1337 * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR.
1338 *
1339 * Returns HWC2_ERROR_NONE or one of the following errors:
1340 * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid
1341 */
1342typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)(
1343 hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace,
1344 float* outMatrix);
1345
Dan Stoza4e9221b2015-09-02 15:43:39 -07001346/*
1347 * Display Functions
1348 *
1349 * All of these functions take as their first two parameters a device pointer
1350 * and a display handle, so these parameters are omitted from the described
1351 * parameter lists.
1352 */
1353
1354/* acceptDisplayChanges(...)
1355 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
1356 * Must be provided by all HWC2 devices
1357 *
1358 * Accepts the changes required by the device from the previous validateDisplay
1359 * call (which may be queried using getChangedCompositionTypes) and revalidates
1360 * the display. This function is equivalent to requesting the changed types from
1361 * getChangedCompositionTypes, setting those types on the corresponding layers,
1362 * and then calling validateDisplay again.
1363 *
1364 * After this call it must be valid to present this display. Calling this after
1365 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
1366 * should have no other effect.
1367 *
1368 * Returns HWC2_ERROR_NONE or one of the following errors:
1369 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1370 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
1371 */
1372typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
1373 hwc2_device_t* device, hwc2_display_t display);
1374
1375/* createLayer(..., outLayer)
1376 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
1377 * Must be provided by all HWC2 devices
1378 *
1379 * Creates a new layer on the given display.
1380 *
1381 * Parameters:
1382 * outLayer - the handle of the new layer; pointer will be non-NULL
1383 *
1384 * Returns HWC2_ERROR_NONE or one of the following errors:
1385 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1386 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
1387 */
1388typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
1389 hwc2_display_t display, hwc2_layer_t* outLayer);
1390
1391/* destroyLayer(..., layer)
1392 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
1393 * Must be provided by all HWC2 devices
1394 *
1395 * Destroys the given layer.
1396 *
1397 * Parameters:
1398 * layer - the handle of the layer to destroy
1399 *
1400 * Returns HWC2_ERROR_NONE or one of the following errors:
1401 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1402 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1403 */
1404typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1405 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1406
1407/* getActiveConfig(..., outConfig)
1408 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1409 * Must be provided by all HWC2 devices
1410 *
1411 * Retrieves which display configuration is currently active.
1412 *
1413 * If no display configuration is currently active, this function must return
1414 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1415 * the responsibility of the client to call setActiveConfig with a valid
1416 * configuration before attempting to present anything on the display.
1417 *
1418 * Parameters:
1419 * outConfig - the currently active display configuration; pointer will be
1420 * non-NULL
1421 *
1422 * Returns HWC2_ERROR_NONE or one of the following errors:
1423 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1424 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1425 */
1426typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1427 hwc2_device_t* device, hwc2_display_t display,
1428 hwc2_config_t* outConfig);
1429
1430/* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1431 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1432 * Must be provided by all HWC2 devices
1433 *
1434 * Retrieves the layers for which the device requires a different composition
1435 * type than had been set prior to the last call to validateDisplay. The client
1436 * will either update its state with these types and call acceptDisplayChanges,
1437 * or will set new types and attempt to validate the display again.
1438 *
1439 * outLayers and outTypes may be NULL to retrieve the number of elements which
1440 * will be returned. The number of elements returned must be the same as the
1441 * value returned in outNumTypes from the last call to validateDisplay.
1442 *
1443 * Parameters:
1444 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1445 * and types which would have been returned; if both were non-NULL, the
1446 * number of elements returned in outLayers and outTypes, which must not
1447 * exceed the value stored in outNumElements prior to the call; pointer
1448 * will be non-NULL
1449 * outLayers - an array of layer handles
1450 * outTypes - an array of composition types, each corresponding to an element
1451 * of outLayers
1452 *
1453 * Returns HWC2_ERROR_NONE or one of the following errors:
1454 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1455 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1456 * display
1457 */
1458typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1459 hwc2_device_t* device, hwc2_display_t display,
1460 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1461 int32_t* /*hwc2_composition_t*/ outTypes);
1462
1463/* getClientTargetSupport(..., width, height, format, dataspace)
1464 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1465 * Must be provided by all HWC2 devices
1466 *
1467 * Returns whether a client target with the given properties can be handled by
1468 * the device.
1469 *
1470 * The valid formats can be found in android_pixel_format_t in
1471 * <system/graphics.h>.
1472 *
1473 * For more about dataspaces, see setLayerDataspace.
1474 *
1475 * This function must return true for a client target with width and height
1476 * equal to the active display configuration dimensions,
1477 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1478 * return true for any other configuration.
1479 *
1480 * Parameters:
1481 * width - client target width in pixels
1482 * height - client target height in pixels
1483 * format - client target format
1484 * dataspace - client target dataspace, as described in setLayerDataspace
1485 *
1486 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1487 * following errors:
1488 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1489 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1490 */
1491typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1492 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1493 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1494 int32_t /*android_dataspace_t*/ dataspace);
1495
1496/* getColorModes(..., outNumModes, outModes)
1497 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1498 * Must be provided by all HWC2 devices
1499 *
1500 * Returns the color modes supported on this display.
1501 *
1502 * The valid color modes can be found in android_color_mode_t in
1503 * <system/graphics.h>. All HWC2 devices must support at least
1504 * HAL_COLOR_MODE_NATIVE.
1505 *
1506 * outNumModes may be NULL to retrieve the number of modes which will be
1507 * returned.
1508 *
1509 * Parameters:
1510 * outNumModes - if outModes was NULL, the number of modes which would have
1511 * been returned; if outModes was not NULL, the number of modes returned,
1512 * which must not exceed the value stored in outNumModes prior to the
1513 * call; pointer will be non-NULL
1514 * outModes - an array of color modes
1515 *
1516 * Returns HWC2_ERROR_NONE or one of the following errors:
1517 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1518 */
1519typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1520 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1521 int32_t* /*android_color_mode_t*/ outModes);
1522
Chia-I Wu28310aa2018-03-15 21:20:55 -07001523/* getRenderIntents(..., mode, outNumIntents, outIntents)
1524 * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS
1525 * Provided by HWC2 devices which don't return nullptr function pointer.
1526 *
1527 * Returns the render intents supported on this display.
1528 *
1529 * The valid render intents can be found in android_render_intent_v1_1_t in
1530 * <system/graphics.h>. All HWC2 devices must support at least
1531 * HAL_RENDER_INTENT_COLORIMETRIC.
1532 *
1533 * outNumIntents may be NULL to retrieve the number of intents which will be
1534 * returned.
1535 *
1536 * Parameters:
1537 * mode - the color mode to query the render intents for
1538 * outNumIntents - if outIntents was NULL, the number of intents which would
1539 * have been returned; if outIntents was not NULL, the number of intents
1540 * returned, which must not exceed the value stored in outNumIntents
1541 * prior to the call; pointer will be non-NULL
1542 * outIntents - an array of render intents
1543 *
1544 * Returns HWC2_ERROR_NONE or one of the following errors:
1545 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1546 */
1547typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)(
1548 hwc2_device_t* device, hwc2_display_t display, int32_t mode,
1549 uint32_t* outNumIntents,
1550 int32_t* /*android_render_intent_v1_1_t*/ outIntents);
1551
Dan Stoza4e9221b2015-09-02 15:43:39 -07001552/* getDisplayAttribute(..., config, attribute, outValue)
1553 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1554 * Must be provided by all HWC2 devices
1555 *
1556 * Returns a display attribute value for a particular display configuration.
1557 *
1558 * Any attribute which is not supported or for which the value is unknown by the
1559 * device must return a value of -1.
1560 *
1561 * Parameters:
1562 * config - the display configuration for which to return attribute values
1563 * attribute - the attribute to query
1564 * outValue - the value of the attribute; the pointer will be non-NULL
1565 *
1566 * Returns HWC2_ERROR_NONE or one of the following errors:
1567 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1568 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1569 * display
1570 */
1571typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1572 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1573 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1574
1575/* getDisplayConfigs(..., outNumConfigs, outConfigs)
1576 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1577 * Must be provided by all HWC2 devices
1578 *
1579 * Returns handles for all of the valid display configurations on this display.
1580 *
1581 * outConfigs may be NULL to retrieve the number of elements which will be
1582 * returned.
1583 *
1584 * Parameters:
1585 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1586 * would have been returned; if outConfigs was not NULL, the number of
1587 * configurations returned, which must not exceed the value stored in
1588 * outNumConfigs prior to the call; pointer will be non-NULL
1589 * outConfigs - an array of configuration handles
1590 *
1591 * Returns HWC2_ERROR_NONE or one of the following errors:
1592 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1593 */
1594typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1595 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1596 hwc2_config_t* outConfigs);
1597
1598/* getDisplayName(..., outSize, outName)
1599 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1600 * Must be provided by all HWC2 devices
1601 *
1602 * Returns a human-readable version of the display's name.
1603 *
1604 * outName may be NULL to retrieve the length of the name.
1605 *
1606 * Parameters:
1607 * outSize - if outName was NULL, the number of bytes needed to return the
1608 * name if outName was not NULL, the number of bytes written into it,
1609 * which must not exceed the value stored in outSize prior to the call;
1610 * pointer will be non-NULL
1611 * outName - the display's name
1612 *
1613 * Returns HWC2_ERROR_NONE or one of the following errors:
1614 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1615 */
1616typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1617 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1618 char* outName);
1619
1620/* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1621 * outLayerRequests)
1622 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1623 * Must be provided by all HWC2 devices
1624 *
1625 * Returns the display requests and the layer requests required for the last
1626 * validated configuration.
1627 *
1628 * Display requests provide information about how the client should handle the
1629 * client target. Layer requests provide information about how the client
1630 * should handle an individual layer.
1631 *
1632 * If outLayers or outLayerRequests is NULL, the required number of layers and
1633 * requests must be returned in outNumElements, but this number may also be
1634 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1635 * to the value returned in outNumRequests from the last call to
1636 * validateDisplay).
1637 *
1638 * Parameters:
1639 * outDisplayRequests - the display requests for the current validated state
1640 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1641 * elements which would have been returned, which must be equal to the
1642 * value returned in outNumRequests from the last validateDisplay call on
1643 * this display; if both were not NULL, the number of elements in
1644 * outLayers and outLayerRequests, which must not exceed the value stored
1645 * in outNumElements prior to the call; pointer will be non-NULL
1646 * outLayers - an array of layers which all have at least one request
1647 * outLayerRequests - the requests corresponding to each element of outLayers
1648 *
1649 * Returns HWC2_ERROR_NONE or one of the following errors:
1650 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1651 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1652 * display
1653 */
1654typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1655 hwc2_device_t* device, hwc2_display_t display,
1656 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1657 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1658 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1659
1660/* getDisplayType(..., outType)
1661 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1662 * Must be provided by all HWC2 devices
1663 *
1664 * Returns whether the given display is a physical or virtual display.
1665 *
1666 * Parameters:
1667 * outType - the type of the display; pointer will be non-NULL
1668 *
1669 * Returns HWC2_ERROR_NONE or one of the following errors:
1670 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1671 */
1672typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1673 hwc2_device_t* device, hwc2_display_t display,
1674 int32_t* /*hwc2_display_type_t*/ outType);
1675
Dominik Laskowski55cf6f02018-03-25 15:12:04 -07001676/* getDisplayIdentificationData(..., outPort, outDataSize, outData)
1677 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
1678 * Optional for HWC2 devices
1679 *
1680 * If supported, getDisplayIdentificationData returns the port and data that
1681 * describe a physical display. The port is a unique number that identifies a
1682 * physical connector (e.g. eDP, HDMI) for display output. The data blob is
1683 * parsed to determine its format, typically EDID 1.3 as specified in VESA
1684 * E-EDID Standard Release A Revision 1.
1685 *
1686 * Devices for which display identification is unsupported must return null when
1687 * getFunction is called with HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA.
1688 *
1689 * Parameters:
1690 * outPort - the connector to which the display is connected;
1691 * pointer will be non-NULL
1692 * outDataSize - if outData is NULL, the size in bytes of the data which would
1693 * have been returned; if outData is not NULL, the size of outData, which
1694 * must not exceed the value stored in outDataSize prior to the call;
1695 * pointer will be non-NULL
1696 * outData - the EDID 1.3 blob identifying the display
1697 *
1698 * Returns HWC2_ERROR_NONE or one of the following errors:
1699 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1700 */
1701typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA)(
1702 hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
1703 uint32_t* outDataSize, uint8_t* outData);
1704
Dan Stoza4e9221b2015-09-02 15:43:39 -07001705/* getDozeSupport(..., outSupport)
1706 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1707 * Must be provided by all HWC2 devices
1708 *
1709 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1710 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1711 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1712 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1713 * device should not claim support.
1714 *
1715 * Parameters:
1716 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1717 * pointer will be non-NULL
1718 *
1719 * Returns HWC2_ERROR_NONE or one of the following errors:
1720 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1721 */
1722typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1723 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1724
Dan Stozaf601e972016-03-16 09:54:40 -07001725/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1726 * outMaxAverageLuminance, outMinLuminance)
1727 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1728 * Must be provided by all HWC2 devices
1729 *
1730 * Returns the high dynamic range (HDR) capabilities of the given display, which
1731 * are invariant with regard to the active configuration.
1732 *
1733 * Displays which are not HDR-capable must return no types in outTypes and set
1734 * outNumTypes to 0.
1735 *
1736 * If outTypes is NULL, the required number of HDR types must be returned in
1737 * outNumTypes.
1738 *
1739 * Parameters:
1740 * outNumTypes - if outTypes was NULL, the number of types which would have
1741 * been returned; if it was not NULL, the number of types stored in
1742 * outTypes, which must not exceed the value stored in outNumTypes prior
1743 * to the call; pointer will be non-NULL
1744 * outTypes - an array of HDR types, may have 0 elements if the display is not
1745 * HDR-capable
1746 * outMaxLuminance - the desired content maximum luminance for this display in
1747 * cd/m^2; pointer will be non-NULL
1748 * outMaxAverageLuminance - the desired content maximum frame-average
1749 * luminance for this display in cd/m^2; pointer will be non-NULL
1750 * outMinLuminance - the desired content minimum luminance for this display in
1751 * cd/m^2; pointer will be non-NULL
1752 *
1753 * Returns HWC2_ERROR_NONE or one of the following errors:
1754 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1755 */
1756typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1757 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1758 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1759 float* outMaxAverageLuminance, float* outMinLuminance);
1760
Dan Stoza4e9221b2015-09-02 15:43:39 -07001761/* getReleaseFences(..., outNumElements, outLayers, outFences)
1762 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1763 * Must be provided by all HWC2 devices
1764 *
1765 * Retrieves the release fences for device layers on this display which will
1766 * receive new buffer contents this frame.
1767 *
1768 * A release fence is a file descriptor referring to a sync fence object which
1769 * will be signaled after the device has finished reading from the buffer
1770 * presented in the prior frame. This indicates that it is safe to start writing
1771 * to the buffer again. If a given layer's fence is not returned from this
1772 * function, it will be assumed that the buffer presented on the previous frame
1773 * is ready to be written.
1774 *
1775 * The fences returned by this function should be unique for each layer (even if
1776 * they point to the same underlying sync object), and ownership of the fences
1777 * is transferred to the client, which is responsible for closing them.
1778 *
1779 * If outLayers or outFences is NULL, the required number of layers and fences
1780 * must be returned in outNumElements.
1781 *
1782 * Parameters:
1783 * outNumElements - if outLayers or outFences were NULL, the number of
1784 * elements which would have been returned; if both were not NULL, the
1785 * number of elements in outLayers and outFences, which must not exceed
1786 * the value stored in outNumElements prior to the call; pointer will be
1787 * non-NULL
1788 * outLayers - an array of layer handles
1789 * outFences - an array of sync fence file descriptors as described above,
1790 * each corresponding to an element of outLayers
1791 *
1792 * Returns HWC2_ERROR_NONE or one of the following errors:
1793 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1794 */
1795typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RELEASE_FENCES)(
1796 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1797 hwc2_layer_t* outLayers, int32_t* outFences);
1798
Dan Stozaef264822016-07-13 14:51:09 -07001799/* presentDisplay(..., outPresentFence)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001800 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1801 * Must be provided by all HWC2 devices
1802 *
1803 * Presents the current display contents on the screen (or in the case of
1804 * virtual displays, into the output buffer).
1805 *
1806 * Prior to calling this function, the display must be successfully validated
1807 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1808 * specifically do not count as layer state, so if there are no other changes
1809 * to the layer state (or to the buffer's properties as described in
1810 * setLayerBuffer), then it is safe to call this function without first
1811 * validating the display.
1812 *
Dan Stozaef264822016-07-13 14:51:09 -07001813 * If this call succeeds, outPresentFence will be populated with a file
1814 * descriptor referring to a present sync fence object. For physical displays,
1815 * this fence will be signaled at the vsync when the result of composition of
1816 * this frame starts to appear (for video-mode panels) or starts to transfer to
1817 * panel memory (for command-mode panels). For virtual displays, this fence will
1818 * be signaled when writes to the output buffer have completed and it is safe to
1819 * read from it.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001820 *
1821 * Parameters:
Dan Stozaef264822016-07-13 14:51:09 -07001822 * outPresentFence - a sync fence file descriptor as described above; pointer
Dan Stoza4e9221b2015-09-02 15:43:39 -07001823 * will be non-NULL
1824 *
1825 * Returns HWC2_ERROR_NONE or one of the following errors:
1826 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1827 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1828 * display
1829 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1830 * for this display
1831 */
1832typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
Dan Stozaef264822016-07-13 14:51:09 -07001833 hwc2_device_t* device, hwc2_display_t display,
1834 int32_t* outPresentFence);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001835
1836/* setActiveConfig(..., config)
1837 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1838 * Must be provided by all HWC2 devices
1839 *
1840 * Sets the active configuration for this display. Upon returning, the given
1841 * display configuration should be active and remain so until either this
1842 * function is called again or the display is disconnected.
1843 *
1844 * Parameters:
1845 * config - the new display configuration
1846 *
1847 * Returns HWC2_ERROR_NONE or one of the following errors:
1848 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1849 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1850 * this display
1851 */
1852typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1853 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1854
Dan Stoza68cd3752016-05-20 13:30:42 -07001855/* setClientTarget(..., target, acquireFence, dataspace, damage)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001856 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1857 * Must be provided by all HWC2 devices
1858 *
1859 * Sets the buffer handle which will receive the output of client composition.
1860 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1861 * prior to the call to presentDisplay, and layers not marked as
1862 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1863 *
Dan Stoza3abcfa52016-05-04 12:21:06 -07001864 * The buffer handle provided may be null if no layers are being composited by
1865 * the client. This must not result in an error (unless an invalid display
1866 * handle is also provided).
1867 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001868 * Also provides a file descriptor referring to an acquire sync fence object,
1869 * which will be signaled when it is safe to read from the client target buffer.
1870 * If it is already safe to read from this buffer, -1 may be passed instead.
1871 * The device must ensure that it is safe for the client to close this file
1872 * descriptor at any point after this function is called.
1873 *
1874 * For more about dataspaces, see setLayerDataspace.
1875 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001876 * The damage parameter describes a surface damage region as defined in the
1877 * description of setLayerSurfaceDamage.
1878 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001879 * Will be called before presentDisplay if any of the layers are marked as
1880 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1881 * necessary to call this function. It is not necessary to call validateDisplay
1882 * after changing the target through this function.
1883 *
1884 * Parameters:
1885 * target - the new target buffer
1886 * acquireFence - a sync fence file descriptor as described above
1887 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
Dan Stoza68cd3752016-05-20 13:30:42 -07001888 * damage - the surface damage region
Dan Stoza4e9221b2015-09-02 15:43:39 -07001889 *
1890 * Returns HWC2_ERROR_NONE or one of the following errors:
1891 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1892 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1893 */
1894typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1895 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
Dan Stoza68cd3752016-05-20 13:30:42 -07001896 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1897 hwc_region_t damage);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001898
Dan Stozac46e96a2016-03-24 10:12:15 -07001899/* setColorMode(..., mode)
1900 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1901 * Must be provided by all HWC2 devices
1902 *
1903 * Sets the color mode of the given display.
1904 *
Chia-I Wu28310aa2018-03-15 21:20:55 -07001905 * This must be called outside of validateDisplay/presentDisplay, and it takes
1906 * effect on next presentDisplay.
Dan Stozac46e96a2016-03-24 10:12:15 -07001907 *
1908 * The valid color modes can be found in android_color_mode_t in
1909 * <system/graphics.h>. All HWC2 devices must support at least
1910 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1911 * hotplug.
1912 *
1913 * Parameters:
1914 * mode - the mode to set
1915 *
1916 * Returns HWC2_ERROR_NONE or one of the following errors:
1917 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1918 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1919 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1920 */
1921typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1922 hwc2_device_t* device, hwc2_display_t display,
1923 int32_t /*android_color_mode_t*/ mode);
1924
Chia-I Wu28310aa2018-03-15 21:20:55 -07001925/* setColorModeWithIntent(..., mode, intent)
1926 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
1927 * Provided by HWC2 devices which don't return nullptr function pointer.
1928 *
1929 * This must be called outside of validateDisplay/presentDisplay, and it takes
1930 * effect on next presentDisplay.
1931 *
1932 * The valid color modes and render intents can be found in
1933 * android_color_mode_t and android_render_intent_v1_1_t in
1934 * <system/graphics.h>. All HWC2 devices must support at least
1935 * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are
1936 * assumed to be in this mode and intent upon hotplug.
1937 *
1938 * Parameters:
1939 * mode - the mode to set
1940 * intent - the intent to set
1941 *
1942 * Returns HWC2_ERROR_NONE or one of the following errors:
1943 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1944 * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or
1945 * render intent
1946 * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display
1947 */
1948typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)(
1949 hwc2_device_t* device, hwc2_display_t display,
1950 int32_t /*android_color_mode_t*/ mode,
1951 int32_t /*android_render_intent_v1_1_t */ intent);
1952
Dan Stoza4e9221b2015-09-02 15:43:39 -07001953/* setColorTransform(..., matrix, hint)
1954 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1955 * Must be provided by all HWC2 devices
1956 *
1957 * Sets a color transform which will be applied after composition.
1958 *
1959 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1960 * hint to apply the desired color transform instead of using the color matrix
1961 * directly.
1962 *
1963 * If the device is not capable of either using the hint or the matrix to apply
1964 * the desired color transform, it should force all layers to client composition
1965 * during validateDisplay.
1966 *
Dan Stozad2168f72016-07-14 11:48:16 -07001967 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1968 * will never apply the color transform during client composition, even if all
1969 * layers are being composed by the client.
1970 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001971 * The matrix provided is an affine color transformation of the following form:
1972 *
1973 * |r.r r.g r.b 0|
1974 * |g.r g.g g.b 0|
1975 * |b.r b.g b.b 0|
1976 * |Tr Tg Tb 1|
1977 *
1978 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1979 *
1980 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1981 * color [R_out, G_out, B_out] will be:
1982 *
1983 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
Dan Stoza5dfbe332016-03-24 09:23:11 -07001984 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1985 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
Dan Stoza4e9221b2015-09-02 15:43:39 -07001986 *
1987 * Parameters:
1988 * matrix - a 4x4 transform matrix (16 floats) as described above
1989 * hint - a hint value which may be used instead of the given matrix unless it
1990 * is HAL_COLOR_TRANSFORM_ARBITRARY
1991 *
1992 * Returns HWC2_ERROR_NONE or one of the following errors:
1993 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1994 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
1995 */
1996typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
Dan Stozac46e96a2016-03-24 10:12:15 -07001997 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
Dan Stoza4e9221b2015-09-02 15:43:39 -07001998 int32_t /*android_color_transform_t*/ hint);
1999
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002000/* getPerFrameMetadataKeys(..., outKeys)
2001 * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
2002 * Optional for HWC2 devices
2003 *
2004 * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null),
2005 * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys
2006 * which are invariant with regard to the active configuration.
2007 *
2008 * Devices which are not HDR-capable, must return null when getFunction is called
2009 * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS.
2010 *
2011 * If outKeys is NULL, the required number of PerFrameMetadataKey keys
2012 * must be returned in outNumKeys.
2013 *
2014 * Parameters:
2015 * outNumKeys - if outKeys is NULL, the number of keys which would have
2016 * been returned; if outKeys is not NULL, the number of keys stored in
2017 * outKeys, which must not exceed the value stored in outNumKeys prior
2018 * to the call; pointer will be non-NULL
2019 * outKeys - an array of hwc2_per_frame_metadata_key_t keys
2020 *
2021 * Returns HWC2_ERROR_NONE or one of the following errors:
2022 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2023 */
2024typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)(
2025 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys,
2026 int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
2027
Dan Stoza4e9221b2015-09-02 15:43:39 -07002028/* setOutputBuffer(..., buffer, releaseFence)
2029 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
2030 * Must be provided by all HWC2 devices
2031 *
2032 * Sets the output buffer for a virtual display. That is, the buffer to which
2033 * the composition result will be written.
2034 *
2035 * Also provides a file descriptor referring to a release sync fence object,
2036 * which will be signaled when it is safe to write to the output buffer. If it
2037 * is already safe to write to the output buffer, -1 may be passed instead. The
2038 * device must ensure that it is safe for the client to close this file
2039 * descriptor at any point after this function is called.
2040 *
2041 * Must be called at least once before presentDisplay, but does not have any
2042 * interaction with layer state or display validation.
2043 *
2044 * Parameters:
2045 * buffer - the new output buffer
2046 * releaseFence - a sync fence file descriptor as described above
2047 *
2048 * Returns HWC2_ERROR_NONE or one of the following errors:
2049 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2050 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
2051 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
2052 */
2053typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
2054 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
2055 int32_t releaseFence);
2056
2057/* setPowerMode(..., mode)
2058 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
2059 * Must be provided by all HWC2 devices
2060 *
2061 * Sets the power mode of the given display. The transition must be complete
2062 * when this function returns. It is valid to call this function multiple times
2063 * with the same power mode.
2064 *
2065 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
2066 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
2067 * be queried using getDozeSupport.
2068 *
2069 * Parameters:
2070 * mode - the new power mode
2071 *
2072 * Returns HWC2_ERROR_NONE or one of the following errors:
2073 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2074 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
2075 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
2076 * on this display
2077 */
2078typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
2079 hwc2_device_t* device, hwc2_display_t display,
2080 int32_t /*hwc2_power_mode_t*/ mode);
2081
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002082/* getReadbackBufferAttributes(..., outFormat, outDataspace)
2083 * Optional for HWC2 devices
2084 *
2085 * Returns the format which should be used when allocating a buffer for use by
2086 * device readback as well as the dataspace in which its contents should be
2087 * interpreted.
2088 *
2089 * If readback is not supported by this HWC implementation, this call will also
2090 * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method.
2091 * Returning NULL to a getFunction request for this function will also indicate
2092 * that readback is not supported.
2093 *
2094 * The width and height of this buffer will be those of the currently-active
2095 * display configuration, and the usage flags will consist of the following:
2096 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
2097 * BufferUsage::COMPOSER_OUTPUT
2098 *
2099 * The format and dataspace provided must be sufficient such that if a
2100 * correctly-configured buffer is passed into setReadbackBuffer, filled by
2101 * the device, and then displayed by the client as a full-screen buffer, the
2102 * output of the display remains the same (subject to the note about protected
2103 * content in the description of setReadbackBuffer).
2104 *
Dan Stozaaf153e02018-05-15 13:09:51 -07002105 * If the active configuration or color mode of this display has changed since
2106 * the previous call to this function, it will be called again prior to setting
2107 * a readback buffer such that the returned format and dataspace can be updated
2108 * accordingly.
2109 *
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002110 * Parameters:
2111 * outFormat - the format the client should use when allocating a device
Dan Stozaaf153e02018-05-15 13:09:51 -07002112 * readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002113 * outDataspace - the dataspace the client will use when interpreting the
Dan Stozaaf153e02018-05-15 13:09:51 -07002114 * contents of a device readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002115 *
2116 * Returns HWC2_ERROR_NONE or one of the following errors:
2117 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002118 *
2119 * See also:
2120 * setReadbackBuffer
2121 * getReadbackBufferFence
2122 */
2123typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)(
2124 hwc2_device_t* device, hwc2_display_t display,
2125 int32_t* /*android_pixel_format_t*/ outFormat,
2126 int32_t* /*android_dataspace_t*/ outDataspace);
2127
2128/* getReadbackBufferFence(..., outFence)
2129 * Optional for HWC2 devices
2130 *
2131 * Returns an acquire sync fence file descriptor which will signal when the
2132 * buffer provided to setReadbackBuffer has been filled by the device and is
2133 * safe for the client to read.
2134 *
2135 * If it is already safe to read from this buffer, -1 may be returned instead.
2136 * The client takes ownership of this file descriptor and is responsible for
2137 * closing it when it is no longer needed.
2138 *
2139 * This function will be called immediately after the composition cycle being
2140 * captured into the readback buffer. The complete ordering of a readback buffer
2141 * capture is as follows:
2142 *
2143 * getReadbackBufferAttributes
2144 * // Readback buffer is allocated
2145 * // Many frames may pass
2146 *
2147 * setReadbackBuffer
2148 * validateDisplay
2149 * presentDisplay
2150 * getReadbackBufferFence
2151 * // Implicitly wait on the acquire fence before accessing the buffer
2152 *
2153 * Parameters:
2154 * outFence - a sync fence file descriptor as described above; pointer
2155 * will be non-NULL
2156 *
2157 * Returns HWC2_ERROR_NONE or one of the following errors:
2158 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Dan Stozaaf153e02018-05-15 13:09:51 -07002159 * HWC2_ERROR_NO_RESOURCES - the readback operation was successful, but
2160 * resulted in a different validate result than would have occurred
2161 * without readback
2162 * HWC2_ERROR_UNSUPPORTED - the readback operation was unsuccessful because
2163 * of resource constraints, the presence of protected content, or other
2164 * reasons; -1 must be returned in outFence
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002165 */
2166typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)(
2167 hwc2_device_t* device, hwc2_display_t display,
2168 int32_t* outFence);
2169
2170/* setReadbackBuffer(..., buffer, releaseFence)
2171 * Optional for HWC2 devices
2172 *
2173 * Sets the readback buffer to be filled with the contents of the next
2174 * composition performed for this display (i.e., the contents present at the
2175 * time of the next validateDisplay/presentDisplay cycle).
2176 *
2177 * This buffer will have been allocated as described in
2178 * getReadbackBufferAttributes and will be interpreted as being in the dataspace
2179 * provided by the same.
2180 *
2181 * If there is hardware protected content on the display at the time of the next
2182 * composition, the area of the readback buffer covered by such content must be
2183 * completely black. Any areas of the buffer not covered by such content may
2184 * optionally be black as well.
2185 *
2186 * The release fence file descriptor provided works identically to the one
2187 * described for setOutputBuffer.
2188 *
2189 * This function will not be called between any call to validateDisplay and a
2190 * subsequent call to presentDisplay.
2191 *
2192 * Parameters:
2193 * buffer - the new readback buffer
2194 * releaseFence - a sync fence file descriptor as described in setOutputBuffer
2195 *
2196 * Returns HWC2_ERROR_NONE or one of the following errors:
2197 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2198 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
2199 *
2200 * See also:
2201 * getReadbackBufferAttributes
2202 * getReadbackBufferFence
2203 */
2204typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)(
2205 hwc2_device_t* device, hwc2_display_t display,
2206 buffer_handle_t buffer, int32_t releaseFence);
2207
Dan Stoza4e9221b2015-09-02 15:43:39 -07002208/* setVsyncEnabled(..., enabled)
2209 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
2210 * Must be provided by all HWC2 devices
2211 *
2212 * Enables or disables the vsync signal for the given display. Virtual displays
2213 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
2214 * display though this function must return HWC2_ERROR_NONE and have no other
2215 * effect.
2216 *
2217 * Parameters:
2218 * enabled - whether to enable or disable vsync
2219 *
2220 * Returns HWC2_ERROR_NONE or one of the following errors:
2221 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2222 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
2223 */
2224typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
2225 hwc2_device_t* device, hwc2_display_t display,
2226 int32_t /*hwc2_vsync_t*/ enabled);
2227
2228/* validateDisplay(..., outNumTypes, outNumRequests)
2229 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
2230 * Must be provided by all HWC2 devices
2231 *
2232 * Instructs the device to inspect all of the layer state and determine if
2233 * there are any composition type changes necessary before presenting the
2234 * display. Permitted changes are described in the definition of
2235 * hwc2_composition_t above.
2236 *
2237 * Also returns the number of layer requests required
2238 * by the given layer configuration.
2239 *
2240 * Parameters:
2241 * outNumTypes - the number of composition type changes required by the
2242 * device; if greater than 0, the client must either set and validate new
2243 * types, or call acceptDisplayChanges to accept the changes returned by
2244 * getChangedCompositionTypes; must be the same as the number of changes
2245 * returned by getChangedCompositionTypes (see the declaration of that
2246 * function for more information); pointer will be non-NULL
2247 * outNumRequests - the number of layer requests required by this layer
2248 * configuration; must be equal to the number of layer requests returned
2249 * by getDisplayRequests (see the declaration of that function for
2250 * more information); pointer will be non-NULL
2251 *
2252 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
2253 * the display using the current layer state. Otherwise returns one of the
2254 * following errors:
2255 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2256 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
2257 * for more information)
2258 */
2259typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
2260 hwc2_device_t* device, hwc2_display_t display,
2261 uint32_t* outNumTypes, uint32_t* outNumRequests);
2262
2263/*
2264 * Layer Functions
2265 *
2266 * These are functions which operate on layers, but which do not modify state
2267 * that must be validated before use. See also 'Layer State Functions' below.
2268 *
2269 * All of these functions take as their first three parameters a device pointer,
2270 * a display handle for the display which contains the layer, and a layer
2271 * handle, so these parameters are omitted from the described parameter lists.
2272 */
2273
2274/* setCursorPosition(..., x, y)
2275 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
2276 * Must be provided by all HWC2 devices
2277 *
2278 * Asynchonously sets the position of a cursor layer.
2279 *
2280 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
2281 * If validation succeeds (i.e., the device does not request a composition
2282 * change for that layer), then once a buffer has been set for the layer and it
2283 * has been presented, its position may be set by this function at any time
2284 * between presentDisplay and any subsequent validateDisplay calls for this
2285 * display.
2286 *
2287 * Once validateDisplay is called, this function will not be called again until
2288 * the validate/present sequence is completed.
2289 *
2290 * May be called from any thread so long as it is not interleaved with the
2291 * validate/present sequence as described above.
2292 *
2293 * Parameters:
2294 * x - the new x coordinate (in pixels from the left of the screen)
2295 * y - the new y coordinate (in pixels from the top of the screen)
2296 *
2297 * Returns HWC2_ERROR_NONE or one of the following errors:
2298 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2299 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
2300 * HWC2_COMPOSITION_CURSOR
2301 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
2302 * validate/present sequence
2303 */
2304typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
2305 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2306 int32_t x, int32_t y);
2307
2308/* setLayerBuffer(..., buffer, acquireFence)
2309 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
2310 * Must be provided by all HWC2 devices
2311 *
2312 * Sets the buffer handle to be displayed for this layer. If the buffer
2313 * properties set at allocation time (width, height, format, and usage) have not
2314 * changed since the previous frame, it is not necessary to call validateDisplay
2315 * before calling presentDisplay unless new state needs to be validated in the
2316 * interim.
2317 *
2318 * Also provides a file descriptor referring to an acquire sync fence object,
2319 * which will be signaled when it is safe to read from the given buffer. If it
2320 * is already safe to read from the buffer, -1 may be passed instead. The
2321 * device must ensure that it is safe for the client to close this file
2322 * descriptor at any point after this function is called.
2323 *
2324 * This function must return HWC2_ERROR_NONE and have no other effect if called
2325 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
2326 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
2327 * (because synchronization and buffer updates for these layers are handled
2328 * elsewhere).
2329 *
2330 * Parameters:
2331 * buffer - the buffer handle to set
2332 * acquireFence - a sync fence file descriptor as described above
2333 *
2334 * Returns HWC2_ERROR_NONE or one of the following errors:
2335 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2336 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
2337 */
2338typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
2339 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2340 buffer_handle_t buffer, int32_t acquireFence);
2341
2342/* setLayerSurfaceDamage(..., damage)
2343 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
2344 * Must be provided by all HWC2 devices
2345 *
2346 * Provides the region of the source buffer which has been modified since the
2347 * last frame. This region does not need to be validated before calling
2348 * presentDisplay.
2349 *
2350 * Once set through this function, the damage region remains the same until a
2351 * subsequent call to this function.
2352 *
2353 * If damage.numRects > 0, then it may be assumed that any portion of the source
2354 * buffer not covered by one of the rects has not been modified this frame. If
2355 * damage.numRects == 0, then the whole source buffer must be treated as if it
2356 * has been modified.
2357 *
2358 * If the layer's contents are not modified relative to the prior frame, damage
2359 * will contain exactly one empty rect([0, 0, 0, 0]).
2360 *
2361 * The damage rects are relative to the pre-transformed buffer, and their origin
2362 * is the top-left corner. They will not exceed the dimensions of the latched
2363 * buffer.
2364 *
2365 * Parameters:
2366 * damage - the new surface damage region
2367 *
2368 * Returns HWC2_ERROR_NONE or one of the following errors:
2369 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2370 */
2371typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
2372 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2373 hwc_region_t damage);
2374
Chia-I Wu28310aa2018-03-15 21:20:55 -07002375/* setLayerPerFrameMetadata(..., numMetadata, metadata)
2376 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
2377 * Optional for HWC2 devices
2378 *
2379 * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is
2380 * non-null), sets the metadata for the given display for all following
2381 * frames.
2382 *
2383 * Upon returning from this function, the metadata change must have
2384 * fully taken effect.
2385 *
2386 * This function will only be called if getPerFrameMetadataKeys is non-NULL
2387 * and returns at least one key.
2388 *
2389 * Parameters:
2390 * numElements is the number of elements in each of the keys and metadata arrays
2391 * keys is a pointer to the array of keys.
2392 * outMetadata is a pointer to the corresponding array of metadata.
2393 *
2394 * Returns HWC2_ERROR_NONE or one of the following errors:
2395 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2396 * HWC2_ERROR_BAD_PARAMETER - metadata is not valid
2397 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2398 */
2399typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)(
2400 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2401 uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
2402 const float* metadata);
2403
Valerie Hau69c53432018-11-13 09:07:44 -08002404/* setLayerPerFrameMetadataBlobs(...,numElements, keys, sizes, blobs)
2405 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS
2406 * Optional for HWC2 devices
2407 *
2408 * If supported, (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS)
2409 * is non-null), sets the metadata for the given display and layer.
2410 *
2411 * Upon returning from this function, the metadata change must have fully taken
2412 * effect.
2413 *
2414 * This function must only be called if getPerFrameMetadataKeys is non-NULL
2415 * and returns at least one key that corresponds to a blob type.
2416 *
2417 * Current valid blob type keys are: HDR10_PLUS_SEI
2418 *
2419 * Parameters:
2420 * numElements is the number of elements in each of the keys, sizes, and
2421 * metadata arrays
2422 * keys is a pointer to an array of keys. Current valid keys are those listed
2423 * above as valid blob type keys.
2424 * sizes is a pointer to an array of unsigned ints specifying the sizes of
2425 * each metadata blob
2426 * metadata is a pointer to a blob of data holding all blobs contiguously in
2427 * memory
2428 *
2429 * Returns HWC2_ERROR_NONE or one of the following erros:
2430 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2431 * HWC2_ERROR_BAD_PARAMETER - sizes of keys and metadata parameters does
2432 * not match numElements, numElements < 0, or keys contains a
2433 * non-valid key (see above for current valid blob type keys).
2434 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2435 */
2436typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS)(
2437 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2438 uint32_t numElements, const int32_t* keys, const uint32_t* sizes,
2439 const uint8_t* metadata);
Dan Stoza4e9221b2015-09-02 15:43:39 -07002440/*
2441 * Layer State Functions
2442 *
2443 * These functions modify the state of a given layer. They do not take effect
2444 * until the display configuration is successfully validated with
2445 * validateDisplay and the display contents are presented with presentDisplay.
2446 *
2447 * All of these functions take as their first three parameters a device pointer,
2448 * a display handle for the display which contains the layer, and a layer
2449 * handle, so these parameters are omitted from the described parameter lists.
2450 */
2451
2452/* setLayerBlendMode(..., mode)
2453 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
2454 * Must be provided by all HWC2 devices
2455 *
2456 * Sets the blend mode of the given layer.
2457 *
2458 * Parameters:
2459 * mode - the new blend mode
2460 *
2461 * Returns HWC2_ERROR_NONE or one of the following errors:
2462 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2463 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
2464 */
2465typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
2466 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2467 int32_t /*hwc2_blend_mode_t*/ mode);
2468
2469/* setLayerColor(..., color)
2470 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
2471 * Must be provided by all HWC2 devices
2472 *
2473 * Sets the color of the given layer. If the composition type of the layer is
2474 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2475 * have no other effect.
2476 *
2477 * Parameters:
2478 * color - the new color
2479 *
2480 * Returns HWC2_ERROR_NONE or one of the following errors:
2481 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2482 */
2483typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
2484 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2485 hwc_color_t color);
2486
Peiyong Linfd05d132018-01-22 12:23:25 -08002487/* setLayerFloatColor(..., color)
2488 * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
2489 * Provided by HWC2 devices which don't return nullptr function pointer.
2490 *
2491 * Sets the color of the given layer. If the composition type of the layer is
2492 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2493 * have no other effect.
2494 *
2495 * Parameters:
2496 * color - the new color in float type, rage is [0.0, 1.0], the colorspace is
2497 * defined by the dataspace that gets set by calling setLayerDataspace.
2498 *
2499 * Returns HWC2_ERROR_NONE or one of the following errors:
2500 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2501 */
2502typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)(
2503 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2504 hwc_float_color_t color);
2505
Dan Stoza4e9221b2015-09-02 15:43:39 -07002506/* setLayerCompositionType(..., type)
2507 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
2508 * Must be provided by all HWC2 devices
2509 *
2510 * Sets the desired composition type of the given layer. During validateDisplay,
2511 * the device may request changes to the composition types of any of the layers
2512 * as described in the definition of hwc2_composition_t above.
2513 *
2514 * Parameters:
2515 * type - the new composition type
2516 *
2517 * Returns HWC2_ERROR_NONE or one of the following errors:
2518 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2519 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
2520 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
2521 * not supported by this device
2522 */
2523typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
2524 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2525 int32_t /*hwc2_composition_t*/ type);
2526
2527/* setLayerDataspace(..., dataspace)
2528 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
2529 * Must be provided by all HWC2 devices
2530 *
2531 * Sets the dataspace that the current buffer on this layer is in.
2532 *
2533 * The dataspace provides more information about how to interpret the buffer
2534 * contents, such as the encoding standard and color transform.
2535 *
2536 * See the values of android_dataspace_t in <system/graphics.h> for more
2537 * information.
2538 *
2539 * Parameters:
2540 * dataspace - the new dataspace
2541 *
2542 * Returns HWC2_ERROR_NONE or one of the following errors:
2543 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2544 */
2545typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
2546 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2547 int32_t /*android_dataspace_t*/ dataspace);
2548
2549/* setLayerDisplayFrame(..., frame)
2550 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
2551 * Must be provided by all HWC2 devices
2552 *
2553 * Sets the display frame (the portion of the display covered by a layer) of the
2554 * given layer. This frame will not exceed the display dimensions.
2555 *
2556 * Parameters:
2557 * frame - the new display frame
2558 *
2559 * Returns HWC2_ERROR_NONE or one of the following errors:
2560 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2561 */
2562typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
2563 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2564 hwc_rect_t frame);
2565
2566/* setLayerPlaneAlpha(..., alpha)
2567 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
2568 * Must be provided by all HWC2 devices
2569 *
2570 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
2571 * will be applied to the whole layer. It can be conceptualized as a
2572 * preprocessing step which applies the following function:
2573 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
2574 * out.rgb = in.rgb * planeAlpha
2575 * out.a = in.a * planeAlpha
2576 *
2577 * If the device does not support this operation on a layer which is marked
2578 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
2579 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
2580 *
2581 * Parameters:
2582 * alpha - the plane alpha value to apply
2583 *
2584 * Returns HWC2_ERROR_NONE or one of the following errors:
2585 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2586 */
2587typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
2588 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2589 float alpha);
2590
2591/* setLayerSidebandStream(..., stream)
2592 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
2593 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
2594 *
2595 * Sets the sideband stream for this layer. If the composition type of the given
2596 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
2597 * and have no other effect.
2598 *
2599 * Parameters:
2600 * stream - the new sideband stream
2601 *
2602 * Returns HWC2_ERROR_NONE or one of the following errors:
2603 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2604 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
2605 */
2606typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
2607 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2608 const native_handle_t* stream);
2609
2610/* setLayerSourceCrop(..., crop)
2611 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
2612 * Must be provided by all HWC2 devices
2613 *
2614 * Sets the source crop (the portion of the source buffer which will fill the
2615 * display frame) of the given layer. This crop rectangle will not exceed the
2616 * dimensions of the latched buffer.
2617 *
2618 * If the device is not capable of supporting a true float source crop (i.e., it
2619 * will truncate or round the floats to integers), it should set this layer to
2620 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
2621 * rendering.
2622 *
2623 * If the device cannot support float source crops, but still wants to handle
2624 * the layer, it should use the following code (or similar) to convert to
2625 * an integer crop:
2626 * intCrop.left = (int) ceilf(crop.left);
2627 * intCrop.top = (int) ceilf(crop.top);
2628 * intCrop.right = (int) floorf(crop.right);
2629 * intCrop.bottom = (int) floorf(crop.bottom);
2630 *
2631 * Parameters:
2632 * crop - the new source crop
2633 *
2634 * Returns HWC2_ERROR_NONE or one of the following errors:
2635 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2636 */
2637typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
2638 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2639 hwc_frect_t crop);
2640
2641/* setLayerTransform(..., transform)
2642 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
2643 * Must be provided by all HWC2 devices
2644 *
2645 * Sets the transform (rotation/flip) of the given layer.
2646 *
2647 * Parameters:
2648 * transform - the new transform
2649 *
2650 * Returns HWC2_ERROR_NONE or one of the following errors:
2651 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2652 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
2653 */
2654typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
2655 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2656 int32_t /*hwc_transform_t*/ transform);
2657
2658/* setLayerVisibleRegion(..., visible)
2659 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
2660 * Must be provided by all HWC2 devices
2661 *
2662 * Specifies the portion of the layer that is visible, including portions under
2663 * translucent areas of other layers. The region is in screen space, and will
2664 * not exceed the dimensions of the screen.
2665 *
2666 * Parameters:
2667 * visible - the new visible region, in screen space
2668 *
2669 * Returns HWC2_ERROR_NONE or one of the following errors:
2670 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2671 */
2672typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
2673 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2674 hwc_region_t visible);
2675
2676/* setLayerZOrder(..., z)
2677 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
2678 * Must be provided by all HWC2 devices
2679 *
2680 * Sets the desired Z order (height) of the given layer. A layer with a greater
2681 * Z value occludes a layer with a lesser Z value.
2682 *
2683 * Parameters:
2684 * z - the new Z order
2685 *
2686 * Returns HWC2_ERROR_NONE or one of the following errors:
2687 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2688 */
2689typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
2690 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2691 uint32_t z);
2692
Peiyong Lin44819b92018-09-13 16:20:08 -07002693/* setLayerColorTransform(..., matrix)
2694 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM
2695 * Optional by all HWC2 devices
2696 *
2697 * Sets a matrix for color transform which will be applied on this layer
2698 * before composition.
2699 *
2700 * If the device is not capable of apply the matrix on this layer, it must force
2701 * this layer to client composition during VALIDATE_DISPLAY.
2702 *
2703 * The matrix provided is an affine color transformation of the following form:
2704 *
2705 * |r.r r.g r.b 0|
2706 * |g.r g.g g.b 0|
2707 * |b.r b.g b.b 0|
2708 * |Tr Tg Tb 1|
2709 *
2710 * This matrix must be provided in row-major form:
2711 *
2712 * {r.r, r.g, r.b, 0, g.r, ...}.
2713 *
2714 * Given a matrix of this form and an input color [R_in, G_in, B_in],
2715 * the input color must first be converted to linear space
2716 * [R_linear, G_linear, B_linear], then the output linear color
2717 * [R_out_linear, G_out_linear, B_out_linear] will be:
2718 *
2719 * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
2720 * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
2721 * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
2722 *
2723 * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
2724 * gamma space: [R_out, G_out, B_out] before blending.
2725 *
2726 * Parameters:
2727 * matrix - a 4x4 transform matrix (16 floats) as described above
2728 *
2729 * Returns HWC2_ERROR_NONE or one of the following errors:
2730 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2731 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2732 */
2733typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR_TRANSFORM)(
2734 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2735 const float* matrix);
2736
Kevin DuBois13458872018-09-10 09:09:12 -07002737/* getDisplayedContentSamplingAttributes(...,
2738 * format, dataspace, supported_components, max_frames)
2739 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES
2740 * Optional by all HWC2 devices
2741 *
2742 * Query for what types of color sampling the hardware supports.
2743 *
2744 * Parameters:
2745 * format - The format of the sampled pixels; pointer will be non-NULL
2746 * dataspace - The dataspace of the sampled pixels; pointer will be non-NULL
2747 * supported_components - The mask of which components can be sampled; pointer
2748 * will be non-NULL
2749 *
2750 * Returns HWC2_ERROR_NONE or one of the following errors:
2751 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2752 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2753 */
2754typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES)(
2755 hwc2_device_t* device, hwc2_display_t display,
2756 int32_t* /* android_pixel_format_t */ format,
2757 int32_t* /* android_dataspace_t */ dataspace,
2758 uint8_t* /* mask of android_component_t */ supported_components);
2759
2760/* setDisplayedContentSamplingEnabled(..., enabled)
2761 * Descriptor: HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED
2762 * Optional by all HWC2 devices
2763 *
2764 * Enables or disables the collection of color content statistics
2765 * on this display.
2766 *
2767 * Sampling occurs on the contents of the final composition on this display
2768 * (i.e., the contents presented on screen).
2769 *
2770 * Sampling support is optional, and is set to DISABLE by default.
2771 * On each call to ENABLE, all collected statistics will be reset.
2772 *
2773 * Sample data can be queried via getDisplayedContentSample().
2774 *
2775 * Parameters:
2776 * enabled - indicates whether to enable or disable sampling.
2777 * component_mask - The mask of which components should be sampled.
2778 * If zero, all supported components are to be enabled.
2779 * max_frames - is the maximum number of frames that should be stored before
2780 * discard. The sample represents the most-recently posted frames.
2781 *
2782 * Returns HWC2_ERROR_NONE or one of the following errors:
2783 * HWC2_ERROR_BAD_DISPLAY when an invalid display handle was passed in,
2784 * HWC2_ERROR_BAD_PARAMETER when enabled was an invalid value, or
2785 * HWC2_ERROR_NO_RESOURCES when the requested ringbuffer size via max_frames
2786 * was not available.
2787 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2788 */
2789typedef int32_t (*HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED)(
2790 hwc2_device_t* device, hwc2_display_t display,
2791 int32_t /*hwc2_displayed_content_sampling_t*/ enabled,
2792 uint8_t /* mask of android_component_t */ component_mask,
2793 uint64_t max_frames);
2794
2795/* getDisplayedContentSample(..., component, max_frames, timestamp,
2796 * samples_size, samples, frame_count)
2797 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE
2798 * Optional by all HWC2 devices
2799 *
2800 * Collects the results of display content color sampling for display.
2801 *
2802 * Collection of data can occur whether the sampling is in ENABLE or
2803 * DISABLE state.
2804 *
2805 * Parameters:
2806 * max_frames - is the maximum number of frames that should be represented in
2807 * the sample. The sample represents the most-recently posted frames.
2808 * If max_frames is 0, all frames are to be represented by the sample.
2809 * timestamp - is the timestamp after which any frames were posted that should
2810 * be included in the sample. Timestamp is CLOCK_MONOTONIC.
2811 * If timestamp is 0, do not filter from the sample by time.
2812 * frame_count - The number of frames represented by this sample; pointer will
2813 * be non-NULL.
2814 * samples_size - The sizes of the color histogram representing the color
2815 * sampling. Sample_sizes are indexed in the same order as
2816 * HWC2_FORMAT_COMPONENT_.
2817 * samples - The arrays of data corresponding to the sampling data. Samples are
2818 * indexed in the same order as HWC2_FORMAT_COMPONENT_.
2819 * The size of each sample is the samples_size for the same index.
2820 * Each components sample is an array that is to be filled with the
2821 * evenly-weighted buckets of a histogram counting how many times a pixel
2822 * of the given component was displayed onscreen. Caller owns the data and
2823 * pointer may be NULL to query samples_size.
2824 *
2825 * Returns HWC2_ERROR_NONE or one of the following errors:
2826 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2827 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample, or
2828 * HWC2_ERROR_BAD_PARAMETER when the component is not supported by the hardware.
2829 */
2830typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE)(
2831 hwc2_device_t* device, hwc2_display_t display,
2832 uint64_t max_frames, uint64_t timestamp,
2833 uint64_t* frame_count, int32_t samples_size[4], uint64_t* samples[4]);
2834
Peiyong Linf09421f2018-10-26 18:31:03 -07002835/* getDisplayCapabilities(..., outCapabilities)
2836 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES
2837 * Required for HWC2 devices for composer 2.3
2838 * Optional for HWC2 devices for composer 2.1 and 2.2
2839 *
2840 * getDisplayCapabilities returns a list of supported capabilities
2841 * (as described in the definition of Capability above).
2842 * This list must not change after initialization.
2843 *
2844 * Parameters:
2845 * outNumCapabilities - if outCapabilities was nullptr, returns the number of capabilities
2846 * if outCapabilities was not nullptr, returns the number of capabilities stored in
2847 * outCapabilities, which must not exceed the value stored in outNumCapabilities prior
2848 * to the call; pointer will be non-NULL
2849 * outCapabilities - a list of supported capabilities.
2850 *
2851 * Returns HWC2_ERROR_NONE or one of the following errors:
2852 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2853 */
2854typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CAPABILITIES)(
2855 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumCapabilities,
2856 uint32_t* outCapabilities);
2857
Peiyong Lin59dedc32019-04-11 13:25:24 -07002858/* Use getDisplayCapabilities instead. If brightness is supported, must return
2859 * DisplayCapability::BRIGHTNESS as one of the display capabilities via getDisplayCapabilities.
2860 * Only use getDisplayCapabilities as the source of truth to query brightness support.
2861 *
2862 * getDisplayBrightnessSupport(displayToken)
Dan Gittik10510ff2019-01-18 19:30:24 +00002863 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT
2864 * Required for HWC2 devices for composer 2.3
2865 * Optional for HWC2 devices for composer 2.1 and 2.2
2866 *
2867 * getDisplayBrightnessSupport returns whether brightness operations are supported on a display.
2868 *
2869 * Parameters:
2870 * outSupport - whether the display supports operations.
2871 *
2872 * Returns HWC2_ERROR_NONE or one of the following errors:
2873 * HWC2_ERROR_BAD_DISPLAY when the display is invalid.
2874 */
2875typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT)(hwc2_device_t* device,
2876 hwc2_display_t display, bool* outSupport);
2877
2878/* setDisplayBrightness(displayToken, brightnesss)
2879 * Descriptor: HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS
2880 * Required for HWC2 devices for composer 2.3
2881 * Optional for HWC2 devices for composer 2.1 and 2.2
2882 *
2883 * setDisplayBrightness sets the brightness of a display.
2884 *
2885 * Parameters:
2886 * brightness - a number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or
2887 * -1.0f to turn the backlight off.
2888 *
2889 * Returns HWC2_ERROR_NONE or one of the following errors:
2890 * HWC2_ERROR_BAD_DISPLAY when the display is invalid, or
2891 * HWC2_ERROR_UNSUPPORTED when brightness operations are not supported, or
2892 * HWC2_ERROR_BAD_PARAMETER when the brightness is invalid, or
2893 * HWC2_ERROR_NO_RESOURCES when the brightness cannot be applied.
2894 */
2895typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_DISPLAY_BRIGHTNESS)(hwc2_device_t* device,
2896 hwc2_display_t display, float brightness);
2897
Dominik Laskowski9c1266c2019-10-01 15:14:53 -07002898/* getDisplayConnectionType(..., outType)
2899 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE
2900 * Optional for all HWC2 devices
2901 *
2902 * Returns whether the given physical display is internal or external.
2903 *
2904 * Parameters:
2905 * outType - the connection type of the display; pointer will be non-NULL
2906 *
2907 * Returns HWC2_ERROR_NONE or one of the following errors:
2908 * HWC2_ERROR_BAD_DISPLAY when the display is invalid or virtual.
2909 */
2910typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE)(
2911 hwc2_device_t* device, hwc2_display_t display,
2912 uint32_t* /*hwc2_display_connection_type_t*/ outType);
2913
Ady Abraham8324c922019-10-10 19:14:07 -07002914/* getDisplayVsyncPeriod(..., outVsyncPeriods)
2915 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD
2916 * Required for HWC2 devices for composer 2.4
2917 *
2918 * Retrieves which vsync period the display is currently using.
2919 *
2920 * If no display configuration is currently active, this function must
2921 * return BAD_CONFIG. If a vsync period is about to change due to a
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002922 * setActiveConfigWithConstraints call, this function must return the current vsync period
Ady Abraham8324c922019-10-10 19:14:07 -07002923 * until the change has taken place.
2924 *
2925 * Parameters:
2926 * outVsyncPeriod - the current vsync period of the display.
2927 *
2928 * Returns HWC2_ERROR_NONE or one of the following errors:
2929 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2930 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
2931 */
2932typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD)(
2933 hwc2_device_t* device, hwc2_display_t display, hwc2_vsync_period_t* outVsyncPeriod);
2934
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002935/* setActiveConfigWithConstraints(...,
2936 * config,
2937 * vsyncPeriodChangeConstraints,
2938 * outTimeline)
2939 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS
Ady Abraham8324c922019-10-10 19:14:07 -07002940 * Required for HWC2 devices for composer 2.4
2941 *
2942 * Sets the active configuration and the refresh rate for this display.
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002943 * If the new config shares the same config group as the current config,
2944 * only the vsync period shall change.
Ady Abraham8324c922019-10-10 19:14:07 -07002945 * Upon returning, the given display configuration, except vsync period, must be active and
2946 * remain so until either this function is called again or the display is disconnected.
2947 * When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
2948 * called with the new vsync period.
2949 *
2950 * Parameters:
2951 * config - the new display configuration.
Ady Abraham8324c922019-10-10 19:14:07 -07002952 * vsyncPeriodChangeConstraints - constraints required for changing vsync period:
2953 * desiredTimeNanos - the time in CLOCK_MONOTONIC after
2954 * which the vsync period may change
2955 * (i.e., the vsync period must not change
2956 * before this time).
2957 * seamlessRequired - if true, requires that the vsync period
2958 * change must happen seamlessly without
2959 * a noticeable visual artifact.
Ady Abrahamc1b2f072019-12-30 12:56:54 -08002960 * When the conditions change and it may be
2961 * possible to change the vsync period
2962 * seamlessly, HWC2_CALLBACK_SEAMLESS_POSSIBLE
2963 * callback must be called to indicate that
2964 * caller should retry.
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002965 * outTimeline - the timeline for the vsync period change.
Ady Abraham8324c922019-10-10 19:14:07 -07002966 *
2967 * Returns HWC2_ERROR_NONE or one of the following errors:
2968 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in.
2969 * HWC2_ERROR_BAD_CONFIG - an invalid configuration handle passed in.
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002970 * HWC2_ERROR_SEAMLESS_NOT_ALLOWED - when seamlessRequired was true but config provided doesn't
2971 * share the same config group as the current config.
Ady Abraham8324c922019-10-10 19:14:07 -07002972 * HWC2_ERROR_SEAMLESS_NOT_POSSIBLE - when seamlessRequired was true but the display cannot
2973 * achieve the vsync period change without a noticeable
2974 * visual artifact.
2975 */
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002976typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG_WITH_CONSTRAINTS)(
Ady Abraham8324c922019-10-10 19:14:07 -07002977 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
Ady Abraham8324c922019-10-10 19:14:07 -07002978 hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
Ady Abrahamb1ea4032019-10-18 18:00:01 -07002979 hwc_vsync_period_change_timeline_t* outTimeline);
Ady Abraham8324c922019-10-10 19:14:07 -07002980
Galia Peycheva038dfb12019-11-06 22:59:52 +01002981/* setAutoLowLatencyMode(displayToken, on)
2982 * Descriptor: HWC2_FUNCTION_SET_AUTO_LOW_LATENCY_MODE
Peiyong Linb923ad02020-01-09 10:34:06 -08002983 * Optional for HWC2 devices
Galia Peycheva038dfb12019-11-06 22:59:52 +01002984 *
2985 * setAutoLowLatencyMode requests that the display goes into low latency mode. If the display
2986 * is connected via HDMI 2.1, then Auto Low Latency Mode should be triggered. If the display is
2987 * internally connected, then a custom low latency mode should be triggered (if available).
2988 *
2989 * Parameters:
2990 * on - indicates whether to turn low latency mode on (=true) or off (=false)
2991 *
2992 * Returns HWC2_ERROR_NONE or one of the following errors:
2993 * HWC2_ERROR_BAD_DISPLAY - when the display is invalid, or
2994 * HWC2_ERROR_UNSUPPORTED - when the display does not support any low latency mode
2995 */
2996typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_AUTO_LOW_LATENCY_MODE)(hwc2_device_t* device,
2997 hwc2_display_t display, bool on);
2998
2999/* getSupportedContentTypes(..., outSupportedContentTypes)
3000 * Descriptor: HWC2_FUNCTION_GET_SUPPORTED_CONTENT_TYPES
Peiyong Linb923ad02020-01-09 10:34:06 -08003001 * Optional for HWC2 devices
Galia Peycheva038dfb12019-11-06 22:59:52 +01003002 *
3003 * getSupportedContentTypes returns a list of supported content types
3004 * (as described in the definition of ContentType above).
3005 * This list must not change after initialization.
3006 *
3007 * Parameters:
3008 * outNumSupportedContentTypes - if outSupportedContentTypes was nullptr, returns the number
3009 * of supported content types; if outSupportedContentTypes was not nullptr, returns the
3010 * number of capabilities stored in outSupportedContentTypes, which must not exceed the
3011 * value stored in outNumSupportedContentTypes prior to the call; pointer will be non-NULL
3012 * outSupportedContentTypes - a list of supported content types.
3013 *
3014 * Returns HWC2_ERROR_NONE or one of the following errors:
3015 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
3016 */
3017typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_GET_SUPPORTED_CONTENT_TYPES)(hwc2_device_t* device,
3018 hwc2_display_t display, uint32_t* outNumSupportedContentTypes, uint32_t* outSupportedContentTypes);
3019
3020/* setContentType(displayToken, contentType)
3021 * Descriptor: HWC2_FUNCTION_SET_CONTENT_TYPE
Peiyong Linb923ad02020-01-09 10:34:06 -08003022 * Optional for HWC2 devices
Galia Peycheva038dfb12019-11-06 22:59:52 +01003023 *
3024 * setContentType instructs the display that the content being shown is of the given contentType
3025 * (one of GRAPHICS, PHOTO, CINEMA, GAME).
3026 *
3027 * According to the HDMI 1.4 specification, supporting all content types is optional. Whether
3028 * the display supports a given content type is reported by getSupportedContentTypes.
3029 *
3030 * Parameters:
3031 * contentType - the type of content that is currently being shown on the display
3032 *
3033 * Returns HWC2_ERROR_NONE or one of the following errors:
3034 * HWC2_ERROR_BAD_DISPLAY - when the display is invalid, or
3035 * HWC2_ERROR_UNSUPPORTED - when the given content type is a valid content type, but is not
3036 * supported on this display, or
3037 * HWC2_ERROR_BAD_PARAMETER - when the given content type is invalid
3038 */
3039typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_CONTENT_TYPE)(hwc2_device_t* device,
3040 hwc2_display_t display, int32_t /* hwc2_content_type_t */ contentType);
Ady Abraham8324c922019-10-10 19:14:07 -07003041
Peiyong Linf7775422020-01-08 15:30:52 -08003042/* getClientTargetProperty(..., outClientTargetProperty)
3043 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_PROPERTY
3044 * Optional for HWC2 devices
3045 *
3046 * Retrieves the client target properties for which the hardware composer
3047 * requests after the last call to validateDisplay. The client must set the
3048 * properties of the client target to match the returned values.
3049 * When this API is implemented, if client composition is needed, the hardware
3050 * composer must return meaningful client target property with dataspace not
3051 * setting to UNKNOWN.
3052 * When the returned dataspace is set to UNKNOWN, it means hardware composer
3053 * requests nothing, the client must ignore the returned client target property
3054 * structrue.
3055 *
3056 * Parameters:
3057 * outClientTargetProperty - the client target properties that hardware
3058 * composer requests. If dataspace field is set to UNKNOWN, it means
3059 * the hardware composer requests nothing, the client must ignore the
3060 * returned client target property structure.
3061 *
3062 * Returns HWC2_ERROR_NONE or one of the following errors:
3063 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
3064 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
3065 * display
3066 */
3067typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_PROPERTY)(
3068 hwc2_device_t* device, hwc2_display_t display,
3069 hwc_client_target_property_t* outClientTargetProperty);
3070
Dan Stoza4e9221b2015-09-02 15:43:39 -07003071__END_DECLS
3072
3073#endif