blob: a6665a1230a926f4875afa6a9703fbd1df257f41 [file] [log] [blame]
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -08001/*
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.2;
18
Chia-I Wu6c8257f2018-02-28 12:24:42 -080019import android.hardware.graphics.common@1.1::ColorMode;
Peiyong Lina2acfa22018-03-28 12:09:42 -070020import android.hardware.graphics.common@1.1::Dataspace;
21import android.hardware.graphics.common@1.1::PixelFormat;
Chia-I Wu6c8257f2018-02-28 12:24:42 -080022import android.hardware.graphics.common@1.1::RenderIntent;
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -080023import @2.1::IComposerClient;
24import @2.1::Display;
25import @2.1::Error;
Peiyong Lina2acfa22018-03-28 12:09:42 -070026import @2.1::IComposerClient;
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -080027
28interface IComposerClient extends @2.1::IComposerClient {
29
30 enum PowerMode : @2.1::IComposerClient.PowerMode {
31 /**
32 * The display is configured as in ON but may stop applying display
33 * updates from the client. This is effectively a hint to the device
34 * that drawing to the display has been suspended and that the the
35 * device must remain on and continue displaying its current contents
36 * indefinitely until the power mode changes.
37 *
38 * This mode may also be used as a signal to enable hardware-based
39 * functionality to take over the display and manage it autonomously
40 * to implement a low power always-on display.
41 */
42 ON_SUSPEND = 4
43 };
44
45 /**
46 * Following enums define keys for metadata defined by SMPTE ST 2086:2014
47 * and CTA 861.3.
48 */
49 enum PerFrameMetadataKey : int32_t {
50 /** SMPTE ST 2084:2014.
51 * Coordinates defined in CIE 1931 xy chromaticity space
52 */
53 /** SMPTE ST 2084:2014 */
54 DISPLAY_RED_PRIMARY_X,
55 /** SMPTE ST 2084:2014 */
56 DISPLAY_RED_PRIMARY_Y,
57 /** SMPTE ST 2084:2014 */
58 DISPLAY_GREEN_PRIMARY_X,
59 /** SMPTE ST 2084:2014 */
60 DISPLAY_GREEN_PRIMARY_Y,
61 /** SMPTE ST 2084:2014 */
62 DISPLAY_BLUE_PRIMARY_X,
63 /** SMPTE ST 2084:2014 */
64 DISPLAY_BLUE_PRIMARY_Y,
65 /** SMPTE ST 2084:2014 */
66 WHITE_POINT_X,
67 /** SMPTE ST 2084:2014 */
68 WHITE_POINT_Y,
69 /** SMPTE ST 2084:2014.
70 * Units: nits
71 * max as defined by ST 2048: 10,000 nits
72 */
73 MAX_LUMINANCE,
74 /** SMPTE ST 2084:2014 */
75 MIN_LUMINANCE,
76 /** CTA 861.3 */
77 MAX_CONTENT_LIGHT_LEVEL,
78 /** CTA 861.3 */
79 MAX_FRAME_AVERAGE_LIGHT_LEVEL,
80 };
81
82 struct PerFrameMetadata {
83 PerFrameMetadataKey key;
84 float value;
85 };
86
Peiyong Linab505aa2018-01-24 20:24:32 -080087 struct FloatColor {
88 float r;
89 float g;
90 float b;
91 float a;
92 };
93
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -080094 enum Command : @2.1::IComposerClient.Command {
Peiyong Linab505aa2018-01-24 20:24:32 -080095 /**
Chia-I Wu6c8257f2018-02-28 12:24:42 -080096 * SET_LAYER_PER_FRAME_METADATA has this pseudo prototype
97 *
98 * setLayerPerFrameMetadata(Display display, Layer layer,
99 * vec<PerFrameMetadata> data);
100 *
Peiyong Linab505aa2018-01-24 20:24:32 -0800101 * Sets the PerFrameMetadata for the display. This metadata must be used
102 * by the implementation to better tone map content to that display.
103 *
104 * This is a method that may be called every frame. Thus it's
105 * implemented using buffered transport.
Chia-I Wu6c8257f2018-02-28 12:24:42 -0800106 * SET_LAYER_PER_FRAME_METADATA is the command used by the buffered transport
Peiyong Linab505aa2018-01-24 20:24:32 -0800107 * mechanism.
108 */
Chia-I Wu6c8257f2018-02-28 12:24:42 -0800109 SET_LAYER_PER_FRAME_METADATA = 0x303 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Peiyong Linab505aa2018-01-24 20:24:32 -0800110
111 /**
112 * SET_LAYER_COLOR has this pseudo prototype
113 *
114 * setLayerColor(FloatColor color);
115 *
116 * Sets the color of the given layer. If the composition type of the layer
117 * is not Composition::SOLID_COLOR, this call must succeed and have no
118 * other effect.
119 *
120 * @param color is the new color using float type.
121 */
122 SET_LAYER_FLOAT_COLOR = 0x40c << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -0800123 };
124
125 /**
126 * Returns the PerFrameMetadataKeys that are supported by this device.
127 *
128 * @param display is the display on which to create the layer.
129 * @return keys is the vector of PerFrameMetadataKey keys that are
130 * supported by this device.
131 * @return error is NONE upon success. Otherwise,
132 * UNSUPPORTED if not supported on underlying HAL
133 */
134 getPerFrameMetadataKeys(Display display)
135 generates (Error error,
136 vec<PerFrameMetadataKey> keys);
137
138 /**
139 * getReadbackBufferAttributes
140 * Returns the format which should be used when allocating a buffer for use by
141 * device readback as well as the dataspace in which its contents should be
142 * interpreted.
143 *
144 * The width and height of this buffer must be those of the currently-active
145 * display configuration, and the usage flags must consist of the following:
146 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
147 * BufferUsage::COMPOSER_OUTPUT
148 *
149 * The format and dataspace provided must be sufficient such that if a
150 * correctly-configured buffer is passed into setReadbackBuffer, filled by
151 * the device, and then displayed by the client as a full-screen buffer, the
152 * output of the display remains the same (subject to the note about protected
153 * content in the description of setReadbackBuffer).
154 *
155 * Parameters:
156 * @param display - the display on which to create the layer.
157 *
158 * @return format - the format the client should use when allocating a device
159 * readback buffer
160 * @return dataspace - the dataspace to use when interpreting the
161 * contents of a device readback buffer
162 * @return error is NONE upon success. Otherwise,
163 * BAD_DISPLAY when an invalid display handle was passed in.
164 * UNSUPPORTED if not supported on underlying HAL
165 *
166 * See also:
167 * setReadbackBuffer
168 * getReadbackBufferFence
169 */
170 getReadbackBufferAttributes(Display display)
171 generates (Error error,
172 PixelFormat format,
173 Dataspace dataspace);
174
175 /**
176 * getReadbackBufferFence
177 * Returns an acquire sync fence file descriptor which must signal when the
178 * buffer provided to setReadbackBuffer has been filled by the device and is
179 * safe for the client to read.
180 *
181 * If it is already safe to read from this buffer, -1 may be returned instead.
182 * The client takes ownership of this file descriptor and is responsible for
183 * closing it when it is no longer needed.
184 *
185 * This function must be called immediately after the composition cycle being
186 * captured into the readback buffer. The complete ordering of a readback buffer
187 * capture is as follows:
188 *
189 * getReadbackBufferAttributes
190 * // Readback buffer is allocated
191 * // Many frames may pass
192 *
193 * setReadbackBuffer
194 * validateDisplay
195 * presentDisplay
196 * getReadbackBufferFence
197 * // Implicitly wait on the acquire fence before accessing the buffer
198 *
199 * Parameters:
200 * @param display - the display on which to create the layer.
201 *
202 * @return acquireFence - a sync fence file descriptor as described above; pointer
203 * must be non-NULL
204 * @return error - is HWC2_ERROR_NONE or one of the following errors:
205 * BAD_DISPLAY - an invalid display handle was passed in
206 * UNSUPPORTED if not supported on underlying HAL
207 *
208 * See also:
209 * getReadbackBufferAttributes
210 * setReadbackBuffer
211 */
212 getReadbackBufferFence(Display display)
213 generates (Error error,
214 handle acquireFence);
215
216 /**
217 * setReadbackBuffer
218 * Sets the readback buffer to be filled with the contents of the next
219 * composition performed for this display (i.e., the contents present at the
220 * time of the next validateDisplay/presentDisplay cycle).
221 *
222 * This buffer must have been allocated as described in
223 * getReadbackBufferAttributes and is in the dataspace provided by the same.
224 *
225 * If there is hardware protected content on the display at the time of the next
226 * composition, the area of the readback buffer covered by such content must be
227 * completely black. Any areas of the buffer not covered by such content may
228 * optionally be black as well.
229 *
230 * The release fence file descriptor provided works identically to the one
231 * described for setOutputBuffer.
232 *
233 * This function must not be called between any call to validateDisplay and a
234 * subsequent call to presentDisplay.
235 *
236 * Parameters:
237 * @param display - the display on which to create the layer.
238 * @param buffer - the new readback buffer
239 * @param releaseFence - a sync fence file descriptor as described in setOutputBuffer
240 *
241 * @return error - is HWC2_ERROR_NONE or one of the following errors:
242 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
243 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
244 *
245 * See also:
246 * getReadbackBufferAttributes
247 * getReadbackBufferFence
248 */
249 setReadbackBuffer(Display display, handle buffer, handle releaseFence) generates (Error error);
250
251 /**
Peiyong Lina2acfa22018-03-28 12:09:42 -0700252 * createVirtualDisplay_2_2
253 * Creates a new virtual display with the given width and height. The
254 * format passed into this function is the default format requested by the
255 * consumer of the virtual display output buffers.
256 *
257 * The display must be assumed to be on from the time the first frame is
258 * presented until the display is destroyed.
259 *
260 * @param width is the width in pixels.
261 * @param height is the height in pixels.
262 * @param formatHint is the default output buffer format selected by
263 * the consumer.
264 * @param outputBufferSlotCount is the number of output buffer slots to be
265 * reserved.
266 * @return error is NONE upon success. Otherwise,
267 * UNSUPPORTED when the width or height is too large for the
268 * device to be able to create a virtual display.
269 * NO_RESOURCES when the device is unable to create a new virtual
270 * display at this time.
271 * @return display is the newly-created virtual display.
272 * @return format is the format of the buffer the device will produce.
273 */
274 @callflow(next="*")
275 createVirtualDisplay_2_2(uint32_t width,
276 uint32_t height,
277 PixelFormat formatHint,
278 uint32_t outputBufferSlotCount)
279 generates (Error error,
280 Display display,
281 PixelFormat format);
282
283 /**
284 * getClientTargetSupport_2_2
285 * Returns whether a client target with the given properties can be
286 * handled by the device.
287 *
288 * This function must return true for a client target with width and
289 * height equal to the active display configuration dimensions,
290 * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to
291 * return true for any other configuration.
292 *
293 * @param display is the display to query.
294 * @param width is the client target width in pixels.
295 * @param height is the client target height in pixels.
296 * @param format is the client target format.
297 * @param dataspace is the client target dataspace, as described in
298 * setLayerDataspace.
299 * @return error is NONE upon success. Otherwise,
300 * BAD_DISPLAY when an invalid display handle was passed in.
301 * UNSUPPORTED when the given configuration is not supported.
302 */
303 @callflow(next="*")
304 getClientTargetSupport_2_2(Display display,
305 uint32_t width,
306 uint32_t height,
307 PixelFormat format,
308 Dataspace dataspace)
309 generates (Error error);
310 /**
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -0800311 * setPowerMode_2_2
312 * Sets the power mode of the given display. The transition must be
313 * complete when this function returns. It is valid to call this function
314 * multiple times with the same power mode.
315 *
316 * All displays must support PowerMode::ON and PowerMode::OFF. Whether a
317 * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
318 * queried using getDozeSupport.
319 *
320 * @param display is the display to which the power mode is set.
321 * @param mode is the new power mode.
322 * @return error is NONE upon success. Otherwise,
323 * BAD_DISPLAY when an invalid display handle was passed in.
324 * BAD_PARAMETER when mode was not a valid power mode.
325 * UNSUPPORTED when mode is not supported on this display.
326 */
327 setPowerMode_2_2(Display display, PowerMode mode) generates (Error error);
328
Chia-I Wu6c8257f2018-02-28 12:24:42 -0800329 /**
330 * Returns the color modes supported on this display.
331 *
332 * All devices must support at least ColorMode::NATIVE.
333 *
334 * @param display is the display to query.
335 * @return error is NONE upon success. Otherwise,
336 * BAD_DISPLAY when an invalid display handle was passed in.
337 * @return modes is an array of color modes.
338 */
339 getColorModes_2_2(Display display)
340 generates (Error error,
341 vec<ColorMode> modes);
342
343 /**
344 * Returns the render intents supported by the specified display and color
345 * mode.
346 *
347 * RenderIntent::COLORIMETRIC is always supported.
348 *
349 * @param display is the display to query.
350 * @param mode is the color mode to query.
351 * @return error is NONE upon success. Otherwise,
352 * BAD_DISPLAY when an invalid display handle was passed in.
353 * BAD_PARAMETER when an invalid color mode was passed in.
354 * @return intents is an array of render intents.
355 */
356 getRenderIntents(Display display, ColorMode mode)
357 generates (Error error,
358 vec<RenderIntent> intents);
359
360 /**
361 * Sets the color mode and render intent of the given display.
362 *
363 * The color mode and render intent change must take effect on next
364 * presentDisplay.
365 *
366 * All devices must support at least ColorMode::NATIVE and
367 * RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode
368 * upon hotplug.
369 *
370 * @param display is the display to which the color mode is set.
371 * @param mode is the color mode to set to.
372 * @param intent is the render intent to set to.
373 * @return error is NONE upon success. Otherwise,
374 * BAD_DISPLAY when an invalid display handle was passed in.
375 * BAD_PARAMETER when mode or intent is invalid
376 * UNSUPPORTED when mode or intent is not supported on this
377 * display.
378 */
379 setColorMode_2_2(Display display, ColorMode mode, RenderIntent intent)
380 generates (Error error);
381
382 /*
383 * By default, layer dataspaces are mapped to the current color mode
384 * colorimetrically with a few exceptions.
385 *
Chia-I Wuc75e0f02018-04-20 13:19:13 -0700386 * When the layer dataspace is a legacy dataspace (see
387 * common@1.1::Dataspace) and the display render intent is
Chia-I Wu6c8257f2018-02-28 12:24:42 -0800388 * RenderIntent::ENHANCE, the pixel values can go through an
389 * implementation-defined saturation transform before being mapped to the
390 * current color mode colorimetrically.
391 *
392 * Colors that are out of the gamut of the current color mode are
393 * hard-clipped.
394 */
395
396 /**
397 * Returns the saturation matrix of the specified legacy dataspace.
398 *
399 * The saturation matrix can be used to approximate the legacy dataspace
400 * saturation transform. It is to be applied on linear pixel values like
401 * this:
402 *
403 * (in GLSL)
Chia-I Wuc75e0f02018-04-20 13:19:13 -0700404 * linearSrgb = saturationMatrix * linearSrgb;
Chia-I Wu6c8257f2018-02-28 12:24:42 -0800405 *
406 * @param dataspace must be Dataspace::SRGB_LINEAR.
407 * @return error is NONE upon success. Otherwise,
408 * BAD_PARAMETER when an invalid dataspace was passed in.
409 * @return matrix is the 4x4 column-major matrix used to approximate the
410 * legacy dataspace saturation operation. The last row must be
411 * [0.0, 0.0, 0.0, 1.0].
412 */
413 getDataspaceSaturationMatrix(Dataspace dataspace)
414 generates (Error error,
415 float[4][4] matrix);
416
417 /**
418 * Executes commands from the input command message queue. Return values
419 * generated by the input commands are written to the output command
420 * message queue in the form of value commands.
421 *
422 * @param inLength is the length of input commands.
423 * @param inHandles is an array of handles referenced by the input
424 * commands.
425 * @return error is NONE upon success. Otherwise,
426 * BAD_PARAMETER when inLength is not equal to the length of
427 * commands in the input command message queue.
428 * NO_RESOURCES when the output command message queue was not
429 * properly drained.
430 * @param outQueueChanged indicates whether the output command message
431 * queue has changed.
432 * @param outLength is the length of output commands.
433 * @param outHandles is an array of handles referenced by the output
434 * commands.
435 */
436 executeCommands_2_2(uint32_t inLength,
437 vec<handle> inHandles)
438 generates (Error error,
439 bool outQueueChanged,
440 uint32_t outLength,
441 vec<handle> outHandles);
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -0800442};