blob: 4a884bc9e2b16ae898a639141042f5c587615656 [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
84 /**
85 * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data)
86 * Sets the PerFrameMetadata for the display. This metadata must be used
87 * by the implementation to better tone map content to that display.
88 *
89 * This is a method that may be called every frame. Thus it's
90 * implemented using buffered transport.
91 * SET_PER_FRAME_METADATA is the command used by the buffered transport
92 * mechanism.
93 */
94 enum Command : @2.1::IComposerClient.Command {
95 SET_PER_FRAME_METADATA = 0x207 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
96 };
97
98 /**
99 * Returns the PerFrameMetadataKeys that are supported by this device.
100 *
101 * @param display is the display on which to create the layer.
102 * @return keys is the vector of PerFrameMetadataKey keys that are
103 * supported by this device.
104 * @return error is NONE upon success. Otherwise,
105 * UNSUPPORTED if not supported on underlying HAL
106 */
107 getPerFrameMetadataKeys(Display display)
108 generates (Error error,
109 vec<PerFrameMetadataKey> keys);
110
111 /**
112 * getReadbackBufferAttributes
113 * Returns the format which should be used when allocating a buffer for use by
114 * device readback as well as the dataspace in which its contents should be
115 * interpreted.
116 *
117 * The width and height of this buffer must be those of the currently-active
118 * display configuration, and the usage flags must consist of the following:
119 * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
120 * BufferUsage::COMPOSER_OUTPUT
121 *
122 * The format and dataspace provided must be sufficient such that if a
123 * correctly-configured buffer is passed into setReadbackBuffer, filled by
124 * the device, and then displayed by the client as a full-screen buffer, the
125 * output of the display remains the same (subject to the note about protected
126 * content in the description of setReadbackBuffer).
127 *
128 * Parameters:
129 * @param display - the display on which to create the layer.
130 *
131 * @return format - the format the client should use when allocating a device
132 * readback buffer
133 * @return dataspace - the dataspace to use when interpreting the
134 * contents of a device readback buffer
135 * @return error is NONE upon success. Otherwise,
136 * BAD_DISPLAY when an invalid display handle was passed in.
137 * UNSUPPORTED if not supported on underlying HAL
138 *
139 * See also:
140 * setReadbackBuffer
141 * getReadbackBufferFence
142 */
143 getReadbackBufferAttributes(Display display)
144 generates (Error error,
145 PixelFormat format,
146 Dataspace dataspace);
147
148 /**
149 * getReadbackBufferFence
150 * Returns an acquire sync fence file descriptor which must signal when the
151 * buffer provided to setReadbackBuffer has been filled by the device and is
152 * safe for the client to read.
153 *
154 * If it is already safe to read from this buffer, -1 may be returned instead.
155 * The client takes ownership of this file descriptor and is responsible for
156 * closing it when it is no longer needed.
157 *
158 * This function must be called immediately after the composition cycle being
159 * captured into the readback buffer. The complete ordering of a readback buffer
160 * capture is as follows:
161 *
162 * getReadbackBufferAttributes
163 * // Readback buffer is allocated
164 * // Many frames may pass
165 *
166 * setReadbackBuffer
167 * validateDisplay
168 * presentDisplay
169 * getReadbackBufferFence
170 * // Implicitly wait on the acquire fence before accessing the buffer
171 *
172 * Parameters:
173 * @param display - the display on which to create the layer.
174 *
175 * @return acquireFence - a sync fence file descriptor as described above; pointer
176 * must be non-NULL
177 * @return error - is HWC2_ERROR_NONE or one of the following errors:
178 * BAD_DISPLAY - an invalid display handle was passed in
179 * UNSUPPORTED if not supported on underlying HAL
180 *
181 * See also:
182 * getReadbackBufferAttributes
183 * setReadbackBuffer
184 */
185 getReadbackBufferFence(Display display)
186 generates (Error error,
187 handle acquireFence);
188
189 /**
190 * setReadbackBuffer
191 * Sets the readback buffer to be filled with the contents of the next
192 * composition performed for this display (i.e., the contents present at the
193 * time of the next validateDisplay/presentDisplay cycle).
194 *
195 * This buffer must have been allocated as described in
196 * getReadbackBufferAttributes and is in the dataspace provided by the same.
197 *
198 * If there is hardware protected content on the display at the time of the next
199 * composition, the area of the readback buffer covered by such content must be
200 * completely black. Any areas of the buffer not covered by such content may
201 * optionally be black as well.
202 *
203 * The release fence file descriptor provided works identically to the one
204 * described for setOutputBuffer.
205 *
206 * This function must not be called between any call to validateDisplay and a
207 * subsequent call to presentDisplay.
208 *
209 * Parameters:
210 * @param display - the display on which to create the layer.
211 * @param buffer - the new readback buffer
212 * @param releaseFence - a sync fence file descriptor as described in setOutputBuffer
213 *
214 * @return error - is HWC2_ERROR_NONE or one of the following errors:
215 * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
216 * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid
217 *
218 * See also:
219 * getReadbackBufferAttributes
220 * getReadbackBufferFence
221 */
222 setReadbackBuffer(Display display, handle buffer, handle releaseFence) generates (Error error);
223
224 /**
225 * setPowerMode_2_2
226 * Sets the power mode of the given display. The transition must be
227 * complete when this function returns. It is valid to call this function
228 * multiple times with the same power mode.
229 *
230 * All displays must support PowerMode::ON and PowerMode::OFF. Whether a
231 * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
232 * queried using getDozeSupport.
233 *
234 * @param display is the display to which the power mode is set.
235 * @param mode is the new power mode.
236 * @return error is NONE upon success. Otherwise,
237 * BAD_DISPLAY when an invalid display handle was passed in.
238 * BAD_PARAMETER when mode was not a valid power mode.
239 * UNSUPPORTED when mode is not supported on this display.
240 */
241 setPowerMode_2_2(Display display, PowerMode mode) generates (Error error);
242
243};