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 29 /* Shared by HWC1 and HWC2 */ 30 31 #define HWC_HEADER_VERSION 1 32 33 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) 34 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) 38 #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) 39 #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) 40 #define HWC_DEVICE_API_VERSION_1_5 HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION) 41 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 61 typedef struct hwc_frect { 62 float left; 63 float top; 64 float right; 65 float bottom; 66 } hwc_frect_t; 67 68 typedef struct hwc_rect { 69 int left; 70 int top; 71 int right; 72 int bottom; 73 } hwc_rect_t; 74 75 typedef struct hwc_region { 76 size_t numRects; 77 hwc_rect_t const* rects; 78 } hwc_region_t; 79 80 /* 81 * hwc_layer_t::transform values 82 */ 83 typedef enum { 84 /* flip source image horizontally */ 85 HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, 86 /* flip source image vertically */ 87 HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, 88 /* rotate source image 90 degrees clock-wise */ 89 HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, 90 /* rotate source image 180 degrees */ 91 HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, 92 /* rotate source image 270 degrees clock-wise */ 93 HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, 94 /* flip source image horizontally, the rotate 90 degrees clock-wise */ 95 HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90, 96 /* flip source image vertically, the rotate 90 degrees clock-wise */ 97 HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90, 98 } hwc_transform_t; 99 100 /******************************************************************************* 101 * Beyond this point are things only used by HWC1, which should be ignored when 102 * implementing a HWC2 device 103 ******************************************************************************/ 104 105 enum { 106 /* hwc_composer_device_t::set failed in EGL */ 107 HWC_EGL_ERROR = -1 108 }; 109 110 /* 111 * hwc_layer_t::hints values 112 * Hints are set by the HAL and read by SurfaceFlinger 113 */ 114 enum { 115 /* 116 * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger 117 * that it should triple buffer this layer. Typically HWC does this when 118 * the layer will be unavailable for use for an extended period of time, 119 * e.g. if the display will be fetching data directly from the layer and 120 * the layer can not be modified until after the next set(). 121 */ 122 HWC_HINT_TRIPLE_BUFFER = 0x00000001, 123 124 /* 125 * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the 126 * framebuffer with transparent pixels where this layer would be. 127 * SurfaceFlinger will only honor this flag when the layer has no blending 128 * 129 */ 130 HWC_HINT_CLEAR_FB = 0x00000002 131 }; 132 133 /* 134 * hwc_layer_t::flags values 135 * Flags are set by SurfaceFlinger and read by the HAL 136 */ 137 enum { 138 /* 139 * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL 140 * shall not consider this layer for composition as it will be handled 141 * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). 142 */ 143 HWC_SKIP_LAYER = 0x00000001, 144 145 /* 146 * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this 147 * layer is being used as a cursor on this particular display, and that 148 * surfaceflinger can potentially perform asynchronous position updates for 149 * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the 150 * composition type of this layer, then the hwcomposer will allow async 151 * position updates to this layer via setCursorPositionAsync(). 152 */ 153 HWC_IS_CURSOR_LAYER = 0x00000002 154 }; 155 156 /* 157 * hwc_layer_t::compositionType values 158 */ 159 enum { 160 /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ 161 HWC_FRAMEBUFFER = 0, 162 163 /* this layer will be handled in the HWC */ 164 HWC_OVERLAY = 1, 165 166 /* this is the background layer. it's used to set the background color. 167 * there is only a single background layer */ 168 HWC_BACKGROUND = 2, 169 170 /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. 171 * Added in HWC_DEVICE_API_VERSION_1_1. */ 172 HWC_FRAMEBUFFER_TARGET = 3, 173 174 /* this layer's contents are taken from a sideband buffer stream. 175 * Added in HWC_DEVICE_API_VERSION_1_4. */ 176 HWC_SIDEBAND = 4, 177 178 /* this layer's composition will be handled by hwcomposer by dedicated 179 cursor overlay hardware. hwcomposer will also all async position updates 180 of this layer outside of the normal prepare()/set() loop. Added in 181 HWC_DEVICE_API_VERSION_1_4. */ 182 HWC_CURSOR_OVERLAY = 5 183 }; 184 /* 185 * hwc_layer_t::blending values 186 */ 187 enum { 188 /* no blending */ 189 HWC_BLENDING_NONE = 0x0100, 190 191 /* ONE / ONE_MINUS_SRC_ALPHA */ 192 HWC_BLENDING_PREMULT = 0x0105, 193 194 /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ 195 HWC_BLENDING_COVERAGE = 0x0405 196 }; 197 198 /* attributes queriable with query() */ 199 enum { 200 /* 201 * Must return 1 if the background layer is supported, 0 otherwise. 202 */ 203 HWC_BACKGROUND_LAYER_SUPPORTED = 0, 204 205 /* 206 * Returns the vsync period in nanoseconds. 207 * 208 * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. 209 * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. 210 */ 211 HWC_VSYNC_PERIOD = 1, 212 213 /* 214 * Availability: HWC_DEVICE_API_VERSION_1_1 215 * Returns a mask of supported display types. 216 */ 217 HWC_DISPLAY_TYPES_SUPPORTED = 2, 218 }; 219 220 /* display attributes returned by getDisplayAttributes() */ 221 enum { 222 /* Indicates the end of an attribute list */ 223 HWC_DISPLAY_NO_ATTRIBUTE = 0, 224 225 /* The vsync period in nanoseconds */ 226 HWC_DISPLAY_VSYNC_PERIOD = 1, 227 228 /* The number of pixels in the horizontal and vertical directions. */ 229 HWC_DISPLAY_WIDTH = 2, 230 HWC_DISPLAY_HEIGHT = 3, 231 232 /* The number of pixels per thousand inches of this configuration. 233 * 234 * Scaling DPI by 1000 allows it to be stored in an int without losing 235 * too much precision. 236 * 237 * If the DPI for a configuration is unavailable or the HWC implementation 238 * considers it unreliable, it should set these attributes to zero. 239 */ 240 HWC_DISPLAY_DPI_X = 4, 241 HWC_DISPLAY_DPI_Y = 5, 242 243 /* Indicates which of the vendor-defined color transforms is provided by 244 * this configuration. */ 245 HWC_DISPLAY_COLOR_TRANSFORM = 6, 246 }; 247 248 /* Allowed events for hwc_methods::eventControl() */ 249 enum { 250 HWC_EVENT_VSYNC = 0 251 }; 252 253 /* Display types and associated mask bits. */ 254 enum { 255 HWC_DISPLAY_PRIMARY = 0, 256 HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. 257 HWC_DISPLAY_VIRTUAL = 2, 258 259 HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, 260 HWC_NUM_DISPLAY_TYPES = 3, 261 }; 262 263 enum { 264 HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, 265 HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, 266 HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, 267 }; 268 269 /* Display power modes */ 270 enum { 271 /* The display is turned off (blanked). */ 272 HWC_POWER_MODE_OFF = 0, 273 /* The display is turned on and configured in a low power state 274 * that is suitable for presenting ambient information to the user, 275 * possibly with lower fidelity than normal but greater efficiency. */ 276 HWC_POWER_MODE_DOZE = 1, 277 /* The display is turned on normally. */ 278 HWC_POWER_MODE_NORMAL = 2, 279 /* The display is configured as in HWC_POWER_MODE_DOZE but may 280 * stop applying frame buffer updates from the graphics subsystem. 281 * This power mode is effectively a hint from the doze dream to 282 * tell the hardware that it is done drawing to the display for the 283 * time being and that the display should remain on in a low power 284 * state and continue showing its current contents indefinitely 285 * until the mode changes. 286 * 287 * This mode may also be used as a signal to enable hardware-based doze 288 * functionality. In this case, the doze dream is effectively 289 * indicating that the hardware is free to take over the display 290 * and manage it autonomously to implement low power always-on display 291 * functionality. */ 292 HWC_POWER_MODE_DOZE_SUSPEND = 3, 293 }; 294 295 /*****************************************************************************/ 296 297 __END_DECLS 298 299 #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ 300