Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 | #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H |
| 18 | #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | |
| 23 | #include <hardware/gralloc.h> |
| 24 | #include <hardware/hardware.h> |
| 25 | #include <cutils/native_handle.h> |
| 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
Dan Stoza | 4e9221b | 2015-09-02 15:43:39 -0700 | [diff] [blame] | 29 | /* Shared by HWC1 and HWC2 */ |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 30 | |
Jesse Hall | 3f5b522 | 2012-08-28 15:23:58 -0700 | [diff] [blame] | 31 | #define HWC_HEADER_VERSION 1 |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 32 | |
Jesse Hall | 903811c | 2012-09-04 11:42:09 -0700 | [diff] [blame] | 33 | #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
Jesse Hall | 3f5b522 | 2012-08-28 15:23:58 -0700 | [diff] [blame] | 34 | |
Jesse Hall | 3f5b522 | 2012-08-28 15:23:58 -0700 | [diff] [blame] | 35 | #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) |
| 36 | #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) |
| 37 | #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) |
Mathias Agopian | 3b4732c | 2013-07-09 19:55:41 -0700 | [diff] [blame] | 38 | #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 39 | #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) |
Dan Stoza | 811445a | 2015-02-12 10:11:21 -0800 | [diff] [blame] | 40 | #define HWC_DEVICE_API_VERSION_1_5 HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION) |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 41 | |
Dan Stoza | 4e9221b | 2015-09-02 15:43:39 -0700 | [diff] [blame] | 42 | #define HWC_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION_2(2, 0, HWC_HEADER_VERSION) |
| 43 | |
| 44 | /** |
| 45 | * The id of this module |
| 46 | */ |
| 47 | #define HWC_HARDWARE_MODULE_ID "hwcomposer" |
| 48 | |
| 49 | /** |
| 50 | * Name of the sensors device to open |
| 51 | */ |
| 52 | #define HWC_HARDWARE_COMPOSER "composer" |
| 53 | |
| 54 | typedef struct hwc_color { |
| 55 | uint8_t r; |
| 56 | uint8_t g; |
| 57 | uint8_t b; |
| 58 | uint8_t a; |
| 59 | } hwc_color_t; |
| 60 | |
Peiyong Lin | fd05d13 | 2018-01-22 12:23:25 -0800 | [diff] [blame] | 61 | typedef struct hwc_float_color { |
| 62 | float r; |
| 63 | float g; |
| 64 | float b; |
| 65 | float a; |
| 66 | } hwc_float_color_t; |
| 67 | |
Dan Stoza | 4e9221b | 2015-09-02 15:43:39 -0700 | [diff] [blame] | 68 | typedef struct hwc_frect { |
| 69 | float left; |
| 70 | float top; |
| 71 | float right; |
| 72 | float bottom; |
| 73 | } hwc_frect_t; |
| 74 | |
| 75 | typedef struct hwc_rect { |
| 76 | int left; |
| 77 | int top; |
| 78 | int right; |
| 79 | int bottom; |
| 80 | } hwc_rect_t; |
| 81 | |
| 82 | typedef struct hwc_region { |
| 83 | size_t numRects; |
| 84 | hwc_rect_t const* rects; |
| 85 | } hwc_region_t; |
| 86 | |
| 87 | /* |
| 88 | * hwc_layer_t::transform values |
| 89 | */ |
| 90 | typedef enum { |
| 91 | /* flip source image horizontally */ |
| 92 | HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, |
| 93 | /* flip source image vertically */ |
| 94 | HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, |
| 95 | /* rotate source image 90 degrees clock-wise */ |
| 96 | HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, |
| 97 | /* rotate source image 180 degrees */ |
| 98 | HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, |
| 99 | /* rotate source image 270 degrees clock-wise */ |
| 100 | HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, |
| 101 | /* flip source image horizontally, the rotate 90 degrees clock-wise */ |
| 102 | HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90, |
| 103 | /* flip source image vertically, the rotate 90 degrees clock-wise */ |
| 104 | HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90, |
| 105 | } hwc_transform_t; |
| 106 | |
Peiyong Lin | f777542 | 2020-01-08 15:30:52 -0800 | [diff] [blame] | 107 | /* Constraints for changing vsync period */ |
| 108 | typedef struct hwc_vsync_period_change_constraints { |
| 109 | /* Time in CLOCK_MONOTONIC after which the vsync period may change |
| 110 | * (i.e., the vsync period must not change before this time). */ |
| 111 | int64_t desiredTimeNanos; |
| 112 | /* |
| 113 | * If true, requires that the vsync period change must happen seamlessly without |
| 114 | * a noticeable visual artifact. */ |
| 115 | uint8_t seamlessRequired; |
| 116 | } hwc_vsync_period_change_constraints_t; |
| 117 | |
| 118 | /* Timing for a vsync period change. */ |
| 119 | typedef struct hwc_vsync_period_change_timeline { |
| 120 | /* The time in CLOCK_MONOTONIC when the new display will start to refresh at |
| 121 | * the new vsync period. */ |
| 122 | int64_t newVsyncAppliedTimeNanos; |
| 123 | |
| 124 | /* Set to true if the client is required to sent a frame to be displayed before |
| 125 | * the change can take place. */ |
| 126 | uint8_t refreshRequired; |
| 127 | |
| 128 | /* The time in CLOCK_MONOTONIC when the client is expected to send the new frame. |
| 129 | * Should be ignored if refreshRequired is false. */ |
| 130 | int64_t refreshTimeNanos; |
| 131 | } hwc_vsync_period_change_timeline_t; |
| 132 | |
| 133 | typedef struct hwc_client_target_property { |
| 134 | // The pixel format of client target requested by hardware composer. |
| 135 | int32_t pixelFormat; |
| 136 | // The dataspace of the client target requested by hardware composer. |
| 137 | int32_t dataspace; |
| 138 | } hwc_client_target_property_t; |
| 139 | |
Dan Stoza | 4e9221b | 2015-09-02 15:43:39 -0700 | [diff] [blame] | 140 | /******************************************************************************* |
| 141 | * Beyond this point are things only used by HWC1, which should be ignored when |
| 142 | * implementing a HWC2 device |
| 143 | ******************************************************************************/ |
| 144 | |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 145 | enum { |
| 146 | /* hwc_composer_device_t::set failed in EGL */ |
| 147 | HWC_EGL_ERROR = -1 |
| 148 | }; |
| 149 | |
| 150 | /* |
| 151 | * hwc_layer_t::hints values |
| 152 | * Hints are set by the HAL and read by SurfaceFlinger |
| 153 | */ |
| 154 | enum { |
| 155 | /* |
| 156 | * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger |
| 157 | * that it should triple buffer this layer. Typically HWC does this when |
| 158 | * the layer will be unavailable for use for an extended period of time, |
| 159 | * e.g. if the display will be fetching data directly from the layer and |
| 160 | * the layer can not be modified until after the next set(). |
| 161 | */ |
| 162 | HWC_HINT_TRIPLE_BUFFER = 0x00000001, |
| 163 | |
| 164 | /* |
| 165 | * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the |
| 166 | * framebuffer with transparent pixels where this layer would be. |
| 167 | * SurfaceFlinger will only honor this flag when the layer has no blending |
| 168 | * |
| 169 | */ |
| 170 | HWC_HINT_CLEAR_FB = 0x00000002 |
| 171 | }; |
| 172 | |
| 173 | /* |
| 174 | * hwc_layer_t::flags values |
| 175 | * Flags are set by SurfaceFlinger and read by the HAL |
| 176 | */ |
| 177 | enum { |
| 178 | /* |
Fabien Sanglard | e203b36 | 2016-11-16 15:01:48 -0800 | [diff] [blame] | 179 | * HWC_SKIP_LAYER is set by SurfaceFlinger to indicate that the HAL |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 180 | * shall not consider this layer for composition as it will be handled |
Fabien Sanglard | e203b36 | 2016-11-16 15:01:48 -0800 | [diff] [blame] | 181 | * by SurfaceFlinger (just as if compositionType was set to HWC_FRAMEBUFFER). |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 182 | */ |
| 183 | HWC_SKIP_LAYER = 0x00000001, |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 184 | |
| 185 | /* |
| 186 | * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this |
| 187 | * layer is being used as a cursor on this particular display, and that |
| 188 | * surfaceflinger can potentially perform asynchronous position updates for |
| 189 | * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the |
| 190 | * composition type of this layer, then the hwcomposer will allow async |
| 191 | * position updates to this layer via setCursorPositionAsync(). |
| 192 | */ |
| 193 | HWC_IS_CURSOR_LAYER = 0x00000002 |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 194 | }; |
| 195 | |
| 196 | /* |
| 197 | * hwc_layer_t::compositionType values |
| 198 | */ |
| 199 | enum { |
| 200 | /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ |
| 201 | HWC_FRAMEBUFFER = 0, |
| 202 | |
| 203 | /* this layer will be handled in the HWC */ |
| 204 | HWC_OVERLAY = 1, |
| 205 | |
| 206 | /* this is the background layer. it's used to set the background color. |
| 207 | * there is only a single background layer */ |
| 208 | HWC_BACKGROUND = 2, |
Jesse Hall | d18c83f | 2012-08-16 16:21:13 -0700 | [diff] [blame] | 209 | |
| 210 | /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. |
| 211 | * Added in HWC_DEVICE_API_VERSION_1_1. */ |
| 212 | HWC_FRAMEBUFFER_TARGET = 3, |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 213 | |
| 214 | /* this layer's contents are taken from a sideband buffer stream. |
| 215 | * Added in HWC_DEVICE_API_VERSION_1_4. */ |
| 216 | HWC_SIDEBAND = 4, |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 217 | |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 218 | /* this layer's composition will be handled by hwcomposer by dedicated |
| 219 | cursor overlay hardware. hwcomposer will also all async position updates |
| 220 | of this layer outside of the normal prepare()/set() loop. Added in |
| 221 | HWC_DEVICE_API_VERSION_1_4. */ |
| 222 | HWC_CURSOR_OVERLAY = 5 |
| 223 | }; |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 224 | /* |
| 225 | * hwc_layer_t::blending values |
| 226 | */ |
| 227 | enum { |
| 228 | /* no blending */ |
| 229 | HWC_BLENDING_NONE = 0x0100, |
| 230 | |
| 231 | /* ONE / ONE_MINUS_SRC_ALPHA */ |
| 232 | HWC_BLENDING_PREMULT = 0x0105, |
| 233 | |
| 234 | /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ |
| 235 | HWC_BLENDING_COVERAGE = 0x0405 |
| 236 | }; |
| 237 | |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 238 | /* attributes queriable with query() */ |
| 239 | enum { |
| 240 | /* |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 241 | * Must return 1 if the background layer is supported, 0 otherwise. |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 242 | */ |
| 243 | HWC_BACKGROUND_LAYER_SUPPORTED = 0, |
| 244 | |
| 245 | /* |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 246 | * Returns the vsync period in nanoseconds. |
| 247 | * |
| 248 | * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. |
| 249 | * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 250 | */ |
| 251 | HWC_VSYNC_PERIOD = 1, |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 252 | |
| 253 | /* |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 254 | * Availability: HWC_DEVICE_API_VERSION_1_1 |
| 255 | * Returns a mask of supported display types. |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 256 | */ |
| 257 | HWC_DISPLAY_TYPES_SUPPORTED = 2, |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 258 | }; |
| 259 | |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 260 | /* display attributes returned by getDisplayAttributes() */ |
| 261 | enum { |
| 262 | /* Indicates the end of an attribute list */ |
| 263 | HWC_DISPLAY_NO_ATTRIBUTE = 0, |
| 264 | |
| 265 | /* The vsync period in nanoseconds */ |
| 266 | HWC_DISPLAY_VSYNC_PERIOD = 1, |
| 267 | |
| 268 | /* The number of pixels in the horizontal and vertical directions. */ |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 269 | HWC_DISPLAY_WIDTH = 2, |
| 270 | HWC_DISPLAY_HEIGHT = 3, |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 271 | |
| 272 | /* The number of pixels per thousand inches of this configuration. |
| 273 | * |
| 274 | * Scaling DPI by 1000 allows it to be stored in an int without losing |
| 275 | * too much precision. |
| 276 | * |
| 277 | * If the DPI for a configuration is unavailable or the HWC implementation |
| 278 | * considers it unreliable, it should set these attributes to zero. |
| 279 | */ |
| 280 | HWC_DISPLAY_DPI_X = 4, |
| 281 | HWC_DISPLAY_DPI_Y = 5, |
Dan Stoza | 95f0179 | 2015-08-31 12:08:57 -0700 | [diff] [blame] | 282 | |
| 283 | /* Indicates which of the vendor-defined color transforms is provided by |
| 284 | * this configuration. */ |
| 285 | HWC_DISPLAY_COLOR_TRANSFORM = 6, |
Ady Abraham | b1ea403 | 2019-10-18 18:00:01 -0700 | [diff] [blame] | 286 | |
| 287 | /* The configuration group this config is associated to. The groups are defined |
| 288 | * to mark certain configs as similar and changing configs within a certain group |
| 289 | * may be done seamlessly in some conditions. setActiveConfigWithConstraints. */ |
| 290 | HWC_DISPLAY_CONFIG_GROUP = 7, |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 291 | }; |
| 292 | |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 293 | /* Allowed events for hwc_methods::eventControl() */ |
| 294 | enum { |
| 295 | HWC_EVENT_VSYNC = 0 |
| 296 | }; |
| 297 | |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 298 | /* Display types and associated mask bits. */ |
| 299 | enum { |
| 300 | HWC_DISPLAY_PRIMARY = 0, |
| 301 | HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 302 | |
Dileep Marchya | 746b62b | 2018-05-25 11:39:56 +0530 | [diff] [blame] | 303 | HWC_DISPLAY_EXTERNAL_2 = 2, |
| 304 | HWC_DISPLAY_EXTERNAL_3 = 3, |
| 305 | HWC_DISPLAY_EXTERNAL_4 = 4, |
| 306 | |
| 307 | HWC_DISPLAY_BUILTIN_2 = 5, |
| 308 | HWC_DISPLAY_BUILTIN_3 = 6, |
| 309 | HWC_DISPLAY_BUILTIN_4 = 7, |
| 310 | |
| 311 | HWC_DISPLAY_VIRTUAL = 8, |
| 312 | |
| 313 | HWC_NUM_PHYSICAL_DISPLAY_TYPES = 8, |
| 314 | HWC_NUM_DISPLAY_TYPES = 9, |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | enum { |
| 318 | HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, |
| 319 | HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 320 | HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 321 | }; |
| 322 | |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 323 | /* Display power modes */ |
| 324 | enum { |
Jeff Brown | 842b906 | 2014-07-17 20:01:59 -0700 | [diff] [blame] | 325 | /* The display is turned off (blanked). */ |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 326 | HWC_POWER_MODE_OFF = 0, |
Jeff Brown | 842b906 | 2014-07-17 20:01:59 -0700 | [diff] [blame] | 327 | /* The display is turned on and configured in a low power state |
| 328 | * that is suitable for presenting ambient information to the user, |
| 329 | * possibly with lower fidelity than normal but greater efficiency. */ |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 330 | HWC_POWER_MODE_DOZE = 1, |
Jeff Brown | 842b906 | 2014-07-17 20:01:59 -0700 | [diff] [blame] | 331 | /* The display is turned on normally. */ |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 332 | HWC_POWER_MODE_NORMAL = 2, |
Jeff Brown | 842b906 | 2014-07-17 20:01:59 -0700 | [diff] [blame] | 333 | /* The display is configured as in HWC_POWER_MODE_DOZE but may |
| 334 | * stop applying frame buffer updates from the graphics subsystem. |
| 335 | * This power mode is effectively a hint from the doze dream to |
| 336 | * tell the hardware that it is done drawing to the display for the |
| 337 | * time being and that the display should remain on in a low power |
| 338 | * state and continue showing its current contents indefinitely |
| 339 | * until the mode changes. |
| 340 | * |
| 341 | * This mode may also be used as a signal to enable hardware-based doze |
| 342 | * functionality. In this case, the doze dream is effectively |
| 343 | * indicating that the hardware is free to take over the display |
| 344 | * and manage it autonomously to implement low power always-on display |
| 345 | * functionality. */ |
| 346 | HWC_POWER_MODE_DOZE_SUSPEND = 3, |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 347 | }; |
| 348 | |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 349 | /*****************************************************************************/ |
| 350 | |
| 351 | __END_DECLS |
| 352 | |
| 353 | #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ |