blob: dcd9c8d04a4a67a64d53a911d5b89cee20251742 [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
19import android.hardware.graphics.common@1.0::PixelFormat;
20import android.hardware.graphics.common@1.0::Dataspace;
21import @2.1::IComposerClient;
22import @2.1::Display;
23import @2.1::Error;
24
25interface IComposerClient extends @2.1::IComposerClient {
26
27 enum PowerMode : @2.1::IComposerClient.PowerMode {
28 /**
29 * The display is configured as in ON but may stop applying display
30 * updates from the client. This is effectively a hint to the device
31 * that drawing to the display has been suspended and that the the
32 * device must remain on and continue displaying its current contents
33 * indefinitely until the power mode changes.
34 *
35 * This mode may also be used as a signal to enable hardware-based
36 * functionality to take over the display and manage it autonomously
37 * to implement a low power always-on display.
38 */
39 ON_SUSPEND = 4
40 };
41
42 /**
43 * Following enums define keys for metadata defined by SMPTE ST 2086:2014
44 * and CTA 861.3.
45 */
46 enum PerFrameMetadataKey : int32_t {
47 /** SMPTE ST 2084:2014.
48 * Coordinates defined in CIE 1931 xy chromaticity space
49 */
50 /** SMPTE ST 2084:2014 */
51 DISPLAY_RED_PRIMARY_X,
52 /** SMPTE ST 2084:2014 */
53 DISPLAY_RED_PRIMARY_Y,
54 /** SMPTE ST 2084:2014 */
55 DISPLAY_GREEN_PRIMARY_X,
56 /** SMPTE ST 2084:2014 */
57 DISPLAY_GREEN_PRIMARY_Y,
58 /** SMPTE ST 2084:2014 */
59 DISPLAY_BLUE_PRIMARY_X,
60 /** SMPTE ST 2084:2014 */
61 DISPLAY_BLUE_PRIMARY_Y,
62 /** SMPTE ST 2084:2014 */
63 WHITE_POINT_X,
64 /** SMPTE ST 2084:2014 */
65 WHITE_POINT_Y,
66 /** SMPTE ST 2084:2014.
67 * Units: nits
68 * max as defined by ST 2048: 10,000 nits
69 */
70 MAX_LUMINANCE,
71 /** SMPTE ST 2084:2014 */
72 MIN_LUMINANCE,
73 /** CTA 861.3 */
74 MAX_CONTENT_LIGHT_LEVEL,
75 /** CTA 861.3 */
76 MAX_FRAME_AVERAGE_LIGHT_LEVEL,
77 };
78
79 struct PerFrameMetadata {
80 PerFrameMetadataKey key;
81 float value;
82 };
83
Peiyong Linab505aa2018-01-24 20:24:32 -080084 struct FloatColor {
85 float r;
86 float g;
87 float b;
88 float a;
89 };
90
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -080091 enum Command : @2.1::IComposerClient.Command {
Peiyong Linab505aa2018-01-24 20:24:32 -080092 /**
93 * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data)
94 * Sets the PerFrameMetadata for the display. This metadata must be used
95 * by the implementation to better tone map content to that display.
96 *
97 * This is a method that may be called every frame. Thus it's
98 * implemented using buffered transport.
99 * SET_PER_FRAME_METADATA is the command used by the buffered transport
100 * mechanism.
101 */
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -0800102 SET_PER_FRAME_METADATA = 0x207 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Peiyong Linab505aa2018-01-24 20:24:32 -0800103
104 /**
105 * SET_LAYER_COLOR has this pseudo prototype
106 *
107 * setLayerColor(FloatColor color);
108 *
109 * Sets the color of the given layer. If the composition type of the layer
110 * is not Composition::SOLID_COLOR, this call must succeed and have no
111 * other effect.
112 *
113 * @param color is the new color using float type.
114 */
115 SET_LAYER_FLOAT_COLOR = 0x40c << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Courtney Goeltzenleuchterbe92bb92018-01-11 08:50:03 -0800116 };
117
118 /**
119 * Returns the PerFrameMetadataKeys that are supported by this device.
120 *
121 * @param display is the display on which to create the layer.
122 * @return keys is the vector of PerFrameMetadataKey keys that are
123 * supported by this device.
124 * @return error is NONE upon success. Otherwise,
125 * UNSUPPORTED if not supported on underlying HAL
126 */
127 getPerFrameMetadataKeys(Display display)
128 generates (Error error,
129 vec<PerFrameMetadataKey> keys);
130
131 /**
132 * getReadbackBufferAttributes
133 * Returns the format which should be used when allocating a buffer for use by
134 * device readback as well as the dataspace in which its contents should be
135 * interpreted.
136 *
137 * The width and height of this buffer must be those of the currently-active
138 * display configuration, and the usage flags must consist of the following:
139 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
140 * BufferUsage::COMPOSER_OUTPUT
141 *
142 * The format and dataspace provided must be sufficient such that if a
143 * correctly-configured buffer is passed into setReadbackBuffer, filled by
144 * the device, and then displayed by the client as a full-screen buffer, the
145 * output of the display remains the same (subject to the note about protected
146 * content in the description of setReadbackBuffer).
147 *
148 * Parameters:
149 * @param display - the display on which to create the layer.
150 *
151 * @return format - the format the client should use when allocating a device
152 * readback buffer
153 * @return dataspace - the dataspace to use when interpreting the
154 * contents of a device readback buffer
155 * @return error is NONE upon success. Otherwise,
156 * BAD_DISPLAY when an invalid display handle was passed in.
157 * UNSUPPORTED if not supported on underlying HAL
158 *
159 * See also:
160 * setReadbackBuffer
161 * getReadbackBufferFence
162 */
163 getReadbackBufferAttributes(Display display)
164 generates (Error error,
165 PixelFormat format,
166 Dataspace dataspace);
167
168 /**
169 * getReadbackBufferFence
170 * Returns an acquire sync fence file descriptor which must signal when the
171 * buffer provided to setReadbackBuffer has been filled by the device and is
172 * safe for the client to read.
173 *
174 * If it is already safe to read from this buffer, -1 may be returned instead.
175 * The client takes ownership of this file descriptor and is responsible for
176 * closing it when it is no longer needed.
177 *
178 * This function must be called immediately after the composition cycle being
179 * captured into the readback buffer. The complete ordering of a readback buffer
180 * capture is as follows:
181 *
182 * getReadbackBufferAttributes
183 * // Readback buffer is allocated
184 * // Many frames may pass
185 *
186 * setReadbackBuffer
187 * validateDisplay
188 * presentDisplay
189 * getReadbackBufferFence
190 * // Implicitly wait on the acquire fence before accessing the buffer
191 *
192 * Parameters:
193 * @param display - the display on which to create the layer.
194 *
195 * @return acquireFence - a sync fence file descriptor as described above; pointer
196 * must be non-NULL
197 * @return error - is HWC2_ERROR_NONE or one of the following errors:
198 * BAD_DISPLAY - an invalid display handle was passed in
199 * UNSUPPORTED if not supported on underlying HAL
200 *
201 * See also:
202 * getReadbackBufferAttributes
203 * setReadbackBuffer
204 */
205 getReadbackBufferFence(Display display)
206 generates (Error error,
207 handle acquireFence);
208
209 /**
210 * setReadbackBuffer
211 * Sets the readback buffer to be filled with the contents of the next
212 * composition performed for this display (i.e., the contents present at the
213 * time of the next validateDisplay/presentDisplay cycle).
214 *
215 * This buffer must have been allocated as described in
216 * getReadbackBufferAttributes and is in the dataspace provided by the same.
217 *
218 * If there is hardware protected content on the display at the time of the next
219 * composition, the area of the readback buffer covered by such content must be
220 * completely black. Any areas of the buffer not covered by such content may
221 * optionally be black as well.
222 *
223 * The release fence file descriptor provided works identically to the one
224 * described for setOutputBuffer.
225 *
226 * This function must not be called between any call to validateDisplay and a
227 * subsequent call to presentDisplay.
228 *
229 * Parameters:
230 * @param display - the display on which to create the layer.
231 * @param buffer - the new readback buffer
232 * @param releaseFence - a sync fence file descriptor as described in setOutputBuffer
233 *
234 * @return error - is HWC2_ERROR_NONE or one of the following errors:
235 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
236 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
237 *
238 * See also:
239 * getReadbackBufferAttributes
240 * getReadbackBufferFence
241 */
242 setReadbackBuffer(Display display, handle buffer, handle releaseFence) generates (Error error);
243
244 /**
245 * setPowerMode_2_2
246 * Sets the power mode of the given display. The transition must be
247 * complete when this function returns. It is valid to call this function
248 * multiple times with the same power mode.
249 *
250 * All displays must support PowerMode::ON and PowerMode::OFF. Whether a
251 * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
252 * queried using getDozeSupport.
253 *
254 * @param display is the display to which the power mode is set.
255 * @param mode is the new power mode.
256 * @return error is NONE upon success. Otherwise,
257 * BAD_DISPLAY when an invalid display handle was passed in.
258 * BAD_PARAMETER when mode was not a valid power mode.
259 * UNSUPPORTED when mode is not supported on this display.
260 */
261 setPowerMode_2_2(Display display, PowerMode mode) generates (Error error);
262
263};