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 | /*****************************************************************************/ |
| 39 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 40 | /** |
| 41 | * The id of this module |
| 42 | */ |
| 43 | #define HWC_HARDWARE_MODULE_ID "hwcomposer" |
| 44 | |
| 45 | /** |
| 46 | * Name of the sensors device to open |
| 47 | */ |
| 48 | #define HWC_HARDWARE_COMPOSER "composer" |
| 49 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 50 | typedef struct hwc_rect { |
| 51 | int left; |
| 52 | int top; |
| 53 | int right; |
| 54 | int bottom; |
| 55 | } hwc_rect_t; |
| 56 | |
Mathias Agopian | 3b4732c | 2013-07-09 19:55:41 -0700 | [diff] [blame] | 57 | typedef struct hwc_frect { |
| 58 | float left; |
| 59 | float top; |
| 60 | float right; |
| 61 | float bottom; |
| 62 | } hwc_frect_t; |
| 63 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 64 | typedef struct hwc_region { |
| 65 | size_t numRects; |
| 66 | hwc_rect_t const* rects; |
| 67 | } hwc_region_t; |
| 68 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 69 | typedef struct hwc_color { |
| 70 | uint8_t r; |
| 71 | uint8_t g; |
| 72 | uint8_t b; |
| 73 | uint8_t a; |
| 74 | } hwc_color_t; |
| 75 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 76 | typedef struct hwc_layer_1 { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 77 | /* |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 78 | * compositionType is used to specify this layer's type and is set by either |
| 79 | * the hardware composer implementation, or by the caller (see below). |
Jesse Hall | d18c83f | 2012-08-16 16:21:13 -0700 | [diff] [blame] | 80 | * |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 81 | * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER |
| 82 | * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is |
| 83 | * also set, otherwise, this field is preserved between (*prepare)() |
| 84 | * calls. |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 85 | * |
| 86 | * HWC_BACKGROUND |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 87 | * Always set by the caller before calling (*prepare)(), this value |
| 88 | * indicates this is a special "background" layer. The only valid field |
| 89 | * is backgroundColor. |
| 90 | * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT |
| 91 | * handle the background color. |
| 92 | * |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 93 | * |
Jesse Hall | d18c83f | 2012-08-16 16:21:13 -0700 | [diff] [blame] | 94 | * HWC_FRAMEBUFFER_TARGET |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 95 | * Always set by the caller before calling (*prepare)(), this value |
| 96 | * indicates this layer is the framebuffer surface used as the target of |
Jesse Hall | d18c83f | 2012-08-16 16:21:13 -0700 | [diff] [blame] | 97 | * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY |
| 98 | * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and |
Jesse Hall | 6b01e2e | 2012-09-14 17:21:22 -0700 | [diff] [blame] | 99 | * this layer should be ignored during set(). |
Jesse Hall | d18c83f | 2012-08-16 16:21:13 -0700 | [diff] [blame] | 100 | * |
| 101 | * This flag (and the framebuffer surface layer) will only be used if the |
| 102 | * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, |
| 103 | * the OpenGL ES target surface is communicated by the (dpy, sur) fields |
| 104 | * in hwc_compositor_device_1_t. |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 105 | * |
| 106 | * This value cannot be set by the HWC implementation. |
| 107 | * |
| 108 | * |
| 109 | * HWC_FRAMEBUFFER |
| 110 | * Set by the caller before calling (*prepare)() ONLY when the |
| 111 | * HWC_GEOMETRY_CHANGED flag is also set. |
| 112 | * |
| 113 | * Set by the HWC implementation during (*prepare)(), this indicates |
| 114 | * that the layer will be drawn into the framebuffer using OpenGL ES. |
| 115 | * The HWC can toggle this value to HWC_OVERLAY to indicate it will |
| 116 | * handle the layer. |
| 117 | * |
| 118 | * |
| 119 | * HWC_OVERLAY |
| 120 | * Set by the HWC implementation during (*prepare)(), this indicates |
| 121 | * that the layer will be handled by the HWC (ie: it must not be |
| 122 | * composited with OpenGL ES). |
| 123 | * |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 124 | * |
| 125 | * HWC_SIDEBAND |
| 126 | * Set by the caller before calling (*prepare)(), this value indicates |
| 127 | * the contents of this layer come from a sideband video stream. |
| 128 | * |
| 129 | * The h/w composer is responsible for receiving new image buffers from |
| 130 | * the stream at the appropriate time (e.g. synchronized to a separate |
| 131 | * audio stream), compositing them with the current contents of other |
| 132 | * layers, and displaying the resulting image. This happens |
| 133 | * independently of the normal prepare/set cycle. The prepare/set calls |
| 134 | * only happen when other layers change, or when properties of the |
| 135 | * sideband layer such as position or size change. |
| 136 | * |
| 137 | * If the h/w composer can't handle the layer as a sideband stream for |
| 138 | * some reason (e.g. unsupported scaling/blending/rotation, or too many |
| 139 | * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in |
| 140 | * (*prepare)(). However, doing so will result in the layer being shown |
| 141 | * as a solid color since the platform is not currently able to composite |
| 142 | * sideband layers with the GPU. This may be improved in future |
| 143 | * versions of the platform. |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 144 | * |
| 145 | * |
| 146 | * HWC_CURSOR_OVERLAY |
| 147 | * Set by the HWC implementation during (*prepare)(), this value |
| 148 | * indicates the layer's composition will now be handled by the HWC. |
| 149 | * Additionally, the client can now asynchronously update the on-screen |
| 150 | * position of this layer using the setCursorPositionAsync() api. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 151 | */ |
| 152 | int32_t compositionType; |
| 153 | |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 154 | /* |
| 155 | * hints is bit mask set by the HWC implementation during (*prepare)(). |
| 156 | * It is preserved between (*prepare)() calls, unless the |
| 157 | * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. |
| 158 | * |
| 159 | * see hwc_layer_t::hints |
| 160 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 161 | uint32_t hints; |
| 162 | |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 163 | /* see hwc_layer_t::flags */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 164 | uint32_t flags; |
| 165 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 166 | union { |
| 167 | /* color of the background. hwc_color_t.a is ignored */ |
| 168 | hwc_color_t backgroundColor; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 169 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 170 | struct { |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 171 | union { |
| 172 | /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, |
| 173 | * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to |
| 174 | * compose. This handle is guaranteed to have been allocated |
| 175 | * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. |
| 176 | * If the layer's handle is unchanged across two consecutive |
| 177 | * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set |
| 178 | * for the second call then the HWComposer implementation may |
| 179 | * assume that the contents of the buffer have not changed. */ |
| 180 | buffer_handle_t handle; |
| 181 | |
| 182 | /* When compositionType is HWC_SIDEBAND, this is the handle |
| 183 | * of the sideband video stream to compose. */ |
| 184 | const native_handle_t* sidebandStream; |
| 185 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 186 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 187 | /* transformation to apply to the buffer during composition */ |
| 188 | uint32_t transform; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 189 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 190 | /* blending to apply during composition */ |
| 191 | int32_t blending; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 192 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 193 | /* area of the source to consider, the origin is the top-left corner of |
Mathias Agopian | 3b4732c | 2013-07-09 19:55:41 -0700 | [diff] [blame] | 194 | * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. |
| 195 | * If the h/w can't support a non-integer source crop rectangle, it should |
| 196 | * punt to OpenGL ES composition. |
| 197 | */ |
| 198 | union { |
| 199 | // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) |
| 200 | hwc_rect_t sourceCropi; |
| 201 | hwc_rect_t sourceCrop; // just for source compatibility |
| 202 | // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) |
| 203 | hwc_frect_t sourceCropf; |
| 204 | }; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 205 | |
| 206 | /* where to composite the sourceCrop onto the display. The sourceCrop |
| 207 | * is scaled using linear filtering to the displayFrame. The origin is the |
| 208 | * top-left corner of the screen. |
| 209 | */ |
| 210 | hwc_rect_t displayFrame; |
| 211 | |
| 212 | /* visible region in screen space. The origin is the |
| 213 | * top-left corner of the screen. |
| 214 | * The visible region INCLUDES areas overlapped by a translucent layer. |
| 215 | */ |
| 216 | hwc_region_t visibleRegionScreen; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 217 | |
| 218 | /* Sync fence object that will be signaled when the buffer's |
| 219 | * contents are available. May be -1 if the contents are already |
| 220 | * available. This field is only valid during set(), and should be |
| 221 | * ignored during prepare(). The set() call must not wait for the |
| 222 | * fence to be signaled before returning, but the HWC must wait for |
| 223 | * all buffers to be signaled before reading from them. |
| 224 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 225 | * HWC_FRAMEBUFFER layers will never have an acquire fence, since |
| 226 | * reads from them are complete before the framebuffer is ready for |
| 227 | * display. |
| 228 | * |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 229 | * HWC_SIDEBAND layers will never have an acquire fence, since |
| 230 | * synchronization is handled through implementation-defined |
| 231 | * sideband mechanisms. |
| 232 | * |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 233 | * The HWC takes ownership of the acquireFenceFd and is responsible |
| 234 | * for closing it when no longer needed. |
| 235 | */ |
| 236 | int acquireFenceFd; |
| 237 | |
| 238 | /* During set() the HWC must set this field to a file descriptor for |
| 239 | * a sync fence object that will signal after the HWC has finished |
| 240 | * reading from the buffer. The field is ignored by prepare(). Each |
| 241 | * layer should have a unique file descriptor, even if more than one |
| 242 | * refer to the same underlying fence object; this allows each to be |
| 243 | * closed independently. |
| 244 | * |
| 245 | * If buffer reads can complete at significantly different times, |
| 246 | * then using independent fences is preferred. For example, if the |
| 247 | * HWC handles some layers with a blit engine and others with |
| 248 | * overlays, then the blit layers can be reused immediately after |
| 249 | * the blit completes, but the overlay layers can't be reused until |
| 250 | * a subsequent frame has been displayed. |
| 251 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 252 | * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't |
| 253 | * produce a release fence for them. The releaseFenceFd will be -1 |
| 254 | * for these layers when set() is called. |
| 255 | * |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 256 | * Since HWC_SIDEBAND buffers don't pass through the HWC client, |
| 257 | * the HWC shouldn't produce a release fence for them. The |
| 258 | * releaseFenceFd will be -1 for these layers when set() is called. |
| 259 | * |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 260 | * The HWC client taks ownership of the releaseFenceFd and is |
| 261 | * responsible for closing it when no longer needed. |
| 262 | */ |
| 263 | int releaseFenceFd; |
Mathias Agopian | e3e0a57 | 2013-01-29 18:57:48 -0800 | [diff] [blame] | 264 | |
| 265 | /* |
| 266 | * Availability: HWC_DEVICE_API_VERSION_1_2 |
| 267 | * |
| 268 | * Alpha value applied to the whole layer. The effective |
| 269 | * value of each pixel is computed as: |
| 270 | * |
| 271 | * if (blending == HWC_BLENDING_PREMULT) |
| 272 | * pixel.rgb = pixel.rgb * planeAlpha / 255 |
| 273 | * pixel.a = pixel.a * planeAlpha / 255 |
| 274 | * |
| 275 | * Then blending proceeds as usual according to the "blending" |
| 276 | * field above. |
| 277 | * |
| 278 | * NOTE: planeAlpha applies to YUV layers as well: |
| 279 | * |
| 280 | * pixel.rgb = yuv_to_rgb(pixel.yuv) |
| 281 | * if (blending == HWC_BLENDING_PREMULT) |
| 282 | * pixel.rgb = pixel.rgb * planeAlpha / 255 |
| 283 | * pixel.a = planeAlpha |
| 284 | * |
| 285 | * |
| 286 | * IMPLEMENTATION NOTE: |
| 287 | * |
| 288 | * If the source image doesn't have an alpha channel, then |
| 289 | * the h/w can use the HWC_BLENDING_COVERAGE equations instead of |
| 290 | * HWC_BLENDING_PREMULT and simply set the alpha channel to |
| 291 | * planeAlpha. |
| 292 | * |
| 293 | * e.g.: |
| 294 | * |
| 295 | * if (blending == HWC_BLENDING_PREMULT) |
| 296 | * blending = HWC_BLENDING_COVERAGE; |
| 297 | * pixel.a = planeAlpha; |
| 298 | * |
| 299 | */ |
| 300 | uint8_t planeAlpha; |
| 301 | |
Dan Stoza | 811445a | 2015-02-12 10:11:21 -0800 | [diff] [blame^] | 302 | /* Pad to 32 bits */ |
Mathias Agopian | e3e0a57 | 2013-01-29 18:57:48 -0800 | [diff] [blame] | 303 | uint8_t _pad[3]; |
Dan Stoza | 811445a | 2015-02-12 10:11:21 -0800 | [diff] [blame^] | 304 | |
| 305 | /* |
| 306 | * Availability: HWC_DEVICE_API_VERSION_1_5 |
| 307 | * |
| 308 | * This defines the region of the source buffer that has been |
| 309 | * modified since the last frame. |
| 310 | * |
| 311 | * If surfaceDamage.numRects > 0, then it may be assumed that any |
| 312 | * portion of the source buffer not covered by one of the rects has |
| 313 | * not been modified this frame. If surfaceDamage.numRects == 0, |
| 314 | * then the whole source buffer must be treated as if it had been |
| 315 | * modified. |
| 316 | * |
| 317 | * If the layer's contents are not modified relative to the prior |
| 318 | * prepare/set cycle, surfaceDamage will contain exactly one empty |
| 319 | * rect ([0, 0, 0, 0]). |
| 320 | * |
| 321 | * The damage rects are relative to the pre-transformed buffer, and |
| 322 | * their origin is the top-left corner. |
| 323 | */ |
| 324 | hwc_region_t surfaceDamage; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 325 | }; |
| 326 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 327 | |
Dan Stoza | 91699a8 | 2014-06-04 15:21:22 -0700 | [diff] [blame] | 328 | #ifdef __LP64__ |
| 329 | /* |
| 330 | * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs |
| 331 | * to be padded as such to maintain binary compatibility. |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 332 | */ |
Dan Stoza | 811445a | 2015-02-12 10:11:21 -0800 | [diff] [blame^] | 333 | uint8_t reserved[120 - 112]; |
Dan Stoza | 91699a8 | 2014-06-04 15:21:22 -0700 | [diff] [blame] | 334 | #else |
| 335 | /* |
| 336 | * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such |
| 337 | * to maintain binary compatibility. |
| 338 | */ |
Dan Stoza | 811445a | 2015-02-12 10:11:21 -0800 | [diff] [blame^] | 339 | uint8_t reserved[96 - 84]; |
Dan Stoza | 91699a8 | 2014-06-04 15:21:22 -0700 | [diff] [blame] | 340 | #endif |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 341 | |
| 342 | } hwc_layer_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 343 | |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 344 | /* This represents a display, typically an EGLDisplay object */ |
| 345 | typedef void* hwc_display_t; |
| 346 | |
| 347 | /* This represents a surface, typically an EGLSurface object */ |
| 348 | typedef void* hwc_surface_t; |
| 349 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 350 | /* |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 351 | * hwc_display_contents_1_t::flags values |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 352 | */ |
| 353 | enum { |
| 354 | /* |
| 355 | * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 356 | * passed to (*prepare)() has changed by more than just the buffer handles |
| 357 | * and acquire fences. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 358 | */ |
| 359 | HWC_GEOMETRY_CHANGED = 0x00000001, |
| 360 | }; |
| 361 | |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 362 | /* |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 363 | * Description of the contents to output on a display. |
| 364 | * |
| 365 | * This is the top-level structure passed to the prepare and set calls to |
| 366 | * negotiate and commit the composition of a display image. |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 367 | */ |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 368 | typedef struct hwc_display_contents_1 { |
| 369 | /* File descriptor referring to a Sync HAL fence object which will signal |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 370 | * when this composition is retired. For a physical display, a composition |
| 371 | * is retired when it has been replaced on-screen by a subsequent set. For |
| 372 | * a virtual display, the composition is retired when the writes to |
| 373 | * outputBuffer are complete and can be read. The fence object is created |
| 374 | * and returned by the set call; this field will be -1 on entry to prepare |
| 375 | * and set. SurfaceFlinger will close the returned file descriptor. |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 376 | */ |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 377 | int retireFenceFd; |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 378 | |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 379 | union { |
| 380 | /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ |
| 381 | struct { |
| 382 | /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES |
| 383 | * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to |
| 384 | * prepare. The set call should commit this surface atomically to |
| 385 | * the display along with any overlay layers. |
| 386 | */ |
| 387 | hwc_display_t dpy; |
| 388 | hwc_surface_t sur; |
| 389 | }; |
| 390 | |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 391 | /* These fields are used for virtual displays when the h/w composer |
| 392 | * version is at least HWC_DEVICE_VERSION_1_3. */ |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 393 | struct { |
| 394 | /* outbuf is the buffer that receives the composed image for |
| 395 | * virtual displays. Writes to the outbuf must wait until |
| 396 | * outbufAcquireFenceFd signals. A fence that will signal when |
| 397 | * writes to outbuf are complete should be returned in |
| 398 | * retireFenceFd. |
| 399 | * |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 400 | * This field is set before prepare(), so properties of the buffer |
| 401 | * can be used to decide which layers can be handled by h/w |
| 402 | * composer. |
Jesse Hall | 380f45d | 2013-03-20 10:11:10 -0700 | [diff] [blame] | 403 | * |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 404 | * If prepare() sets all layers to FRAMEBUFFER, then GLES |
| 405 | * composition will happen directly to the output buffer. In this |
| 406 | * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will |
| 407 | * be the same, and set() has no work to do besides managing fences. |
| 408 | * |
| 409 | * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config |
| 410 | * variable is defined (not the default), then this behavior is |
| 411 | * changed: if all layers are marked for FRAMEBUFFER, GLES |
| 412 | * composition will take place to a scratch framebuffer, and |
| 413 | * h/w composer must copy it to the output buffer. This allows the |
| 414 | * h/w composer to do format conversion if there are cases where |
| 415 | * that is more desirable than doing it in the GLES driver or at the |
| 416 | * virtual display consumer. |
| 417 | * |
| 418 | * If some or all layers are marked OVERLAY, then the framebuffer |
| 419 | * and output buffer will be different. As with physical displays, |
| 420 | * the framebuffer handle will not change between frames if all |
| 421 | * layers are marked for OVERLAY. |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 422 | */ |
| 423 | buffer_handle_t outbuf; |
| 424 | |
| 425 | /* File descriptor for a fence that will signal when outbuf is |
| 426 | * ready to be written. The h/w composer is responsible for closing |
| 427 | * this when no longer needed. |
| 428 | * |
| 429 | * Will be -1 whenever outbuf is NULL, or when the outbuf can be |
| 430 | * written immediately. |
| 431 | */ |
| 432 | int outbufAcquireFenceFd; |
| 433 | }; |
| 434 | }; |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 435 | |
| 436 | /* List of layers that will be composed on the display. The buffer handles |
Jesse Hall | ac3f7e1 | 2012-07-31 15:18:32 -0700 | [diff] [blame] | 437 | * in the list will be unique. If numHwLayers is 0, all composition will be |
| 438 | * performed by SurfaceFlinger. |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 439 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 440 | uint32_t flags; |
| 441 | size_t numHwLayers; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 442 | hwc_layer_1_t hwLayers[0]; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 443 | |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 444 | } hwc_display_contents_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 445 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 446 | /* see hwc_composer_device::registerProcs() |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 447 | * All of the callbacks are required and non-NULL unless otherwise noted. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 448 | */ |
| 449 | typedef struct hwc_procs { |
| 450 | /* |
| 451 | * (*invalidate)() triggers a screen refresh, in particular prepare and set |
| 452 | * will be called shortly after this call is made. Note that there is |
| 453 | * NO GUARANTEE that the screen refresh will happen after invalidate() |
| 454 | * returns (in particular, it could happen before). |
| 455 | * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and |
| 456 | * it is safe to call invalidate() from any of hwc_composer_device |
| 457 | * hooks, unless noted otherwise. |
| 458 | */ |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 459 | void (*invalidate)(const struct hwc_procs* procs); |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 460 | |
| 461 | /* |
| 462 | * (*vsync)() is called by the h/w composer HAL when a vsync event is |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 463 | * received and HWC_EVENT_VSYNC is enabled on a display |
| 464 | * (see: hwc_event_control). |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 465 | * |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 466 | * the "disp" parameter indicates which display the vsync event is for. |
Jamie Gennis | 6b7adef | 2012-04-30 12:57:11 -0700 | [diff] [blame] | 467 | * the "timestamp" parameter is the system monotonic clock timestamp in |
| 468 | * nanosecond of when the vsync event happened. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 469 | * |
| 470 | * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. |
| 471 | * |
| 472 | * 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] | 473 | * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 474 | * typically less than 0.5 ms. |
| 475 | * |
Mathias Agopian | 6d3fec7 | 2012-04-10 21:22:28 -0700 | [diff] [blame] | 476 | * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling |
| 477 | * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation |
| 478 | * can either stop or continue to process VSYNC events, but must not |
| 479 | * crash or cause other problems. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 480 | */ |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 481 | void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); |
| 482 | |
| 483 | /* |
| 484 | * (*hotplug)() is called by the h/w composer HAL when a display is |
| 485 | * connected or disconnected. The PRIMARY display is always connected and |
| 486 | * the hotplug callback should not be called for it. |
| 487 | * |
| 488 | * The disp parameter indicates which display type this event is for. |
| 489 | * The connected parameter indicates whether the display has just been |
| 490 | * connected (1) or disconnected (0). |
| 491 | * |
| 492 | * The hotplug() callback may call back into the h/w composer on the same |
| 493 | * thread to query refresh rate and dpi for the display. Additionally, |
| 494 | * other threads may be calling into the h/w composer while the callback |
| 495 | * is in progress. |
| 496 | * |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 497 | * The h/w composer must serialize calls to the hotplug callback; only |
| 498 | * one thread may call it at a time. |
| 499 | * |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 500 | * This callback will be NULL if the h/w composer is using |
| 501 | * HWC_DEVICE_API_VERSION_1_0. |
| 502 | */ |
| 503 | void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); |
| 504 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 505 | } hwc_procs_t; |
| 506 | |
| 507 | |
| 508 | /*****************************************************************************/ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 509 | |
| 510 | typedef struct hwc_module { |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame] | 511 | /** |
| 512 | * Common methods of the hardware composer module. This *must* be the first member of |
| 513 | * hwc_module as users of this structure will cast a hw_module_t to |
| 514 | * hwc_module pointer in contexts where it's known the hw_module_t references a |
| 515 | * hwc_module. |
| 516 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 517 | struct hw_module_t common; |
| 518 | } hwc_module_t; |
| 519 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 520 | typedef struct hwc_composer_device_1 { |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame] | 521 | /** |
| 522 | * Common methods of the hardware composer device. This *must* be the first member of |
| 523 | * hwc_composer_device_1 as users of this structure will cast a hw_device_t to |
| 524 | * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a |
| 525 | * hwc_composer_device_1. |
| 526 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 527 | struct hw_device_t common; |
| 528 | |
| 529 | /* |
| 530 | * (*prepare)() is called for each frame before composition and is used by |
| 531 | * SurfaceFlinger to determine what composition steps the HWC can handle. |
| 532 | * |
| 533 | * (*prepare)() can be called more than once, the last call prevails. |
| 534 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 535 | * The HWC responds by setting the compositionType field in each layer to |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 536 | * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the |
| 537 | * HWC_FRAMEBUFFER type, composition for the layer is handled by |
| 538 | * SurfaceFlinger with OpenGL ES. For the latter two overlay types, |
| 539 | * the HWC will have to handle the layer's composition. compositionType |
| 540 | * and hints are preserved between (*prepare)() calles unless the |
| 541 | * HWC_GEOMETRY_CHANGED flag is set. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 542 | * |
| 543 | * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the |
| 544 | * list's geometry has changed, that is, when more than just the buffer's |
| 545 | * handles have been updated. Typically this happens (but is not limited to) |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 546 | * when a window is added, removed, resized or moved. In this case |
| 547 | * compositionType and hints are reset to their default value. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 548 | * |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 549 | * For HWC 1.0, numDisplays will always be one, and displays[0] will be |
| 550 | * non-NULL. |
| 551 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 552 | * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. |
| 553 | * Entries for unsupported or disabled/disconnected display types will be |
| 554 | * NULL. |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 555 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 556 | * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra |
| 557 | * entries correspond to enabled virtual displays, and will be non-NULL. |
Jesse Hall | ac3f7e1 | 2012-07-31 15:18:32 -0700 | [diff] [blame] | 558 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 559 | * returns: 0 on success. An negative error code on error. If an error is |
| 560 | * returned, SurfaceFlinger will assume that none of the layer will be |
| 561 | * handled by the HWC. |
| 562 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 563 | int (*prepare)(struct hwc_composer_device_1 *dev, |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 564 | size_t numDisplays, hwc_display_contents_1_t** displays); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 565 | |
| 566 | /* |
| 567 | * (*set)() is used in place of eglSwapBuffers(), and assumes the same |
| 568 | * functionality, except it also commits the work list atomically with |
| 569 | * the actual eglSwapBuffers(). |
| 570 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 571 | * The layer lists are guaranteed to be the same as the ones returned from |
| 572 | * the last call to (*prepare)(). |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 573 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 574 | * When this call returns the caller assumes that the displays will be |
| 575 | * updated in the near future with the content of their work lists, without |
| 576 | * artifacts during the transition from the previous frame. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 577 | * |
Jesse Hall | ac3f7e1 | 2012-07-31 15:18:32 -0700 | [diff] [blame] | 578 | * A display with zero layers indicates that the entire composition has |
| 579 | * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() |
| 580 | * behaves just like eglSwapBuffers(). |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 581 | * |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 582 | * For HWC 1.0, numDisplays will always be one, and displays[0] will be |
| 583 | * non-NULL. |
| 584 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 585 | * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. |
| 586 | * Entries for unsupported or disabled/disconnected display types will be |
| 587 | * NULL. |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 588 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 589 | * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra |
| 590 | * entries correspond to enabled virtual displays, and will be non-NULL. |
Mathias Agopian | 71212e3 | 2011-11-21 17:35:15 -0800 | [diff] [blame] | 591 | * |
Jamie Gennis | c754518 | 2012-10-08 19:23:56 -0700 | [diff] [blame] | 592 | * IMPORTANT NOTE: There is an implicit layer containing opaque black |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 593 | * pixels behind all the layers in the list. It is the responsibility of |
| 594 | * the hwcomposer module to make sure black pixels are output (or blended |
| 595 | * from). |
Mathias Agopian | fb41036 | 2011-11-15 21:27:52 -0800 | [diff] [blame] | 596 | * |
Jamie Gennis | c754518 | 2012-10-08 19:23:56 -0700 | [diff] [blame] | 597 | * IMPORTANT NOTE: In the event of an error this call *MUST* still cause |
| 598 | * any fences returned in the previous call to set to eventually become |
| 599 | * signaled. The caller may have already issued wait commands on these |
| 600 | * fences, and having set return without causing those fences to signal |
| 601 | * will likely result in a deadlock. |
| 602 | * |
| 603 | * returns: 0 on success. A negative error code on error: |
| 604 | * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only |
| 605 | * allowed prior to HWComposer 1.1) |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 606 | * Another code for non EGL errors. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 607 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 608 | int (*set)(struct hwc_composer_device_1 *dev, |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 609 | size_t numDisplays, hwc_display_contents_1_t** displays); |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 610 | |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 611 | /* |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 612 | * eventControl(..., event, enabled) |
| 613 | * Enables or disables h/w composer events for a display. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 614 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 615 | * eventControl can be called from any thread and takes effect |
| 616 | * immediately. |
| 617 | * |
| 618 | * Supported events are: |
| 619 | * HWC_EVENT_VSYNC |
| 620 | * |
| 621 | * returns -EINVAL if the "event" parameter is not one of the value above |
| 622 | * or if the "enabled" parameter is not 0 or 1. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 623 | */ |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 624 | int (*eventControl)(struct hwc_composer_device_1* dev, int disp, |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 625 | int event, int enabled); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 626 | |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 627 | union { |
| 628 | /* |
| 629 | * For HWC 1.3 and earlier, the blank() interface is used. |
| 630 | * |
| 631 | * blank(..., blank) |
| 632 | * Blanks or unblanks a display's screen. |
| 633 | * |
| 634 | * Turns the screen off when blank is nonzero, on when blank is zero. |
| 635 | * Multiple sequential calls with the same blank value must be |
| 636 | * supported. |
| 637 | * The screen state transition must be be complete when the function |
| 638 | * returns. |
| 639 | * |
| 640 | * returns 0 on success, negative on error. |
| 641 | */ |
| 642 | int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); |
| 643 | |
| 644 | /* |
| 645 | * For HWC 1.4 and above, setPowerMode() will be used in place of |
| 646 | * blank(). |
| 647 | * |
| 648 | * setPowerMode(..., mode) |
| 649 | * Sets the display screen's power state. |
| 650 | * |
Jeff Brown | 842b906 | 2014-07-17 20:01:59 -0700 | [diff] [blame] | 651 | * Refer to the documentation of the HWC_POWER_MODE_* constants |
| 652 | * for information about each power mode. |
Prashant Malani | 02b3198 | 2014-05-25 20:41:20 -0700 | [diff] [blame] | 653 | * |
| 654 | * The functionality is similar to the blank() command in previous |
| 655 | * versions of HWC, but with support for more power states. |
| 656 | * |
| 657 | * The display driver is expected to retain and restore the low power |
| 658 | * state of the display while entering and exiting from suspend. |
| 659 | * |
| 660 | * Multiple sequential calls with the same mode value must be supported. |
| 661 | * |
| 662 | * The screen state transition must be be complete when the function |
| 663 | * returns. |
| 664 | * |
| 665 | * returns 0 on success, negative on error. |
| 666 | */ |
| 667 | int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, |
| 668 | int mode); |
| 669 | }; |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 670 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 671 | /* |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 672 | * Used to retrieve information about the h/w composer |
| 673 | * |
| 674 | * Returns 0 on success or -errno on error. |
| 675 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 676 | int (*query)(struct hwc_composer_device_1* dev, int what, int* value); |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 677 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 678 | /* |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 679 | * (*registerProcs)() registers callbacks that the h/w composer HAL can |
| 680 | * later use. It will be called immediately after the composer device is |
| 681 | * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks |
| 682 | * from within registerProcs(). registerProcs() must save the hwc_procs_t |
| 683 | * pointer which is needed when calling a registered callback. |
| 684 | */ |
| 685 | void (*registerProcs)(struct hwc_composer_device_1* dev, |
| 686 | hwc_procs_t const* procs); |
| 687 | |
| 688 | /* |
| 689 | * This field is OPTIONAL and can be NULL. |
| 690 | * |
| 691 | * If non NULL it will be called by SurfaceFlinger on dumpsys |
| 692 | */ |
| 693 | void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); |
| 694 | |
| 695 | /* |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 696 | * (*getDisplayConfigs)() returns handles for the configurations available |
| 697 | * on the connected display. These handles must remain valid as long as the |
| 698 | * display is connected. |
| 699 | * |
| 700 | * Configuration handles are written to configs. The number of entries |
| 701 | * allocated by the caller is passed in *numConfigs; getDisplayConfigs must |
| 702 | * not try to write more than this number of config handles. On return, the |
| 703 | * total number of configurations available for the display is returned in |
| 704 | * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. |
| 705 | * |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 706 | * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior |
| 707 | * shall choose one configuration to activate and report it as the first |
| 708 | * entry in the returned list. Reporting the inactive configurations is not |
| 709 | * required. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 710 | * |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 711 | * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management |
| 712 | * through SurfaceFlinger, and hardware composers implementing these APIs |
| 713 | * must also provide getActiveConfig and setActiveConfig. Hardware composers |
| 714 | * implementing these API versions may choose not to activate any |
| 715 | * configuration, leaving configuration selection to higher levels of the |
| 716 | * framework. |
| 717 | * |
| 718 | * Returns 0 on success or a negative error code on error. If disp is a |
| 719 | * hotpluggable display type and no display is connected, an error shall be |
| 720 | * returned. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 721 | * |
| 722 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 723 | * It shall be NULL for previous versions. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 724 | */ |
| 725 | int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, |
| 726 | uint32_t* configs, size_t* numConfigs); |
| 727 | |
| 728 | /* |
| 729 | * (*getDisplayAttributes)() returns attributes for a specific config of a |
| 730 | * connected display. The config parameter is one of the config handles |
| 731 | * returned by getDisplayConfigs. |
| 732 | * |
| 733 | * The list of attributes to return is provided in the attributes |
| 734 | * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each |
| 735 | * requested attribute is written in order to the values array. The |
| 736 | * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values |
| 737 | * array will have one less value than the attributes array. |
| 738 | * |
| 739 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 740 | * It shall be NULL for previous versions. |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 741 | * |
| 742 | * If disp is a hotpluggable display type and no display is connected, |
| 743 | * or if config is not a valid configuration for the display, a negative |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 744 | * error code shall be returned. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 745 | */ |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 746 | int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 747 | uint32_t config, const uint32_t* attributes, int32_t* values); |
| 748 | |
| 749 | /* |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 750 | * (*getActiveConfig)() returns the index of the configuration that is |
| 751 | * currently active on the connected display. The index is relative to |
| 752 | * the list of configuration handles returned by getDisplayConfigs. If there |
| 753 | * is no active configuration, -1 shall be returned. |
| 754 | * |
| 755 | * Returns the configuration index on success or -1 on error. |
| 756 | * |
| 757 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. |
| 758 | * It shall be NULL for previous versions. |
| 759 | */ |
| 760 | int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); |
| 761 | |
| 762 | /* |
| 763 | * (*setActiveConfig)() instructs the hardware composer to switch to the |
| 764 | * display configuration at the given index in the list of configuration |
| 765 | * handles returned by getDisplayConfigs. |
| 766 | * |
| 767 | * If this function returns without error, any subsequent calls to |
| 768 | * getActiveConfig shall return the index set by this function until one |
| 769 | * of the following occurs: |
| 770 | * 1) Another successful call of this function |
| 771 | * 2) The display is disconnected |
| 772 | * |
| 773 | * Returns 0 on success or a negative error code on error. If disp is a |
| 774 | * hotpluggable display type and no display is connected, or if index is |
| 775 | * outside of the range of hardware configurations returned by |
| 776 | * getDisplayConfigs, an error shall be returned. |
| 777 | * |
| 778 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. |
| 779 | * It shall be NULL for previous versions. |
| 780 | */ |
| 781 | int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, |
| 782 | int index); |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 783 | /* |
| 784 | * Asynchronously update the location of the cursor layer. |
| 785 | * |
| 786 | * Within the standard prepare()/set() composition loop, the client |
| 787 | * (surfaceflinger) can request that a given layer uses dedicated cursor |
| 788 | * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only |
| 789 | * one layer per display can have this flag set. If the layer is suitable |
| 790 | * for the platform's cursor hardware, hwcomposer will return from prepare() |
| 791 | * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates |
| 792 | * not only that the client is not responsible for compositing that layer, |
| 793 | * but also that the client can continue to update the position of that layer |
| 794 | * after a call to set(). This can reduce the visible latency of mouse |
| 795 | * movement to visible, on-screen cursor updates. Calls to |
| 796 | * setCursorPositionAsync() may be made from a different thread doing the |
| 797 | * prepare()/set() composition loop, but care must be taken to not interleave |
| 798 | * calls of setCursorPositionAsync() between calls of set()/prepare(). |
| 799 | * |
| 800 | * Notes: |
| 801 | * - Only one layer per display can be specified as a cursor layer with |
| 802 | * HWC_IS_CURSOR_LAYER. |
| 803 | * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY |
| 804 | * - This returns 0 on success or -errno on error. |
| 805 | * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It |
| 806 | * should be null for previous versions. |
| 807 | */ |
| 808 | int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); |
Dan Stoza | e83d10c | 2014-05-06 15:56:59 -0700 | [diff] [blame] | 809 | |
| 810 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 811 | * Reserved for future use. Must be NULL. |
| 812 | */ |
Riley Andrews | 4a6788b | 2014-06-30 15:55:55 -0700 | [diff] [blame] | 813 | void* reserved_proc[1]; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 814 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 815 | } hwc_composer_device_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 816 | |
| 817 | /** convenience API for opening and closing a device */ |
| 818 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 819 | static inline int hwc_open_1(const struct hw_module_t* module, |
| 820 | hwc_composer_device_1_t** device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 821 | return module->methods->open(module, |
| 822 | HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); |
| 823 | } |
| 824 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 825 | static inline int hwc_close_1(hwc_composer_device_1_t* device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 826 | return device->common.close(&device->common); |
| 827 | } |
| 828 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 829 | /*****************************************************************************/ |
| 830 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 831 | __END_DECLS |
| 832 | |
| 833 | #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ |