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