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 | |
Mathias Agopian | e291f71 | 2012-05-13 22:49:06 -0700 | [diff] [blame] | 27 | #include <hardware/hwcomposer_defs.h> |
| 28 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 29 | __BEGIN_DECLS |
| 30 | |
| 31 | /*****************************************************************************/ |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 32 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 33 | /* for compatibility */ |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 34 | #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 |
| 35 | #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 |
Mathias Agopian | 81c323d | 2012-03-25 01:09:35 -0700 | [diff] [blame] | 36 | #define HWC_API_VERSION HWC_DEVICE_API_VERSION |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 37 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 38 | /* Users of this header can define HWC_REMOVE_DEPRECATED_VERSIONS to test that |
| 39 | * they still work with just the current version declared, before the |
| 40 | * deprecated versions are actually removed. |
| 41 | * |
| 42 | * To find code that still depends on the old versions, set the #define to 1 |
| 43 | * here. Code that explicitly sets it to zero (rather than simply not defining |
| 44 | * it) will still see the old versions. |
| 45 | */ |
| 46 | #if !defined(HWC_REMOVE_DEPRECATED_VERSIONS) |
| 47 | #define HWC_REMOVE_DEPRECATED_VERSIONS 0 |
| 48 | #endif |
| 49 | |
| 50 | /*****************************************************************************/ |
| 51 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 52 | /** |
| 53 | * The id of this module |
| 54 | */ |
| 55 | #define HWC_HARDWARE_MODULE_ID "hwcomposer" |
| 56 | |
| 57 | /** |
| 58 | * Name of the sensors device to open |
| 59 | */ |
| 60 | #define HWC_HARDWARE_COMPOSER "composer" |
| 61 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 62 | struct hwc_composer_device_1; |
| 63 | typedef struct hwc_methods_1 { |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | * eventControl(..., event, enabled) |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 67 | * Enables or disables h/w composer events. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 68 | * |
| 69 | * eventControl can be called from any thread and takes effect |
| 70 | * immediately. |
| 71 | * |
| 72 | * Supported events are: |
| 73 | * HWC_EVENT_VSYNC |
| 74 | * |
| 75 | * returns -EINVAL if the "event" parameter is not one of the value above |
| 76 | * or if the "enabled" parameter is not 0 or 1. |
| 77 | */ |
| 78 | |
| 79 | int (*eventControl)( |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 80 | struct hwc_composer_device_1* dev, int event, int enabled); |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 81 | |
Colin Cross | 38fccf4 | 2012-07-12 17:54:59 -0700 | [diff] [blame] | 82 | /* |
| 83 | * This field is OPTIONAL and can be NULL. |
| 84 | * |
| 85 | * blank(..., blank) |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 86 | * Blanks or unblanks the screen. |
Colin Cross | 38fccf4 | 2012-07-12 17:54:59 -0700 | [diff] [blame] | 87 | * |
| 88 | * Turns the screen off when blank is nonzero, on when blank is zero. |
| 89 | * Blanking may also be triggered by a call to set..., 0, 0, 0). Multiple |
| 90 | * sequential calls with the same blank value must be supported. |
| 91 | * |
| 92 | * returns 0 on success, negative on error. |
| 93 | */ |
| 94 | |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 95 | int (*blank)(struct hwc_composer_device_1* dev, int blank); |
Colin Cross | 38fccf4 | 2012-07-12 17:54:59 -0700 | [diff] [blame] | 96 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 97 | } hwc_methods_1_t; |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 98 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 99 | typedef struct hwc_rect { |
| 100 | int left; |
| 101 | int top; |
| 102 | int right; |
| 103 | int bottom; |
| 104 | } hwc_rect_t; |
| 105 | |
| 106 | typedef struct hwc_region { |
| 107 | size_t numRects; |
| 108 | hwc_rect_t const* rects; |
| 109 | } hwc_region_t; |
| 110 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 111 | typedef struct hwc_color { |
| 112 | uint8_t r; |
| 113 | uint8_t g; |
| 114 | uint8_t b; |
| 115 | uint8_t a; |
| 116 | } hwc_color_t; |
| 117 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 118 | typedef struct hwc_layer_1 { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 119 | /* |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 120 | * initially set to HWC_FRAMEBUFFER or HWC_BACKGROUND. |
| 121 | * HWC_FRAMEBUFFER |
| 122 | * indicates the layer will be drawn into the framebuffer |
| 123 | * using OpenGL ES. |
| 124 | * The HWC can toggle this value to HWC_OVERLAY, to indicate |
| 125 | * it will handle the layer. |
| 126 | * |
| 127 | * HWC_BACKGROUND |
| 128 | * indicates this is a special "background" layer. The only valid |
| 129 | * field is backgroundColor. HWC_BACKGROUND can only be used with |
| 130 | * HWC_API_VERSION >= 0.2 |
| 131 | * The HWC can toggle this value to HWC_FRAMEBUFFER, to indicate |
| 132 | * it CANNOT handle the background color |
| 133 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 134 | */ |
| 135 | int32_t compositionType; |
| 136 | |
| 137 | /* see hwc_layer_t::hints above */ |
| 138 | uint32_t hints; |
| 139 | |
| 140 | /* see hwc_layer_t::flags above */ |
| 141 | uint32_t flags; |
| 142 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 143 | union { |
| 144 | /* color of the background. hwc_color_t.a is ignored */ |
| 145 | hwc_color_t backgroundColor; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 146 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 147 | struct { |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 148 | /* handle of buffer to compose. This handle is guaranteed to have been |
| 149 | * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If |
| 150 | * the layer's handle is unchanged across two consecutive prepare calls and |
| 151 | * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the |
| 152 | * HWComposer implementation may assume that the contents of the buffer have |
| 153 | * not changed. */ |
| 154 | buffer_handle_t handle; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 155 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 156 | /* transformation to apply to the buffer during composition */ |
| 157 | uint32_t transform; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 158 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 159 | /* blending to apply during composition */ |
| 160 | int32_t blending; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 161 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 162 | /* area of the source to consider, the origin is the top-left corner of |
| 163 | * the buffer */ |
| 164 | hwc_rect_t sourceCrop; |
| 165 | |
| 166 | /* where to composite the sourceCrop onto the display. The sourceCrop |
| 167 | * is scaled using linear filtering to the displayFrame. The origin is the |
| 168 | * top-left corner of the screen. |
| 169 | */ |
| 170 | hwc_rect_t displayFrame; |
| 171 | |
| 172 | /* visible region in screen space. The origin is the |
| 173 | * top-left corner of the screen. |
| 174 | * The visible region INCLUDES areas overlapped by a translucent layer. |
| 175 | */ |
| 176 | hwc_region_t visibleRegionScreen; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 177 | |
| 178 | /* Sync fence object that will be signaled when the buffer's |
| 179 | * contents are available. May be -1 if the contents are already |
| 180 | * available. This field is only valid during set(), and should be |
| 181 | * ignored during prepare(). The set() call must not wait for the |
| 182 | * fence to be signaled before returning, but the HWC must wait for |
| 183 | * all buffers to be signaled before reading from them. |
| 184 | * |
| 185 | * The HWC takes ownership of the acquireFenceFd and is responsible |
| 186 | * for closing it when no longer needed. |
| 187 | */ |
| 188 | int acquireFenceFd; |
| 189 | |
| 190 | /* During set() the HWC must set this field to a file descriptor for |
| 191 | * a sync fence object that will signal after the HWC has finished |
| 192 | * reading from the buffer. The field is ignored by prepare(). Each |
| 193 | * layer should have a unique file descriptor, even if more than one |
| 194 | * refer to the same underlying fence object; this allows each to be |
| 195 | * closed independently. |
| 196 | * |
| 197 | * If buffer reads can complete at significantly different times, |
| 198 | * then using independent fences is preferred. For example, if the |
| 199 | * HWC handles some layers with a blit engine and others with |
| 200 | * overlays, then the blit layers can be reused immediately after |
| 201 | * the blit completes, but the overlay layers can't be reused until |
| 202 | * a subsequent frame has been displayed. |
| 203 | * |
| 204 | * The HWC client taks ownership of the releaseFenceFd and is |
| 205 | * responsible for closing it when no longer needed. |
| 206 | */ |
| 207 | int releaseFenceFd; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 208 | }; |
| 209 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 210 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 211 | /* Allow for expansion w/o breaking binary compatibility. |
| 212 | * Pad layer to 96 bytes, assuming 32-bit pointers. |
| 213 | */ |
| 214 | int32_t reserved[24 - 18]; |
| 215 | |
| 216 | } hwc_layer_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 217 | |
| 218 | /* |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 219 | * hwc_layer_list_t::flags values |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 220 | */ |
| 221 | enum { |
| 222 | /* |
| 223 | * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 224 | * passed to (*prepare)() has changed by more than just the buffer handles |
| 225 | * and acquire fences. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 226 | */ |
| 227 | HWC_GEOMETRY_CHANGED = 0x00000001, |
| 228 | }; |
| 229 | |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 230 | /* |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 231 | * List of layers. |
| 232 | * The handle members of hwLayers elements must be unique. |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 233 | */ |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 234 | typedef struct hwc_layer_list_1 { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 235 | uint32_t flags; |
| 236 | size_t numHwLayers; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 237 | hwc_layer_1_t hwLayers[0]; |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 238 | } hwc_layer_list_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 239 | |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 240 | /* This represents a display, typically an EGLDisplay object */ |
| 241 | typedef void* hwc_display_t; |
| 242 | |
| 243 | /* This represents a surface, typically an EGLSurface object */ |
| 244 | typedef void* hwc_surface_t; |
| 245 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 246 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 247 | /* see hwc_composer_device::registerProcs() |
| 248 | * Any of the callbacks can be NULL, in which case the corresponding |
| 249 | * functionality is not supported. |
| 250 | */ |
| 251 | typedef struct hwc_procs { |
| 252 | /* |
| 253 | * (*invalidate)() triggers a screen refresh, in particular prepare and set |
| 254 | * will be called shortly after this call is made. Note that there is |
| 255 | * NO GUARANTEE that the screen refresh will happen after invalidate() |
| 256 | * returns (in particular, it could happen before). |
| 257 | * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and |
| 258 | * it is safe to call invalidate() from any of hwc_composer_device |
| 259 | * hooks, unless noted otherwise. |
| 260 | */ |
| 261 | void (*invalidate)(struct hwc_procs* procs); |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 262 | |
| 263 | /* |
| 264 | * (*vsync)() is called by the h/w composer HAL when a vsync event is |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 265 | * received and HWC_EVENT_VSYNC is enabled (see: hwc_event_control). |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 266 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 267 | * the "zero" parameter must always be 0. |
Jamie Gennis | 6b7adef | 2012-04-30 12:57:11 -0700 | [diff] [blame] | 268 | * the "timestamp" parameter is the system monotonic clock timestamp in |
| 269 | * nanosecond of when the vsync event happened. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 270 | * |
| 271 | * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. |
| 272 | * |
| 273 | * 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] | 274 | * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 275 | * typically less than 0.5 ms. |
| 276 | * |
Mathias Agopian | 6d3fec7 | 2012-04-10 21:22:28 -0700 | [diff] [blame] | 277 | * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling |
| 278 | * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation |
| 279 | * can either stop or continue to process VSYNC events, but must not |
| 280 | * crash or cause other problems. |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 281 | * |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 282 | */ |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 283 | void (*vsync)(struct hwc_procs* procs, int zero, int64_t timestamp); |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 284 | } hwc_procs_t; |
| 285 | |
| 286 | |
| 287 | /*****************************************************************************/ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 288 | |
| 289 | typedef struct hwc_module { |
| 290 | struct hw_module_t common; |
| 291 | } hwc_module_t; |
| 292 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 293 | typedef struct hwc_composer_device_1 { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 294 | struct hw_device_t common; |
| 295 | |
| 296 | /* |
| 297 | * (*prepare)() is called for each frame before composition and is used by |
| 298 | * SurfaceFlinger to determine what composition steps the HWC can handle. |
| 299 | * |
| 300 | * (*prepare)() can be called more than once, the last call prevails. |
| 301 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 302 | * The HWC responds by setting the compositionType field to either |
| 303 | * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for |
| 304 | * this layer is handled by SurfaceFlinger with OpenGL ES, in the later |
| 305 | * case, the HWC will have to handle this layer's composition. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 306 | * |
| 307 | * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the |
| 308 | * list's geometry has changed, that is, when more than just the buffer's |
| 309 | * handles have been updated. Typically this happens (but is not limited to) |
| 310 | * when a window is added, removed, resized or moved. |
| 311 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 312 | * a NULL list parameter or a numHwLayers of zero indicates that the |
| 313 | * entire composition will be handled by SurfaceFlinger with OpenGL ES. |
| 314 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 315 | * returns: 0 on success. An negative error code on error. If an error is |
| 316 | * returned, SurfaceFlinger will assume that none of the layer will be |
| 317 | * handled by the HWC. |
| 318 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 319 | int (*prepare)(struct hwc_composer_device_1 *dev, |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 320 | hwc_layer_list_1_t* list); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * (*set)() is used in place of eglSwapBuffers(), and assumes the same |
| 324 | * functionality, except it also commits the work list atomically with |
| 325 | * the actual eglSwapBuffers(). |
| 326 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 327 | * The list parameter is guaranteed to be the same as the one returned |
| 328 | * from the last call to (*prepare)(). |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 329 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 330 | * When this call returns the caller assumes that: |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 331 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 332 | * - the display will be updated in the near future with the content |
| 333 | * of the work list, without artifacts during the transition from the |
| 334 | * previous frame. |
| 335 | * |
| 336 | * - all objects are available for immediate access or destruction, in |
| 337 | * particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer. |
| 338 | * Note that this means that immediately accessing (potentially from a |
| 339 | * different process) a buffer used in this call will not result in |
| 340 | * screen corruption, the driver must apply proper synchronization or |
| 341 | * scheduling (eg: block the caller, such as gralloc_module_t::lock(), |
| 342 | * OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work |
| 343 | * after the buffer is freed from the actual composition). |
| 344 | * |
| 345 | * a NULL list parameter or a numHwLayers of zero indicates that the |
| 346 | * entire composition has been handled by SurfaceFlinger with OpenGL ES. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 347 | * In this case, (*set)() behaves just like eglSwapBuffers(). |
| 348 | * |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 349 | * dpy, sur, and list are set to NULL to indicate that the screen is |
| 350 | * turning off. This happens WITHOUT prepare() being called first. |
| 351 | * This is a good time to free h/w resources and/or power |
| 352 | * the relevant h/w blocks down. |
Mathias Agopian | 71212e3 | 2011-11-21 17:35:15 -0800 | [diff] [blame] | 353 | * |
Mathias Agopian | fb41036 | 2011-11-15 21:27:52 -0800 | [diff] [blame] | 354 | * IMPORTANT NOTE: there is an implicit layer containing opaque black |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 355 | * pixels behind all the layers in the list. |
| 356 | * It is the responsibility of the hwcomposer module to make |
| 357 | * sure black pixels are output (or blended from). |
Mathias Agopian | fb41036 | 2011-11-15 21:27:52 -0800 | [diff] [blame] | 358 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 359 | * returns: 0 on success. An negative error code on error: |
| 360 | * HWC_EGL_ERROR: eglGetError() will provide the proper error code |
| 361 | * Another code for non EGL errors. |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 362 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 363 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 364 | int (*set)(struct hwc_composer_device_1 *dev, |
Jesse Hall | 85ab59a | 2012-07-31 12:16:24 -0700 | [diff] [blame] | 365 | hwc_display_t dpy, |
| 366 | hwc_surface_t sur, |
| 367 | hwc_layer_list_1_t* list); |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 368 | |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 369 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 370 | * This field is OPTIONAL and can be NULL. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 371 | * |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 372 | * If non NULL it will be called by SurfaceFlinger on dumpsys |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 373 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 374 | void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 375 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 376 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 377 | * This field is OPTIONAL and can be NULL. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 378 | * |
| 379 | * (*registerProcs)() registers a set of callbacks the h/w composer HAL |
| 380 | * can later use. It is FORBIDDEN to call any of the callbacks from |
| 381 | * within registerProcs(). registerProcs() must save the hwc_procs_t pointer |
| 382 | * which is needed when calling a registered callback. |
| 383 | * Each call to registerProcs replaces the previous set of callbacks. |
| 384 | * registerProcs is called with NULL to unregister all callbacks. |
| 385 | * |
| 386 | * Any of the callbacks can be NULL, in which case the corresponding |
| 387 | * functionality is not supported. |
| 388 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 389 | void (*registerProcs)(struct hwc_composer_device_1* dev, |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 390 | hwc_procs_t const* procs); |
| 391 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 392 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 393 | * This field is OPTIONAL and can be NULL. |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 394 | * |
| 395 | * Used to retrieve information about the h/w composer |
| 396 | * |
| 397 | * Returns 0 on success or -errno on error. |
| 398 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 399 | int (*query)(struct hwc_composer_device_1* dev, int what, int* value); |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 400 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 401 | /* |
| 402 | * Reserved for future use. Must be NULL. |
| 403 | */ |
| 404 | void* reserved_proc[4]; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 405 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 406 | /* |
| 407 | * This field is OPTIONAL and can be NULL. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 408 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 409 | hwc_methods_1_t const *methods; |
Erik Gilling | e995204 | 2010-12-07 18:46:04 -0800 | [diff] [blame] | 410 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 411 | } hwc_composer_device_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 412 | |
| 413 | /** convenience API for opening and closing a device */ |
| 414 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 415 | static inline int hwc_open_1(const struct hw_module_t* module, |
| 416 | hwc_composer_device_1_t** device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 417 | return module->methods->open(module, |
| 418 | HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); |
| 419 | } |
| 420 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 421 | static inline int hwc_close_1(hwc_composer_device_1_t* device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 422 | return device->common.close(&device->common); |
| 423 | } |
| 424 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 425 | /*****************************************************************************/ |
| 426 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 427 | #if !HWC_REMOVE_DEPRECATED_VERSIONS |
| 428 | #include <hardware/hwcomposer_v0.h> |
| 429 | #endif |
| 430 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 431 | __END_DECLS |
| 432 | |
| 433 | #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ |