Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -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_H |
| 18 | #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | |
Louis Huemiller | 45e2371 | 2010-12-01 12:25:00 -0800 | [diff] [blame] | 23 | #include <hardware/gralloc.h> |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 24 | #include <hardware/hardware.h> |
| 25 | #include <cutils/native_handle.h> |
| 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
| 29 | /*****************************************************************************/ |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 30 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 31 | #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
| 32 | |
| 33 | #define HWC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) |
| 34 | #define HWC_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2) |
| 35 | #define HWC_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3) |
| 36 | |
Mathias Agopian | 81c323d | 2012-03-25 01:09:35 -0700 | [diff] [blame] | 37 | // for compatibility |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 38 | #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 |
| 39 | #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 |
Mathias Agopian | 81c323d | 2012-03-25 01:09:35 -0700 | [diff] [blame] | 40 | #define HWC_API_VERSION HWC_DEVICE_API_VERSION |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 41 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 42 | /** |
| 43 | * The id of this module |
| 44 | */ |
| 45 | #define HWC_HARDWARE_MODULE_ID "hwcomposer" |
| 46 | |
| 47 | /** |
| 48 | * Name of the sensors device to open |
| 49 | */ |
| 50 | #define HWC_HARDWARE_COMPOSER "composer" |
| 51 | |
| 52 | |
| 53 | enum { |
| 54 | /* hwc_composer_device_t::set failed in EGL */ |
| 55 | HWC_EGL_ERROR = -1 |
| 56 | }; |
| 57 | |
| 58 | /* |
| 59 | * hwc_layer_t::hints values |
| 60 | * Hints are set by the HAL and read by SurfaceFlinger |
| 61 | */ |
| 62 | enum { |
| 63 | /* |
Mathias Agopian | cdd44a0 | 2010-08-12 15:04:58 -0700 | [diff] [blame] | 64 | * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 65 | * that it should triple buffer this layer. Typically HWC does this when |
| 66 | * the layer will be unavailable for use for an extended period of time, |
| 67 | * e.g. if the display will be fetching data directly from the layer and |
| 68 | * the layer can not be modified until after the next set(). |
| 69 | */ |
Mathias Agopian | cdd44a0 | 2010-08-12 15:04:58 -0700 | [diff] [blame] | 70 | HWC_HINT_TRIPLE_BUFFER = 0x00000001, |
| 71 | |
| 72 | /* |
| 73 | * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the |
| 74 | * framebuffer with transparent pixels where this layer would be. |
| 75 | * SurfaceFlinger will only honor this flag when the layer has no blending |
| 76 | * |
| 77 | */ |
| 78 | HWC_HINT_CLEAR_FB = 0x00000002 |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /* |
| 82 | * hwc_layer_t::flags values |
| 83 | * Flags are set by SurfaceFlinger and read by the HAL |
| 84 | */ |
| 85 | enum { |
| 86 | /* |
| 87 | * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL |
| 88 | * shall not consider this layer for composition as it will be handled |
| 89 | * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). |
| 90 | */ |
| 91 | HWC_SKIP_LAYER = 0x00000001, |
| 92 | }; |
| 93 | |
| 94 | /* |
| 95 | * hwc_layer_t::compositionType values |
| 96 | */ |
| 97 | enum { |
| 98 | /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ |
| 99 | HWC_FRAMEBUFFER = 0, |
| 100 | |
| 101 | /* this layer will be handled in the HWC */ |
| 102 | HWC_OVERLAY = 1, |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 103 | |
| 104 | /* this is the background layer. it's used to set the background color. |
| 105 | * there is only a single background layer */ |
| 106 | HWC_BACKGROUND = 2, |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | /* |
| 110 | * hwc_layer_t::blending values |
| 111 | */ |
| 112 | enum { |
| 113 | /* no blending */ |
| 114 | HWC_BLENDING_NONE = 0x0100, |
| 115 | |
| 116 | /* ONE / ONE_MINUS_SRC_ALPHA */ |
| 117 | HWC_BLENDING_PREMULT = 0x0105, |
| 118 | |
| 119 | /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ |
| 120 | HWC_BLENDING_COVERAGE = 0x0405 |
| 121 | }; |
| 122 | |
| 123 | /* |
| 124 | * hwc_layer_t::transform values |
| 125 | */ |
| 126 | enum { |
| 127 | /* flip source image horizontally */ |
| 128 | HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, |
| 129 | /* flip source image vertically */ |
| 130 | HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, |
| 131 | /* rotate source image 90 degrees clock-wise */ |
| 132 | HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, |
| 133 | /* rotate source image 180 degrees */ |
| 134 | HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, |
| 135 | /* rotate source image 270 degrees clock-wise */ |
| 136 | HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, |
| 137 | }; |
| 138 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 139 | /* attributes queriable with query() */ |
| 140 | enum { |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 141 | /* |
| 142 | * availability: HWC_DEVICE_API_VERSION_0_2 |
| 143 | * must return 1 if the background layer is supported, 0 otherwise |
| 144 | */ |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 145 | HWC_BACKGROUND_LAYER_SUPPORTED = 0, |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 146 | |
| 147 | /* |
| 148 | * availability: HWC_DEVICE_API_VERSION_0_3 |
| 149 | * returns the vsync period in nanosecond |
| 150 | */ |
| 151 | HWC_VSYNC_PERIOD = 1, |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 152 | }; |
| 153 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 154 | /* Allowed events for hwc_methods::eventControl() */ |
| 155 | enum { |
| 156 | HWC_EVENT_VSYNC = 0 |
| 157 | }; |
| 158 | |
| 159 | struct hwc_composer_device; |
| 160 | |
| 161 | /* |
| 162 | * availability: HWC_DEVICE_API_VERSION_0_3 |
| 163 | * |
| 164 | * struct hwc_methods cannot be embedded in other structures as |
| 165 | * sizeof(struct hwc_methods) cannot be relied upon. |
| 166 | * |
| 167 | */ |
| 168 | typedef struct hwc_methods { |
| 169 | |
| 170 | /************************************************************************* |
| 171 | * HWC_DEVICE_API_VERSION_0_3 |
| 172 | *************************************************************************/ |
| 173 | |
| 174 | /* |
| 175 | * eventControl(..., event, enabled) |
| 176 | * Enables or disables h/w composer events. |
| 177 | * |
| 178 | * eventControl can be called from any thread and takes effect |
| 179 | * immediately. |
| 180 | * |
| 181 | * Supported events are: |
| 182 | * HWC_EVENT_VSYNC |
| 183 | * |
| 184 | * returns -EINVAL if the "event" parameter is not one of the value above |
| 185 | * or if the "enabled" parameter is not 0 or 1. |
| 186 | */ |
| 187 | |
| 188 | int (*eventControl)( |
| 189 | struct hwc_composer_device* dev, int event, int enabled); |
| 190 | |
| 191 | } hwc_methods_t; |
| 192 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 193 | typedef struct hwc_rect { |
| 194 | int left; |
| 195 | int top; |
| 196 | int right; |
| 197 | int bottom; |
| 198 | } hwc_rect_t; |
| 199 | |
| 200 | typedef struct hwc_region { |
| 201 | size_t numRects; |
| 202 | hwc_rect_t const* rects; |
| 203 | } hwc_region_t; |
| 204 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 205 | typedef struct hwc_color { |
| 206 | uint8_t r; |
| 207 | uint8_t g; |
| 208 | uint8_t b; |
| 209 | uint8_t a; |
| 210 | } hwc_color_t; |
| 211 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 212 | typedef struct hwc_layer { |
| 213 | /* |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 214 | * initially set to HWC_FRAMEBUFFER or HWC_BACKGROUND. |
| 215 | * HWC_FRAMEBUFFER |
| 216 | * indicates the layer will be drawn into the framebuffer |
| 217 | * using OpenGL ES. |
| 218 | * The HWC can toggle this value to HWC_OVERLAY, to indicate |
| 219 | * it will handle the layer. |
| 220 | * |
| 221 | * HWC_BACKGROUND |
| 222 | * indicates this is a special "background" layer. The only valid |
| 223 | * field is backgroundColor. HWC_BACKGROUND can only be used with |
| 224 | * HWC_API_VERSION >= 0.2 |
| 225 | * The HWC can toggle this value to HWC_FRAMEBUFFER, to indicate |
| 226 | * it CANNOT handle the background color |
| 227 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 228 | */ |
| 229 | int32_t compositionType; |
| 230 | |
| 231 | /* see hwc_layer_t::hints above */ |
| 232 | uint32_t hints; |
| 233 | |
| 234 | /* see hwc_layer_t::flags above */ |
| 235 | uint32_t flags; |
| 236 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 237 | union { |
| 238 | /* color of the background. hwc_color_t.a is ignored */ |
| 239 | hwc_color_t backgroundColor; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 240 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 241 | struct { |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 242 | /* handle of buffer to compose. This handle is guaranteed to have been |
| 243 | * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If |
| 244 | * the layer's handle is unchanged across two consecutive prepare calls and |
| 245 | * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the |
| 246 | * HWComposer implementation may assume that the contents of the buffer have |
| 247 | * not changed. */ |
| 248 | buffer_handle_t handle; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 249 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 250 | /* transformation to apply to the buffer during composition */ |
| 251 | uint32_t transform; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 252 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 253 | /* blending to apply during composition */ |
| 254 | int32_t blending; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 255 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 256 | /* area of the source to consider, the origin is the top-left corner of |
| 257 | * the buffer */ |
| 258 | hwc_rect_t sourceCrop; |
| 259 | |
| 260 | /* where to composite the sourceCrop onto the display. The sourceCrop |
| 261 | * is scaled using linear filtering to the displayFrame. The origin is the |
| 262 | * top-left corner of the screen. |
| 263 | */ |
| 264 | hwc_rect_t displayFrame; |
| 265 | |
| 266 | /* visible region in screen space. The origin is the |
| 267 | * top-left corner of the screen. |
| 268 | * The visible region INCLUDES areas overlapped by a translucent layer. |
| 269 | */ |
| 270 | hwc_region_t visibleRegionScreen; |
| 271 | }; |
| 272 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 273 | } hwc_layer_t; |
| 274 | |
| 275 | |
| 276 | /* |
| 277 | * hwc_layer_list_t::flags values |
| 278 | */ |
| 279 | enum { |
| 280 | /* |
| 281 | * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list |
| 282 | * passed to (*prepare)() has changed by more than just the buffer handles. |
| 283 | */ |
| 284 | HWC_GEOMETRY_CHANGED = 0x00000001, |
| 285 | }; |
| 286 | |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 287 | /* |
| 288 | * List of layers. |
| 289 | * The handle members of hwLayers elements must be unique. |
| 290 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 291 | typedef struct hwc_layer_list { |
| 292 | uint32_t flags; |
| 293 | size_t numHwLayers; |
| 294 | hwc_layer_t hwLayers[0]; |
| 295 | } hwc_layer_list_t; |
| 296 | |
| 297 | /* This represents a display, typically an EGLDisplay object */ |
| 298 | typedef void* hwc_display_t; |
| 299 | |
| 300 | /* This represents a surface, typically an EGLSurface object */ |
| 301 | typedef void* hwc_surface_t; |
| 302 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 303 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 304 | /* see hwc_composer_device::registerProcs() |
| 305 | * Any of the callbacks can be NULL, in which case the corresponding |
| 306 | * functionality is not supported. |
| 307 | */ |
| 308 | typedef struct hwc_procs { |
| 309 | /* |
| 310 | * (*invalidate)() triggers a screen refresh, in particular prepare and set |
| 311 | * will be called shortly after this call is made. Note that there is |
| 312 | * NO GUARANTEE that the screen refresh will happen after invalidate() |
| 313 | * returns (in particular, it could happen before). |
| 314 | * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and |
| 315 | * it is safe to call invalidate() from any of hwc_composer_device |
| 316 | * hooks, unless noted otherwise. |
| 317 | */ |
| 318 | void (*invalidate)(struct hwc_procs* procs); |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 319 | |
| 320 | /* |
| 321 | * (*vsync)() is called by the h/w composer HAL when a vsync event is |
| 322 | * received and HWC_EVENT_VSYNC is enabled (see: hwc_event_control). |
| 323 | * |
| 324 | * the "zero" parameter must always be 0. |
Jamie Gennis | 6b7adef | 2012-04-30 12:57:11 -0700 | [diff] [blame] | 325 | * the "timestamp" parameter is the system monotonic clock timestamp in |
| 326 | * nanosecond of when the vsync event happened. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 327 | * |
| 328 | * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. |
| 329 | * |
| 330 | * It is expected that vsync() is called from a thread of at least |
Mathias Agopian | eb67160 | 2012-04-24 15:42:37 -0700 | [diff] [blame] | 331 | * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 332 | * typically less than 0.5 ms. |
| 333 | * |
Mathias Agopian | 6d3fec7 | 2012-04-10 21:22:28 -0700 | [diff] [blame] | 334 | * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling |
| 335 | * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation |
| 336 | * can either stop or continue to process VSYNC events, but must not |
| 337 | * crash or cause other problems. |
| 338 | * |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 339 | */ |
| 340 | void (*vsync)(struct hwc_procs* procs, int zero, int64_t timestamp); |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 341 | } hwc_procs_t; |
| 342 | |
| 343 | |
| 344 | /*****************************************************************************/ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 345 | |
| 346 | typedef struct hwc_module { |
| 347 | struct hw_module_t common; |
| 348 | } hwc_module_t; |
| 349 | |
| 350 | |
| 351 | typedef struct hwc_composer_device { |
| 352 | struct hw_device_t common; |
| 353 | |
| 354 | /* |
| 355 | * (*prepare)() is called for each frame before composition and is used by |
| 356 | * SurfaceFlinger to determine what composition steps the HWC can handle. |
| 357 | * |
| 358 | * (*prepare)() can be called more than once, the last call prevails. |
| 359 | * |
| 360 | * The HWC responds by setting the compositionType field to either |
| 361 | * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for |
| 362 | * this layer is handled by SurfaceFlinger with OpenGL ES, in the later |
| 363 | * case, the HWC will have to handle this layer's composition. |
| 364 | * |
| 365 | * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the |
| 366 | * list's geometry has changed, that is, when more than just the buffer's |
| 367 | * handles have been updated. Typically this happens (but is not limited to) |
| 368 | * when a window is added, removed, resized or moved. |
| 369 | * |
| 370 | * a NULL list parameter or a numHwLayers of zero indicates that the |
| 371 | * entire composition will be handled by SurfaceFlinger with OpenGL ES. |
| 372 | * |
| 373 | * returns: 0 on success. An negative error code on error. If an error is |
| 374 | * returned, SurfaceFlinger will assume that none of the layer will be |
| 375 | * handled by the HWC. |
| 376 | */ |
| 377 | int (*prepare)(struct hwc_composer_device *dev, hwc_layer_list_t* list); |
| 378 | |
| 379 | |
| 380 | /* |
| 381 | * (*set)() is used in place of eglSwapBuffers(), and assumes the same |
| 382 | * functionality, except it also commits the work list atomically with |
| 383 | * the actual eglSwapBuffers(). |
| 384 | * |
| 385 | * The list parameter is guaranteed to be the same as the one returned |
| 386 | * from the last call to (*prepare)(). |
| 387 | * |
| 388 | * When this call returns the caller assumes that: |
| 389 | * |
| 390 | * - the display will be updated in the near future with the content |
| 391 | * of the work list, without artifacts during the transition from the |
| 392 | * previous frame. |
| 393 | * |
| 394 | * - all objects are available for immediate access or destruction, in |
| 395 | * particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer. |
| 396 | * Note that this means that immediately accessing (potentially from a |
| 397 | * different process) a buffer used in this call will not result in |
| 398 | * screen corruption, the driver must apply proper synchronization or |
| 399 | * scheduling (eg: block the caller, such as gralloc_module_t::lock(), |
| 400 | * OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work |
| 401 | * after the buffer is freed from the actual composition). |
| 402 | * |
| 403 | * a NULL list parameter or a numHwLayers of zero indicates that the |
| 404 | * entire composition has been handled by SurfaceFlinger with OpenGL ES. |
| 405 | * In this case, (*set)() behaves just like eglSwapBuffers(). |
| 406 | * |
Mathias Agopian | 71212e3 | 2011-11-21 17:35:15 -0800 | [diff] [blame] | 407 | * dpy, sur, and list are set to NULL to indicate that the screen is |
| 408 | * turning off. This happens WITHOUT prepare() being called first. |
| 409 | * This is a good time to free h/w resources and/or power |
| 410 | * the relevant h/w blocks down. |
| 411 | * |
Mathias Agopian | fb41036 | 2011-11-15 21:27:52 -0800 | [diff] [blame] | 412 | * IMPORTANT NOTE: there is an implicit layer containing opaque black |
| 413 | * pixels behind all the layers in the list. |
| 414 | * It is the responsibility of the hwcomposer module to make |
| 415 | * sure black pixels are output (or blended from). |
| 416 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 417 | * returns: 0 on success. An negative error code on error: |
| 418 | * HWC_EGL_ERROR: eglGetError() will provide the proper error code |
| 419 | * Another code for non EGL errors. |
| 420 | * |
| 421 | */ |
| 422 | int (*set)(struct hwc_composer_device *dev, |
| 423 | hwc_display_t dpy, |
| 424 | hwc_surface_t sur, |
| 425 | hwc_layer_list_t* list); |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 426 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 427 | * This field is OPTIONAL and can be NULL. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 428 | * |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 429 | * If non NULL it will be called by SurfaceFlinger on dumpsys |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 430 | */ |
| 431 | void (*dump)(struct hwc_composer_device* dev, char *buff, int buff_len); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 432 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 433 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 434 | * This field is OPTIONAL and can be NULL. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 435 | * |
| 436 | * (*registerProcs)() registers a set of callbacks the h/w composer HAL |
| 437 | * can later use. It is FORBIDDEN to call any of the callbacks from |
| 438 | * within registerProcs(). registerProcs() must save the hwc_procs_t pointer |
| 439 | * which is needed when calling a registered callback. |
| 440 | * Each call to registerProcs replaces the previous set of callbacks. |
| 441 | * registerProcs is called with NULL to unregister all callbacks. |
| 442 | * |
| 443 | * Any of the callbacks can be NULL, in which case the corresponding |
| 444 | * functionality is not supported. |
| 445 | */ |
| 446 | void (*registerProcs)(struct hwc_composer_device* dev, |
| 447 | hwc_procs_t const* procs); |
| 448 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 449 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 450 | * This field is OPTIONAL and can be NULL. |
| 451 | * availability: HWC_DEVICE_API_VERSION_0_2 |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 452 | * |
| 453 | * Used to retrieve information about the h/w composer |
| 454 | * |
| 455 | * Returns 0 on success or -errno on error. |
| 456 | */ |
| 457 | int (*query)(struct hwc_composer_device* dev, int what, int* value); |
| 458 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 459 | /* |
| 460 | * Reserved for future use. Must be NULL. |
| 461 | */ |
| 462 | void* reserved_proc[4]; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 463 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 464 | /* |
| 465 | * This field is OPTIONAL and can be NULL. |
| 466 | * availability: HWC_DEVICE_API_VERSION_0_3 |
| 467 | */ |
| 468 | hwc_methods_t const *methods; |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 469 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 470 | } hwc_composer_device_t; |
| 471 | |
| 472 | |
| 473 | /** convenience API for opening and closing a device */ |
| 474 | |
| 475 | static inline int hwc_open(const struct hw_module_t* module, |
| 476 | hwc_composer_device_t** device) { |
| 477 | return module->methods->open(module, |
| 478 | HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); |
| 479 | } |
| 480 | |
| 481 | static inline int hwc_close(hwc_composer_device_t* device) { |
| 482 | return device->common.close(&device->common); |
| 483 | } |
| 484 | |
| 485 | |
| 486 | /*****************************************************************************/ |
| 487 | |
| 488 | __END_DECLS |
| 489 | |
| 490 | #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ |