blob: 7db2aba2a5358d5c277ea0e08747c1be8fe9d8e5 [file] [log] [blame]
Dan Stoza4e9221b2015-09-02 15:43:39 -07001/*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_HARDWARE_HWCOMPOSER2_H
18#define ANDROID_HARDWARE_HWCOMPOSER2_H
19
Colin Cross248ec3d2016-10-06 16:53:00 -070020#include <sys/cdefs.h>
21
Dan Stoza4e9221b2015-09-02 15:43:39 -070022#include <hardware/hardware.h>
23
24#include "hwcomposer_defs.h"
25
26__BEGIN_DECLS
27
28/*
29 * Enums
30 *
31 * For most of these enums, there is an invalid value defined to be 0. This is
32 * an attempt to catch uninitialized fields, and these values should not be
33 * used.
34 */
35
36/* Display attributes queryable through getDisplayAttribute */
37typedef enum {
38 HWC2_ATTRIBUTE_INVALID = 0,
39
40 /* Dimensions in pixels */
41 HWC2_ATTRIBUTE_WIDTH = 1,
42 HWC2_ATTRIBUTE_HEIGHT = 2,
43
44 /* Vsync period in nanoseconds */
45 HWC2_ATTRIBUTE_VSYNC_PERIOD = 3,
46
47 /* Dots per thousand inches (DPI * 1000). Scaling by 1000 allows these
48 * numbers to be stored in an int32_t without losing too much precision. If
49 * the DPI for a configuration is unavailable or is considered unreliable,
50 * the device may return -1 instead */
51 HWC2_ATTRIBUTE_DPI_X = 4,
52 HWC2_ATTRIBUTE_DPI_Y = 5,
53} hwc2_attribute_t;
54
55/* Blend modes, settable per layer */
56typedef enum {
57 HWC2_BLEND_MODE_INVALID = 0,
58
59 /* colorOut = colorSrc */
60 HWC2_BLEND_MODE_NONE = 1,
61
62 /* colorOut = colorSrc + colorDst * (1 - alphaSrc) */
63 HWC2_BLEND_MODE_PREMULTIPLIED = 2,
64
65 /* colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc) */
66 HWC2_BLEND_MODE_COVERAGE = 3,
67} hwc2_blend_mode_t;
68
69/* See the 'Callbacks' section for more detailed descriptions of what these
70 * functions do */
71typedef enum {
72 HWC2_CALLBACK_INVALID = 0,
73 HWC2_CALLBACK_HOTPLUG = 1,
74 HWC2_CALLBACK_REFRESH = 2,
75 HWC2_CALLBACK_VSYNC = 3,
Ady Abraham8324c922019-10-10 19:14:07 -070076 HWC2_CALLBACK_VSYNC_2_4 = 4,
Dan Stoza4e9221b2015-09-02 15:43:39 -070077} hwc2_callback_descriptor_t;
78
79/* Optional capabilities which may be supported by some devices. The particular
80 * set of supported capabilities for a given device may be retrieved using
81 * getCapabilities. */
82typedef enum {
83 HWC2_CAPABILITY_INVALID = 0,
84
85 /* Specifies that the device supports sideband stream layers, for which
86 * buffer content updates and other synchronization will not be provided
87 * through the usual validate/present cycle and must be handled by an
88 * external implementation-defined mechanism. Only changes to layer state
89 * (such as position, size, etc.) need to be performed through the
90 * validate/present cycle. */
91 HWC2_CAPABILITY_SIDEBAND_STREAM = 1,
Dan Stozad2168f72016-07-14 11:48:16 -070092
93 /* Specifies that the device will apply a color transform even when either
94 * the client or the device has chosen that all layers should be composed by
95 * the client. This will prevent the client from applying the color
96 * transform during its composition step. */
97 HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2,
Brian Anderson49018a52017-04-04 16:43:11 -070098
99 /* Specifies that the present fence must not be used as an accurate
100 * representation of the actual present time of a frame.
101 * This capability must never be set by HWC2 devices.
102 * This capability may be set for HWC1 devices that use the
103 * HWC2On1Adapter where emulation of the present fence using the retire
104 * fence is not feasible.
105 * In the future, CTS tests will require present time to be reliable.
106 */
107 HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE = 3,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700108
109 /* Specifies that a device is able to skip the validateDisplay call before
110 * receiving a call to presentDisplay. The client will always skip
111 * validateDisplay and try to call presentDisplay regardless of the changes
112 * in the properties of the layers. If the device returns anything else than
113 * HWC2_ERROR_NONE, it will call validateDisplay then presentDisplay again.
114 * For this capability to be worthwhile the device implementation of
115 * presentDisplay should fail as fast as possible in the case a
116 * validateDisplay step is needed.
117 */
Peiyong Linfd05d132018-01-22 12:23:25 -0800118 HWC2_CAPABILITY_SKIP_VALIDATE = 4,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700119} hwc2_capability_t;
120
121/* Possible composition types for a given layer */
122typedef enum {
123 HWC2_COMPOSITION_INVALID = 0,
124
125 /* The client will composite this layer into the client target buffer
126 * (provided to the device through setClientTarget).
127 *
128 * The device must not request any composition type changes for layers of
129 * this type. */
130 HWC2_COMPOSITION_CLIENT = 1,
131
132 /* The device will handle the composition of this layer through a hardware
133 * overlay or other similar means.
134 *
135 * Upon validateDisplay, the device may request a change from this type to
136 * HWC2_COMPOSITION_CLIENT. */
137 HWC2_COMPOSITION_DEVICE = 2,
138
139 /* The device will render this layer using the color set through
140 * setLayerColor. If this functionality is not supported on a layer that the
141 * client sets to HWC2_COMPOSITION_SOLID_COLOR, the device must request that
142 * the composition type of that layer is changed to HWC2_COMPOSITION_CLIENT
143 * upon the next call to validateDisplay.
144 *
145 * Upon validateDisplay, the device may request a change from this type to
146 * HWC2_COMPOSITION_CLIENT. */
147 HWC2_COMPOSITION_SOLID_COLOR = 3,
148
149 /* Similar to DEVICE, but the position of this layer may also be set
150 * asynchronously through setCursorPosition. If this functionality is not
151 * supported on a layer that the client sets to HWC2_COMPOSITION_CURSOR, the
152 * device must request that the composition type of that layer is changed to
153 * HWC2_COMPOSITION_CLIENT upon the next call to validateDisplay.
154 *
155 * Upon validateDisplay, the device may request a change from this type to
156 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT. Changing to
157 * HWC2_COMPOSITION_DEVICE will prevent the use of setCursorPosition but
158 * still permit the device to composite the layer. */
159 HWC2_COMPOSITION_CURSOR = 4,
160
161 /* The device will handle the composition of this layer, as well as its
162 * buffer updates and content synchronization. Only supported on devices
163 * which provide HWC2_CAPABILITY_SIDEBAND_STREAM.
164 *
165 * Upon validateDisplay, the device may request a change from this type to
166 * either HWC2_COMPOSITION_DEVICE or HWC2_COMPOSITION_CLIENT, but it is
167 * unlikely that content will display correctly in these cases. */
168 HWC2_COMPOSITION_SIDEBAND = 5,
169} hwc2_composition_t;
170
171/* Possible connection options from the hotplug callback */
172typedef enum {
173 HWC2_CONNECTION_INVALID = 0,
174
175 /* The display has been connected */
176 HWC2_CONNECTION_CONNECTED = 1,
177
178 /* The display has been disconnected */
179 HWC2_CONNECTION_DISCONNECTED = 2,
180} hwc2_connection_t;
181
182/* Display requests returned by getDisplayRequests */
183typedef enum {
184 /* Instructs the client to provide a new client target buffer, even if no
185 * layers are marked for client composition. */
186 HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET = 1 << 0,
187
188 /* Instructs the client to write the result of client composition directly
189 * into the virtual display output buffer. If any of the layers are not
190 * marked as HWC2_COMPOSITION_CLIENT or the given display is not a virtual
191 * display, this request has no effect. */
192 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
193} hwc2_display_request_t;
194
195/* Display types returned by getDisplayType */
196typedef enum {
197 HWC2_DISPLAY_TYPE_INVALID = 0,
198
199 /* All physical displays, including both internal displays and hotpluggable
200 * external displays */
201 HWC2_DISPLAY_TYPE_PHYSICAL = 1,
202
203 /* Virtual displays created by createVirtualDisplay */
204 HWC2_DISPLAY_TYPE_VIRTUAL = 2,
205} hwc2_display_type_t;
206
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700207/* Physical display types returned by getDisplayConnectionType */
208typedef enum {
209 HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL = 0,
210 HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL = 1,
211} hwc2_display_connection_type_t;
212
Dan Stoza4e9221b2015-09-02 15:43:39 -0700213/* Return codes from all functions */
214typedef enum {
215 HWC2_ERROR_NONE = 0,
216 HWC2_ERROR_BAD_CONFIG,
217 HWC2_ERROR_BAD_DISPLAY,
218 HWC2_ERROR_BAD_LAYER,
219 HWC2_ERROR_BAD_PARAMETER,
220 HWC2_ERROR_HAS_CHANGES,
221 HWC2_ERROR_NO_RESOURCES,
222 HWC2_ERROR_NOT_VALIDATED,
223 HWC2_ERROR_UNSUPPORTED,
Ady Abraham8324c922019-10-10 19:14:07 -0700224 HWC2_ERROR_BAD_VSYNC_PERIOD,
225 HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700226} hwc2_error_t;
227
228/* Function descriptors for use with getFunction */
229typedef enum {
230 HWC2_FUNCTION_INVALID = 0,
231 HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
232 HWC2_FUNCTION_CREATE_LAYER,
233 HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
234 HWC2_FUNCTION_DESTROY_LAYER,
235 HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
236 HWC2_FUNCTION_DUMP,
237 HWC2_FUNCTION_GET_ACTIVE_CONFIG,
238 HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
239 HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
240 HWC2_FUNCTION_GET_COLOR_MODES,
241 HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
242 HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
243 HWC2_FUNCTION_GET_DISPLAY_NAME,
244 HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
245 HWC2_FUNCTION_GET_DISPLAY_TYPE,
246 HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700247 HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700248 HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
249 HWC2_FUNCTION_GET_RELEASE_FENCES,
250 HWC2_FUNCTION_PRESENT_DISPLAY,
251 HWC2_FUNCTION_REGISTER_CALLBACK,
252 HWC2_FUNCTION_SET_ACTIVE_CONFIG,
253 HWC2_FUNCTION_SET_CLIENT_TARGET,
254 HWC2_FUNCTION_SET_COLOR_MODE,
255 HWC2_FUNCTION_SET_COLOR_TRANSFORM,
256 HWC2_FUNCTION_SET_CURSOR_POSITION,
257 HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
258 HWC2_FUNCTION_SET_LAYER_BUFFER,
259 HWC2_FUNCTION_SET_LAYER_COLOR,
260 HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
261 HWC2_FUNCTION_SET_LAYER_DATASPACE,
262 HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
263 HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
264 HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
265 HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
266 HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
267 HWC2_FUNCTION_SET_LAYER_TRANSFORM,
268 HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
269 HWC2_FUNCTION_SET_LAYER_Z_ORDER,
270 HWC2_FUNCTION_SET_OUTPUT_BUFFER,
271 HWC2_FUNCTION_SET_POWER_MODE,
272 HWC2_FUNCTION_SET_VSYNC_ENABLED,
273 HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800274 HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700275 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700276 HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
277 HWC2_FUNCTION_SET_READBACK_BUFFER,
278 HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700279 HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
280 HWC2_FUNCTION_GET_RENDER_INTENTS,
281 HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700282 HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700283
284 // composer 2.3
285 HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Peiyong Linf09421f2018-10-26 18:31:03 -0700286 HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
Peiyong Lin44819b92018-09-13 16:20:08 -0700287 HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700288 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
289 HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
290 HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Valerie Hau69c53432018-11-13 09:07:44 -0800291 HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
Dan Gittik10510ff2019-01-18 19:30:24 +0000292 HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
293 HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700294
295 // composer 2.4
296 HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
Ady Abraham8324c922019-10-10 19:14:07 -0700297 HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS,
298 HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
299 HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700300} hwc2_function_descriptor_t;
301
Dan Stozaf601e972016-03-16 09:54:40 -0700302/* Layer requests returned from getDisplayRequests */
Dan Stoza4e9221b2015-09-02 15:43:39 -0700303typedef enum {
304 /* The client should clear its target with transparent pixels where this
305 * layer would be. The client may ignore this request if the layer must be
306 * blended. */
307 HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET = 1 << 0,
308} hwc2_layer_request_t;
309
310/* Power modes for use with setPowerMode */
311typedef enum {
312 /* The display is fully off (blanked) */
313 HWC2_POWER_MODE_OFF = 0,
314
315 /* These are optional low power modes. getDozeSupport may be called to
316 * determine whether a given display supports these modes. */
317
318 /* The display is turned on and configured in a low power state that is
319 * suitable for presenting ambient information to the user, possibly with
320 * lower fidelity than HWC2_POWER_MODE_ON, but with greater efficiency. */
321 HWC2_POWER_MODE_DOZE = 1,
322
323 /* The display is configured as in HWC2_POWER_MODE_DOZE but may stop
324 * applying display updates from the client. This is effectively a hint to
325 * the device that drawing to the display has been suspended and that the
326 * the device should remain on in a low power state and continue displaying
327 * its current contents indefinitely until the power mode changes.
328 *
329 * This mode may also be used as a signal to enable hardware-based doze
330 * functionality. In this case, the device is free to take over the display
331 * and manage it autonomously to implement a low power always-on display. */
332 HWC2_POWER_MODE_DOZE_SUSPEND = 3,
333
334 /* The display is fully on */
335 HWC2_POWER_MODE_ON = 2,
336} hwc2_power_mode_t;
337
338/* Vsync values passed to setVsyncEnabled */
339typedef enum {
340 HWC2_VSYNC_INVALID = 0,
341
342 /* Enable vsync */
343 HWC2_VSYNC_ENABLE = 1,
344
345 /* Disable vsync */
346 HWC2_VSYNC_DISABLE = 2,
347} hwc2_vsync_t;
348
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700349/* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */
350typedef enum {
351 /* SMPTE ST 2084:2014.
352 * Coordinates defined in CIE 1931 xy chromaticity space
353 */
354 HWC2_DISPLAY_RED_PRIMARY_X = 0,
355 HWC2_DISPLAY_RED_PRIMARY_Y = 1,
356 HWC2_DISPLAY_GREEN_PRIMARY_X = 2,
357 HWC2_DISPLAY_GREEN_PRIMARY_Y = 3,
358 HWC2_DISPLAY_BLUE_PRIMARY_X = 4,
359 HWC2_DISPLAY_BLUE_PRIMARY_Y = 5,
360 HWC2_WHITE_POINT_X = 6,
361 HWC2_WHITE_POINT_Y = 7,
362 /* SMPTE ST 2084:2014.
363 * Units: nits
364 * max as defined by ST 2048: 10,000 nits
365 */
366 HWC2_MAX_LUMINANCE = 8,
367 HWC2_MIN_LUMINANCE = 9,
368
369 /* CTA 861.3
370 * Units: nits
371 */
372 HWC2_MAX_CONTENT_LIGHT_LEVEL = 10,
373 HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
374} hwc2_per_frame_metadata_key_t;
375
Kevin DuBois13458872018-09-10 09:09:12 -0700376/* SetDisplayedContentSampling values passed to setDisplayedContentSamplingEnabled */
377typedef enum {
378 HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID = 0,
379
380 /* Enable displayed content sampling */
381 HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE = 1,
382
383 /* Disable displayed content sampling */
384 HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE = 2,
385} hwc2_displayed_content_sampling_t;
386
387typedef enum {
388 HWC2_FORMAT_COMPONENT_0 = 1 << 0, /* The first component (eg, for RGBA_8888, this is R) */
389 HWC2_FORMAT_COMPONENT_1 = 1 << 1, /* The second component (eg, for RGBA_8888, this is G) */
390 HWC2_FORMAT_COMPONENT_2 = 1 << 2, /* The third component (eg, for RGBA_8888, this is B) */
391 HWC2_FORMAT_COMPONENT_3 = 1 << 3, /* The fourth component (eg, for RGBA_8888, this is A) */
392} hwc2_format_color_component_t;
393
Peiyong Linf09421f2018-10-26 18:31:03 -0700394/* Optional display capabilities which may be supported by some displays.
395 * The particular set of supported capabilities for a given display may be
396 * retrieved using getDisplayCapabilities. */
397typedef enum {
398 HWC2_DISPLAY_CAPABILITY_INVALID = 0,
399
400 /**
401 * Specifies that the display must apply a color transform even when either
402 * the client or the device has chosen that all layers should be composed by
403 * the client. This prevents the client from applying the color transform
404 * during its composition step.
405 * If getDisplayCapabilities is supported, the global capability
406 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is ignored.
407 * If getDisplayCapabilities is not supported, and the global capability
408 * HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
409 * then all displays must be treated as having
410 * HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM.
411 */
412 HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 1,
413
414 /**
415 * Specifies that the display supports PowerMode::DOZE and
416 * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
417 * over DOZE (see the definition of PowerMode for more information),
418 * but if both DOZE and DOZE_SUSPEND are no different from
419 * PowerMode::ON, the device must not claim support.
420 * HWC2_DISPLAY_CAPABILITY_DOZE must be returned by getDisplayCapabilities
421 * when getDozeSupport indicates the display supports PowerMode::DOZE and
422 * PowerMode::DOZE_SUSPEND.
423 */
424 HWC2_DISPLAY_CAPABILITY_DOZE = 2,
Dan Gittik10510ff2019-01-18 19:30:24 +0000425
426 /**
427 * Specified that the display supports brightness operations.
428 */
429 HWC2_DISPLAY_CAPABILITY_BRIGHTNESS = 3,
Peiyong Linf09421f2018-10-26 18:31:03 -0700430} hwc2_display_capability_t;
431
Dan Stoza4e9221b2015-09-02 15:43:39 -0700432/*
433 * Stringification Functions
434 */
435
436#ifdef HWC2_INCLUDE_STRINGIFICATION
437
438static inline const char* getAttributeName(hwc2_attribute_t attribute) {
439 switch (attribute) {
440 case HWC2_ATTRIBUTE_INVALID: return "Invalid";
441 case HWC2_ATTRIBUTE_WIDTH: return "Width";
442 case HWC2_ATTRIBUTE_HEIGHT: return "Height";
443 case HWC2_ATTRIBUTE_VSYNC_PERIOD: return "VsyncPeriod";
444 case HWC2_ATTRIBUTE_DPI_X: return "DpiX";
445 case HWC2_ATTRIBUTE_DPI_Y: return "DpiY";
446 default: return "Unknown";
447 }
448}
449
450static inline const char* getBlendModeName(hwc2_blend_mode_t mode) {
451 switch (mode) {
452 case HWC2_BLEND_MODE_INVALID: return "Invalid";
453 case HWC2_BLEND_MODE_NONE: return "None";
454 case HWC2_BLEND_MODE_PREMULTIPLIED: return "Premultiplied";
455 case HWC2_BLEND_MODE_COVERAGE: return "Coverage";
456 default: return "Unknown";
457 }
458}
459
460static inline const char* getCallbackDescriptorName(
461 hwc2_callback_descriptor_t desc) {
462 switch (desc) {
463 case HWC2_CALLBACK_INVALID: return "Invalid";
464 case HWC2_CALLBACK_HOTPLUG: return "Hotplug";
465 case HWC2_CALLBACK_REFRESH: return "Refresh";
466 case HWC2_CALLBACK_VSYNC: return "Vsync";
467 default: return "Unknown";
468 }
469}
470
471static inline const char* getCapabilityName(hwc2_capability_t capability) {
472 switch (capability) {
473 case HWC2_CAPABILITY_INVALID: return "Invalid";
474 case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream";
Dan Stozad2168f72016-07-14 11:48:16 -0700475 case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
476 return "SkipClientColorTransform";
Brian Anderson49018a52017-04-04 16:43:11 -0700477 case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
478 return "PresentFenceIsNotReliable";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700479 default: return "Unknown";
480 }
481}
482
483static inline const char* getCompositionName(hwc2_composition_t composition) {
484 switch (composition) {
485 case HWC2_COMPOSITION_INVALID: return "Invalid";
486 case HWC2_COMPOSITION_CLIENT: return "Client";
487 case HWC2_COMPOSITION_DEVICE: return "Device";
488 case HWC2_COMPOSITION_SOLID_COLOR: return "SolidColor";
489 case HWC2_COMPOSITION_CURSOR: return "Cursor";
490 case HWC2_COMPOSITION_SIDEBAND: return "Sideband";
491 default: return "Unknown";
492 }
493}
494
495static inline const char* getConnectionName(hwc2_connection_t connection) {
496 switch (connection) {
497 case HWC2_CONNECTION_INVALID: return "Invalid";
498 case HWC2_CONNECTION_CONNECTED: return "Connected";
499 case HWC2_CONNECTION_DISCONNECTED: return "Disconnected";
500 default: return "Unknown";
501 }
502}
503
504static inline const char* getDisplayRequestName(
505 hwc2_display_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700506 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700507 case 0: return "None";
508 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget";
509 case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
510 return "WriteClientTargetToOutput";
511 case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET |
512 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT:
513 return "FlipClientTarget|WriteClientTargetToOutput";
514 default: return "Unknown";
515 }
516}
517
518static inline const char* getDisplayTypeName(hwc2_display_type_t type) {
519 switch (type) {
520 case HWC2_DISPLAY_TYPE_INVALID: return "Invalid";
521 case HWC2_DISPLAY_TYPE_PHYSICAL: return "Physical";
522 case HWC2_DISPLAY_TYPE_VIRTUAL: return "Virtual";
523 default: return "Unknown";
524 }
525}
526
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700527static inline const char* getDisplayConnectionTypeName(hwc2_display_connection_type_t type) {
528 switch (type) {
529 case HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL: return "Internal";
530 case HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL: return "External";
531 default: return "Unknown";
532 }
533}
534
Dan Stoza4e9221b2015-09-02 15:43:39 -0700535static inline const char* getErrorName(hwc2_error_t error) {
536 switch (error) {
537 case HWC2_ERROR_NONE: return "None";
538 case HWC2_ERROR_BAD_CONFIG: return "BadConfig";
539 case HWC2_ERROR_BAD_DISPLAY: return "BadDisplay";
540 case HWC2_ERROR_BAD_LAYER: return "BadLayer";
541 case HWC2_ERROR_BAD_PARAMETER: return "BadParameter";
542 case HWC2_ERROR_HAS_CHANGES: return "HasChanges";
543 case HWC2_ERROR_NO_RESOURCES: return "NoResources";
544 case HWC2_ERROR_NOT_VALIDATED: return "NotValidated";
545 case HWC2_ERROR_UNSUPPORTED: return "Unsupported";
Ady Abraham8324c922019-10-10 19:14:07 -0700546 case HWC2_ERROR_BAD_VSYNC_PERIOD: return "BadVsyncPeriod";
547 case HWC2_ERROR_SEAMLESS_NOT_POSSIBLE: return "SeamlessNotPossible";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700548 default: return "Unknown";
549 }
550}
551
552static inline const char* getFunctionDescriptorName(
553 hwc2_function_descriptor_t desc) {
554 switch (desc) {
555 case HWC2_FUNCTION_INVALID: return "Invalid";
556 case HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES:
557 return "AcceptDisplayChanges";
558 case HWC2_FUNCTION_CREATE_LAYER: return "CreateLayer";
559 case HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY:
560 return "CreateVirtualDisplay";
561 case HWC2_FUNCTION_DESTROY_LAYER: return "DestroyLayer";
562 case HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY:
563 return "DestroyVirtualDisplay";
564 case HWC2_FUNCTION_DUMP: return "Dump";
565 case HWC2_FUNCTION_GET_ACTIVE_CONFIG: return "GetActiveConfig";
566 case HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES:
567 return "GetChangedCompositionTypes";
568 case HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT:
569 return "GetClientTargetSupport";
570 case HWC2_FUNCTION_GET_COLOR_MODES: return "GetColorModes";
571 case HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE: return "GetDisplayAttribute";
572 case HWC2_FUNCTION_GET_DISPLAY_CONFIGS: return "GetDisplayConfigs";
573 case HWC2_FUNCTION_GET_DISPLAY_NAME: return "GetDisplayName";
574 case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
575 case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
576 case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
Dan Stozaf601e972016-03-16 09:54:40 -0700577 case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
Dan Stoza4e9221b2015-09-02 15:43:39 -0700578 case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
579 return "GetMaxVirtualDisplayCount";
580 case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
581 case HWC2_FUNCTION_PRESENT_DISPLAY: return "PresentDisplay";
582 case HWC2_FUNCTION_REGISTER_CALLBACK: return "RegisterCallback";
583 case HWC2_FUNCTION_SET_ACTIVE_CONFIG: return "SetActiveConfig";
584 case HWC2_FUNCTION_SET_CLIENT_TARGET: return "SetClientTarget";
585 case HWC2_FUNCTION_SET_COLOR_MODE: return "SetColorMode";
586 case HWC2_FUNCTION_SET_COLOR_TRANSFORM: return "SetColorTransform";
587 case HWC2_FUNCTION_SET_CURSOR_POSITION: return "SetCursorPosition";
588 case HWC2_FUNCTION_SET_LAYER_BLEND_MODE: return "SetLayerBlendMode";
589 case HWC2_FUNCTION_SET_LAYER_BUFFER: return "SetLayerBuffer";
590 case HWC2_FUNCTION_SET_LAYER_COLOR: return "SetLayerColor";
591 case HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE:
592 return "SetLayerCompositionType";
593 case HWC2_FUNCTION_SET_LAYER_DATASPACE: return "SetLayerDataspace";
594 case HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME:
595 return "SetLayerDisplayFrame";
596 case HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA: return "SetLayerPlaneAlpha";
597 case HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM:
598 return "SetLayerSidebandStream";
599 case HWC2_FUNCTION_SET_LAYER_SOURCE_CROP: return "SetLayerSourceCrop";
600 case HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE:
601 return "SetLayerSurfaceDamage";
602 case HWC2_FUNCTION_SET_LAYER_TRANSFORM: return "SetLayerTransform";
603 case HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION:
604 return "SetLayerVisibleRegion";
605 case HWC2_FUNCTION_SET_LAYER_Z_ORDER: return "SetLayerZOrder";
606 case HWC2_FUNCTION_SET_OUTPUT_BUFFER: return "SetOutputBuffer";
607 case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode";
608 case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled";
609 case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay";
Peiyong Linfd05d132018-01-22 12:23:25 -0800610 case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700611 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata";
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700612 case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys";
613 case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer";
614 case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes";
615 case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence";
Chia-I Wu28310aa2018-03-15 21:20:55 -0700616 case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents";
617 case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent";
618 case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix";
Peiyong Lin44819b92018-09-13 16:20:08 -0700619
620 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700621 case HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA: return "GetDisplayIdentificationData";
Peiyong Linf09421f2018-10-26 18:31:03 -0700622 case HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES: return "GetDisplayCapabilities";
Peiyong Lin44819b92018-09-13 16:20:08 -0700623 case HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM: return "SetLayerColorTransform";
Kevin DuBois13458872018-09-10 09:09:12 -0700624 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES: return "GetDisplayedContentSamplingAttributes";
625 case HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED: return "SetDisplayedContentSamplingEnabled";
626 case HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE: return "GetDisplayedContentSample";
Valerie Hau69c53432018-11-13 09:07:44 -0800627 case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS: return "SetLayerPerFrameMetadataBlobs";
Dan Gittik10510ff2019-01-18 19:30:24 +0000628 case HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT: return "GetDisplayBrightnessSupport";
629 case HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS: return "SetDisplayBrightness";
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700630
631 // composer 2.4
632 case HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE: return "GetDisplayConnectionType";
Ady Abraham8324c922019-10-10 19:14:07 -0700633 case HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS: return "getSupportedDisplayVsyncPeriods";
634 case HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD: return "getDisplayVsyncPeriod";
635 case HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD: return "setActiveConfigAndVsyncPeriod";
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700636
Dan Stoza4e9221b2015-09-02 15:43:39 -0700637 default: return "Unknown";
638 }
639}
640
641static inline const char* getLayerRequestName(hwc2_layer_request_t request) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700642 switch (__BIONIC_CAST(static_cast, int, request)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700643 case 0: return "None";
644 case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget";
645 default: return "Unknown";
646 }
647}
648
649static inline const char* getPowerModeName(hwc2_power_mode_t mode) {
650 switch (mode) {
651 case HWC2_POWER_MODE_OFF: return "Off";
652 case HWC2_POWER_MODE_DOZE_SUSPEND: return "DozeSuspend";
653 case HWC2_POWER_MODE_DOZE: return "Doze";
654 case HWC2_POWER_MODE_ON: return "On";
655 default: return "Unknown";
656 }
657}
658
659static inline const char* getTransformName(hwc_transform_t transform) {
Colin Cross248ec3d2016-10-06 16:53:00 -0700660 switch (__BIONIC_CAST(static_cast, int, transform)) {
Dan Stoza4e9221b2015-09-02 15:43:39 -0700661 case 0: return "None";
662 case HWC_TRANSFORM_FLIP_H: return "FlipH";
663 case HWC_TRANSFORM_FLIP_V: return "FlipV";
664 case HWC_TRANSFORM_ROT_90: return "Rotate90";
665 case HWC_TRANSFORM_ROT_180: return "Rotate180";
666 case HWC_TRANSFORM_ROT_270: return "Rotate270";
667 case HWC_TRANSFORM_FLIP_H_ROT_90: return "FlipHRotate90";
668 case HWC_TRANSFORM_FLIP_V_ROT_90: return "FlipVRotate90";
669 default: return "Unknown";
670 }
671}
672
673static inline const char* getVsyncName(hwc2_vsync_t vsync) {
674 switch (vsync) {
675 case HWC2_VSYNC_INVALID: return "Invalid";
676 case HWC2_VSYNC_ENABLE: return "Enable";
677 case HWC2_VSYNC_DISABLE: return "Disable";
678 default: return "Unknown";
679 }
680}
681
Kevin DuBois13458872018-09-10 09:09:12 -0700682static inline const char* getDisplayedContentSamplingName(
683 hwc2_displayed_content_sampling_t sampling) {
684 switch (sampling) {
685 case HWC2_DISPLAYED_CONTENT_SAMPLING_INVALID: return "Invalid";
686 case HWC2_DISPLAYED_CONTENT_SAMPLING_ENABLE: return "Enable";
687 case HWC2_DISPLAYED_CONTENT_SAMPLING_DISABLE: return "Disable";
688 default: return "Unknown";
689 }
690}
691
692static inline const char* getFormatColorComponentName(hwc2_format_color_component_t component) {
693 switch (component) {
694 case HWC2_FORMAT_COMPONENT_0: return "FirstComponent";
695 case HWC2_FORMAT_COMPONENT_1: return "SecondComponent";
696 case HWC2_FORMAT_COMPONENT_2: return "ThirdComponent";
697 case HWC2_FORMAT_COMPONENT_3: return "FourthComponent";
698 default: return "Unknown";
699 }
700}
701
Peiyong Linf09421f2018-10-26 18:31:03 -0700702static inline const char* getDisplayCapabilityName(hwc2_display_capability_t capability) {
703 switch (capability) {
704 case HWC2_DISPLAY_CAPABILITY_INVALID: return "Invalid";
705 case HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
706 return "SkipClientColorTransform";
707 case HWC2_DISPLAY_CAPABILITY_DOZE:
708 return "Doze";
Dan Gittik10510ff2019-01-18 19:30:24 +0000709 case HWC2_DISPLAY_CAPABILITY_BRIGHTNESS:
710 return "Brightness";
Peiyong Linf09421f2018-10-26 18:31:03 -0700711 default:
712 return "Unknown";
713 }
714}
715
Dan Stoza4e9221b2015-09-02 15:43:39 -0700716#define TO_STRING(E, T, printer) \
717 inline std::string to_string(E value) { return printer(value); } \
718 inline std::string to_string(T value) { return to_string(static_cast<E>(value)); }
719#else // !HWC2_INCLUDE_STRINGIFICATION
720#define TO_STRING(name, printer)
721#endif // HWC2_INCLUDE_STRINGIFICATION
722
723/*
724 * C++11 features
725 */
726
727#ifdef HWC2_USE_CPP11
728__END_DECLS
729
730#ifdef HWC2_INCLUDE_STRINGIFICATION
731#include <string>
732#endif
733
734namespace HWC2 {
735
736enum class Attribute : int32_t {
737 Invalid = HWC2_ATTRIBUTE_INVALID,
738 Width = HWC2_ATTRIBUTE_WIDTH,
739 Height = HWC2_ATTRIBUTE_HEIGHT,
740 VsyncPeriod = HWC2_ATTRIBUTE_VSYNC_PERIOD,
741 DpiX = HWC2_ATTRIBUTE_DPI_X,
742 DpiY = HWC2_ATTRIBUTE_DPI_Y,
743};
744TO_STRING(hwc2_attribute_t, Attribute, getAttributeName)
745
746enum class BlendMode : int32_t {
747 Invalid = HWC2_BLEND_MODE_INVALID,
748 None = HWC2_BLEND_MODE_NONE,
749 Premultiplied = HWC2_BLEND_MODE_PREMULTIPLIED,
750 Coverage = HWC2_BLEND_MODE_COVERAGE,
751};
752TO_STRING(hwc2_blend_mode_t, BlendMode, getBlendModeName)
753
754enum class Callback : int32_t {
755 Invalid = HWC2_CALLBACK_INVALID,
756 Hotplug = HWC2_CALLBACK_HOTPLUG,
757 Refresh = HWC2_CALLBACK_REFRESH,
758 Vsync = HWC2_CALLBACK_VSYNC,
Ady Abraham8324c922019-10-10 19:14:07 -0700759 Vsync_2_4 = HWC2_CALLBACK_VSYNC_2_4,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700760};
761TO_STRING(hwc2_callback_descriptor_t, Callback, getCallbackDescriptorName)
762
763enum class Capability : int32_t {
764 Invalid = HWC2_CAPABILITY_INVALID,
765 SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM,
Dan Stozad2168f72016-07-14 11:48:16 -0700766 SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
Brian Anderson49018a52017-04-04 16:43:11 -0700767 PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE,
Fabien Sanglard9bdc0b62017-06-13 14:56:08 -0700768 SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700769};
770TO_STRING(hwc2_capability_t, Capability, getCapabilityName)
771
772enum class Composition : int32_t {
773 Invalid = HWC2_COMPOSITION_INVALID,
774 Client = HWC2_COMPOSITION_CLIENT,
775 Device = HWC2_COMPOSITION_DEVICE,
776 SolidColor = HWC2_COMPOSITION_SOLID_COLOR,
777 Cursor = HWC2_COMPOSITION_CURSOR,
778 Sideband = HWC2_COMPOSITION_SIDEBAND,
779};
780TO_STRING(hwc2_composition_t, Composition, getCompositionName)
781
782enum class Connection : int32_t {
783 Invalid = HWC2_CONNECTION_INVALID,
784 Connected = HWC2_CONNECTION_CONNECTED,
785 Disconnected = HWC2_CONNECTION_DISCONNECTED,
786};
787TO_STRING(hwc2_connection_t, Connection, getConnectionName)
788
789enum class DisplayRequest : int32_t {
790 FlipClientTarget = HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET,
791 WriteClientTargetToOutput =
792 HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT,
793};
794TO_STRING(hwc2_display_request_t, DisplayRequest, getDisplayRequestName)
795
796enum class DisplayType : int32_t {
797 Invalid = HWC2_DISPLAY_TYPE_INVALID,
798 Physical = HWC2_DISPLAY_TYPE_PHYSICAL,
799 Virtual = HWC2_DISPLAY_TYPE_VIRTUAL,
800};
801TO_STRING(hwc2_display_type_t, DisplayType, getDisplayTypeName)
802
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700803enum class DisplayConnectionType : uint32_t {
804 Internal = HWC2_DISPLAY_CONNECTION_TYPE_INTERNAL,
805 External = HWC2_DISPLAY_CONNECTION_TYPE_EXTERNAL,
806};
807TO_STRING(hwc2_display_connection_type_t, DisplayConnectionType, getDisplayConnectionTypeName)
808
Dan Stoza4e9221b2015-09-02 15:43:39 -0700809enum class Error : int32_t {
810 None = HWC2_ERROR_NONE,
811 BadConfig = HWC2_ERROR_BAD_CONFIG,
812 BadDisplay = HWC2_ERROR_BAD_DISPLAY,
813 BadLayer = HWC2_ERROR_BAD_LAYER,
814 BadParameter = HWC2_ERROR_BAD_PARAMETER,
815 HasChanges = HWC2_ERROR_HAS_CHANGES,
816 NoResources = HWC2_ERROR_NO_RESOURCES,
817 NotValidated = HWC2_ERROR_NOT_VALIDATED,
818 Unsupported = HWC2_ERROR_UNSUPPORTED,
Ady Abraham8324c922019-10-10 19:14:07 -0700819 BadVsyncPeriod = HWC2_ERROR_BAD_VSYNC_PERIOD,
820 SeamlessNotPossible = HWC2_ERROR_SEAMLESS_NOT_POSSIBLE,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700821};
822TO_STRING(hwc2_error_t, Error, getErrorName)
823
824enum class FunctionDescriptor : int32_t {
825 Invalid = HWC2_FUNCTION_INVALID,
826 AcceptDisplayChanges = HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES,
827 CreateLayer = HWC2_FUNCTION_CREATE_LAYER,
828 CreateVirtualDisplay = HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY,
829 DestroyLayer = HWC2_FUNCTION_DESTROY_LAYER,
830 DestroyVirtualDisplay = HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY,
831 Dump = HWC2_FUNCTION_DUMP,
832 GetActiveConfig = HWC2_FUNCTION_GET_ACTIVE_CONFIG,
833 GetChangedCompositionTypes = HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES,
834 GetClientTargetSupport = HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT,
835 GetColorModes = HWC2_FUNCTION_GET_COLOR_MODES,
836 GetDisplayAttribute = HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE,
837 GetDisplayConfigs = HWC2_FUNCTION_GET_DISPLAY_CONFIGS,
838 GetDisplayName = HWC2_FUNCTION_GET_DISPLAY_NAME,
839 GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
840 GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
841 GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
Dan Stozaf601e972016-03-16 09:54:40 -0700842 GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
Dan Stoza4e9221b2015-09-02 15:43:39 -0700843 GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
844 GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
845 PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
846 RegisterCallback = HWC2_FUNCTION_REGISTER_CALLBACK,
847 SetActiveConfig = HWC2_FUNCTION_SET_ACTIVE_CONFIG,
848 SetClientTarget = HWC2_FUNCTION_SET_CLIENT_TARGET,
849 SetColorMode = HWC2_FUNCTION_SET_COLOR_MODE,
850 SetColorTransform = HWC2_FUNCTION_SET_COLOR_TRANSFORM,
851 SetCursorPosition = HWC2_FUNCTION_SET_CURSOR_POSITION,
852 SetLayerBlendMode = HWC2_FUNCTION_SET_LAYER_BLEND_MODE,
853 SetLayerBuffer = HWC2_FUNCTION_SET_LAYER_BUFFER,
854 SetLayerColor = HWC2_FUNCTION_SET_LAYER_COLOR,
855 SetLayerCompositionType = HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE,
856 SetLayerDataspace = HWC2_FUNCTION_SET_LAYER_DATASPACE,
857 SetLayerDisplayFrame = HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME,
858 SetLayerPlaneAlpha = HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
859 SetLayerSidebandStream = HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
860 SetLayerSourceCrop = HWC2_FUNCTION_SET_LAYER_SOURCE_CROP,
861 SetLayerSurfaceDamage = HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE,
862 SetLayerTransform = HWC2_FUNCTION_SET_LAYER_TRANSFORM,
863 SetLayerVisibleRegion = HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION,
864 SetLayerZOrder = HWC2_FUNCTION_SET_LAYER_Z_ORDER,
865 SetOutputBuffer = HWC2_FUNCTION_SET_OUTPUT_BUFFER,
866 SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE,
867 SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED,
868 ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY,
Peiyong Linfd05d132018-01-22 12:23:25 -0800869 SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700870 SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA,
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -0700871 GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS,
872 SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER,
873 GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES,
874 GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE,
Chia-I Wu28310aa2018-03-15 21:20:55 -0700875 GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS,
876 SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT,
877 GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX,
Peiyong Lin44819b92018-09-13 16:20:08 -0700878
879 // composer 2.3
Dominik Laskowski55cf6f02018-03-25 15:12:04 -0700880 GetDisplayIdentificationData = HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
Peiyong Linf09421f2018-10-26 18:31:03 -0700881 GetDisplayCapabilities = HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
Peiyong Lin44819b92018-09-13 16:20:08 -0700882 SetLayerColorTransform = HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM,
Kevin DuBois13458872018-09-10 09:09:12 -0700883 GetDisplayedContentSamplingAttributes = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES,
884 SetDisplayedContentSamplingEnabled = HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED,
885 GetDisplayedContentSample = HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
Valerie Hau69c53432018-11-13 09:07:44 -0800886 SetLayerPerFrameMetadataBlobs = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
Dan Gittik10510ff2019-01-18 19:30:24 +0000887 GetDisplayBrightnessSupport = HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
888 SetDisplayBrightness = HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
Dominik Laskowski9c1266c2019-10-01 15:14:53 -0700889
890 // composer 2.4
891 GetDisplayConnectionType = HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE,
Ady Abraham8324c922019-10-10 19:14:07 -0700892 getSupportedDisplayVsyncPeriods = HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS,
893 getDisplayVsyncPeriod = HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD,
894 setActiveConfigAndVsyncPeriod = HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD,
895
Dan Stoza4e9221b2015-09-02 15:43:39 -0700896};
897TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor,
898 getFunctionDescriptorName)
899
900enum class LayerRequest : int32_t {
901 ClearClientTarget = HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET,
902};
903TO_STRING(hwc2_layer_request_t, LayerRequest, getLayerRequestName)
904
905enum class PowerMode : int32_t {
906 Off = HWC2_POWER_MODE_OFF,
907 DozeSuspend = HWC2_POWER_MODE_DOZE_SUSPEND,
908 Doze = HWC2_POWER_MODE_DOZE,
909 On = HWC2_POWER_MODE_ON,
910};
911TO_STRING(hwc2_power_mode_t, PowerMode, getPowerModeName)
912
913enum class Transform : int32_t {
914 None = 0,
915 FlipH = HWC_TRANSFORM_FLIP_H,
916 FlipV = HWC_TRANSFORM_FLIP_V,
917 Rotate90 = HWC_TRANSFORM_ROT_90,
918 Rotate180 = HWC_TRANSFORM_ROT_180,
919 Rotate270 = HWC_TRANSFORM_ROT_270,
920 FlipHRotate90 = HWC_TRANSFORM_FLIP_H_ROT_90,
921 FlipVRotate90 = HWC_TRANSFORM_FLIP_V_ROT_90,
922};
923TO_STRING(hwc_transform_t, Transform, getTransformName)
924
925enum class Vsync : int32_t {
926 Invalid = HWC2_VSYNC_INVALID,
927 Enable = HWC2_VSYNC_ENABLE,
928 Disable = HWC2_VSYNC_DISABLE,
929};
930TO_STRING(hwc2_vsync_t, Vsync, getVsyncName)
931
Peiyong Linf09421f2018-10-26 18:31:03 -0700932enum class DisplayCapability : int32_t {
933 Invalid = HWC2_DISPLAY_CAPABILITY_INVALID,
934 SkipClientColorTransform = HWC2_DISPLAY_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM,
935 Doze = HWC2_DISPLAY_CAPABILITY_DOZE,
Dan Gittik10510ff2019-01-18 19:30:24 +0000936 Brightness = HWC2_DISPLAY_CAPABILITY_BRIGHTNESS,
Peiyong Linf09421f2018-10-26 18:31:03 -0700937};
938TO_STRING(hwc2_display_capability_t, DisplayCapability, getDisplayCapabilityName)
939
Dan Stoza4e9221b2015-09-02 15:43:39 -0700940} // namespace HWC2
941
942__BEGIN_DECLS
943#endif // HWC2_USE_CPP11
944
945/*
946 * Typedefs
947 */
948
949typedef void (*hwc2_function_pointer_t)();
950
951typedef void* hwc2_callback_data_t;
952typedef uint32_t hwc2_config_t;
953typedef uint64_t hwc2_display_t;
954typedef uint64_t hwc2_layer_t;
Ady Abraham8324c922019-10-10 19:14:07 -0700955typedef uint32_t hwc2_vsync_period_t;
Dan Stoza4e9221b2015-09-02 15:43:39 -0700956
957/*
958 * Device Struct
959 */
960
961typedef struct hwc2_device {
962 /* Must be the first member of this struct, since a pointer to this struct
963 * will be generated by casting from a hw_device_t* */
964 struct hw_device_t common;
965
966 /* getCapabilities(..., outCount, outCapabilities)
967 *
968 * Provides a list of capabilities (described in the definition of
969 * hwc2_capability_t above) supported by this device. This list must
970 * not change after the device has been loaded.
971 *
972 * Parameters:
973 * outCount - if outCapabilities was NULL, the number of capabilities
974 * which would have been returned; if outCapabilities was not NULL,
975 * the number of capabilities returned, which must not exceed the
976 * value stored in outCount prior to the call
977 * outCapabilities - a list of capabilities supported by this device; may
978 * be NULL, in which case this function must write into outCount the
979 * number of capabilities which would have been written into
980 * outCapabilities
981 */
982 void (*getCapabilities)(struct hwc2_device* device, uint32_t* outCount,
983 int32_t* /*hwc2_capability_t*/ outCapabilities);
984
985 /* getFunction(..., descriptor)
986 *
987 * Returns a function pointer which implements the requested description.
988 *
989 * Parameters:
990 * descriptor - the function to return
991 *
992 * Returns either a function pointer implementing the requested descriptor
993 * or NULL if the described function is not supported by this device.
994 */
995 hwc2_function_pointer_t (*getFunction)(struct hwc2_device* device,
996 int32_t /*hwc2_function_descriptor_t*/ descriptor);
997} hwc2_device_t;
998
999static inline int hwc2_open(const struct hw_module_t* module,
1000 hwc2_device_t** device) {
1001 return module->methods->open(module, HWC_HARDWARE_COMPOSER,
Colin Crosscc8d9f92016-10-06 16:44:23 -07001002 TO_HW_DEVICE_T_OPEN(device));
Dan Stoza4e9221b2015-09-02 15:43:39 -07001003}
1004
1005static inline int hwc2_close(hwc2_device_t* device) {
1006 return device->common.close(&device->common);
1007}
1008
1009/*
1010 * Callbacks
1011 *
1012 * All of these callbacks take as their first parameter the callbackData which
1013 * was provided at the time of callback registration, so this parameter is
1014 * omitted from the described parameter lists.
1015 */
1016
1017/* hotplug(..., display, connected)
1018 * Descriptor: HWC2_CALLBACK_HOTPLUG
1019 * Will be provided to all HWC2 devices
1020 *
1021 * Notifies the client that the given display has either been connected or
1022 * disconnected. Every active display (even a built-in physical display) must
1023 * trigger at least one hotplug notification, even if it only occurs immediately
1024 * after callback registration.
1025 *
1026 * The client may call back into the device on the same thread to query display
1027 * properties (such as width, height, and vsync period), and other threads may
1028 * call into the device while the callback is in progress. The device must
1029 * serialize calls to this callback such that only one thread is calling it at a
1030 * time.
1031 *
1032 * Displays which have been connected are assumed to be in HWC2_POWER_MODE_OFF,
1033 * and the vsync callback should not be called for a display until vsync has
1034 * been enabled with setVsyncEnabled.
1035 *
1036 * Parameters:
1037 * display - the display which has been hotplugged
1038 * connected - whether the display has been connected or disconnected
1039 */
1040typedef void (*HWC2_PFN_HOTPLUG)(hwc2_callback_data_t callbackData,
1041 hwc2_display_t display, int32_t /*hwc2_connection_t*/ connected);
1042
1043/* refresh(..., display)
1044 * Descriptor: HWC2_CALLBACK_REFRESH
1045 * Will be provided to all HWC2 devices
1046 *
1047 * Notifies the client to trigger a screen refresh. This forces all layer state
1048 * for this display to be resent, and the display to be validated and presented,
1049 * even if there have been no changes.
1050 *
1051 * This refresh will occur some time after the callback is initiated, but not
1052 * necessarily before it returns. This thread, however, is guaranteed not to
1053 * call back into the device, thus it is safe to trigger this callback from
1054 * other functions which call into the device.
1055 *
1056 * Parameters:
1057 * display - the display to refresh
1058 */
1059typedef void (*HWC2_PFN_REFRESH)(hwc2_callback_data_t callbackData,
1060 hwc2_display_t display);
1061
1062/* vsync(..., display, timestamp)
1063 * Descriptor: HWC2_CALLBACK_VSYNC
1064 * Will be provided to all HWC2 devices
1065 *
1066 * Notifies the client that a vsync event has occurred. This callback must
1067 * only be triggered when vsync is enabled for this display (through
1068 * setVsyncEnabled).
1069 *
1070 * This callback should be triggered from a thread of at least
1071 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1072 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1073 *
1074 * Parameters:
1075 * display - the display which has received a vsync event
1076 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1077 * nanoseconds
1078 */
1079typedef void (*HWC2_PFN_VSYNC)(hwc2_callback_data_t callbackData,
1080 hwc2_display_t display, int64_t timestamp);
1081
Ady Abraham8324c922019-10-10 19:14:07 -07001082/* vsync_2_4(..., display, timestamp, vsyncPeriodNanos)
1083 * Descriptor: HWC2_CALLBACK_VSYNC_2_4
1084 * Required for HWC2 devices for composer 2.4
1085 *
1086 * Notifies the client that a vsync event has occurred. This callback must
1087 * only be triggered when vsync is enabled for this display (through
1088 * setVsyncEnabled).
1089 *
1090 * This callback should be triggered from a thread of at least
1091 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, typically
1092 * less than 0.5 ms. This thread is guaranteed not to call back into the device.
1093 *
1094 * Parameters:
1095 * display - the display which has received a vsync event
1096 * timestamp - the CLOCK_MONOTONIC time at which the vsync event occurred, in
1097 * nanoseconds
1098 * vsyncPeriodNanos - the display vsync period in nanoseconds i.e. the next onVsync2_4 is
1099 * expected to be called vsyncPeriod nanoseconds after this call.
1100 */
1101typedef void (*HWC2_PFN_VSYNC_2_4)(hwc2_callback_data_t callbackData,
1102 hwc2_display_t display, int64_t timestamp, hwc2_vsync_period_t vsyncPeriodNanos);
1103
Dan Stoza4e9221b2015-09-02 15:43:39 -07001104/*
1105 * Device Functions
1106 *
1107 * All of these functions take as their first parameter a device pointer, so
1108 * this parameter is omitted from the described parameter lists.
1109 */
1110
Dan Stoza68cd3752016-05-20 13:30:42 -07001111/* createVirtualDisplay(..., width, height, format, outDisplay)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001112 * Descriptor: HWC2_FUNCTION_CREATE_VIRTUAL_DISPLAY
1113 * Must be provided by all HWC2 devices
1114 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001115 * Creates a new virtual display with the given width and height. The format
1116 * passed into this function is the default format requested by the consumer of
1117 * the virtual display output buffers. If a different format will be returned by
1118 * the device, it should be returned in this parameter so it can be set properly
1119 * when handing the buffers to the consumer.
1120 *
1121 * The display will be assumed to be on from the time the first frame is
1122 * presented until the display is destroyed.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001123 *
1124 * Parameters:
1125 * width - width in pixels
1126 * height - height in pixels
Dan Stoza68cd3752016-05-20 13:30:42 -07001127 * format - prior to the call, the default output buffer format selected by
1128 * the consumer; after the call, the format the device will produce
Dan Stoza4e9221b2015-09-02 15:43:39 -07001129 * outDisplay - the newly-created virtual display; pointer will be non-NULL
1130 *
1131 * Returns HWC2_ERROR_NONE or one of the following errors:
1132 * HWC2_ERROR_UNSUPPORTED - the width or height is too large for the device to
1133 * be able to create a virtual display
1134 * HWC2_ERROR_NO_RESOURCES - the device is unable to create a new virtual
1135 * display at this time
1136 */
1137typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_VIRTUAL_DISPLAY)(
1138 hwc2_device_t* device, uint32_t width, uint32_t height,
Dan Stoza68cd3752016-05-20 13:30:42 -07001139 int32_t* /*android_pixel_format_t*/ format, hwc2_display_t* outDisplay);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001140
1141/* destroyVirtualDisplay(..., display)
1142 * Descriptor: HWC2_FUNCTION_DESTROY_VIRTUAL_DISPLAY
1143 * Must be provided by all HWC2 devices
1144 *
1145 * Destroys a virtual display. After this call all resources consumed by this
1146 * display may be freed by the device and any operations performed on this
1147 * display should fail.
1148 *
1149 * Parameters:
1150 * display - the virtual display to destroy
1151 *
1152 * Returns HWC2_ERROR_NONE or one of the following errors:
1153 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1154 * HWC2_ERROR_BAD_PARAMETER - the display handle which was passed in does not
1155 * refer to a virtual display
1156 */
1157typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_VIRTUAL_DISPLAY)(
1158 hwc2_device_t* device, hwc2_display_t display);
1159
1160/* dump(..., outSize, outBuffer)
1161 * Descriptor: HWC2_FUNCTION_DUMP
1162 * Must be provided by all HWC2 devices
1163 *
1164 * Retrieves implementation-defined debug information, which will be displayed
1165 * during, for example, `dumpsys SurfaceFlinger`.
1166 *
1167 * If called with outBuffer == NULL, the device should store a copy of the
1168 * desired output and return its length in bytes in outSize. If the device
1169 * already has a stored copy, that copy should be purged and replaced with a
1170 * fresh copy.
1171 *
1172 * If called with outBuffer != NULL, the device should copy its stored version
1173 * of the output into outBuffer and store how many bytes of data it copied into
1174 * outSize. Prior to this call, the client will have populated outSize with the
1175 * maximum number of bytes outBuffer can hold. The device must not write more
1176 * than this amount into outBuffer. If the device does not currently have a
1177 * stored copy, then it should return 0 in outSize.
1178 *
1179 * Any data written into outBuffer need not be null-terminated.
1180 *
1181 * Parameters:
1182 * outSize - if outBuffer was NULL, the number of bytes needed to copy the
1183 * device's stored output; if outBuffer was not NULL, the number of bytes
1184 * written into it, which must not exceed the value stored in outSize
1185 * prior to the call; pointer will be non-NULL
1186 * outBuffer - the buffer to write the dump output into; may be NULL as
1187 * described above; data written into this buffer need not be
1188 * null-terminated
1189 */
1190typedef void (*HWC2_PFN_DUMP)(hwc2_device_t* device, uint32_t* outSize,
1191 char* outBuffer);
1192
1193/* getMaxVirtualDisplayCount(...)
1194 * Descriptor: HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT
1195 * Must be provided by all HWC2 devices
1196 *
1197 * Returns the maximum number of virtual displays supported by this device
1198 * (which may be 0). The client will not attempt to create more than this many
1199 * virtual displays on this device. This number must not change for the lifetime
1200 * of the device.
1201 */
1202typedef uint32_t (*HWC2_PFN_GET_MAX_VIRTUAL_DISPLAY_COUNT)(
1203 hwc2_device_t* device);
1204
1205/* registerCallback(..., descriptor, callbackData, pointer)
1206 * Descriptor: HWC2_FUNCTION_REGISTER_CALLBACK
1207 * Must be provided by all HWC2 devices
1208 *
1209 * Provides a callback for the device to call. All callbacks take a callbackData
1210 * item as the first parameter, so this value should be stored with the callback
1211 * for later use. The callbackData may differ from one callback to another. If
1212 * this function is called multiple times with the same descriptor, later
1213 * callbacks replace earlier ones.
1214 *
1215 * Parameters:
1216 * descriptor - which callback should be set
1217 * callBackdata - opaque data which must be passed back through the callback
1218 * pointer - a non-NULL function pointer corresponding to the descriptor
1219 *
1220 * Returns HWC2_ERROR_NONE or one of the following errors:
1221 * HWC2_ERROR_BAD_PARAMETER - descriptor was invalid
1222 */
1223typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)(
1224 hwc2_device_t* device,
1225 int32_t /*hwc2_callback_descriptor_t*/ descriptor,
1226 hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer);
1227
Chia-I Wu28310aa2018-03-15 21:20:55 -07001228/* getDataspaceSaturationMatrix(..., dataspace, outMatrix)
1229 * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX
1230 * Provided by HWC2 devices which don't return nullptr function pointer.
1231 *
1232 * Get the saturation matrix of the specified dataspace. The saturation matrix
1233 * can be used to approximate the dataspace saturation operation performed by
1234 * the HWC2 device when non-colorimetric mapping is allowed. It is to be
1235 * applied on linear pixel values.
1236 *
1237 * Parameters:
1238 * dataspace - the dataspace to query for
1239 * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity
1240 * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR.
1241 *
1242 * Returns HWC2_ERROR_NONE or one of the following errors:
1243 * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid
1244 */
1245typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)(
1246 hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace,
1247 float* outMatrix);
1248
Dan Stoza4e9221b2015-09-02 15:43:39 -07001249/*
1250 * Display Functions
1251 *
1252 * All of these functions take as their first two parameters a device pointer
1253 * and a display handle, so these parameters are omitted from the described
1254 * parameter lists.
1255 */
1256
1257/* acceptDisplayChanges(...)
1258 * Descriptor: HWC2_FUNCTION_ACCEPT_DISPLAY_CHANGES
1259 * Must be provided by all HWC2 devices
1260 *
1261 * Accepts the changes required by the device from the previous validateDisplay
1262 * call (which may be queried using getChangedCompositionTypes) and revalidates
1263 * the display. This function is equivalent to requesting the changed types from
1264 * getChangedCompositionTypes, setting those types on the corresponding layers,
1265 * and then calling validateDisplay again.
1266 *
1267 * After this call it must be valid to present this display. Calling this after
1268 * validateDisplay returns 0 changes must succeed with HWC2_ERROR_NONE, but
1269 * should have no other effect.
1270 *
1271 * Returns HWC2_ERROR_NONE or one of the following errors:
1272 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1273 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called
1274 */
1275typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_ACCEPT_DISPLAY_CHANGES)(
1276 hwc2_device_t* device, hwc2_display_t display);
1277
1278/* createLayer(..., outLayer)
1279 * Descriptor: HWC2_FUNCTION_CREATE_LAYER
1280 * Must be provided by all HWC2 devices
1281 *
1282 * Creates a new layer on the given display.
1283 *
1284 * Parameters:
1285 * outLayer - the handle of the new layer; pointer will be non-NULL
1286 *
1287 * Returns HWC2_ERROR_NONE or one of the following errors:
1288 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1289 * HWC2_ERROR_NO_RESOURCES - the device was unable to create this layer
1290 */
1291typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_CREATE_LAYER)(hwc2_device_t* device,
1292 hwc2_display_t display, hwc2_layer_t* outLayer);
1293
1294/* destroyLayer(..., layer)
1295 * Descriptor: HWC2_FUNCTION_DESTROY_LAYER
1296 * Must be provided by all HWC2 devices
1297 *
1298 * Destroys the given layer.
1299 *
1300 * Parameters:
1301 * layer - the handle of the layer to destroy
1302 *
1303 * Returns HWC2_ERROR_NONE or one of the following errors:
1304 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1305 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
1306 */
1307typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_DESTROY_LAYER)(
1308 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer);
1309
1310/* getActiveConfig(..., outConfig)
1311 * Descriptor: HWC2_FUNCTION_GET_ACTIVE_CONFIG
1312 * Must be provided by all HWC2 devices
1313 *
1314 * Retrieves which display configuration is currently active.
1315 *
1316 * If no display configuration is currently active, this function must return
1317 * HWC2_ERROR_BAD_CONFIG and place no configuration handle in outConfig. It is
1318 * the responsibility of the client to call setActiveConfig with a valid
1319 * configuration before attempting to present anything on the display.
1320 *
1321 * Parameters:
1322 * outConfig - the currently active display configuration; pointer will be
1323 * non-NULL
1324 *
1325 * Returns HWC2_ERROR_NONE or one of the following errors:
1326 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1327 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
1328 */
1329typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_ACTIVE_CONFIG)(
1330 hwc2_device_t* device, hwc2_display_t display,
1331 hwc2_config_t* outConfig);
1332
1333/* getChangedCompositionTypes(..., outNumElements, outLayers, outTypes)
1334 * Descriptor: HWC2_FUNCTION_GET_CHANGED_COMPOSITION_TYPES
1335 * Must be provided by all HWC2 devices
1336 *
1337 * Retrieves the layers for which the device requires a different composition
1338 * type than had been set prior to the last call to validateDisplay. The client
1339 * will either update its state with these types and call acceptDisplayChanges,
1340 * or will set new types and attempt to validate the display again.
1341 *
1342 * outLayers and outTypes may be NULL to retrieve the number of elements which
1343 * will be returned. The number of elements returned must be the same as the
1344 * value returned in outNumTypes from the last call to validateDisplay.
1345 *
1346 * Parameters:
1347 * outNumElements - if outLayers or outTypes were NULL, the number of layers
1348 * and types which would have been returned; if both were non-NULL, the
1349 * number of elements returned in outLayers and outTypes, which must not
1350 * exceed the value stored in outNumElements prior to the call; pointer
1351 * will be non-NULL
1352 * outLayers - an array of layer handles
1353 * outTypes - an array of composition types, each corresponding to an element
1354 * of outLayers
1355 *
1356 * Returns HWC2_ERROR_NONE or one of the following errors:
1357 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1358 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1359 * display
1360 */
1361typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CHANGED_COMPOSITION_TYPES)(
1362 hwc2_device_t* device, hwc2_display_t display,
1363 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1364 int32_t* /*hwc2_composition_t*/ outTypes);
1365
1366/* getClientTargetSupport(..., width, height, format, dataspace)
1367 * Descriptor: HWC2_FUNCTION_GET_CLIENT_TARGET_SUPPORT
1368 * Must be provided by all HWC2 devices
1369 *
1370 * Returns whether a client target with the given properties can be handled by
1371 * the device.
1372 *
1373 * The valid formats can be found in android_pixel_format_t in
1374 * <system/graphics.h>.
1375 *
1376 * For more about dataspaces, see setLayerDataspace.
1377 *
1378 * This function must return true for a client target with width and height
1379 * equal to the active display configuration dimensions,
1380 * HAL_PIXEL_FORMAT_RGBA_8888, and HAL_DATASPACE_UNKNOWN. It is not required to
1381 * return true for any other configuration.
1382 *
1383 * Parameters:
1384 * width - client target width in pixels
1385 * height - client target height in pixels
1386 * format - client target format
1387 * dataspace - client target dataspace, as described in setLayerDataspace
1388 *
1389 * Returns HWC2_ERROR_NONE if the given configuration is supported or one of the
1390 * following errors:
1391 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1392 * HWC2_ERROR_UNSUPPORTED - the given configuration is not supported
1393 */
1394typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_CLIENT_TARGET_SUPPORT)(
1395 hwc2_device_t* device, hwc2_display_t display, uint32_t width,
1396 uint32_t height, int32_t /*android_pixel_format_t*/ format,
1397 int32_t /*android_dataspace_t*/ dataspace);
1398
1399/* getColorModes(..., outNumModes, outModes)
1400 * Descriptor: HWC2_FUNCTION_GET_COLOR_MODES
1401 * Must be provided by all HWC2 devices
1402 *
1403 * Returns the color modes supported on this display.
1404 *
1405 * The valid color modes can be found in android_color_mode_t in
1406 * <system/graphics.h>. All HWC2 devices must support at least
1407 * HAL_COLOR_MODE_NATIVE.
1408 *
1409 * outNumModes may be NULL to retrieve the number of modes which will be
1410 * returned.
1411 *
1412 * Parameters:
1413 * outNumModes - if outModes was NULL, the number of modes which would have
1414 * been returned; if outModes was not NULL, the number of modes returned,
1415 * which must not exceed the value stored in outNumModes prior to the
1416 * call; pointer will be non-NULL
1417 * outModes - an array of color modes
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 */
1422typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)(
1423 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes,
1424 int32_t* /*android_color_mode_t*/ outModes);
1425
Chia-I Wu28310aa2018-03-15 21:20:55 -07001426/* getRenderIntents(..., mode, outNumIntents, outIntents)
1427 * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS
1428 * Provided by HWC2 devices which don't return nullptr function pointer.
1429 *
1430 * Returns the render intents supported on this display.
1431 *
1432 * The valid render intents can be found in android_render_intent_v1_1_t in
1433 * <system/graphics.h>. All HWC2 devices must support at least
1434 * HAL_RENDER_INTENT_COLORIMETRIC.
1435 *
1436 * outNumIntents may be NULL to retrieve the number of intents which will be
1437 * returned.
1438 *
1439 * Parameters:
1440 * mode - the color mode to query the render intents for
1441 * outNumIntents - if outIntents was NULL, the number of intents which would
1442 * have been returned; if outIntents was not NULL, the number of intents
1443 * returned, which must not exceed the value stored in outNumIntents
1444 * prior to the call; pointer will be non-NULL
1445 * outIntents - an array of render intents
1446 *
1447 * Returns HWC2_ERROR_NONE or one of the following errors:
1448 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1449 */
1450typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)(
1451 hwc2_device_t* device, hwc2_display_t display, int32_t mode,
1452 uint32_t* outNumIntents,
1453 int32_t* /*android_render_intent_v1_1_t*/ outIntents);
1454
Dan Stoza4e9221b2015-09-02 15:43:39 -07001455/* getDisplayAttribute(..., config, attribute, outValue)
1456 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE
1457 * Must be provided by all HWC2 devices
1458 *
1459 * Returns a display attribute value for a particular display configuration.
1460 *
1461 * Any attribute which is not supported or for which the value is unknown by the
1462 * device must return a value of -1.
1463 *
1464 * Parameters:
1465 * config - the display configuration for which to return attribute values
1466 * attribute - the attribute to query
1467 * outValue - the value of the attribute; the pointer will be non-NULL
1468 *
1469 * Returns HWC2_ERROR_NONE or one of the following errors:
1470 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1471 * HWC2_ERROR_BAD_CONFIG - config does not name a valid configuration for this
1472 * display
1473 */
1474typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_ATTRIBUTE)(
1475 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
1476 int32_t /*hwc2_attribute_t*/ attribute, int32_t* outValue);
1477
1478/* getDisplayConfigs(..., outNumConfigs, outConfigs)
1479 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONFIGS
1480 * Must be provided by all HWC2 devices
1481 *
1482 * Returns handles for all of the valid display configurations on this display.
1483 *
1484 * outConfigs may be NULL to retrieve the number of elements which will be
1485 * returned.
1486 *
1487 * Parameters:
1488 * outNumConfigs - if outConfigs was NULL, the number of configurations which
1489 * would have been returned; if outConfigs was not NULL, the number of
1490 * configurations returned, which must not exceed the value stored in
1491 * outNumConfigs prior to the call; pointer will be non-NULL
1492 * outConfigs - an array of configuration handles
1493 *
1494 * Returns HWC2_ERROR_NONE or one of the following errors:
1495 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1496 */
1497typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONFIGS)(
1498 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumConfigs,
1499 hwc2_config_t* outConfigs);
1500
1501/* getDisplayName(..., outSize, outName)
1502 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_NAME
1503 * Must be provided by all HWC2 devices
1504 *
1505 * Returns a human-readable version of the display's name.
1506 *
1507 * outName may be NULL to retrieve the length of the name.
1508 *
1509 * Parameters:
1510 * outSize - if outName was NULL, the number of bytes needed to return the
1511 * name if outName was not NULL, the number of bytes written into it,
1512 * which must not exceed the value stored in outSize prior to the call;
1513 * pointer will be non-NULL
1514 * outName - the display's name
1515 *
1516 * Returns HWC2_ERROR_NONE or one of the following errors:
1517 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1518 */
1519typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_NAME)(
1520 hwc2_device_t* device, hwc2_display_t display, uint32_t* outSize,
1521 char* outName);
1522
1523/* getDisplayRequests(..., outDisplayRequests, outNumElements, outLayers,
1524 * outLayerRequests)
1525 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_REQUESTS
1526 * Must be provided by all HWC2 devices
1527 *
1528 * Returns the display requests and the layer requests required for the last
1529 * validated configuration.
1530 *
1531 * Display requests provide information about how the client should handle the
1532 * client target. Layer requests provide information about how the client
1533 * should handle an individual layer.
1534 *
1535 * If outLayers or outLayerRequests is NULL, the required number of layers and
1536 * requests must be returned in outNumElements, but this number may also be
1537 * obtained from validateDisplay as outNumRequests (outNumElements must be equal
1538 * to the value returned in outNumRequests from the last call to
1539 * validateDisplay).
1540 *
1541 * Parameters:
1542 * outDisplayRequests - the display requests for the current validated state
1543 * outNumElements - if outLayers or outLayerRequests were NULL, the number of
1544 * elements which would have been returned, which must be equal to the
1545 * value returned in outNumRequests from the last validateDisplay call on
1546 * this display; if both were not NULL, the number of elements in
1547 * outLayers and outLayerRequests, which must not exceed the value stored
1548 * in outNumElements prior to the call; pointer will be non-NULL
1549 * outLayers - an array of layers which all have at least one request
1550 * outLayerRequests - the requests corresponding to each element of outLayers
1551 *
1552 * Returns HWC2_ERROR_NONE or one of the following errors:
1553 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1554 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not been called for this
1555 * display
1556 */
1557typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_REQUESTS)(
1558 hwc2_device_t* device, hwc2_display_t display,
1559 int32_t* /*hwc2_display_request_t*/ outDisplayRequests,
1560 uint32_t* outNumElements, hwc2_layer_t* outLayers,
1561 int32_t* /*hwc2_layer_request_t*/ outLayerRequests);
1562
1563/* getDisplayType(..., outType)
1564 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_TYPE
1565 * Must be provided by all HWC2 devices
1566 *
1567 * Returns whether the given display is a physical or virtual display.
1568 *
1569 * Parameters:
1570 * outType - the type of the display; pointer will be non-NULL
1571 *
1572 * Returns HWC2_ERROR_NONE or one of the following errors:
1573 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1574 */
1575typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_TYPE)(
1576 hwc2_device_t* device, hwc2_display_t display,
1577 int32_t* /*hwc2_display_type_t*/ outType);
1578
Dominik Laskowski55cf6f02018-03-25 15:12:04 -07001579/* getDisplayIdentificationData(..., outPort, outDataSize, outData)
1580 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA
1581 * Optional for HWC2 devices
1582 *
1583 * If supported, getDisplayIdentificationData returns the port and data that
1584 * describe a physical display. The port is a unique number that identifies a
1585 * physical connector (e.g. eDP, HDMI) for display output. The data blob is
1586 * parsed to determine its format, typically EDID 1.3 as specified in VESA
1587 * E-EDID Standard Release A Revision 1.
1588 *
1589 * Devices for which display identification is unsupported must return null when
1590 * getFunction is called with HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA.
1591 *
1592 * Parameters:
1593 * outPort - the connector to which the display is connected;
1594 * pointer will be non-NULL
1595 * outDataSize - if outData is NULL, the size in bytes of the data which would
1596 * have been returned; if outData is not NULL, the size of outData, which
1597 * must not exceed the value stored in outDataSize prior to the call;
1598 * pointer will be non-NULL
1599 * outData - the EDID 1.3 blob identifying the display
1600 *
1601 * Returns HWC2_ERROR_NONE or one of the following errors:
1602 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1603 */
1604typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA)(
1605 hwc2_device_t* device, hwc2_display_t display, uint8_t* outPort,
1606 uint32_t* outDataSize, uint8_t* outData);
1607
Dan Stoza4e9221b2015-09-02 15:43:39 -07001608/* getDozeSupport(..., outSupport)
1609 * Descriptor: HWC2_FUNCTION_GET_DOZE_SUPPORT
1610 * Must be provided by all HWC2 devices
1611 *
1612 * Returns whether the given display supports HWC2_POWER_MODE_DOZE and
1613 * HWC2_POWER_MODE_DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
1614 * DOZE (see the definition of hwc2_power_mode_t for more information), but if
1615 * both DOZE and DOZE_SUSPEND are no different from HWC2_POWER_MODE_ON, the
1616 * device should not claim support.
1617 *
1618 * Parameters:
1619 * outSupport - whether the display supports doze modes (1 for yes, 0 for no);
1620 * pointer will be non-NULL
1621 *
1622 * Returns HWC2_ERROR_NONE or one of the following errors:
1623 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1624 */
1625typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
1626 hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
1627
Dan Stozaf601e972016-03-16 09:54:40 -07001628/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
1629 * outMaxAverageLuminance, outMinLuminance)
1630 * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
1631 * Must be provided by all HWC2 devices
1632 *
1633 * Returns the high dynamic range (HDR) capabilities of the given display, which
1634 * are invariant with regard to the active configuration.
1635 *
1636 * Displays which are not HDR-capable must return no types in outTypes and set
1637 * outNumTypes to 0.
1638 *
1639 * If outTypes is NULL, the required number of HDR types must be returned in
1640 * outNumTypes.
1641 *
1642 * Parameters:
1643 * outNumTypes - if outTypes was NULL, the number of types which would have
1644 * been returned; if it was not NULL, the number of types stored in
1645 * outTypes, which must not exceed the value stored in outNumTypes prior
1646 * to the call; pointer will be non-NULL
1647 * outTypes - an array of HDR types, may have 0 elements if the display is not
1648 * HDR-capable
1649 * outMaxLuminance - the desired content maximum luminance for this display in
1650 * cd/m^2; pointer will be non-NULL
1651 * outMaxAverageLuminance - the desired content maximum frame-average
1652 * luminance for this display in cd/m^2; pointer will be non-NULL
1653 * outMinLuminance - the desired content minimum luminance for this display in
1654 * cd/m^2; pointer will be non-NULL
1655 *
1656 * Returns HWC2_ERROR_NONE or one of the following errors:
1657 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1658 */
1659typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
1660 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
1661 int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
1662 float* outMaxAverageLuminance, float* outMinLuminance);
1663
Dan Stoza4e9221b2015-09-02 15:43:39 -07001664/* getReleaseFences(..., outNumElements, outLayers, outFences)
1665 * Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
1666 * Must be provided by all HWC2 devices
1667 *
1668 * Retrieves the release fences for device layers on this display which will
1669 * receive new buffer contents this frame.
1670 *
1671 * A release fence is a file descriptor referring to a sync fence object which
1672 * will be signaled after the device has finished reading from the buffer
1673 * presented in the prior frame. This indicates that it is safe to start writing
1674 * to the buffer again. If a given layer's fence is not returned from this
1675 * function, it will be assumed that the buffer presented on the previous frame
1676 * is ready to be written.
1677 *
1678 * The fences returned by this function should be unique for each layer (even if
1679 * they point to the same underlying sync object), and ownership of the fences
1680 * is transferred to the client, which is responsible for closing them.
1681 *
1682 * If outLayers or outFences is NULL, the required number of layers and fences
1683 * must be returned in outNumElements.
1684 *
1685 * Parameters:
1686 * outNumElements - if outLayers or outFences were NULL, the number of
1687 * elements which would have been returned; if both were not NULL, the
1688 * number of elements in outLayers and outFences, which must not exceed
1689 * the value stored in outNumElements prior to the call; pointer will be
1690 * non-NULL
1691 * outLayers - an array of layer handles
1692 * outFences - an array of sync fence file descriptors as described above,
1693 * each corresponding to an element of outLayers
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_RELEASE_FENCES)(
1699 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumElements,
1700 hwc2_layer_t* outLayers, int32_t* outFences);
1701
Dan Stozaef264822016-07-13 14:51:09 -07001702/* presentDisplay(..., outPresentFence)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001703 * Descriptor: HWC2_FUNCTION_PRESENT_DISPLAY
1704 * Must be provided by all HWC2 devices
1705 *
1706 * Presents the current display contents on the screen (or in the case of
1707 * virtual displays, into the output buffer).
1708 *
1709 * Prior to calling this function, the display must be successfully validated
1710 * with validateDisplay. Note that setLayerBuffer and setLayerSurfaceDamage
1711 * specifically do not count as layer state, so if there are no other changes
1712 * to the layer state (or to the buffer's properties as described in
1713 * setLayerBuffer), then it is safe to call this function without first
1714 * validating the display.
1715 *
Dan Stozaef264822016-07-13 14:51:09 -07001716 * If this call succeeds, outPresentFence will be populated with a file
1717 * descriptor referring to a present sync fence object. For physical displays,
1718 * this fence will be signaled at the vsync when the result of composition of
1719 * this frame starts to appear (for video-mode panels) or starts to transfer to
1720 * panel memory (for command-mode panels). For virtual displays, this fence will
1721 * be signaled when writes to the output buffer have completed and it is safe to
1722 * read from it.
Dan Stoza4e9221b2015-09-02 15:43:39 -07001723 *
1724 * Parameters:
Dan Stozaef264822016-07-13 14:51:09 -07001725 * outPresentFence - a sync fence file descriptor as described above; pointer
Dan Stoza4e9221b2015-09-02 15:43:39 -07001726 * will be non-NULL
1727 *
1728 * Returns HWC2_ERROR_NONE or one of the following errors:
1729 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1730 * HWC2_ERROR_NO_RESOURCES - no valid output buffer has been set for a virtual
1731 * display
1732 * HWC2_ERROR_NOT_VALIDATED - validateDisplay has not successfully been called
1733 * for this display
1734 */
1735typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_PRESENT_DISPLAY)(
Dan Stozaef264822016-07-13 14:51:09 -07001736 hwc2_device_t* device, hwc2_display_t display,
1737 int32_t* outPresentFence);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001738
1739/* setActiveConfig(..., config)
1740 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG
1741 * Must be provided by all HWC2 devices
1742 *
1743 * Sets the active configuration for this display. Upon returning, the given
1744 * display configuration should be active and remain so until either this
1745 * function is called again or the display is disconnected.
1746 *
1747 * Parameters:
1748 * config - the new display configuration
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 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
1753 * this display
1754 */
1755typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG)(
1756 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config);
1757
Dan Stoza68cd3752016-05-20 13:30:42 -07001758/* setClientTarget(..., target, acquireFence, dataspace, damage)
Dan Stoza4e9221b2015-09-02 15:43:39 -07001759 * Descriptor: HWC2_FUNCTION_SET_CLIENT_TARGET
1760 * Must be provided by all HWC2 devices
1761 *
1762 * Sets the buffer handle which will receive the output of client composition.
1763 * Layers marked as HWC2_COMPOSITION_CLIENT will be composited into this buffer
1764 * prior to the call to presentDisplay, and layers not marked as
1765 * HWC2_COMPOSITION_CLIENT should be composited with this buffer by the device.
1766 *
Dan Stoza3abcfa52016-05-04 12:21:06 -07001767 * The buffer handle provided may be null if no layers are being composited by
1768 * the client. This must not result in an error (unless an invalid display
1769 * handle is also provided).
1770 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001771 * Also provides a file descriptor referring to an acquire sync fence object,
1772 * which will be signaled when it is safe to read from the client target buffer.
1773 * If it is already safe to read from this buffer, -1 may be passed instead.
1774 * The device must ensure that it is safe for the client to close this file
1775 * descriptor at any point after this function is called.
1776 *
1777 * For more about dataspaces, see setLayerDataspace.
1778 *
Dan Stoza68cd3752016-05-20 13:30:42 -07001779 * The damage parameter describes a surface damage region as defined in the
1780 * description of setLayerSurfaceDamage.
1781 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001782 * Will be called before presentDisplay if any of the layers are marked as
1783 * HWC2_COMPOSITION_CLIENT. If no layers are so marked, then it is not
1784 * necessary to call this function. It is not necessary to call validateDisplay
1785 * after changing the target through this function.
1786 *
1787 * Parameters:
1788 * target - the new target buffer
1789 * acquireFence - a sync fence file descriptor as described above
1790 * dataspace - the dataspace of the buffer, as described in setLayerDataspace
Dan Stoza68cd3752016-05-20 13:30:42 -07001791 * damage - the surface damage region
Dan Stoza4e9221b2015-09-02 15:43:39 -07001792 *
1793 * Returns HWC2_ERROR_NONE or one of the following errors:
1794 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1795 * HWC2_ERROR_BAD_PARAMETER - the new target handle was invalid
1796 */
1797typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)(
1798 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t target,
Dan Stoza68cd3752016-05-20 13:30:42 -07001799 int32_t acquireFence, int32_t /*android_dataspace_t*/ dataspace,
1800 hwc_region_t damage);
Dan Stoza4e9221b2015-09-02 15:43:39 -07001801
Dan Stozac46e96a2016-03-24 10:12:15 -07001802/* setColorMode(..., mode)
1803 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE
1804 * Must be provided by all HWC2 devices
1805 *
1806 * Sets the color mode of the given display.
1807 *
Chia-I Wu28310aa2018-03-15 21:20:55 -07001808 * This must be called outside of validateDisplay/presentDisplay, and it takes
1809 * effect on next presentDisplay.
Dan Stozac46e96a2016-03-24 10:12:15 -07001810 *
1811 * The valid color modes can be found in android_color_mode_t in
1812 * <system/graphics.h>. All HWC2 devices must support at least
1813 * HAL_COLOR_MODE_NATIVE, and displays are assumed to be in this mode upon
1814 * hotplug.
1815 *
1816 * Parameters:
1817 * mode - the mode to set
1818 *
1819 * Returns HWC2_ERROR_NONE or one of the following errors:
1820 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1821 * HWC2_ERROR_BAD_PARAMETER - mode is not a valid color mode
1822 * HWC2_ERROR_UNSUPPORTED - mode is not supported on this display
1823 */
1824typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)(
1825 hwc2_device_t* device, hwc2_display_t display,
1826 int32_t /*android_color_mode_t*/ mode);
1827
Chia-I Wu28310aa2018-03-15 21:20:55 -07001828/* setColorModeWithIntent(..., mode, intent)
1829 * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT
1830 * Provided by HWC2 devices which don't return nullptr function pointer.
1831 *
1832 * This must be called outside of validateDisplay/presentDisplay, and it takes
1833 * effect on next presentDisplay.
1834 *
1835 * The valid color modes and render intents can be found in
1836 * android_color_mode_t and android_render_intent_v1_1_t in
1837 * <system/graphics.h>. All HWC2 devices must support at least
1838 * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are
1839 * assumed to be in this mode and intent upon hotplug.
1840 *
1841 * Parameters:
1842 * mode - the mode to set
1843 * intent - the intent to set
1844 *
1845 * Returns HWC2_ERROR_NONE or one of the following errors:
1846 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1847 * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or
1848 * render intent
1849 * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display
1850 */
1851typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)(
1852 hwc2_device_t* device, hwc2_display_t display,
1853 int32_t /*android_color_mode_t*/ mode,
1854 int32_t /*android_render_intent_v1_1_t */ intent);
1855
Dan Stoza4e9221b2015-09-02 15:43:39 -07001856/* setColorTransform(..., matrix, hint)
1857 * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM
1858 * Must be provided by all HWC2 devices
1859 *
1860 * Sets a color transform which will be applied after composition.
1861 *
1862 * If hint is not HAL_COLOR_TRANSFORM_ARBITRARY, then the device may use the
1863 * hint to apply the desired color transform instead of using the color matrix
1864 * directly.
1865 *
1866 * If the device is not capable of either using the hint or the matrix to apply
1867 * the desired color transform, it should force all layers to client composition
1868 * during validateDisplay.
1869 *
Dan Stozad2168f72016-07-14 11:48:16 -07001870 * If HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM is present, then the client
1871 * will never apply the color transform during client composition, even if all
1872 * layers are being composed by the client.
1873 *
Dan Stoza4e9221b2015-09-02 15:43:39 -07001874 * The matrix provided is an affine color transformation of the following form:
1875 *
1876 * |r.r r.g r.b 0|
1877 * |g.r g.g g.b 0|
1878 * |b.r b.g b.b 0|
1879 * |Tr Tg Tb 1|
1880 *
1881 * This matrix will be provided in row-major form: {r.r, r.g, r.b, 0, g.r, ...}.
1882 *
1883 * Given a matrix of this form and an input color [R_in, G_in, B_in], the output
1884 * color [R_out, G_out, B_out] will be:
1885 *
1886 * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
Dan Stoza5dfbe332016-03-24 09:23:11 -07001887 * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
1888 * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
Dan Stoza4e9221b2015-09-02 15:43:39 -07001889 *
1890 * Parameters:
1891 * matrix - a 4x4 transform matrix (16 floats) as described above
1892 * hint - a hint value which may be used instead of the given matrix unless it
1893 * is HAL_COLOR_TRANSFORM_ARBITRARY
1894 *
1895 * Returns HWC2_ERROR_NONE or one of the following errors:
1896 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1897 * HWC2_ERROR_BAD_PARAMETER - hint is not a valid color transform hint
1898 */
1899typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)(
Dan Stozac46e96a2016-03-24 10:12:15 -07001900 hwc2_device_t* device, hwc2_display_t display, const float* matrix,
Dan Stoza4e9221b2015-09-02 15:43:39 -07001901 int32_t /*android_color_transform_t*/ hint);
1902
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001903/* getPerFrameMetadataKeys(..., outKeys)
1904 * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS
1905 * Optional for HWC2 devices
1906 *
1907 * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null),
1908 * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys
1909 * which are invariant with regard to the active configuration.
1910 *
1911 * Devices which are not HDR-capable, must return null when getFunction is called
1912 * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS.
1913 *
1914 * If outKeys is NULL, the required number of PerFrameMetadataKey keys
1915 * must be returned in outNumKeys.
1916 *
1917 * Parameters:
1918 * outNumKeys - if outKeys is NULL, the number of keys which would have
1919 * been returned; if outKeys is not NULL, the number of keys stored in
1920 * outKeys, which must not exceed the value stored in outNumKeys prior
1921 * to the call; pointer will be non-NULL
1922 * outKeys - an array of hwc2_per_frame_metadata_key_t keys
1923 *
1924 * Returns HWC2_ERROR_NONE or one of the following errors:
1925 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1926 */
1927typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)(
1928 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys,
1929 int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys);
1930
Dan Stoza4e9221b2015-09-02 15:43:39 -07001931/* setOutputBuffer(..., buffer, releaseFence)
1932 * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER
1933 * Must be provided by all HWC2 devices
1934 *
1935 * Sets the output buffer for a virtual display. That is, the buffer to which
1936 * the composition result will be written.
1937 *
1938 * Also provides a file descriptor referring to a release sync fence object,
1939 * which will be signaled when it is safe to write to the output buffer. If it
1940 * is already safe to write to the output buffer, -1 may be passed instead. The
1941 * device must ensure that it is safe for the client to close this file
1942 * descriptor at any point after this function is called.
1943 *
1944 * Must be called at least once before presentDisplay, but does not have any
1945 * interaction with layer state or display validation.
1946 *
1947 * Parameters:
1948 * buffer - the new output buffer
1949 * releaseFence - a sync fence file descriptor as described above
1950 *
1951 * Returns HWC2_ERROR_NONE or one of the following errors:
1952 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1953 * HWC2_ERROR_BAD_PARAMETER - the new output buffer handle was invalid
1954 * HWC2_ERROR_UNSUPPORTED - display does not refer to a virtual display
1955 */
1956typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_OUTPUT_BUFFER)(
1957 hwc2_device_t* device, hwc2_display_t display, buffer_handle_t buffer,
1958 int32_t releaseFence);
1959
1960/* setPowerMode(..., mode)
1961 * Descriptor: HWC2_FUNCTION_SET_POWER_MODE
1962 * Must be provided by all HWC2 devices
1963 *
1964 * Sets the power mode of the given display. The transition must be complete
1965 * when this function returns. It is valid to call this function multiple times
1966 * with the same power mode.
1967 *
1968 * All displays must support HWC2_POWER_MODE_ON and HWC2_POWER_MODE_OFF. Whether
1969 * a display supports HWC2_POWER_MODE_DOZE or HWC2_POWER_MODE_DOZE_SUSPEND may
1970 * be queried using getDozeSupport.
1971 *
1972 * Parameters:
1973 * mode - the new power mode
1974 *
1975 * Returns HWC2_ERROR_NONE or one of the following errors:
1976 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
1977 * HWC2_ERROR_BAD_PARAMETER - mode was not a valid power mode
1978 * HWC2_ERROR_UNSUPPORTED - mode was a valid power mode, but is not supported
1979 * on this display
1980 */
1981typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)(
1982 hwc2_device_t* device, hwc2_display_t display,
1983 int32_t /*hwc2_power_mode_t*/ mode);
1984
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07001985/* getReadbackBufferAttributes(..., outFormat, outDataspace)
1986 * Optional for HWC2 devices
1987 *
1988 * Returns the format which should be used when allocating a buffer for use by
1989 * device readback as well as the dataspace in which its contents should be
1990 * interpreted.
1991 *
1992 * If readback is not supported by this HWC implementation, this call will also
1993 * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method.
1994 * Returning NULL to a getFunction request for this function will also indicate
1995 * that readback is not supported.
1996 *
1997 * The width and height of this buffer will be those of the currently-active
1998 * display configuration, and the usage flags will consist of the following:
1999 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
2000 * BufferUsage::COMPOSER_OUTPUT
2001 *
2002 * The format and dataspace provided must be sufficient such that if a
2003 * correctly-configured buffer is passed into setReadbackBuffer, filled by
2004 * the device, and then displayed by the client as a full-screen buffer, the
2005 * output of the display remains the same (subject to the note about protected
2006 * content in the description of setReadbackBuffer).
2007 *
Dan Stozaaf153e02018-05-15 13:09:51 -07002008 * If the active configuration or color mode of this display has changed since
2009 * the previous call to this function, it will be called again prior to setting
2010 * a readback buffer such that the returned format and dataspace can be updated
2011 * accordingly.
2012 *
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002013 * Parameters:
2014 * outFormat - the format the client should use when allocating a device
Dan Stozaaf153e02018-05-15 13:09:51 -07002015 * readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002016 * outDataspace - the dataspace the client will use when interpreting the
Dan Stozaaf153e02018-05-15 13:09:51 -07002017 * contents of a device readback buffer; pointer will be non-NULL
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002018 *
2019 * Returns HWC2_ERROR_NONE or one of the following errors:
2020 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002021 *
2022 * See also:
2023 * setReadbackBuffer
2024 * getReadbackBufferFence
2025 */
2026typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)(
2027 hwc2_device_t* device, hwc2_display_t display,
2028 int32_t* /*android_pixel_format_t*/ outFormat,
2029 int32_t* /*android_dataspace_t*/ outDataspace);
2030
2031/* getReadbackBufferFence(..., outFence)
2032 * Optional for HWC2 devices
2033 *
2034 * Returns an acquire sync fence file descriptor which will signal when the
2035 * buffer provided to setReadbackBuffer has been filled by the device and is
2036 * safe for the client to read.
2037 *
2038 * If it is already safe to read from this buffer, -1 may be returned instead.
2039 * The client takes ownership of this file descriptor and is responsible for
2040 * closing it when it is no longer needed.
2041 *
2042 * This function will be called immediately after the composition cycle being
2043 * captured into the readback buffer. The complete ordering of a readback buffer
2044 * capture is as follows:
2045 *
2046 * getReadbackBufferAttributes
2047 * // Readback buffer is allocated
2048 * // Many frames may pass
2049 *
2050 * setReadbackBuffer
2051 * validateDisplay
2052 * presentDisplay
2053 * getReadbackBufferFence
2054 * // Implicitly wait on the acquire fence before accessing the buffer
2055 *
2056 * Parameters:
2057 * outFence - a sync fence file descriptor as described above; pointer
2058 * will be non-NULL
2059 *
2060 * Returns HWC2_ERROR_NONE or one of the following errors:
2061 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
Dan Stozaaf153e02018-05-15 13:09:51 -07002062 * HWC2_ERROR_NO_RESOURCES - the readback operation was successful, but
2063 * resulted in a different validate result than would have occurred
2064 * without readback
2065 * HWC2_ERROR_UNSUPPORTED - the readback operation was unsuccessful because
2066 * of resource constraints, the presence of protected content, or other
2067 * reasons; -1 must be returned in outFence
Courtney Goeltzenleuchter437ce432017-02-26 14:39:34 -07002068 */
2069typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)(
2070 hwc2_device_t* device, hwc2_display_t display,
2071 int32_t* outFence);
2072
2073/* setReadbackBuffer(..., buffer, releaseFence)
2074 * Optional for HWC2 devices
2075 *
2076 * Sets the readback buffer to be filled with the contents of the next
2077 * composition performed for this display (i.e., the contents present at the
2078 * time of the next validateDisplay/presentDisplay cycle).
2079 *
2080 * This buffer will have been allocated as described in
2081 * getReadbackBufferAttributes and will be interpreted as being in the dataspace
2082 * provided by the same.
2083 *
2084 * If there is hardware protected content on the display at the time of the next
2085 * composition, the area of the readback buffer covered by such content must be
2086 * completely black. Any areas of the buffer not covered by such content may
2087 * optionally be black as well.
2088 *
2089 * The release fence file descriptor provided works identically to the one
2090 * described for setOutputBuffer.
2091 *
2092 * This function will not be called between any call to validateDisplay and a
2093 * subsequent call to presentDisplay.
2094 *
2095 * Parameters:
2096 * buffer - the new readback buffer
2097 * releaseFence - a sync fence file descriptor as described in setOutputBuffer
2098 *
2099 * Returns HWC2_ERROR_NONE or one of the following errors:
2100 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2101 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
2102 *
2103 * See also:
2104 * getReadbackBufferAttributes
2105 * getReadbackBufferFence
2106 */
2107typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)(
2108 hwc2_device_t* device, hwc2_display_t display,
2109 buffer_handle_t buffer, int32_t releaseFence);
2110
Dan Stoza4e9221b2015-09-02 15:43:39 -07002111/* setVsyncEnabled(..., enabled)
2112 * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED
2113 * Must be provided by all HWC2 devices
2114 *
2115 * Enables or disables the vsync signal for the given display. Virtual displays
2116 * never generate vsync callbacks, and any attempt to enable vsync for a virtual
2117 * display though this function must return HWC2_ERROR_NONE and have no other
2118 * effect.
2119 *
2120 * Parameters:
2121 * enabled - whether to enable or disable vsync
2122 *
2123 * Returns HWC2_ERROR_NONE or one of the following errors:
2124 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2125 * HWC2_ERROR_BAD_PARAMETER - enabled was an invalid value
2126 */
2127typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_VSYNC_ENABLED)(
2128 hwc2_device_t* device, hwc2_display_t display,
2129 int32_t /*hwc2_vsync_t*/ enabled);
2130
2131/* validateDisplay(..., outNumTypes, outNumRequests)
2132 * Descriptor: HWC2_FUNCTION_VALIDATE_DISPLAY
2133 * Must be provided by all HWC2 devices
2134 *
2135 * Instructs the device to inspect all of the layer state and determine if
2136 * there are any composition type changes necessary before presenting the
2137 * display. Permitted changes are described in the definition of
2138 * hwc2_composition_t above.
2139 *
2140 * Also returns the number of layer requests required
2141 * by the given layer configuration.
2142 *
2143 * Parameters:
2144 * outNumTypes - the number of composition type changes required by the
2145 * device; if greater than 0, the client must either set and validate new
2146 * types, or call acceptDisplayChanges to accept the changes returned by
2147 * getChangedCompositionTypes; must be the same as the number of changes
2148 * returned by getChangedCompositionTypes (see the declaration of that
2149 * function for more information); pointer will be non-NULL
2150 * outNumRequests - the number of layer requests required by this layer
2151 * configuration; must be equal to the number of layer requests returned
2152 * by getDisplayRequests (see the declaration of that function for
2153 * more information); pointer will be non-NULL
2154 *
2155 * Returns HWC2_ERROR_NONE if no changes are necessary and it is safe to present
2156 * the display using the current layer state. Otherwise returns one of the
2157 * following errors:
2158 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2159 * HWC2_ERROR_HAS_CHANGES - outNumTypes was greater than 0 (see parameter list
2160 * for more information)
2161 */
2162typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_VALIDATE_DISPLAY)(
2163 hwc2_device_t* device, hwc2_display_t display,
2164 uint32_t* outNumTypes, uint32_t* outNumRequests);
2165
2166/*
2167 * Layer Functions
2168 *
2169 * These are functions which operate on layers, but which do not modify state
2170 * that must be validated before use. See also 'Layer State Functions' below.
2171 *
2172 * All of these functions take as their first three parameters a device pointer,
2173 * a display handle for the display which contains the layer, and a layer
2174 * handle, so these parameters are omitted from the described parameter lists.
2175 */
2176
2177/* setCursorPosition(..., x, y)
2178 * Descriptor: HWC2_FUNCTION_SET_CURSOR_POSITION
2179 * Must be provided by all HWC2 devices
2180 *
2181 * Asynchonously sets the position of a cursor layer.
2182 *
2183 * Prior to validateDisplay, a layer may be marked as HWC2_COMPOSITION_CURSOR.
2184 * If validation succeeds (i.e., the device does not request a composition
2185 * change for that layer), then once a buffer has been set for the layer and it
2186 * has been presented, its position may be set by this function at any time
2187 * between presentDisplay and any subsequent validateDisplay calls for this
2188 * display.
2189 *
2190 * Once validateDisplay is called, this function will not be called again until
2191 * the validate/present sequence is completed.
2192 *
2193 * May be called from any thread so long as it is not interleaved with the
2194 * validate/present sequence as described above.
2195 *
2196 * Parameters:
2197 * x - the new x coordinate (in pixels from the left of the screen)
2198 * y - the new y coordinate (in pixels from the top of the screen)
2199 *
2200 * Returns HWC2_ERROR_NONE or one of the following errors:
2201 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2202 * HWC2_ERROR_BAD_LAYER - the layer is invalid or is not currently marked as
2203 * HWC2_COMPOSITION_CURSOR
2204 * HWC2_ERROR_NOT_VALIDATED - the device is currently in the middle of the
2205 * validate/present sequence
2206 */
2207typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CURSOR_POSITION)(
2208 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2209 int32_t x, int32_t y);
2210
2211/* setLayerBuffer(..., buffer, acquireFence)
2212 * Descriptor: HWC2_FUNCTION_SET_LAYER_BUFFER
2213 * Must be provided by all HWC2 devices
2214 *
2215 * Sets the buffer handle to be displayed for this layer. If the buffer
2216 * properties set at allocation time (width, height, format, and usage) have not
2217 * changed since the previous frame, it is not necessary to call validateDisplay
2218 * before calling presentDisplay unless new state needs to be validated in the
2219 * interim.
2220 *
2221 * Also provides a file descriptor referring to an acquire sync fence object,
2222 * which will be signaled when it is safe to read from the given buffer. If it
2223 * is already safe to read from the buffer, -1 may be passed instead. The
2224 * device must ensure that it is safe for the client to close this file
2225 * descriptor at any point after this function is called.
2226 *
2227 * This function must return HWC2_ERROR_NONE and have no other effect if called
2228 * for a layer with a composition type of HWC2_COMPOSITION_SOLID_COLOR (because
2229 * it has no buffer) or HWC2_COMPOSITION_SIDEBAND or HWC2_COMPOSITION_CLIENT
2230 * (because synchronization and buffer updates for these layers are handled
2231 * elsewhere).
2232 *
2233 * Parameters:
2234 * buffer - the buffer handle to set
2235 * acquireFence - a sync fence file descriptor as described above
2236 *
2237 * Returns HWC2_ERROR_NONE or one of the following errors:
2238 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2239 * HWC2_ERROR_BAD_PARAMETER - the buffer handle passed in was invalid
2240 */
2241typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BUFFER)(
2242 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2243 buffer_handle_t buffer, int32_t acquireFence);
2244
2245/* setLayerSurfaceDamage(..., damage)
2246 * Descriptor: HWC2_FUNCTION_SET_LAYER_SURFACE_DAMAGE
2247 * Must be provided by all HWC2 devices
2248 *
2249 * Provides the region of the source buffer which has been modified since the
2250 * last frame. This region does not need to be validated before calling
2251 * presentDisplay.
2252 *
2253 * Once set through this function, the damage region remains the same until a
2254 * subsequent call to this function.
2255 *
2256 * If damage.numRects > 0, then it may be assumed that any portion of the source
2257 * buffer not covered by one of the rects has not been modified this frame. If
2258 * damage.numRects == 0, then the whole source buffer must be treated as if it
2259 * has been modified.
2260 *
2261 * If the layer's contents are not modified relative to the prior frame, damage
2262 * will contain exactly one empty rect([0, 0, 0, 0]).
2263 *
2264 * The damage rects are relative to the pre-transformed buffer, and their origin
2265 * is the top-left corner. They will not exceed the dimensions of the latched
2266 * buffer.
2267 *
2268 * Parameters:
2269 * damage - the new surface damage region
2270 *
2271 * Returns HWC2_ERROR_NONE or one of the following errors:
2272 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2273 */
2274typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)(
2275 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2276 hwc_region_t damage);
2277
Chia-I Wu28310aa2018-03-15 21:20:55 -07002278/* setLayerPerFrameMetadata(..., numMetadata, metadata)
2279 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA
2280 * Optional for HWC2 devices
2281 *
2282 * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is
2283 * non-null), sets the metadata for the given display for all following
2284 * frames.
2285 *
2286 * Upon returning from this function, the metadata change must have
2287 * fully taken effect.
2288 *
2289 * This function will only be called if getPerFrameMetadataKeys is non-NULL
2290 * and returns at least one key.
2291 *
2292 * Parameters:
2293 * numElements is the number of elements in each of the keys and metadata arrays
2294 * keys is a pointer to the array of keys.
2295 * outMetadata is a pointer to the corresponding array of metadata.
2296 *
2297 * Returns HWC2_ERROR_NONE or one of the following errors:
2298 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2299 * HWC2_ERROR_BAD_PARAMETER - metadata is not valid
2300 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2301 */
2302typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)(
2303 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2304 uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys,
2305 const float* metadata);
2306
Valerie Hau69c53432018-11-13 09:07:44 -08002307/* setLayerPerFrameMetadataBlobs(...,numElements, keys, sizes, blobs)
2308 * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS
2309 * Optional for HWC2 devices
2310 *
2311 * If supported, (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS)
2312 * is non-null), sets the metadata for the given display and layer.
2313 *
2314 * Upon returning from this function, the metadata change must have fully taken
2315 * effect.
2316 *
2317 * This function must only be called if getPerFrameMetadataKeys is non-NULL
2318 * and returns at least one key that corresponds to a blob type.
2319 *
2320 * Current valid blob type keys are: HDR10_PLUS_SEI
2321 *
2322 * Parameters:
2323 * numElements is the number of elements in each of the keys, sizes, and
2324 * metadata arrays
2325 * keys is a pointer to an array of keys. Current valid keys are those listed
2326 * above as valid blob type keys.
2327 * sizes is a pointer to an array of unsigned ints specifying the sizes of
2328 * each metadata blob
2329 * metadata is a pointer to a blob of data holding all blobs contiguously in
2330 * memory
2331 *
2332 * Returns HWC2_ERROR_NONE or one of the following erros:
2333 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2334 * HWC2_ERROR_BAD_PARAMETER - sizes of keys and metadata parameters does
2335 * not match numElements, numElements < 0, or keys contains a
2336 * non-valid key (see above for current valid blob type keys).
2337 * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display
2338 */
2339typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS)(
2340 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2341 uint32_t numElements, const int32_t* keys, const uint32_t* sizes,
2342 const uint8_t* metadata);
Dan Stoza4e9221b2015-09-02 15:43:39 -07002343/*
2344 * Layer State Functions
2345 *
2346 * These functions modify the state of a given layer. They do not take effect
2347 * until the display configuration is successfully validated with
2348 * validateDisplay and the display contents are presented with presentDisplay.
2349 *
2350 * All of these functions take as their first three parameters a device pointer,
2351 * a display handle for the display which contains the layer, and a layer
2352 * handle, so these parameters are omitted from the described parameter lists.
2353 */
2354
2355/* setLayerBlendMode(..., mode)
2356 * Descriptor: HWC2_FUNCTION_SET_LAYER_BLEND_MODE
2357 * Must be provided by all HWC2 devices
2358 *
2359 * Sets the blend mode of the given layer.
2360 *
2361 * Parameters:
2362 * mode - the new blend mode
2363 *
2364 * Returns HWC2_ERROR_NONE or one of the following errors:
2365 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2366 * HWC2_ERROR_BAD_PARAMETER - an invalid blend mode was passed in
2367 */
2368typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_BLEND_MODE)(
2369 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2370 int32_t /*hwc2_blend_mode_t*/ mode);
2371
2372/* setLayerColor(..., color)
2373 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR
2374 * Must be provided by all HWC2 devices
2375 *
2376 * Sets the color of the given layer. If the composition type of the layer is
2377 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2378 * have no other effect.
2379 *
2380 * Parameters:
2381 * color - the new color
2382 *
2383 * Returns HWC2_ERROR_NONE or one of the following errors:
2384 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2385 */
2386typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)(
2387 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2388 hwc_color_t color);
2389
Peiyong Linfd05d132018-01-22 12:23:25 -08002390/* setLayerFloatColor(..., color)
2391 * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR
2392 * Provided by HWC2 devices which don't return nullptr function pointer.
2393 *
2394 * Sets the color of the given layer. If the composition type of the layer is
2395 * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and
2396 * have no other effect.
2397 *
2398 * Parameters:
2399 * color - the new color in float type, rage is [0.0, 1.0], the colorspace is
2400 * defined by the dataspace that gets set by calling setLayerDataspace.
2401 *
2402 * Returns HWC2_ERROR_NONE or one of the following errors:
2403 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2404 */
2405typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)(
2406 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2407 hwc_float_color_t color);
2408
Dan Stoza4e9221b2015-09-02 15:43:39 -07002409/* setLayerCompositionType(..., type)
2410 * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE
2411 * Must be provided by all HWC2 devices
2412 *
2413 * Sets the desired composition type of the given layer. During validateDisplay,
2414 * the device may request changes to the composition types of any of the layers
2415 * as described in the definition of hwc2_composition_t above.
2416 *
2417 * Parameters:
2418 * type - the new composition type
2419 *
2420 * Returns HWC2_ERROR_NONE or one of the following errors:
2421 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2422 * HWC2_ERROR_BAD_PARAMETER - an invalid composition type was passed in
2423 * HWC2_ERROR_UNSUPPORTED - a valid composition type was passed in, but it is
2424 * not supported by this device
2425 */
2426typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COMPOSITION_TYPE)(
2427 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2428 int32_t /*hwc2_composition_t*/ type);
2429
2430/* setLayerDataspace(..., dataspace)
2431 * Descriptor: HWC2_FUNCTION_SET_LAYER_DATASPACE
2432 * Must be provided by all HWC2 devices
2433 *
2434 * Sets the dataspace that the current buffer on this layer is in.
2435 *
2436 * The dataspace provides more information about how to interpret the buffer
2437 * contents, such as the encoding standard and color transform.
2438 *
2439 * See the values of android_dataspace_t in <system/graphics.h> for more
2440 * information.
2441 *
2442 * Parameters:
2443 * dataspace - the new dataspace
2444 *
2445 * Returns HWC2_ERROR_NONE or one of the following errors:
2446 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2447 */
2448typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DATASPACE)(
2449 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2450 int32_t /*android_dataspace_t*/ dataspace);
2451
2452/* setLayerDisplayFrame(..., frame)
2453 * Descriptor: HWC2_FUNCTION_SET_LAYER_DISPLAY_FRAME
2454 * Must be provided by all HWC2 devices
2455 *
2456 * Sets the display frame (the portion of the display covered by a layer) of the
2457 * given layer. This frame will not exceed the display dimensions.
2458 *
2459 * Parameters:
2460 * frame - the new display frame
2461 *
2462 * Returns HWC2_ERROR_NONE or one of the following errors:
2463 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2464 */
2465typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_DISPLAY_FRAME)(
2466 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2467 hwc_rect_t frame);
2468
2469/* setLayerPlaneAlpha(..., alpha)
2470 * Descriptor: HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA
2471 * Must be provided by all HWC2 devices
2472 *
2473 * Sets an alpha value (a floating point value in the range [0.0, 1.0]) which
2474 * will be applied to the whole layer. It can be conceptualized as a
2475 * preprocessing step which applies the following function:
2476 * if (blendMode == HWC2_BLEND_MODE_PREMULTIPLIED)
2477 * out.rgb = in.rgb * planeAlpha
2478 * out.a = in.a * planeAlpha
2479 *
2480 * If the device does not support this operation on a layer which is marked
2481 * HWC2_COMPOSITION_DEVICE, it must request a composition type change to
2482 * HWC2_COMPOSITION_CLIENT upon the next validateDisplay call.
2483 *
2484 * Parameters:
2485 * alpha - the plane alpha value to apply
2486 *
2487 * Returns HWC2_ERROR_NONE or one of the following errors:
2488 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2489 */
2490typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PLANE_ALPHA)(
2491 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2492 float alpha);
2493
2494/* setLayerSidebandStream(..., stream)
2495 * Descriptor: HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM
2496 * Provided by HWC2 devices which support HWC2_CAPABILITY_SIDEBAND_STREAM
2497 *
2498 * Sets the sideband stream for this layer. If the composition type of the given
2499 * layer is not HWC2_COMPOSITION_SIDEBAND, this call must return HWC2_ERROR_NONE
2500 * and have no other effect.
2501 *
2502 * Parameters:
2503 * stream - the new sideband stream
2504 *
2505 * Returns HWC2_ERROR_NONE or one of the following errors:
2506 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2507 * HWC2_ERROR_BAD_PARAMETER - an invalid sideband stream was passed in
2508 */
2509typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SIDEBAND_STREAM)(
2510 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2511 const native_handle_t* stream);
2512
2513/* setLayerSourceCrop(..., crop)
2514 * Descriptor: HWC2_FUNCTION_SET_LAYER_SOURCE_CROP
2515 * Must be provided by all HWC2 devices
2516 *
2517 * Sets the source crop (the portion of the source buffer which will fill the
2518 * display frame) of the given layer. This crop rectangle will not exceed the
2519 * dimensions of the latched buffer.
2520 *
2521 * If the device is not capable of supporting a true float source crop (i.e., it
2522 * will truncate or round the floats to integers), it should set this layer to
2523 * HWC2_COMPOSITION_CLIENT when crop is non-integral for the most accurate
2524 * rendering.
2525 *
2526 * If the device cannot support float source crops, but still wants to handle
2527 * the layer, it should use the following code (or similar) to convert to
2528 * an integer crop:
2529 * intCrop.left = (int) ceilf(crop.left);
2530 * intCrop.top = (int) ceilf(crop.top);
2531 * intCrop.right = (int) floorf(crop.right);
2532 * intCrop.bottom = (int) floorf(crop.bottom);
2533 *
2534 * Parameters:
2535 * crop - the new source crop
2536 *
2537 * Returns HWC2_ERROR_NONE or one of the following errors:
2538 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2539 */
2540typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SOURCE_CROP)(
2541 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2542 hwc_frect_t crop);
2543
2544/* setLayerTransform(..., transform)
2545 * Descriptor: HWC2_FUNCTION_SET_LAYER_TRANSFORM
2546 * Must be provided by all HWC2 devices
2547 *
2548 * Sets the transform (rotation/flip) of the given layer.
2549 *
2550 * Parameters:
2551 * transform - the new transform
2552 *
2553 * Returns HWC2_ERROR_NONE or one of the following errors:
2554 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2555 * HWC2_ERROR_BAD_PARAMETER - an invalid transform was passed in
2556 */
2557typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_TRANSFORM)(
2558 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2559 int32_t /*hwc_transform_t*/ transform);
2560
2561/* setLayerVisibleRegion(..., visible)
2562 * Descriptor: HWC2_FUNCTION_SET_LAYER_VISIBLE_REGION
2563 * Must be provided by all HWC2 devices
2564 *
2565 * Specifies the portion of the layer that is visible, including portions under
2566 * translucent areas of other layers. The region is in screen space, and will
2567 * not exceed the dimensions of the screen.
2568 *
2569 * Parameters:
2570 * visible - the new visible region, in screen space
2571 *
2572 * Returns HWC2_ERROR_NONE or one of the following errors:
2573 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2574 */
2575typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_VISIBLE_REGION)(
2576 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2577 hwc_region_t visible);
2578
2579/* setLayerZOrder(..., z)
2580 * Descriptor: HWC2_FUNCTION_SET_LAYER_Z_ORDER
2581 * Must be provided by all HWC2 devices
2582 *
2583 * Sets the desired Z order (height) of the given layer. A layer with a greater
2584 * Z value occludes a layer with a lesser Z value.
2585 *
2586 * Parameters:
2587 * z - the new Z order
2588 *
2589 * Returns HWC2_ERROR_NONE or one of the following errors:
2590 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2591 */
2592typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_Z_ORDER)(
2593 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2594 uint32_t z);
2595
Peiyong Lin44819b92018-09-13 16:20:08 -07002596/* setLayerColorTransform(..., matrix)
2597 * Descriptor: HWC2_FUNCTION_SET_LAYER_COLOR_TRANSFORM
2598 * Optional by all HWC2 devices
2599 *
2600 * Sets a matrix for color transform which will be applied on this layer
2601 * before composition.
2602 *
2603 * If the device is not capable of apply the matrix on this layer, it must force
2604 * this layer to client composition during VALIDATE_DISPLAY.
2605 *
2606 * The matrix provided is an affine color transformation of the following form:
2607 *
2608 * |r.r r.g r.b 0|
2609 * |g.r g.g g.b 0|
2610 * |b.r b.g b.b 0|
2611 * |Tr Tg Tb 1|
2612 *
2613 * This matrix must be provided in row-major form:
2614 *
2615 * {r.r, r.g, r.b, 0, g.r, ...}.
2616 *
2617 * Given a matrix of this form and an input color [R_in, G_in, B_in],
2618 * the input color must first be converted to linear space
2619 * [R_linear, G_linear, B_linear], then the output linear color
2620 * [R_out_linear, G_out_linear, B_out_linear] will be:
2621 *
2622 * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
2623 * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
2624 * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
2625 *
2626 * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
2627 * gamma space: [R_out, G_out, B_out] before blending.
2628 *
2629 * Parameters:
2630 * matrix - a 4x4 transform matrix (16 floats) as described above
2631 *
2632 * Returns HWC2_ERROR_NONE or one of the following errors:
2633 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2634 * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in
2635 */
2636typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR_TRANSFORM)(
2637 hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer,
2638 const float* matrix);
2639
Kevin DuBois13458872018-09-10 09:09:12 -07002640/* getDisplayedContentSamplingAttributes(...,
2641 * format, dataspace, supported_components, max_frames)
2642 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES
2643 * Optional by all HWC2 devices
2644 *
2645 * Query for what types of color sampling the hardware supports.
2646 *
2647 * Parameters:
2648 * format - The format of the sampled pixels; pointer will be non-NULL
2649 * dataspace - The dataspace of the sampled pixels; pointer will be non-NULL
2650 * supported_components - The mask of which components can be sampled; pointer
2651 * will be non-NULL
2652 *
2653 * Returns HWC2_ERROR_NONE or one of the following errors:
2654 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2655 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2656 */
2657typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES)(
2658 hwc2_device_t* device, hwc2_display_t display,
2659 int32_t* /* android_pixel_format_t */ format,
2660 int32_t* /* android_dataspace_t */ dataspace,
2661 uint8_t* /* mask of android_component_t */ supported_components);
2662
2663/* setDisplayedContentSamplingEnabled(..., enabled)
2664 * Descriptor: HWC2_FUNCTION_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED
2665 * Optional by all HWC2 devices
2666 *
2667 * Enables or disables the collection of color content statistics
2668 * on this display.
2669 *
2670 * Sampling occurs on the contents of the final composition on this display
2671 * (i.e., the contents presented on screen).
2672 *
2673 * Sampling support is optional, and is set to DISABLE by default.
2674 * On each call to ENABLE, all collected statistics will be reset.
2675 *
2676 * Sample data can be queried via getDisplayedContentSample().
2677 *
2678 * Parameters:
2679 * enabled - indicates whether to enable or disable sampling.
2680 * component_mask - The mask of which components should be sampled.
2681 * If zero, all supported components are to be enabled.
2682 * max_frames - is the maximum number of frames that should be stored before
2683 * discard. The sample represents the most-recently posted frames.
2684 *
2685 * Returns HWC2_ERROR_NONE or one of the following errors:
2686 * HWC2_ERROR_BAD_DISPLAY when an invalid display handle was passed in,
2687 * HWC2_ERROR_BAD_PARAMETER when enabled was an invalid value, or
2688 * HWC2_ERROR_NO_RESOURCES when the requested ringbuffer size via max_frames
2689 * was not available.
2690 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample.
2691 */
2692typedef int32_t (*HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED)(
2693 hwc2_device_t* device, hwc2_display_t display,
2694 int32_t /*hwc2_displayed_content_sampling_t*/ enabled,
2695 uint8_t /* mask of android_component_t */ component_mask,
2696 uint64_t max_frames);
2697
2698/* getDisplayedContentSample(..., component, max_frames, timestamp,
2699 * samples_size, samples, frame_count)
2700 * Descriptor: HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE
2701 * Optional by all HWC2 devices
2702 *
2703 * Collects the results of display content color sampling for display.
2704 *
2705 * Collection of data can occur whether the sampling is in ENABLE or
2706 * DISABLE state.
2707 *
2708 * Parameters:
2709 * max_frames - is the maximum number of frames that should be represented in
2710 * the sample. The sample represents the most-recently posted frames.
2711 * If max_frames is 0, all frames are to be represented by the sample.
2712 * timestamp - is the timestamp after which any frames were posted that should
2713 * be included in the sample. Timestamp is CLOCK_MONOTONIC.
2714 * If timestamp is 0, do not filter from the sample by time.
2715 * frame_count - The number of frames represented by this sample; pointer will
2716 * be non-NULL.
2717 * samples_size - The sizes of the color histogram representing the color
2718 * sampling. Sample_sizes are indexed in the same order as
2719 * HWC2_FORMAT_COMPONENT_.
2720 * samples - The arrays of data corresponding to the sampling data. Samples are
2721 * indexed in the same order as HWC2_FORMAT_COMPONENT_.
2722 * The size of each sample is the samples_size for the same index.
2723 * Each components sample is an array that is to be filled with the
2724 * evenly-weighted buckets of a histogram counting how many times a pixel
2725 * of the given component was displayed onscreen. Caller owns the data and
2726 * pointer may be NULL to query samples_size.
2727 *
2728 * Returns HWC2_ERROR_NONE or one of the following errors:
2729 * HWC2_ERROR_BAD_DISPLAY when an invalid display was passed in, or
2730 * HWC2_ERROR_UNSUPPORTED when there is no efficient way to sample, or
2731 * HWC2_ERROR_BAD_PARAMETER when the component is not supported by the hardware.
2732 */
2733typedef int32_t (*HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE)(
2734 hwc2_device_t* device, hwc2_display_t display,
2735 uint64_t max_frames, uint64_t timestamp,
2736 uint64_t* frame_count, int32_t samples_size[4], uint64_t* samples[4]);
2737
Peiyong Linf09421f2018-10-26 18:31:03 -07002738/* getDisplayCapabilities(..., outCapabilities)
2739 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES
2740 * Required for HWC2 devices for composer 2.3
2741 * Optional for HWC2 devices for composer 2.1 and 2.2
2742 *
2743 * getDisplayCapabilities returns a list of supported capabilities
2744 * (as described in the definition of Capability above).
2745 * This list must not change after initialization.
2746 *
2747 * Parameters:
2748 * outNumCapabilities - if outCapabilities was nullptr, returns the number of capabilities
2749 * if outCapabilities was not nullptr, returns the number of capabilities stored in
2750 * outCapabilities, which must not exceed the value stored in outNumCapabilities prior
2751 * to the call; pointer will be non-NULL
2752 * outCapabilities - a list of supported capabilities.
2753 *
2754 * Returns HWC2_ERROR_NONE or one of the following errors:
2755 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2756 */
2757typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CAPABILITIES)(
2758 hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumCapabilities,
2759 uint32_t* outCapabilities);
2760
Peiyong Lin59dedc32019-04-11 13:25:24 -07002761/* Use getDisplayCapabilities instead. If brightness is supported, must return
2762 * DisplayCapability::BRIGHTNESS as one of the display capabilities via getDisplayCapabilities.
2763 * Only use getDisplayCapabilities as the source of truth to query brightness support.
2764 *
2765 * getDisplayBrightnessSupport(displayToken)
Dan Gittik10510ff2019-01-18 19:30:24 +00002766 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT
2767 * Required for HWC2 devices for composer 2.3
2768 * Optional for HWC2 devices for composer 2.1 and 2.2
2769 *
2770 * getDisplayBrightnessSupport returns whether brightness operations are supported on a display.
2771 *
2772 * Parameters:
2773 * outSupport - whether the display supports operations.
2774 *
2775 * Returns HWC2_ERROR_NONE or one of the following errors:
2776 * HWC2_ERROR_BAD_DISPLAY when the display is invalid.
2777 */
2778typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT)(hwc2_device_t* device,
2779 hwc2_display_t display, bool* outSupport);
2780
2781/* setDisplayBrightness(displayToken, brightnesss)
2782 * Descriptor: HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS
2783 * Required for HWC2 devices for composer 2.3
2784 * Optional for HWC2 devices for composer 2.1 and 2.2
2785 *
2786 * setDisplayBrightness sets the brightness of a display.
2787 *
2788 * Parameters:
2789 * brightness - a number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or
2790 * -1.0f to turn the backlight off.
2791 *
2792 * Returns HWC2_ERROR_NONE or one of the following errors:
2793 * HWC2_ERROR_BAD_DISPLAY when the display is invalid, or
2794 * HWC2_ERROR_UNSUPPORTED when brightness operations are not supported, or
2795 * HWC2_ERROR_BAD_PARAMETER when the brightness is invalid, or
2796 * HWC2_ERROR_NO_RESOURCES when the brightness cannot be applied.
2797 */
2798typedef int32_t /*hwc_error_t*/ (*HWC2_PFN_SET_DISPLAY_BRIGHTNESS)(hwc2_device_t* device,
2799 hwc2_display_t display, float brightness);
2800
Dominik Laskowski9c1266c2019-10-01 15:14:53 -07002801/* getDisplayConnectionType(..., outType)
2802 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_CONNECTION_TYPE
2803 * Optional for all HWC2 devices
2804 *
2805 * Returns whether the given physical display is internal or external.
2806 *
2807 * Parameters:
2808 * outType - the connection type of the display; pointer will be non-NULL
2809 *
2810 * Returns HWC2_ERROR_NONE or one of the following errors:
2811 * HWC2_ERROR_BAD_DISPLAY when the display is invalid or virtual.
2812 */
2813typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_CONNECTION_TYPE)(
2814 hwc2_device_t* device, hwc2_display_t display,
2815 uint32_t* /*hwc2_display_connection_type_t*/ outType);
2816
Ady Abraham8324c922019-10-10 19:14:07 -07002817/* getSupportedDisplayVsyncPeriods(..., outNumVsyncPeriods, outVsyncPeriods)
2818 * Descriptor: HWC2_FUNCTION_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS
2819 * Required for HWC2 devices for composer 2.4
2820 *
2821 * Returns a array of supported vsync periods the display can refresh at a given configuration.
2822 *
2823 * outVsyncPeriods may be NULL to retrieve the number of elements which will be returned.
2824 *
2825 * Parameters:
2826 * outNumVsyncPeriods - if outVsyncPeriods was NULL, the number of vsync periods which
2827 * would have been returned; if outVsyncPeriods was not NULL, the number of
2828 * vsync periods returned, which must not exceed the value stored in
2829 * outNumVsyncPeriods prior to the call; pointer will be non-NULL
2830 * outVsyncPeriods - an array of vsync periods
2831 *
2832 * Returns HWC2_ERROR_NONE or one of the following errors:
2833 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2834 * HWC2_ERROR_BAD_CONFIG - the configuration handle passed in is not valid for
2835 * this display
2836 */
2837typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_SUPPORTED_DISPLAY_VSYNC_PERIODS)(
2838 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
2839 uint32_t* outNumVsyncPeriods, hwc2_vsync_period_t* outVsyncPeriods);
2840
2841/* getDisplayVsyncPeriod(..., outVsyncPeriods)
2842 * Descriptor: HWC2_FUNCTION_GET_DISPLAY_VSYNC_PERIOD
2843 * Required for HWC2 devices for composer 2.4
2844 *
2845 * Retrieves which vsync period the display is currently using.
2846 *
2847 * If no display configuration is currently active, this function must
2848 * return BAD_CONFIG. If a vsync period is about to change due to a
2849 * setActiveConfigAndVsyncPeriod call, this function must return the current vsync period
2850 * until the change has taken place.
2851 *
2852 * Parameters:
2853 * outVsyncPeriod - the current vsync period of the display.
2854 *
2855 * Returns HWC2_ERROR_NONE or one of the following errors:
2856 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
2857 * HWC2_ERROR_BAD_CONFIG - no configuration is currently active
2858 */
2859typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DISPLAY_VSYNC_PERIOD)(
2860 hwc2_device_t* device, hwc2_display_t display, hwc2_vsync_period_t* outVsyncPeriod);
2861
2862/* setActiveConfigAndVsyncPeriod(..., config, vsyncPeriodNanos,
2863 * vsyncPeriodChangeConstraints, outNewVsyncAppliedTime)
2864 * Descriptor: HWC2_FUNCTION_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD
2865 * Required for HWC2 devices for composer 2.4
2866 *
2867 * Sets the active configuration and the refresh rate for this display.
2868 * If the config is the same as the current config, only the vsync period shall change.
2869 * Upon returning, the given display configuration, except vsync period, must be active and
2870 * remain so until either this function is called again or the display is disconnected.
2871 * When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
2872 * called with the new vsync period.
2873 *
2874 * Parameters:
2875 * config - the new display configuration.
2876 * vsyncPeriodNanos - the new display vsync period.
2877 * vsyncPeriodChangeConstraints - constraints required for changing vsync period:
2878 * desiredTimeNanos - the time in CLOCK_MONOTONIC after
2879 * which the vsync period may change
2880 * (i.e., the vsync period must not change
2881 * before this time).
2882 * seamlessRequired - if true, requires that the vsync period
2883 * change must happen seamlessly without
2884 * a noticeable visual artifact.
2885 * outNewVsyncAppliedTime - the time in CLOCK_MONOTONIC when the new display will start to
2886 * refresh at the new vsync period.
2887 *
2888 * Returns HWC2_ERROR_NONE or one of the following errors:
2889 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in.
2890 * HWC2_ERROR_BAD_CONFIG - an invalid configuration handle passed in.
2891 * HWC2_ERROR_BAD_VSYNC_PERIOD - an invalid vsync period is passed in.
2892 * HWC2_ERROR_SEAMLESS_NOT_POSSIBLE - when seamlessRequired was true but the display cannot
2893 * achieve the vsync period change without a noticeable
2894 * visual artifact.
2895 */
2896typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_ACTIVE_CONFIG_AND_VSYNC_PERIOD)(
2897 hwc2_device_t* device, hwc2_display_t display, hwc2_config_t config,
2898 hwc2_vsync_period_t vsyncPeriodNanos,
2899 hwc_vsync_period_change_constraints_t* vsyncPeriodChangeConstraints,
2900 int64_t* outNewVsyncAppliedTime);
2901
2902
Dan Stoza4e9221b2015-09-02 15:43:39 -07002903__END_DECLS
2904
2905#endif