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 17package android.hardware.graphics.composer@2.4; 18 19import android.hardware.graphics.common@1.2::PixelFormat; 20import android.hardware.graphics.common@1.2::Dataspace; 21import android.hardware.graphics.composer@2.1::IComposerClient.Command; 22import IComposerCallback; 23import @2.1::Config; 24import @2.1::Display; 25import @2.1::Error; 26import @2.1::IComposerClient; 27import @2.3::IComposerClient; 28 29interface IComposerClient extends @2.3::IComposerClient { 30 /** 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 37 * in some conditions via setActiveConfigWithConstraints. 38 */ 39 CONFIG_GROUP = 7, 40 }; 41 42 /** 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 */ 47 enum DisplayCapability : @2.3::IComposerClient.DisplayCapability { 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, 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, 60 }; 61 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, 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, 119 }; 120 121 /** 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 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 147 /** 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; 156 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 164 struct ClientTargetProperty { 165 PixelFormat pixelFormat; 166 Dataspace dataspace; 167 }; 168 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 */ 176 registerCallback_2_4(IComposerCallback callback); 177 178 /** 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) 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); 198 199 /** 200 * Returns a display attribute value for a particular display 201 * configuration. 202 * 203 * @param display is the display to query. 204 * @param config is the display configuration for which to return 205 * attribute values. 206 * @return error is NONE upon success. Otherwise, 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. 213 */ 214 getDisplayAttribute_2_4(Display display, Config config, Attribute attribute) 215 generates (Error error, int32_t value); 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 222 * setActiveConfigWithConstraints call, this function must return the current vsync period 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. 236 * If the new config shares the same config group as the current config, 237 * only the vsync period shall change. 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. 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. 251 * SEAMLESS_NOT_ALLOWED when seamlessRequired was true but config provided doesn't 252 * share the same config group as the current config. 253 * SEAMLESS_NOT_POSSIBLE when seamlessRequired was true but the display cannot achieve 254 * the vsync period change without a noticeable visual artifact. 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. 258 * @return timeline is the timeline for the vsync period change. 259 */ 260 setActiveConfigWithConstraints(Display display, Config config, 261 VsyncPeriodChangeConstraints vsyncPeriodChangeConstraints) 262 generates (Error error, VsyncPeriodChangeTimeline timeline); 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 * 308 * This function can be called for a content type even if no support for it is 309 * reported from getSupportedContentTypes. 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); 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); 347}; 348