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