Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware.graphics.composer@2.3; |
| 18 | |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 19 | import android.hardware.graphics.common@1.1::RenderIntent; |
| 20 | import android.hardware.graphics.common@1.1::PixelFormat; |
| 21 | import android.hardware.graphics.common@1.2::ColorMode; |
| 22 | import android.hardware.graphics.common@1.2::Dataspace; |
Peiyong Lin | 830137f | 2018-09-13 17:19:38 -0700 | [diff] [blame] | 23 | import android.hardware.graphics.composer@2.1::IComposerClient.Command; |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 24 | import @2.2::IComposerClient; |
| 25 | import @2.1::Display; |
| 26 | import @2.1::Error; |
| 27 | |
| 28 | interface IComposerClient extends @2.2::IComposerClient { |
| 29 | |
Peiyong Lin | 55d50d6 | 2018-10-26 18:24:46 -0700 | [diff] [blame] | 30 | // TODO: Move this enum to LLNDK after we decide where to put graphic types. |
| 31 | /** |
| 32 | * Required capabilities which are supported by the display. The |
| 33 | * particular set of supported capabilities for a given display may be |
| 34 | * retrieved using getDisplayCapabilities. |
| 35 | */ |
| 36 | enum DisplayCapability : uint32_t { |
| 37 | INVALID = 0, |
| 38 | |
| 39 | /** |
Peiyong Lin | 02dd3d3 | 2018-12-05 06:59:39 -0800 | [diff] [blame] | 40 | * Indicates that the display must apply a color transform even when |
Peiyong Lin | 55d50d6 | 2018-10-26 18:24:46 -0700 | [diff] [blame] | 41 | * either the client or the device has chosen that all layers should |
| 42 | * be composed by the client. This prevents the client from applying |
| 43 | * the color transform during its composition step. |
| 44 | * If getDisplayCapabilities is supported, the global capability |
| 45 | * SKIP_CLIENT_COLOR_TRANSFORM is ignored. |
| 46 | * If getDisplayCapabilities is not supported, and the global capability |
| 47 | * SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities, |
| 48 | * then all displays must be treated as having |
| 49 | * SKIP_CLIENT_COLOR_TRANSFORM. |
| 50 | */ |
| 51 | SKIP_CLIENT_COLOR_TRANSFORM = 1, |
| 52 | |
| 53 | /** |
Peiyong Lin | 02dd3d3 | 2018-12-05 06:59:39 -0800 | [diff] [blame] | 54 | * Indicates that the display supports PowerMode::DOZE and |
Peiyong Lin | 55d50d6 | 2018-10-26 18:24:46 -0700 | [diff] [blame] | 55 | * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit |
| 56 | * over DOZE (see the definition of PowerMode for more information), |
| 57 | * but if both DOZE and DOZE_SUSPEND are no different from |
| 58 | * PowerMode::ON, the device must not claim support. |
| 59 | * Must be returned by getDisplayCapabilities when getDozeSupport |
| 60 | * indicates the display supports PowerMode::DOZE and |
| 61 | * PowerMode::DOZE_SUSPEND. |
| 62 | */ |
| 63 | DOZE = 2, |
| 64 | }; |
| 65 | |
Peiyong Lin | 830137f | 2018-09-13 17:19:38 -0700 | [diff] [blame] | 66 | enum Command : @2.2::IComposerClient.Command { |
| 67 | /** |
| 68 | * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype |
| 69 | * |
| 70 | * setLayerColorTransform(float[16] matrix); |
| 71 | * |
| 72 | * This command has the following binary layout in bytes: |
| 73 | * |
| 74 | * 0 - 16 * 4: matrix |
| 75 | * |
| 76 | * Sets a matrix for color transform which will be applied on this layer |
| 77 | * before composition. |
| 78 | * |
| 79 | * If the device is not capable of apply the matrix on this layer, it must force |
| 80 | * this layer to client composition during VALIDATE_DISPLAY. |
| 81 | * |
| 82 | * The matrix provided is an affine color transformation of the following |
| 83 | * form: |
| 84 | * |
| 85 | * |r.r r.g r.b 0| |
| 86 | * |g.r g.g g.b 0| |
| 87 | * |b.r b.g b.b 0| |
| 88 | * |Tr Tg Tb 1| |
| 89 | * |
| 90 | * This matrix must be provided in row-major form: |
| 91 | * |
| 92 | * {r.r, r.g, r.b, 0, g.r, ...}. |
| 93 | * |
| 94 | * Given a matrix of this form and an input color [R_in, G_in, B_in], |
| 95 | * the input color must first be converted to linear space |
| 96 | * [R_linear, G_linear, B_linear], then the output linear color |
| 97 | * [R_out_linear, G_out_linear, B_out_linear] will be: |
| 98 | * |
| 99 | * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr |
| 100 | * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg |
| 101 | * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb |
| 102 | * |
| 103 | * [R_out_linear, G_out_linear, B_out_linear] must then be converted to |
| 104 | * gamma space: [R_out, G_out, B_out] before blending. |
| 105 | * |
| 106 | * @param matrix is a 4x4 transform matrix (16 floats) as described above. |
| 107 | */ |
| 108 | SET_LAYER_COLOR_TRANSFORM = 0x40d << @2.1::IComposerClient.Command:OPCODE_SHIFT, |
| 109 | }; |
| 110 | |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 111 | /** |
| 112 | * Returns the port and data that describe a physical display. The port is |
| 113 | * a unique number that identifies a physical connector (e.g. eDP, HDMI) |
| 114 | * for display output. The data blob is parsed to determine its format, |
| 115 | * typically EDID 1.3 as specified in VESA E-EDID Standard Release A |
| 116 | * Revision 1. |
| 117 | * |
| 118 | * @param display is the display to query. |
| 119 | * @return error is NONE upon success. Otherwise, |
| 120 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 121 | * UNSUPPORTED when identification data is unavailable. |
| 122 | * @return port is the connector to which the display is connected. |
| 123 | * @return data is the EDID 1.3 blob identifying the display. |
| 124 | */ |
| 125 | @callflow(next="*") |
| 126 | getDisplayIdentificationData(Display display) |
| 127 | generates (Error error, |
| 128 | uint8_t port, |
| 129 | vec<uint8_t> data); |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 130 | /** |
| 131 | * getReadbackBufferAttributes_2_3 |
| 132 | * Returns the format which should be used when allocating a buffer for use by |
| 133 | * device readback as well as the dataspace in which its contents must be |
| 134 | * interpreted. |
| 135 | * |
| 136 | * The width and height of this buffer must be those of the currently-active |
| 137 | * display configuration, and the usage flags must consist of the following: |
| 138 | * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE | |
| 139 | * BufferUsage::COMPOSER_OUTPUT |
| 140 | * |
| 141 | * The format and dataspace provided must be sufficient such that if a |
| 142 | * correctly-configured buffer is passed into setReadbackBuffer, filled by |
| 143 | * the device, and then displayed by the client as a full-screen buffer, the |
| 144 | * output of the display remains the same (subject to the note about protected |
| 145 | * content in the description of setReadbackBuffer). |
| 146 | * |
| 147 | * If the active configuration or color mode of this display has changed |
| 148 | * since a previous call to this function, it must be called again prior to |
| 149 | * setting a readback buffer such that the returned format and dataspace will |
| 150 | * be updated accordingly. |
| 151 | * |
| 152 | * Parameters: |
| 153 | * @param display - the display on which to create the layer. |
| 154 | * |
| 155 | * @return format - the format the client should use when allocating a device |
| 156 | * readback buffer |
| 157 | * @return dataspace - the dataspace to use when interpreting the |
| 158 | * contents of a device readback buffer |
| 159 | * @return error is NONE upon success. Otherwise, |
| 160 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 161 | * UNSUPPORTED if not supported on underlying HAL |
| 162 | * |
| 163 | * See also: |
| 164 | * setReadbackBuffer |
| 165 | * getReadbackBufferFence |
| 166 | */ |
| 167 | getReadbackBufferAttributes_2_3(Display display) |
| 168 | generates (Error error, |
| 169 | PixelFormat format, |
| 170 | Dataspace dataspace); |
| 171 | |
| 172 | /** |
| 173 | * getClientTargetSupport_2_3 |
| 174 | * Returns whether a client target with the given properties can be |
| 175 | * handled by the device. |
| 176 | * |
| 177 | * This function must return true for a client target with width and |
| 178 | * height equal to the active display configuration dimensions, |
| 179 | * PixelFormat::RGBA_8888, and Dataspace::UNKNOWN. It is not required to |
| 180 | * return true for any other configuration. |
| 181 | * |
| 182 | * @param display is the display to query. |
| 183 | * @param width is the client target width in pixels. |
| 184 | * @param height is the client target height in pixels. |
| 185 | * @param format is the client target format. |
| 186 | * @param dataspace is the client target dataspace, as described in |
| 187 | * setLayerDataspace. |
| 188 | * @return error is NONE upon success. Otherwise, |
| 189 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 190 | * UNSUPPORTED when the given configuration is not supported. |
| 191 | */ |
| 192 | @callflow(next="*") |
| 193 | getClientTargetSupport_2_3(Display display, |
| 194 | uint32_t width, |
| 195 | uint32_t height, |
| 196 | PixelFormat format, |
| 197 | Dataspace dataspace) |
| 198 | generates (Error error); |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 199 | |
Kevin DuBois | bf14148 | 2018-09-10 09:07:54 -0700 | [diff] [blame] | 200 | enum FormatColorComponent : uint8_t { |
| 201 | /* The first component (eg, for RGBA_8888, this is R) */ |
| 202 | FORMAT_COMPONENT_0 = 1 << 0, |
| 203 | /* The second component (eg, for RGBA_8888, this is G) */ |
| 204 | FORMAT_COMPONENT_1 = 1 << 1, |
| 205 | /* The third component (eg, for RGBA_8888, this is B) */ |
| 206 | FORMAT_COMPONENT_2 = 1 << 2, |
| 207 | /* The fourth component (eg, for RGBA_8888, this is A) */ |
| 208 | FORMAT_COMPONENT_3 = 1 << 3, |
| 209 | }; |
| 210 | |
| 211 | /** |
| 212 | * Query for what types of color sampling the hardware supports. |
| 213 | * |
| 214 | * @param display is the display where the samples are collected. |
| 215 | * @return error is NONE upon success. Otherwise, |
| 216 | * BAD_DISPLAY when an invalid display was passed in, or |
| 217 | * UNSUPPORTED when there is no efficient way to sample. |
| 218 | * @return format The format of the sampled pixels. |
| 219 | * @return dataspace The dataspace of the sampled pixels. |
| 220 | * @return componentMask The mask of which components can be sampled. |
| 221 | */ |
| 222 | getDisplayedContentSamplingAttributes(Display display) |
| 223 | generates (Error error, |
| 224 | PixelFormat format, |
| 225 | Dataspace dataspace, |
| 226 | bitfield<FormatColorComponent> componentMask); |
| 227 | |
| 228 | /** DisplayedContentSampling values passed to setDisplayedContentSamplingEnabled. */ |
| 229 | enum DisplayedContentSampling : int32_t { |
| 230 | INVALID = 0, |
| 231 | |
| 232 | /** Enable content sampling. */ |
| 233 | ENABLE = 1, |
| 234 | |
| 235 | /** Disable content sampling. */ |
| 236 | DISABLE = 2, |
| 237 | }; |
| 238 | |
| 239 | /** |
| 240 | * Enables or disables the collection of color content statistics |
| 241 | * on this display. |
| 242 | * |
| 243 | * Sampling occurs on the contents of the final composition on this display |
| 244 | * (i.e., the contents presented on screen). Samples should be collected after all |
| 245 | * color transforms have been applied. |
| 246 | * |
| 247 | * Sampling support is optional, and is set to DISABLE by default. |
| 248 | * On each call to ENABLE, all collected statistics must be reset. |
| 249 | * |
| 250 | * Sample data can be queried via getDisplayedContentSample(). |
| 251 | * |
| 252 | * @param display is the display to which the sampling mode is set. |
| 253 | * @param enabled indicates whether to enable or disable sampling. |
| 254 | * @param componentMask The mask of which components should be sampled. If zero, all supported |
| 255 | * components are to be enabled. |
| 256 | * @param maxFrames is the maximum number of frames that should be stored before discard. |
| 257 | * The sample represents the most-recently posted frames. |
| 258 | * @return error is NONE upon success. Otherwise, |
| 259 | * BAD_DISPLAY when an invalid display handle was passed in, |
| 260 | * BAD_PARAMETER when enabled was an invalid value, or |
| 261 | * NO_RESOURCES when the requested ringbuffer size via maxFrames was |
| 262 | * not available. |
| 263 | * UNSUPPORTED when there is no efficient way to sample. |
| 264 | */ |
| 265 | setDisplayedContentSamplingEnabled( |
| 266 | Display display, DisplayedContentSampling enable, |
| 267 | bitfield<FormatColorComponent> componentMask, uint64_t maxFrames) |
| 268 | generates (Error error); |
| 269 | |
| 270 | /** |
| 271 | * Collects the results of display content color sampling for display. |
| 272 | * |
| 273 | * Collection of data can occur whether the sampling is in ENABLE or |
| 274 | * DISABLE state. |
| 275 | * |
| 276 | * @param display is the display to which the sampling is collected. |
| 277 | * @param maxFrames is the maximum number of frames that should be represented in the sample. |
| 278 | * The sample represents the most-recently posted frames. |
| 279 | * If maxFrames is 0, all frames are to be represented by the sample. |
| 280 | * @param timestamp is the timestamp after which any frames were posted that should be |
| 281 | * included in the sample. Timestamp is CLOCK_MONOTONIC. |
| 282 | * If timestamp is 0, do not filter from the sample by time. |
| 283 | * @return error is NONE upon success. Otherwise, |
| 284 | * BAD_DISPLAY when an invalid display was passed in, or |
| 285 | * UNSUPPORTED when there is no efficient way to sample, or |
| 286 | * BAD_PARAMETER when the component is not supported by the hardware. |
| 287 | * @return frameCount The number of frames represented by this sample. |
| 288 | * @return sampleComponent0 is a histogram counting how many times a pixel of a given value |
| 289 | * was displayed onscreen for FORMAT_COMPONENT_0. |
| 290 | * The buckets of the histogram are evenly weighted, the number of buckets |
| 291 | * is device specific. |
| 292 | * eg, for RGBA_8888, if sampleComponent0 is {10, 6, 4, 1} this means that |
| 293 | * 10 red pixels were displayed onscreen in range 0x00->0x3F, 6 red pixels |
| 294 | * were displayed onscreen in range 0x40->0x7F, etc. |
| 295 | * @return sampleComponent1 is the same sample definition as sampleComponent0, |
| 296 | * but for FORMAT_COMPONENT_1. |
| 297 | * @return sampleComponent2 is the same sample definition as sampleComponent0, |
| 298 | * but for FORMAT_COMPONENT_2. |
| 299 | * @return sampleComponent3 is the same sample definition as sampleComponent0, |
| 300 | * but for FORMAT_COMPONENT_3. |
| 301 | */ |
| 302 | getDisplayedContentSample(Display display, uint64_t maxFrames, uint64_t timestamp) |
| 303 | generates (Error error, |
| 304 | uint64_t frameCount, |
| 305 | vec<uint64_t> sampleComponent0, |
| 306 | vec<uint64_t> sampleComponent1, |
| 307 | vec<uint64_t> sampleComponent2, |
| 308 | vec<uint64_t> sampleComponent3); |
| 309 | |
Peiyong Lin | 830137f | 2018-09-13 17:19:38 -0700 | [diff] [blame] | 310 | /** |
| 311 | * Executes commands from the input command message queue. Return values |
| 312 | * generated by the input commands are written to the output command |
| 313 | * message queue in the form of value commands. |
| 314 | * |
| 315 | * @param inLength is the length of input commands. |
| 316 | * @param inHandles is an array of handles referenced by the input |
| 317 | * commands. |
| 318 | * @return error is NONE upon success. Otherwise, |
| 319 | * BAD_PARAMETER when inLength is not equal to the length of |
| 320 | * commands in the input command message queue. |
| 321 | * NO_RESOURCES when the output command message queue was not |
| 322 | * properly drained. |
| 323 | * @param outQueueChanged indicates whether the output command message |
| 324 | * queue has changed. |
| 325 | * @param outLength is the length of output commands. |
| 326 | * @param outHandles is an array of handles referenced by the output |
| 327 | * commands. |
| 328 | */ |
| 329 | executeCommands_2_3(uint32_t inLength, |
| 330 | vec<handle> inHandles) |
| 331 | generates (Error error, |
| 332 | bool outQueueChanged, |
| 333 | uint32_t outLength, |
| 334 | vec<handle> outHandles); |
Valerie Hau | ec98306 | 2018-10-09 16:09:12 -0700 | [diff] [blame] | 335 | |
| 336 | /** |
| 337 | * Returns the render intents supported by the specified display and color |
| 338 | * mode. |
| 339 | * |
| 340 | * For SDR color modes, RenderIntent::COLORIMETRIC must be supported. For |
| 341 | * HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC must be supported. |
| 342 | * |
| 343 | * @param display is the display to query. |
| 344 | * @param mode is the color mode to query. |
| 345 | * @return error is NONE upon success. Otherwise, |
| 346 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 347 | * BAD_PARAMETER when an invalid color mode was passed in. |
| 348 | * @return intents is an array of render intents. |
| 349 | */ |
| 350 | getRenderIntents_2_3(Display display, ColorMode mode) |
| 351 | generates (Error error, |
| 352 | vec<RenderIntent> intents); |
| 353 | |
| 354 | /** |
| 355 | * Returns the color modes supported on this display. |
| 356 | * |
| 357 | * All devices must support at least ColorMode::NATIVE. |
| 358 | * |
| 359 | * @param display is the display to query. |
| 360 | * @return error is NONE upon success. Otherwise, |
| 361 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 362 | * @return modes is an array of color modes. |
| 363 | */ |
| 364 | getColorModes_2_3(Display display) |
| 365 | generates (Error error, |
| 366 | vec<ColorMode> modes); |
| 367 | |
| 368 | /** |
| 369 | * Sets the color mode and render intent of the given display. |
| 370 | * |
| 371 | * The color mode and render intent change must take effect on next |
| 372 | * presentDisplay. |
| 373 | * |
| 374 | * All devices must support at least ColorMode::NATIVE and |
| 375 | * RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode |
| 376 | * upon hotplug. |
| 377 | * |
| 378 | * @param display is the display to which the color mode is set. |
| 379 | * @param mode is the color mode to set to. |
| 380 | * @param intent is the render intent to set to. |
| 381 | * @return error is NONE upon success. Otherwise, |
| 382 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 383 | * BAD_PARAMETER when mode or intent is invalid |
| 384 | * UNSUPPORTED when mode or intent is not supported on this |
| 385 | * display. |
| 386 | */ |
| 387 | setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent) |
| 388 | generates (Error error); |
Peiyong Lin | 55d50d6 | 2018-10-26 18:24:46 -0700 | [diff] [blame] | 389 | |
| 390 | /** |
| 391 | * Provides a list of supported capabilities (as described in the |
| 392 | * definition of DisplayCapability above). This list must not change after |
| 393 | * initialization. |
| 394 | * |
| 395 | * @return error is NONE upon success. Otherwise, |
| 396 | * BAD_DISPLAY when an invalid display handle was passed in. |
| 397 | * @return capabilities is a list of supported capabilities. |
| 398 | */ |
| 399 | getDisplayCapabilities(Display display) |
| 400 | generates (Error error, |
| 401 | vec<DisplayCapability> capabilities); |
Dominik Laskowski | cd2e9f5 | 2018-03-12 19:41:03 -0700 | [diff] [blame] | 402 | }; |