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