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