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