blob: 5fcc0e67d61762a4bda63365cc6710b87aa6161d [file] [log] [blame]
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -07001/*
2 * Copyright (C) 2018 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
17package android.hardware.graphics.composer@2.3;
18
Valerie Hauec983062018-10-09 16:09:12 -070019import android.hardware.graphics.common@1.1::RenderIntent;
Kevin DuBois1ec0b522019-01-25 11:06:13 -080020import android.hardware.graphics.common@1.2::PixelFormat;
Valerie Hauec983062018-10-09 16:09:12 -070021import android.hardware.graphics.common@1.2::ColorMode;
22import android.hardware.graphics.common@1.2::Dataspace;
Valerie Hauc25748d2018-10-29 14:53:40 -070023import android.hardware.graphics.common@1.2::Hdr;
Peiyong Lin830137f2018-09-13 17:19:38 -070024import android.hardware.graphics.composer@2.1::IComposerClient.Command;
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -070025import @2.2::IComposerClient;
26import @2.1::Display;
27import @2.1::Error;
28
29interface IComposerClient extends @2.2::IComposerClient {
30
Peiyong Lin55d50d62018-10-26 18:24:46 -070031 /**
32 * Required capabilities which are supported by the display. The
33 * particular set of supported capabilities for a given display may be
34 * retrieved using getDisplayCapabilities.
35 */
36 enum DisplayCapability : uint32_t {
37 INVALID = 0,
38
39 /**
Peiyong Lin02dd3d32018-12-05 06:59:39 -080040 * Indicates that the display must apply a color transform even when
Peiyong Lin55d50d62018-10-26 18:24:46 -070041 * either the client or the device has chosen that all layers should
42 * be composed by the client. This prevents the client from applying
43 * the color transform during its composition step.
44 * If getDisplayCapabilities is supported, the global capability
45 * SKIP_CLIENT_COLOR_TRANSFORM is ignored.
46 * If getDisplayCapabilities is not supported, and the global capability
47 * SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
48 * then all displays must be treated as having
49 * SKIP_CLIENT_COLOR_TRANSFORM.
50 */
51 SKIP_CLIENT_COLOR_TRANSFORM = 1,
52
53 /**
Peiyong Lin02dd3d32018-12-05 06:59:39 -080054 * Indicates that the display supports PowerMode::DOZE and
Peiyong Lin55d50d62018-10-26 18:24:46 -070055 * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
56 * over DOZE (see the definition of PowerMode for more information),
57 * but if both DOZE and DOZE_SUSPEND are no different from
58 * PowerMode::ON, the device must not claim support.
59 * Must be returned by getDisplayCapabilities when getDozeSupport
60 * indicates the display supports PowerMode::DOZE and
61 * PowerMode::DOZE_SUSPEND.
62 */
63 DOZE = 2,
64 };
65
Valerie Hauc25748d2018-10-29 14:53:40 -070066 /**
67 * PerFrameMetadataKey
68 *
69 * A set of PerFrameMetadataKey pertains specifically to blob-formatted
70 * metadata (as opposed to float-valued metadata).
71 * The list of keys that represent blobs are:
72 * 1. HDR10_PLUS_SEI
73 */
74 enum PerFrameMetadataKey : @2.2::IComposerClient.PerFrameMetadataKey {
75 /**HDR10+ metadata
76 * Specifies a metadata blob adhering to
77 * the ST2094-40 SEI message spec, Version 1.0
78 */
79 HDR10_PLUS_SEI,
80 };
81
82 /**
83 * PerFrameMetadata
84 * This struct encapsulates float-valued
85 * metadata - key must not be in the list
86 * of keys representing blob-formatted metadata
87 * (see PerFrameMetadataKey)
88 */
89 struct PerFrameMetadata {
90 PerFrameMetadataKey key;
91 float value;
92 };
93
94 /**
95 * PerFrameMetadataBlob
96 * This struct encapsulates blob
97 * metadata - key must be one of the list of keys
98 * associated with blob-type metadata key
99 * and the blob must adhere to the format specified by
100 * that key (See PerFrameMetadataKey).
101 */
102 struct PerFrameMetadataBlob {
103 PerFrameMetadataKey key;
104 vec<uint8_t> blob;
105 };
106
Peiyong Lin830137f2018-09-13 17:19:38 -0700107 enum Command : @2.2::IComposerClient.Command {
108 /**
109 * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype
110 *
111 * setLayerColorTransform(float[16] matrix);
112 *
113 * This command has the following binary layout in bytes:
114 *
115 * 0 - 16 * 4: matrix
116 *
117 * Sets a matrix for color transform which will be applied on this layer
118 * before composition.
119 *
120 * If the device is not capable of apply the matrix on this layer, it must force
121 * this layer to client composition during VALIDATE_DISPLAY.
122 *
123 * The matrix provided is an affine color transformation of the following
124 * form:
125 *
126 * |r.r r.g r.b 0|
127 * |g.r g.g g.b 0|
128 * |b.r b.g b.b 0|
129 * |Tr Tg Tb 1|
130 *
131 * This matrix must be provided in row-major form:
132 *
133 * {r.r, r.g, r.b, 0, g.r, ...}.
134 *
135 * Given a matrix of this form and an input color [R_in, G_in, B_in],
136 * the input color must first be converted to linear space
137 * [R_linear, G_linear, B_linear], then the output linear color
138 * [R_out_linear, G_out_linear, B_out_linear] will be:
139 *
140 * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
141 * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
142 * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
143 *
144 * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
145 * gamma space: [R_out, G_out, B_out] before blending.
146 *
147 * @param matrix is a 4x4 transform matrix (16 floats) as described above.
148 */
149 SET_LAYER_COLOR_TRANSFORM = 0x40d << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Valerie Hauc25748d2018-10-29 14:53:40 -0700150
151 /* SET_LAYER_PER_FRAME_METADATA_BLOBS has this pseudo prototype
152 *
153 * setLayerPerFrameMetadataBlobs(Display display, Layer layer,
154 * vec<PerFrameMetadataBlob> metadata);
155 *
156 * This command sends metadata that may be used for tone-mapping the
157 * associated layer. The metadata structure follows a {key, blob}
158 * format (see the PerFrameMetadataBlob struct). All keys must be
159 * returned by a prior call to getPerFrameMetadataKeys and must
160 * be part of the list of keys associated with blob-type metadata
161 * (see PerFrameMetadataKey).
162 *
163 * This method may be called every frame.
164 */
165 SET_LAYER_PER_FRAME_METADATA_BLOBS = 0x304 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Peiyong Lin830137f2018-09-13 17:19:38 -0700166 };
167
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -0700168 /**
169 * Returns the port and data that describe a physical display. The port is
170 * a unique number that identifies a physical connector (e.g. eDP, HDMI)
171 * for display output. The data blob is parsed to determine its format,
172 * typically EDID 1.3 as specified in VESA E-EDID Standard Release A
173 * Revision 1.
174 *
175 * @param display is the display to query.
176 * @return error is NONE upon success. Otherwise,
177 * BAD_DISPLAY when an invalid display handle was passed in.
178 * UNSUPPORTED when identification data is unavailable.
179 * @return port is the connector to which the display is connected.
180 * @return data is the EDID 1.3 blob identifying the display.
181 */
182 @callflow(next="*")
183 getDisplayIdentificationData(Display display)
184 generates (Error error,
185 uint8_t port,
186 vec<uint8_t> data);
Valerie Hauec983062018-10-09 16:09:12 -0700187 /**
188 * getReadbackBufferAttributes_2_3
189 * Returns the format which should be used when allocating a buffer for use by
190 * device readback as well as the dataspace in which its contents must be
191 * interpreted.
192 *
193 * The width and height of this buffer must be those of the currently-active
194 * display configuration, and the usage flags must consist of the following:
195 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
196 * BufferUsage::COMPOSER_OUTPUT
197 *
198 * The format and dataspace provided must be sufficient such that if a
199 * correctly-configured buffer is passed into setReadbackBuffer, filled by
200 * the device, and then displayed by the client as a full-screen buffer, the
201 * output of the display remains the same (subject to the note about protected
202 * content in the description of setReadbackBuffer).
203 *
204 * If the active configuration or color mode of this display has changed
205 * since a previous call to this function, it must be called again prior to
206 * setting a readback buffer such that the returned format and dataspace will
207 * be updated accordingly.
208 *
209 * Parameters:
210 * @param display - the display on which to create the layer.
211 *
212 * @return format - the format the client should use when allocating a device
213 * readback buffer
214 * @return dataspace - the dataspace to use when interpreting the
215 * contents of a device readback buffer
216 * @return error is NONE upon success. Otherwise,
217 * BAD_DISPLAY when an invalid display handle was passed in.
218 * UNSUPPORTED if not supported on underlying HAL
219 *
220 * See also:
221 * setReadbackBuffer
222 * getReadbackBufferFence
223 */
224 getReadbackBufferAttributes_2_3(Display display)
225 generates (Error error,
226 PixelFormat format,
227 Dataspace dataspace);
228
229 /**
230 * getClientTargetSupport_2_3
231 * Returns whether a client target with the given properties can be
232 * handled by the device.
233 *
234 * This function must return true for a client target with width and
235 * height equal to the active display configuration dimensions,
236 * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to
237 * return true for any other configuration.
238 *
239 * @param display is the display to query.
240 * @param width is the client target width in pixels.
241 * @param height is the client target height in pixels.
242 * @param format is the client target format.
243 * @param dataspace is the client target dataspace, as described in
244 * setLayerDataspace.
245 * @return error is NONE upon success. Otherwise,
246 * BAD_DISPLAY when an invalid display handle was passed in.
247 * UNSUPPORTED when the given configuration is not supported.
248 */
249 @callflow(next="*")
250 getClientTargetSupport_2_3(Display display,
251 uint32_t width,
252 uint32_t height,
253 PixelFormat format,
254 Dataspace dataspace)
255 generates (Error error);
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -0700256
Kevin DuBoisbf141482018-09-10 09:07:54 -0700257 enum FormatColorComponent : uint8_t {
258 /* The first component (eg, for RGBA_8888, this is R) */
259 FORMAT_COMPONENT_0 = 1 << 0,
260 /* The second component (eg, for RGBA_8888, this is G) */
261 FORMAT_COMPONENT_1 = 1 << 1,
262 /* The third component (eg, for RGBA_8888, this is B) */
263 FORMAT_COMPONENT_2 = 1 << 2,
264 /* The fourth component (eg, for RGBA_8888, this is A) */
265 FORMAT_COMPONENT_3 = 1 << 3,
266 };
267
268 /**
269 * Query for what types of color sampling the hardware supports.
270 *
271 * @param display is the display where the samples are collected.
272 * @return error is NONE upon success. Otherwise,
273 * BAD_DISPLAY when an invalid display was passed in, or
274 * UNSUPPORTED when there is no efficient way to sample.
275 * @return format The format of the sampled pixels.
276 * @return dataspace The dataspace of the sampled pixels.
277 * @return componentMask The mask of which components can be sampled.
278 */
279 getDisplayedContentSamplingAttributes(Display display)
280 generates (Error error,
281 PixelFormat format,
282 Dataspace dataspace,
283 bitfield<FormatColorComponent> componentMask);
284
285 /** DisplayedContentSampling values passed to setDisplayedContentSamplingEnabled. */
286 enum DisplayedContentSampling : int32_t {
287 INVALID = 0,
288
289 /** Enable content sampling. */
290 ENABLE = 1,
291
292 /** Disable content sampling. */
293 DISABLE = 2,
294 };
295
296 /**
297 * Enables or disables the collection of color content statistics
298 * on this display.
299 *
300 * Sampling occurs on the contents of the final composition on this display
301 * (i.e., the contents presented on screen). Samples should be collected after all
302 * color transforms have been applied.
303 *
304 * Sampling support is optional, and is set to DISABLE by default.
305 * On each call to ENABLE, all collected statistics must be reset.
306 *
307 * Sample data can be queried via getDisplayedContentSample().
308 *
309 * @param display is the display to which the sampling mode is set.
310 * @param enabled indicates whether to enable or disable sampling.
311 * @param componentMask The mask of which components should be sampled. If zero, all supported
312 * components are to be enabled.
313 * @param maxFrames is the maximum number of frames that should be stored before discard.
314 * The sample represents the most-recently posted frames.
315 * @return error is NONE upon success. Otherwise,
316 * BAD_DISPLAY when an invalid display handle was passed in,
317 * BAD_PARAMETER when enabled was an invalid value, or
318 * NO_RESOURCES when the requested ringbuffer size via maxFrames was
319 * not available.
320 * UNSUPPORTED when there is no efficient way to sample.
321 */
322 setDisplayedContentSamplingEnabled(
323 Display display, DisplayedContentSampling enable,
324 bitfield<FormatColorComponent> componentMask, uint64_t maxFrames)
325 generates (Error error);
326
327 /**
328 * Collects the results of display content color sampling for display.
329 *
330 * Collection of data can occur whether the sampling is in ENABLE or
331 * DISABLE state.
332 *
333 * @param display is the display to which the sampling is collected.
334 * @param maxFrames is the maximum number of frames that should be represented in the sample.
335 * The sample represents the most-recently posted frames.
336 * If maxFrames is 0, all frames are to be represented by the sample.
337 * @param timestamp is the timestamp after which any frames were posted that should be
338 * included in the sample. Timestamp is CLOCK_MONOTONIC.
339 * If timestamp is 0, do not filter from the sample by time.
340 * @return error is NONE upon success. Otherwise,
341 * BAD_DISPLAY when an invalid display was passed in, or
342 * UNSUPPORTED when there is no efficient way to sample, or
343 * BAD_PARAMETER when the component is not supported by the hardware.
344 * @return frameCount The number of frames represented by this sample.
345 * @return sampleComponent0 is a histogram counting how many times a pixel of a given value
346 * was displayed onscreen for FORMAT_COMPONENT_0.
347 * The buckets of the histogram are evenly weighted, the number of buckets
348 * is device specific.
349 * eg, for RGBA_8888, if sampleComponent0 is {10, 6, 4, 1} this means that
350 * 10 red pixels were displayed onscreen in range 0x00->0x3F, 6 red pixels
351 * were displayed onscreen in range 0x40->0x7F, etc.
352 * @return sampleComponent1 is the same sample definition as sampleComponent0,
353 * but for FORMAT_COMPONENT_1.
354 * @return sampleComponent2 is the same sample definition as sampleComponent0,
355 * but for FORMAT_COMPONENT_2.
356 * @return sampleComponent3 is the same sample definition as sampleComponent0,
357 * but for FORMAT_COMPONENT_3.
358 */
359 getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp)
360 generates (Error error,
361 uint64_t frameCount,
362 vec<uint64_t> sampleComponent0,
363 vec<uint64_t> sampleComponent1,
364 vec<uint64_t> sampleComponent2,
365 vec<uint64_t> sampleComponent3);
366
Peiyong Lin830137f2018-09-13 17:19:38 -0700367 /**
368 * Executes commands from the input command message queue. Return values
369 * generated by the input commands are written to the output command
370 * message queue in the form of value commands.
371 *
372 * @param inLength is the length of input commands.
373 * @param inHandles is an array of handles referenced by the input
374 * commands.
375 * @return error is NONE upon success. Otherwise,
376 * BAD_PARAMETER when inLength is not equal to the length of
377 * commands in the input command message queue.
378 * NO_RESOURCES when the output command message queue was not
379 * properly drained.
380 * @param outQueueChanged indicates whether the output command message
381 * queue has changed.
382 * @param outLength is the length of output commands.
383 * @param outHandles is an array of handles referenced by the output
384 * commands.
385 */
386 executeCommands_2_3(uint32_t inLength,
387 vec<handle> inHandles)
388 generates (Error error,
389 bool outQueueChanged,
390 uint32_t outLength,
391 vec<handle> outHandles);
Valerie Hauec983062018-10-09 16:09:12 -0700392
393 /**
394 * Returns the render intents supported by the specified display and color
395 * mode.
396 *
397 * For SDR color modes, RenderIntent::COLORIMETRIC must be supported. For
398 * HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC must be supported.
399 *
400 * @param display is the display to query.
401 * @param mode is the color mode to query.
402 * @return error is NONE upon success. Otherwise,
403 * BAD_DISPLAY when an invalid display handle was passed in.
404 * BAD_PARAMETER when an invalid color mode was passed in.
405 * @return intents is an array of render intents.
406 */
407 getRenderIntents_2_3(Display display, ColorMode mode)
408 generates (Error error,
409 vec<RenderIntent> intents);
410
411 /**
412 * Returns the color modes supported on this display.
413 *
414 * All devices must support at least ColorMode::NATIVE.
415 *
416 * @param display is the display to query.
417 * @return error is NONE upon success. Otherwise,
418 * BAD_DISPLAY when an invalid display handle was passed in.
419 * @return modes is an array of color modes.
420 */
421 getColorModes_2_3(Display display)
422 generates (Error error,
423 vec<ColorMode> modes);
424
425 /**
426 * Sets the color mode and render intent of the given display.
427 *
428 * The color mode and render intent change must take effect on next
429 * presentDisplay.
430 *
431 * All devices must support at least ColorMode::NATIVE and
432 * RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode
433 * upon hotplug.
434 *
435 * @param display is the display to which the color mode is set.
436 * @param mode is the color mode to set to.
437 * @param intent is the render intent to set to.
438 * @return error is NONE upon success. Otherwise,
439 * BAD_DISPLAY when an invalid display handle was passed in.
440 * BAD_PARAMETER when mode or intent is invalid
441 * UNSUPPORTED when mode or intent is not supported on this
442 * display.
443 */
444 setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent)
445 generates (Error error);
Peiyong Lin55d50d62018-10-26 18:24:46 -0700446
447 /**
448 * Provides a list of supported capabilities (as described in the
449 * definition of DisplayCapability above). This list must not change after
450 * initialization.
451 *
452 * @return error is NONE upon success. Otherwise,
453 * BAD_DISPLAY when an invalid display handle was passed in.
454 * @return capabilities is a list of supported capabilities.
455 */
456 getDisplayCapabilities(Display display)
457 generates (Error error,
458 vec<DisplayCapability> capabilities);
Valerie Hauc25748d2018-10-29 14:53:40 -0700459
460 /**
461 * Returns the PerFrameMetadataKeys that are supported by this device.
462 *
463 * @param display is the display on which to create the layer.
464 * @return keys is the vector of PerFrameMetadataKey keys that are
465 * supported by this device.
466 * @return error is NONE upon success. Otherwise,
467 * UNSUPPORTED if not supported on underlying HAL
468 */
469 getPerFrameMetadataKeys_2_3(Display display)
470 generates (Error error,
471 vec<PerFrameMetadataKey> keys);
472
473 /**
474 * Returns the high dynamic range (HDR) capabilities of the given display,
475 * which are invariant with regard to the active configuration.
476 *
477 * Displays which are not HDR-capable must return no types.
478 *
479 * @param display is the display to query.
480 * @return error is NONE upon success. Otherwise,
481 * BAD_DISPLAY when an invalid display handle was passed in.
482 * @return types is an array of HDR types, may have 0 elements if the
483 * display is not HDR-capable.
484 * @return maxLuminance is the desired content maximum luminance for this
485 * display in cd/m^2.
486 * @return maxAverageLuminance - the desired content maximum frame-average
487 * luminance for this display in cd/m^2.
488 * @return minLuminance is the desired content minimum luminance for this
489 * display in cd/m^2.
490 */
491 @callflow(next="*")
492 getHdrCapabilities_2_3(Display display)
493 generates (Error error,
494 vec<Hdr> types,
495 float maxLuminance,
496 float maxAverageLuminance,
497 float minLuminance);
Dominik Laskowskicd2e9f52018-03-12 19:41:03 -0700498};