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