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