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