blob: 1a59bbde80f27cbb919c006d620d69d8e7f4d1b5 [file] [log] [blame]
Peiyong Lin781d0bb2019-07-03 10:57:02 -07001/*
2 * Copyright 2019 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.4;
18
Peiyong Linbc51e082020-01-08 15:33:30 -080019import android.hardware.graphics.common@1.2::PixelFormat;
20import android.hardware.graphics.common@1.2::Dataspace;
21import android.hardware.graphics.composer@2.1::IComposerClient.Command;
Ady Abraham7882ae62019-10-10 17:04:47 -070022import IComposerCallback;
23import @2.1::Config;
Peiyong Lin781d0bb2019-07-03 10:57:02 -070024import @2.1::Display;
25import @2.1::Error;
Ady Abrahama1df7c32019-10-22 16:56:08 -070026import @2.1::IComposerClient;
Peiyong Lin781d0bb2019-07-03 10:57:02 -070027import @2.3::IComposerClient;
28
29interface IComposerClient extends @2.3::IComposerClient {
Peiyong Lin781d0bb2019-07-03 10:57:02 -070030 /**
Ady Abrahama1df7c32019-10-22 16:56:08 -070031 * Display attributes queryable through getDisplayAttribute_2_4.
32 */
33 enum Attribute : @2.1::IComposerClient.Attribute {
34 /**
35 * The configuration group ID (as int32_t) this config is associated to.
36 * Switching between configurations within the same group may be done seamlessly
Marin Shalamanov657404c2020-11-13 19:38:53 +010037 * in some conditions via setActiveConfigWithConstraints. Configurations which
38 * share the same config group are similar in all attributes except for the
39 * vsync period.
Ady Abrahama1df7c32019-10-22 16:56:08 -070040 */
41 CONFIG_GROUP = 7,
42 };
43
44 /**
Peiyong Lin781d0bb2019-07-03 10:57:02 -070045 * Required capabilities which are supported by the display. The
46 * particular set of supported capabilities for a given display may be
47 * retrieved using getDisplayCapabilities.
48 */
Dominik Laskowskice44a4b2019-09-19 15:50:09 -070049 enum DisplayCapability : @2.3::IComposerClient.DisplayCapability {
Peiyong Lin781d0bb2019-07-03 10:57:02 -070050 /**
51 * Indicates that the display supports protected contents.
52 * When returned, hardware composer must be able to accept client target
53 * with protected buffers.
54 */
55 PROTECTED_CONTENTS = 4,
Galia Peychevaa0973452019-11-01 11:04:42 +010056
57 /**
58 * Indicates that both the composer HAL implementation and the given display
59 * support a low latency mode, such as HDMI 2.1 Auto Low Latency Mode.
60 */
61 AUTO_LOW_LATENCY_MODE = 5,
Peiyong Lin781d0bb2019-07-03 10:57:02 -070062 };
63
Peiyong Linbc51e082020-01-08 15:33:30 -080064 enum Command : @2.3::IComposerClient.Command {
65 /**
66 * SET_CLIENT_TARGET_PROPERTY has this pseudo prototype
67 *
68 * This command has the following binary layout in bytes:
69 *
70 * 0 - 3: clientTargetProperty.pixelFormat
71 * 4 - 7: clientTargetProperty.dataspace
72 *
73 * setClientTargetProperty(ClientTargetProperty clientTargetProperty);
74 */
75 SET_CLIENT_TARGET_PROPERTY = 0x105 << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Dan Stozaa4bea0e2019-10-21 15:43:55 -070076
77 /**
78 * SET_LAYER_GENERIC_METADATA has this pseudo prototype
79 *
80 * setLayerGenericMetadata(string key, bool mandatory, vec<uint8_t> value);
81 *
82 * Sets a piece of generic metadata for the given layer. If this
83 * function is called twice with the same key but different values, the
84 * newer value must override the older one. Calling this function with a
85 * 0-length value must reset that key's metadata as if it had not been
86 * set.
87 *
88 * A given piece of metadata may either be mandatory or a hint
89 * (non-mandatory) as indicated by the second parameter. Mandatory
90 * metadata may affect the composition result, which is to say that it
91 * may cause a visible change in the final image. By contrast, hints may
92 * only affect the composition strategy, such as which layers are
93 * composited by the client, but must not cause a visible change in the
94 * final image. The value of the mandatory flag shall match the value
95 * returned from getLayerGenericMetadataKeys for the given key.
96 *
97 * Only keys which have been returned from getLayerGenericMetadataKeys()
98 * shall be accepted. Any other keys must result in an UNSUPPORTED error.
99 *
100 * The value passed into this function shall be the binary
101 * representation of a HIDL type corresponding to the given key. For
102 * example, a key of 'com.example.V1_3.Foo' shall be paired with a
103 * value of type com.example@1.3::Foo, which would be defined in a
104 * vendor HAL extension.
105 *
106 * This function will be encoded in the command buffer in this order:
107 * 1) The key length, stored as a uint32_t
108 * 2) The key itself, padded to a uint32_t boundary if necessary
109 * 3) The mandatory flag, stored as a uint32_t
110 * 4) The value length in bytes, stored as a uint32_t
111 * 5) The value itself, padded to a uint32_t boundary if necessary
112 *
113 * @param key indicates which metadata value should be set on this layer
114 * @param mandatory indicates whether this particular key represents
115 * mandatory metadata or a hint (non-mandatory metadata), as
116 * described above
117 * @param value is a binary representation of a HIDL struct
118 * corresponding to the key as described above
119 */
120 SET_LAYER_GENERIC_METADATA = 0x40e << @2.1::IComposerClient.Command:OPCODE_SHIFT,
Peiyong Linbc51e082020-01-08 15:33:30 -0800121 };
122
Peiyong Lin781d0bb2019-07-03 10:57:02 -0700123 /**
Dominik Laskowskice44a4b2019-09-19 15:50:09 -0700124 * Supersedes {@link @2.1::IComposerClient.DisplayType}.
125 */
126 enum DisplayConnectionType : uint32_t {
127 /**
128 * Display is connected through internal port, e.g. DSI, eDP.
129 */
130 INTERNAL = 0,
131 /**
132 * Display is connected through external port, e.g. HDMI, DisplayPort.
133 */
134 EXTERNAL = 1,
135 };
136
Galia Peychevaa0973452019-11-01 11:04:42 +0100137 enum ContentType : uint32_t {
138 NONE = 0,
139
140 /**
141 * These modes correspond to those found in the HDMI 1.4 specification.
142 */
143 GRAPHICS = 1,
144 PHOTO = 2,
145 CINEMA = 3,
146 GAME = 4,
147 };
148
Dominik Laskowskice44a4b2019-09-19 15:50:09 -0700149 /**
Ady Abraham7882ae62019-10-10 17:04:47 -0700150 * Constraints for changing vsync period.
151 */
152 struct VsyncPeriodChangeConstraints {
153 /**
154 * Time in CLOCK_MONOTONIC after which the vsync period may change
155 * (i.e., the vsync period must not change before this time).
156 */
157 int64_t desiredTimeNanos;
Ady Abrahama1df7c32019-10-22 16:56:08 -0700158
Ady Abraham7882ae62019-10-10 17:04:47 -0700159 /**
160 * If true, requires that the vsync period change must happen seamlessly without
161 * a noticeable visual artifact.
162 */
163 bool seamlessRequired;
164 };
165
Peiyong Linbc51e082020-01-08 15:33:30 -0800166 struct ClientTargetProperty {
167 PixelFormat pixelFormat;
168 Dataspace dataspace;
169 };
170
Ady Abraham7882ae62019-10-10 17:04:47 -0700171 /**
172 * Provides a IComposerCallback object for the device to call.
173 *
174 * This function must be called only once.
175 *
176 * @param callback is the IComposerCallback object.
177 */
Ady Abraham7882ae62019-10-10 17:04:47 -0700178 registerCallback_2_4(IComposerCallback callback);
179
180 /**
Peiyong Lin781d0bb2019-07-03 10:57:02 -0700181 * Provides a list of supported capabilities (as described in the
182 * definition of DisplayCapability above). This list must not change after
183 * initialization.
184 *
185 * @return error is NONE upon success. Otherwise,
186 * BAD_DISPLAY when an invalid display handle was passed in.
187 * @return capabilities is a list of supported capabilities.
188 */
189 getDisplayCapabilities_2_4(Display display)
Dominik Laskowskice44a4b2019-09-19 15:50:09 -0700190 generates (Error error, vec<DisplayCapability> capabilities);
191
192 /**
193 * Returns whether the given physical display is internal or external.
194 *
195 * @return error is NONE upon success. Otherwise,
196 * BAD_DISPLAY when the given display is invalid or virtual.
197 * @return type is the connection type of the display.
198 */
199 getDisplayConnectionType(Display display) generates (Error error, DisplayConnectionType type);
Ady Abraham7882ae62019-10-10 17:04:47 -0700200
201 /**
Ady Abrahama1df7c32019-10-22 16:56:08 -0700202 * Returns a display attribute value for a particular display
203 * configuration.
Ady Abraham7882ae62019-10-10 17:04:47 -0700204 *
Ady Abrahama1df7c32019-10-22 16:56:08 -0700205 * @param display is the display to query.
206 * @param config is the display configuration for which to return
207 * attribute values.
Ady Abraham7882ae62019-10-10 17:04:47 -0700208 * @return error is NONE upon success. Otherwise,
Ady Abrahama1df7c32019-10-22 16:56:08 -0700209 * BAD_DISPLAY when an invalid display handle was passed in.
210 * BAD_CONFIG when config does not name a valid configuration for
211 * this display.
212 * BAD_PARAMETER when attribute is unrecognized.
213 * UNSUPPORTED when attribute cannot be queried for the config.
214 * @return value is the value of the attribute.
Ady Abraham7882ae62019-10-10 17:04:47 -0700215 */
Ady Abrahama1df7c32019-10-22 16:56:08 -0700216 getDisplayAttribute_2_4(Display display, Config config, Attribute attribute)
217 generates (Error error, int32_t value);
Ady Abraham7882ae62019-10-10 17:04:47 -0700218
219 /**
220 * Retrieves which vsync period the display is currently using.
221 *
222 * If no display configuration is currently active, this function must
223 * return BAD_CONFIG. If the vsync period is about to change due to a
Ady Abrahama1df7c32019-10-22 16:56:08 -0700224 * setActiveConfigWithConstraints call, this function must return the current vsync period
Ady Abraham7882ae62019-10-10 17:04:47 -0700225 * until the change takes place.
226 *
227 * @param display is the display for which the vsync period is queried.
228 * @return error is NONE upon success. Otherwise,
229 * BAD_DISPLAY when an invalid display handle was passed in.
230 * BAD_CONFIG when no configuration is currently active.
231 * @return vsyncPeriodNanos is the current vsync period of the display.
232 */
233 getDisplayVsyncPeriod(Display display)
234 generates (Error error, VsyncPeriodNanos vsyncPeriodNanos);
235
236 /**
237 * Sets the active configuration and the refresh rate for this display.
Ady Abrahama1df7c32019-10-22 16:56:08 -0700238 * If the new config shares the same config group as the current config,
239 * only the vsync period shall change.
Ady Abraham7882ae62019-10-10 17:04:47 -0700240 * Upon returning, the given display configuration, except vsync period, must be active and
241 * remain so until either this function is called again or the display is disconnected.
242 * When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
243 * called with the new vsync period.
244 *
245 * @param display is the display for which the active config is set.
246 * @param config is the new display configuration.
Ady Abraham7882ae62019-10-10 17:04:47 -0700247 * @param vsyncPeriodChangeConstraints are the constraints required for changing vsync period.
248 *
249 * @return error is NONE upon success. Otherwise,
250 * BAD_DISPLAY when an invalid display handle was passed in.
251 * BAD_CONFIG when the configuration handle passed in is not valid
252 * for this display.
Ady Abrahama1df7c32019-10-22 16:56:08 -0700253 * SEAMLESS_NOT_ALLOWED when seamlessRequired was true but config provided doesn't
254 * share the same config group as the current config.
Ady Abraham7882ae62019-10-10 17:04:47 -0700255 * SEAMLESS_NOT_POSSIBLE when seamlessRequired was true but the display cannot achieve
256 * the vsync period change without a noticeable visual artifact.
Ady Abraham30d818e2019-12-30 12:59:08 -0800257 * When the conditions change and it may be possible to change
258 * the vsync period seamlessly, onSeamlessPossible callback
259 * must be called to indicate that caller should retry.
Ady Abrahama1df7c32019-10-22 16:56:08 -0700260 * @return timeline is the timeline for the vsync period change.
Ady Abraham7882ae62019-10-10 17:04:47 -0700261 */
Ady Abrahama1df7c32019-10-22 16:56:08 -0700262 setActiveConfigWithConstraints(Display display, Config config,
Ady Abraham7882ae62019-10-10 17:04:47 -0700263 VsyncPeriodChangeConstraints vsyncPeriodChangeConstraints)
Ady Abrahama1df7c32019-10-22 16:56:08 -0700264 generates (Error error, VsyncPeriodChangeTimeline timeline);
Galia Peychevaa0973452019-11-01 11:04:42 +0100265
266 /**
267 * Requests the display to enable/disable its low latency mode.
268 *
269 * If the display is connected via HDMI 2.1, then Auto Low Latency Mode should be triggered. If
270 * the display is internally connected and a custom low latency mode is available, that should
271 * be triggered.
272 *
273 * This function should only be called if the display reports support for
274 * DisplayCapability::AUTO_LOW_LATENCY_MODE from getDisplayCapabilities_2_4.
275 *
276 * @return error is NONE upon success. Otherwise,
277 * BAD_DISPLAY when an invalid display handle was passed in.
278 * UNSUPPORTED when AUTO_LOW_LATENCY_MODE is not supported by the composer
279 * implementation or the given display
280 */
281 setAutoLowLatencyMode(Display display, bool on)
282 generates (Error error);
283
284 /**
285 * Provides a list of all the content types supported by this display (any of
286 * ContentType::{GRAPHICS, PHOTO, CINEMA, GAME}). This list must not change after
287 * initialization.
288 *
289 * Content types are introduced in HDMI 1.4 and supporting them is optional. The
290 * ContentType::NONE is always supported and will not be returned by this method..
291 *
292 * @return error is NONE upon success. Otherwise,
293 * BAD_DISPLAY when an invalid display handle was passed in.
294 * @return supportedContentTypes is a list of supported content types.
295 */
296 getSupportedContentTypes(Display display)
297 generates(Error error, vec<ContentType> supportedContentTypes);
298
299 /**
300 * Instructs the connected display that the content being shown is of the given type - one of
301 * GRAPHICS, PHOTO, CINEMA, GAME.
302 *
303 * Content types are introduced in HDMI 1.4 and supporting them is optional. If they are
304 * supported, this signal should switch the display to a mode that is optimal for the given
305 * type of content. See HDMI 1.4 specification for more information.
306 *
307 * If the display is internally connected (not through HDMI), and such modes are available,
308 * this method should trigger them.
309 *
310 * This function should only be called if the display reports support for the corresponding
311 * content type (ContentType::{GRAPHICS, PHOTO, CINEMA, GAME}) from getSupportedContentTypes.
312 * ContentType::NONE is supported by default and can always be set.
313 *
314 * @return error is NONE upon success. Otherwise,
315 * BAD_DISPLAY when an invalid display handle was passed in.
316 * UNSUPPORTED when the given content type is not supported by the composer
317 * implementation or the given display
318 */
319 setContentType(Display display, ContentType type)
320 generates (Error error);
Dan Stozaa4bea0e2019-10-21 15:43:55 -0700321
322 struct LayerGenericMetadataKey {
323 /**
324 * Key names must comply with the requirements specified for
325 * getLayerGenericMetadataKeys below
326 */
327 string name;
328
329 /**
330 * The mandatory flag is defined in the description of
331 * setLayerGenericMetadata above
332 */
333 bool mandatory;
334 };
335
336 /**
337 * Retrieves the set of keys that may be passed into setLayerGenericMetadata
338 *
339 * Key names must meet the following requirements:
340 * - Must be specified in reverse domain name notation
341 * - Must not start with 'com.android' or 'android'
342 * - Must be unique within the returned vector
343 * - Must correspond to a matching HIDL struct type, which defines the
344 * structure of its values. For example, the key 'com.example.V1-3.Foo'
345 * should correspond to a value of type com.example@1.3::Foo, which is
346 * defined in a vendor HAL extension
347 */
348 getLayerGenericMetadataKeys()
349 generates(Error error, vec<LayerGenericMetadataKey> keys);
Peiyong Lin781d0bb2019-07-03 10:57:02 -0700350};