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. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 144 | */ |
| 145 | int32_t compositionType; |
| 146 | |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 147 | /* |
| 148 | * hints is bit mask set by the HWC implementation during (*prepare)(). |
| 149 | * It is preserved between (*prepare)() calls, unless the |
| 150 | * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. |
| 151 | * |
| 152 | * see hwc_layer_t::hints |
| 153 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 154 | uint32_t hints; |
| 155 | |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 156 | /* see hwc_layer_t::flags */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 157 | uint32_t flags; |
| 158 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 159 | union { |
| 160 | /* color of the background. hwc_color_t.a is ignored */ |
| 161 | hwc_color_t backgroundColor; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 162 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 163 | struct { |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 164 | union { |
| 165 | /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, |
| 166 | * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to |
| 167 | * compose. This handle is guaranteed to have been allocated |
| 168 | * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. |
| 169 | * If the layer's handle is unchanged across two consecutive |
| 170 | * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set |
| 171 | * for the second call then the HWComposer implementation may |
| 172 | * assume that the contents of the buffer have not changed. */ |
| 173 | buffer_handle_t handle; |
| 174 | |
| 175 | /* When compositionType is HWC_SIDEBAND, this is the handle |
| 176 | * of the sideband video stream to compose. */ |
| 177 | const native_handle_t* sidebandStream; |
| 178 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 179 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 180 | /* transformation to apply to the buffer during composition */ |
| 181 | uint32_t transform; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 182 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 183 | /* blending to apply during composition */ |
| 184 | int32_t blending; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 185 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 186 | /* 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] | 187 | * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. |
| 188 | * If the h/w can't support a non-integer source crop rectangle, it should |
| 189 | * punt to OpenGL ES composition. |
| 190 | */ |
| 191 | union { |
| 192 | // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) |
| 193 | hwc_rect_t sourceCropi; |
| 194 | hwc_rect_t sourceCrop; // just for source compatibility |
| 195 | // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) |
| 196 | hwc_frect_t sourceCropf; |
| 197 | }; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 198 | |
| 199 | /* where to composite the sourceCrop onto the display. The sourceCrop |
| 200 | * is scaled using linear filtering to the displayFrame. The origin is the |
| 201 | * top-left corner of the screen. |
| 202 | */ |
| 203 | hwc_rect_t displayFrame; |
| 204 | |
| 205 | /* visible region in screen space. The origin is the |
| 206 | * top-left corner of the screen. |
| 207 | * The visible region INCLUDES areas overlapped by a translucent layer. |
| 208 | */ |
| 209 | hwc_region_t visibleRegionScreen; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 210 | |
| 211 | /* Sync fence object that will be signaled when the buffer's |
| 212 | * contents are available. May be -1 if the contents are already |
| 213 | * available. This field is only valid during set(), and should be |
| 214 | * ignored during prepare(). The set() call must not wait for the |
| 215 | * fence to be signaled before returning, but the HWC must wait for |
| 216 | * all buffers to be signaled before reading from them. |
| 217 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 218 | * HWC_FRAMEBUFFER layers will never have an acquire fence, since |
| 219 | * reads from them are complete before the framebuffer is ready for |
| 220 | * display. |
| 221 | * |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 222 | * HWC_SIDEBAND layers will never have an acquire fence, since |
| 223 | * synchronization is handled through implementation-defined |
| 224 | * sideband mechanisms. |
| 225 | * |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 226 | * The HWC takes ownership of the acquireFenceFd and is responsible |
| 227 | * for closing it when no longer needed. |
| 228 | */ |
| 229 | int acquireFenceFd; |
| 230 | |
| 231 | /* During set() the HWC must set this field to a file descriptor for |
| 232 | * a sync fence object that will signal after the HWC has finished |
| 233 | * reading from the buffer. The field is ignored by prepare(). Each |
| 234 | * layer should have a unique file descriptor, even if more than one |
| 235 | * refer to the same underlying fence object; this allows each to be |
| 236 | * closed independently. |
| 237 | * |
| 238 | * If buffer reads can complete at significantly different times, |
| 239 | * then using independent fences is preferred. For example, if the |
| 240 | * HWC handles some layers with a blit engine and others with |
| 241 | * overlays, then the blit layers can be reused immediately after |
| 242 | * the blit completes, but the overlay layers can't be reused until |
| 243 | * a subsequent frame has been displayed. |
| 244 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 245 | * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't |
| 246 | * produce a release fence for them. The releaseFenceFd will be -1 |
| 247 | * for these layers when set() is called. |
| 248 | * |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 249 | * Since HWC_SIDEBAND buffers don't pass through the HWC client, |
| 250 | * the HWC shouldn't produce a release fence for them. The |
| 251 | * releaseFenceFd will be -1 for these layers when set() is called. |
| 252 | * |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 253 | * The HWC client taks ownership of the releaseFenceFd and is |
| 254 | * responsible for closing it when no longer needed. |
| 255 | */ |
| 256 | int releaseFenceFd; |
Mathias Agopian | e3e0a57 | 2013-01-29 18:57:48 -0800 | [diff] [blame] | 257 | |
| 258 | /* |
| 259 | * Availability: HWC_DEVICE_API_VERSION_1_2 |
| 260 | * |
| 261 | * Alpha value applied to the whole layer. The effective |
| 262 | * value of each pixel is computed as: |
| 263 | * |
| 264 | * if (blending == HWC_BLENDING_PREMULT) |
| 265 | * pixel.rgb = pixel.rgb * planeAlpha / 255 |
| 266 | * pixel.a = pixel.a * planeAlpha / 255 |
| 267 | * |
| 268 | * Then blending proceeds as usual according to the "blending" |
| 269 | * field above. |
| 270 | * |
| 271 | * NOTE: planeAlpha applies to YUV layers as well: |
| 272 | * |
| 273 | * pixel.rgb = yuv_to_rgb(pixel.yuv) |
| 274 | * if (blending == HWC_BLENDING_PREMULT) |
| 275 | * pixel.rgb = pixel.rgb * planeAlpha / 255 |
| 276 | * pixel.a = planeAlpha |
| 277 | * |
| 278 | * |
| 279 | * IMPLEMENTATION NOTE: |
| 280 | * |
| 281 | * If the source image doesn't have an alpha channel, then |
| 282 | * the h/w can use the HWC_BLENDING_COVERAGE equations instead of |
| 283 | * HWC_BLENDING_PREMULT and simply set the alpha channel to |
| 284 | * planeAlpha. |
| 285 | * |
| 286 | * e.g.: |
| 287 | * |
| 288 | * if (blending == HWC_BLENDING_PREMULT) |
| 289 | * blending = HWC_BLENDING_COVERAGE; |
| 290 | * pixel.a = planeAlpha; |
| 291 | * |
| 292 | */ |
| 293 | uint8_t planeAlpha; |
| 294 | |
| 295 | /* reserved for future use */ |
| 296 | uint8_t _pad[3]; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 297 | }; |
| 298 | }; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 299 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 300 | /* Allow for expansion w/o breaking binary compatibility. |
Jesse Hall | 8c79c08 | 2014-02-13 15:38:56 -0800 | [diff] [blame] | 301 | * Pad layer to 96 bytes, assuming 32-bit pointers. |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 302 | */ |
Mathias Agopian | e3e0a57 | 2013-01-29 18:57:48 -0800 | [diff] [blame] | 303 | int32_t reserved[24 - 19]; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 304 | |
| 305 | } hwc_layer_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 306 | |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 307 | /* This represents a display, typically an EGLDisplay object */ |
| 308 | typedef void* hwc_display_t; |
| 309 | |
| 310 | /* This represents a surface, typically an EGLSurface object */ |
| 311 | typedef void* hwc_surface_t; |
| 312 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 313 | /* |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 314 | * hwc_display_contents_1_t::flags values |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 315 | */ |
| 316 | enum { |
| 317 | /* |
| 318 | * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 319 | * passed to (*prepare)() has changed by more than just the buffer handles |
| 320 | * and acquire fences. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 321 | */ |
| 322 | HWC_GEOMETRY_CHANGED = 0x00000001, |
| 323 | }; |
| 324 | |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 325 | /* |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 326 | * Description of the contents to output on a display. |
| 327 | * |
| 328 | * This is the top-level structure passed to the prepare and set calls to |
| 329 | * negotiate and commit the composition of a display image. |
Louis Huemiller | 871815b | 2010-10-25 17:00:52 -0700 | [diff] [blame] | 330 | */ |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 331 | typedef struct hwc_display_contents_1 { |
| 332 | /* File descriptor referring to a Sync HAL fence object which will signal |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 333 | * when this composition is retired. For a physical display, a composition |
| 334 | * is retired when it has been replaced on-screen by a subsequent set. For |
| 335 | * a virtual display, the composition is retired when the writes to |
| 336 | * outputBuffer are complete and can be read. The fence object is created |
| 337 | * and returned by the set call; this field will be -1 on entry to prepare |
| 338 | * and set. SurfaceFlinger will close the returned file descriptor. |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 339 | */ |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 340 | int retireFenceFd; |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 341 | |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 342 | union { |
| 343 | /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ |
| 344 | struct { |
| 345 | /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES |
| 346 | * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to |
| 347 | * prepare. The set call should commit this surface atomically to |
| 348 | * the display along with any overlay layers. |
| 349 | */ |
| 350 | hwc_display_t dpy; |
| 351 | hwc_surface_t sur; |
| 352 | }; |
| 353 | |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 354 | /* These fields are used for virtual displays when the h/w composer |
| 355 | * version is at least HWC_DEVICE_VERSION_1_3. */ |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 356 | struct { |
| 357 | /* outbuf is the buffer that receives the composed image for |
| 358 | * virtual displays. Writes to the outbuf must wait until |
| 359 | * outbufAcquireFenceFd signals. A fence that will signal when |
| 360 | * writes to outbuf are complete should be returned in |
| 361 | * retireFenceFd. |
| 362 | * |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 363 | * This field is set before prepare(), so properties of the buffer |
| 364 | * can be used to decide which layers can be handled by h/w |
| 365 | * composer. |
Jesse Hall | 380f45d | 2013-03-20 10:11:10 -0700 | [diff] [blame] | 366 | * |
Jesse Hall | 7ccf148 | 2013-11-13 14:48:15 -0800 | [diff] [blame] | 367 | * If prepare() sets all layers to FRAMEBUFFER, then GLES |
| 368 | * composition will happen directly to the output buffer. In this |
| 369 | * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will |
| 370 | * be the same, and set() has no work to do besides managing fences. |
| 371 | * |
| 372 | * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config |
| 373 | * variable is defined (not the default), then this behavior is |
| 374 | * changed: if all layers are marked for FRAMEBUFFER, GLES |
| 375 | * composition will take place to a scratch framebuffer, and |
| 376 | * h/w composer must copy it to the output buffer. This allows the |
| 377 | * h/w composer to do format conversion if there are cases where |
| 378 | * that is more desirable than doing it in the GLES driver or at the |
| 379 | * virtual display consumer. |
| 380 | * |
| 381 | * If some or all layers are marked OVERLAY, then the framebuffer |
| 382 | * and output buffer will be different. As with physical displays, |
| 383 | * the framebuffer handle will not change between frames if all |
| 384 | * layers are marked for OVERLAY. |
Jesse Hall | 7cb03d7 | 2012-09-06 16:57:12 -0700 | [diff] [blame] | 385 | */ |
| 386 | buffer_handle_t outbuf; |
| 387 | |
| 388 | /* File descriptor for a fence that will signal when outbuf is |
| 389 | * ready to be written. The h/w composer is responsible for closing |
| 390 | * this when no longer needed. |
| 391 | * |
| 392 | * Will be -1 whenever outbuf is NULL, or when the outbuf can be |
| 393 | * written immediately. |
| 394 | */ |
| 395 | int outbufAcquireFenceFd; |
| 396 | }; |
| 397 | }; |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 398 | |
| 399 | /* 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] | 400 | * in the list will be unique. If numHwLayers is 0, all composition will be |
| 401 | * performed by SurfaceFlinger. |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 402 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 403 | uint32_t flags; |
| 404 | size_t numHwLayers; |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 405 | hwc_layer_1_t hwLayers[0]; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 406 | |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 407 | } hwc_display_contents_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 408 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 409 | /* see hwc_composer_device::registerProcs() |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 410 | * All of the callbacks are required and non-NULL unless otherwise noted. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 411 | */ |
| 412 | typedef struct hwc_procs { |
| 413 | /* |
| 414 | * (*invalidate)() triggers a screen refresh, in particular prepare and set |
| 415 | * will be called shortly after this call is made. Note that there is |
| 416 | * NO GUARANTEE that the screen refresh will happen after invalidate() |
| 417 | * returns (in particular, it could happen before). |
| 418 | * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and |
| 419 | * it is safe to call invalidate() from any of hwc_composer_device |
| 420 | * hooks, unless noted otherwise. |
| 421 | */ |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 422 | void (*invalidate)(const struct hwc_procs* procs); |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 423 | |
| 424 | /* |
| 425 | * (*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] | 426 | * received and HWC_EVENT_VSYNC is enabled on a display |
| 427 | * (see: hwc_event_control). |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 428 | * |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 429 | * the "disp" parameter indicates which display the vsync event is for. |
Jamie Gennis | 6b7adef | 2012-04-30 12:57:11 -0700 | [diff] [blame] | 430 | * the "timestamp" parameter is the system monotonic clock timestamp in |
| 431 | * nanosecond of when the vsync event happened. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 432 | * |
| 433 | * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. |
| 434 | * |
| 435 | * 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] | 436 | * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 437 | * typically less than 0.5 ms. |
| 438 | * |
Mathias Agopian | 6d3fec7 | 2012-04-10 21:22:28 -0700 | [diff] [blame] | 439 | * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling |
| 440 | * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation |
| 441 | * can either stop or continue to process VSYNC events, but must not |
| 442 | * crash or cause other problems. |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 443 | */ |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 444 | void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); |
| 445 | |
| 446 | /* |
| 447 | * (*hotplug)() is called by the h/w composer HAL when a display is |
| 448 | * connected or disconnected. The PRIMARY display is always connected and |
| 449 | * the hotplug callback should not be called for it. |
| 450 | * |
| 451 | * The disp parameter indicates which display type this event is for. |
| 452 | * The connected parameter indicates whether the display has just been |
| 453 | * connected (1) or disconnected (0). |
| 454 | * |
| 455 | * The hotplug() callback may call back into the h/w composer on the same |
| 456 | * thread to query refresh rate and dpi for the display. Additionally, |
| 457 | * other threads may be calling into the h/w composer while the callback |
| 458 | * is in progress. |
| 459 | * |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 460 | * The h/w composer must serialize calls to the hotplug callback; only |
| 461 | * one thread may call it at a time. |
| 462 | * |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 463 | * This callback will be NULL if the h/w composer is using |
| 464 | * HWC_DEVICE_API_VERSION_1_0. |
| 465 | */ |
| 466 | void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); |
| 467 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 468 | } hwc_procs_t; |
| 469 | |
| 470 | |
| 471 | /*****************************************************************************/ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 472 | |
| 473 | typedef struct hwc_module { |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame^] | 474 | /** |
| 475 | * Common methods of the hardware composer module. This *must* be the first member of |
| 476 | * hwc_module as users of this structure will cast a hw_module_t to |
| 477 | * hwc_module pointer in contexts where it's known the hw_module_t references a |
| 478 | * hwc_module. |
| 479 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 480 | struct hw_module_t common; |
| 481 | } hwc_module_t; |
| 482 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 483 | typedef struct hwc_composer_device_1 { |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame^] | 484 | /** |
| 485 | * Common methods of the hardware composer device. This *must* be the first member of |
| 486 | * hwc_composer_device_1 as users of this structure will cast a hw_device_t to |
| 487 | * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a |
| 488 | * hwc_composer_device_1. |
| 489 | */ |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 490 | struct hw_device_t common; |
| 491 | |
| 492 | /* |
| 493 | * (*prepare)() is called for each frame before composition and is used by |
| 494 | * SurfaceFlinger to determine what composition steps the HWC can handle. |
| 495 | * |
| 496 | * (*prepare)() can be called more than once, the last call prevails. |
| 497 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 498 | * The HWC responds by setting the compositionType field in each layer to |
| 499 | * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the |
| 500 | * composition for the layer is handled by SurfaceFlinger with OpenGL ES, |
| 501 | * in the later case, the HWC will have to handle the layer's composition. |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 502 | * compositionType and hints are preserved between (*prepare)() calles |
| 503 | * unless the HWC_GEOMETRY_CHANGED flag is set. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 504 | * |
| 505 | * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the |
| 506 | * list's geometry has changed, that is, when more than just the buffer's |
| 507 | * handles have been updated. Typically this happens (but is not limited to) |
Mathias Agopian | 48697f6 | 2012-11-20 15:23:25 -0800 | [diff] [blame] | 508 | * when a window is added, removed, resized or moved. In this case |
| 509 | * compositionType and hints are reset to their default value. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 510 | * |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 511 | * For HWC 1.0, numDisplays will always be one, and displays[0] will be |
| 512 | * non-NULL. |
| 513 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 514 | * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. |
| 515 | * Entries for unsupported or disabled/disconnected display types will be |
| 516 | * NULL. |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 517 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 518 | * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra |
| 519 | * entries correspond to enabled virtual displays, and will be non-NULL. |
Jesse Hall | ac3f7e1 | 2012-07-31 15:18:32 -0700 | [diff] [blame] | 520 | * |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 521 | * returns: 0 on success. An negative error code on error. If an error is |
| 522 | * returned, SurfaceFlinger will assume that none of the layer will be |
| 523 | * handled by the HWC. |
| 524 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 525 | int (*prepare)(struct hwc_composer_device_1 *dev, |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 526 | size_t numDisplays, hwc_display_contents_1_t** displays); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 527 | |
| 528 | /* |
| 529 | * (*set)() is used in place of eglSwapBuffers(), and assumes the same |
| 530 | * functionality, except it also commits the work list atomically with |
| 531 | * the actual eglSwapBuffers(). |
| 532 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 533 | * The layer lists are guaranteed to be the same as the ones returned from |
| 534 | * the last call to (*prepare)(). |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 535 | * |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 536 | * When this call returns the caller assumes that the displays will be |
| 537 | * updated in the near future with the content of their work lists, without |
| 538 | * artifacts during the transition from the previous frame. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 539 | * |
Jesse Hall | ac3f7e1 | 2012-07-31 15:18:32 -0700 | [diff] [blame] | 540 | * A display with zero layers indicates that the entire composition has |
| 541 | * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() |
| 542 | * behaves just like eglSwapBuffers(). |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 543 | * |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 544 | * For HWC 1.0, numDisplays will always be one, and displays[0] will be |
| 545 | * non-NULL. |
| 546 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 547 | * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. |
| 548 | * Entries for unsupported or disabled/disconnected display types will be |
| 549 | * NULL. |
Jesse Hall | 43b51d9 | 2012-08-22 11:42:57 -0700 | [diff] [blame] | 550 | * |
Jesse Hall | fc0ff2a | 2013-08-16 11:13:36 -0700 | [diff] [blame] | 551 | * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra |
| 552 | * entries correspond to enabled virtual displays, and will be non-NULL. |
Mathias Agopian | 71212e3 | 2011-11-21 17:35:15 -0800 | [diff] [blame] | 553 | * |
Jamie Gennis | c754518 | 2012-10-08 19:23:56 -0700 | [diff] [blame] | 554 | * IMPORTANT NOTE: There is an implicit layer containing opaque black |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 555 | * pixels behind all the layers in the list. It is the responsibility of |
| 556 | * the hwcomposer module to make sure black pixels are output (or blended |
| 557 | * from). |
Mathias Agopian | fb41036 | 2011-11-15 21:27:52 -0800 | [diff] [blame] | 558 | * |
Jamie Gennis | c754518 | 2012-10-08 19:23:56 -0700 | [diff] [blame] | 559 | * IMPORTANT NOTE: In the event of an error this call *MUST* still cause |
| 560 | * any fences returned in the previous call to set to eventually become |
| 561 | * signaled. The caller may have already issued wait commands on these |
| 562 | * fences, and having set return without causing those fences to signal |
| 563 | * will likely result in a deadlock. |
| 564 | * |
| 565 | * returns: 0 on success. A negative error code on error: |
| 566 | * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only |
| 567 | * allowed prior to HWComposer 1.1) |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 568 | * Another code for non EGL errors. |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 569 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 570 | int (*set)(struct hwc_composer_device_1 *dev, |
Jesse Hall | f9d6cd7 | 2012-07-31 14:29:00 -0700 | [diff] [blame] | 571 | size_t numDisplays, hwc_display_contents_1_t** displays); |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 572 | |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 573 | /* |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 574 | * eventControl(..., event, enabled) |
| 575 | * Enables or disables h/w composer events for a display. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 576 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 577 | * eventControl can be called from any thread and takes effect |
| 578 | * immediately. |
| 579 | * |
| 580 | * Supported events are: |
| 581 | * HWC_EVENT_VSYNC |
| 582 | * |
| 583 | * returns -EINVAL if the "event" parameter is not one of the value above |
| 584 | * or if the "enabled" parameter is not 0 or 1. |
Erik Gilling | 158549c | 2010-12-01 16:34:08 -0800 | [diff] [blame] | 585 | */ |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 586 | int (*eventControl)(struct hwc_composer_device_1* dev, int disp, |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 587 | int event, int enabled); |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 588 | |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 589 | /* |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 590 | * blank(..., blank) |
| 591 | * Blanks or unblanks a display's screen. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 592 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 593 | * Turns the screen off when blank is nonzero, on when blank is zero. |
| 594 | * Multiple sequential calls with the same blank value must be supported. |
| 595 | * The screen state transition must be be complete when the function |
| 596 | * returns. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 597 | * |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 598 | * returns 0 on success, negative on error. |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 599 | */ |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 600 | int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); |
Mathias Agopian | d6afef6 | 2011-08-01 16:34:42 -0700 | [diff] [blame] | 601 | |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 602 | /* |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 603 | * Used to retrieve information about the h/w composer |
| 604 | * |
| 605 | * Returns 0 on success or -errno on error. |
| 606 | */ |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 607 | int (*query)(struct hwc_composer_device_1* dev, int what, int* value); |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 608 | |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 609 | /* |
Jesse Hall | 0a0a416 | 2012-08-21 12:06:28 -0700 | [diff] [blame] | 610 | * (*registerProcs)() registers callbacks that the h/w composer HAL can |
| 611 | * later use. It will be called immediately after the composer device is |
| 612 | * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks |
| 613 | * from within registerProcs(). registerProcs() must save the hwc_procs_t |
| 614 | * pointer which is needed when calling a registered callback. |
| 615 | */ |
| 616 | void (*registerProcs)(struct hwc_composer_device_1* dev, |
| 617 | hwc_procs_t const* procs); |
| 618 | |
| 619 | /* |
| 620 | * This field is OPTIONAL and can be NULL. |
| 621 | * |
| 622 | * If non NULL it will be called by SurfaceFlinger on dumpsys |
| 623 | */ |
| 624 | void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); |
| 625 | |
| 626 | /* |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 627 | * (*getDisplayConfigs)() returns handles for the configurations available |
| 628 | * on the connected display. These handles must remain valid as long as the |
| 629 | * display is connected. |
| 630 | * |
| 631 | * Configuration handles are written to configs. The number of entries |
| 632 | * allocated by the caller is passed in *numConfigs; getDisplayConfigs must |
| 633 | * not try to write more than this number of config handles. On return, the |
| 634 | * total number of configurations available for the display is returned in |
| 635 | * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. |
| 636 | * |
| 637 | * HWC_DEVICE_API_VERSION_1_1 does not provide a way to choose a config. |
| 638 | * For displays that support multiple configurations, the h/w composer |
| 639 | * implementation should choose one and report it as the first config in |
| 640 | * the list. Reporting the not-chosen configs is not required. |
| 641 | * |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 642 | * Returns 0 on success or -errno on error. If disp is a hotpluggable |
| 643 | * display type and no display is connected, an error should be returned. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 644 | * |
| 645 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. |
| 646 | * It should be NULL for previous versions. |
| 647 | */ |
| 648 | int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, |
| 649 | uint32_t* configs, size_t* numConfigs); |
| 650 | |
| 651 | /* |
| 652 | * (*getDisplayAttributes)() returns attributes for a specific config of a |
| 653 | * connected display. The config parameter is one of the config handles |
| 654 | * returned by getDisplayConfigs. |
| 655 | * |
| 656 | * The list of attributes to return is provided in the attributes |
| 657 | * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each |
| 658 | * requested attribute is written in order to the values array. The |
| 659 | * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values |
| 660 | * array will have one less value than the attributes array. |
| 661 | * |
| 662 | * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. |
| 663 | * It should be NULL for previous versions. |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 664 | * |
| 665 | * If disp is a hotpluggable display type and no display is connected, |
| 666 | * or if config is not a valid configuration for the display, a negative |
| 667 | * value should be returned. |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 668 | */ |
Jesse Hall | d91697a | 2012-09-19 22:53:30 -0700 | [diff] [blame] | 669 | int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, |
Jesse Hall | 2c13759 | 2012-08-29 10:37:37 -0700 | [diff] [blame] | 670 | uint32_t config, const uint32_t* attributes, int32_t* values); |
| 671 | |
| 672 | /* |
Mathias Agopian | b08d45d | 2012-03-24 15:56:29 -0700 | [diff] [blame] | 673 | * Reserved for future use. Must be NULL. |
| 674 | */ |
| 675 | void* reserved_proc[4]; |
Mathias Agopian | eb8fb50 | 2012-02-03 15:54:11 -0800 | [diff] [blame] | 676 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 677 | } hwc_composer_device_1_t; |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 678 | |
| 679 | /** convenience API for opening and closing a device */ |
| 680 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 681 | static inline int hwc_open_1(const struct hw_module_t* module, |
| 682 | hwc_composer_device_1_t** device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 683 | return module->methods->open(module, |
| 684 | HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); |
| 685 | } |
| 686 | |
Jesse Hall | d479ad2 | 2012-06-05 23:41:37 -0700 | [diff] [blame] | 687 | static inline int hwc_close_1(hwc_composer_device_1_t* device) { |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 688 | return device->common.close(&device->common); |
| 689 | } |
| 690 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 691 | /*****************************************************************************/ |
| 692 | |
Mathias Agopian | 5d3de30 | 2010-08-05 15:24:35 -0700 | [diff] [blame] | 693 | __END_DECLS |
| 694 | |
| 695 | #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ |