blob: f03ac705dfe8df258edba880764f5cf930dfa000 [file] [log] [blame]
Mathias Agopian5d3de302010-08-05 15:24:35 -07001/*
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 Huemiller45e23712010-12-01 12:25:00 -080023#include <hardware/gralloc.h>
Mathias Agopian5d3de302010-08-05 15:24:35 -070024#include <hardware/hardware.h>
25#include <cutils/native_handle.h>
26
Mathias Agopiane291f712012-05-13 22:49:06 -070027#include <hardware/hwcomposer_defs.h>
28
Mathias Agopian5d3de302010-08-05 15:24:35 -070029__BEGIN_DECLS
30
31/*****************************************************************************/
Erik Gillinge9952042010-12-07 18:46:04 -080032
Jesse Halld479ad22012-06-05 23:41:37 -070033/* for compatibility */
Mathias Agopianb08d45d2012-03-24 15:56:29 -070034#define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
35#define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
Mathias Agopian81c323d2012-03-25 01:09:35 -070036#define HWC_API_VERSION HWC_DEVICE_API_VERSION
Erik Gillinge9952042010-12-07 18:46:04 -080037
Jesse Halld479ad22012-06-05 23:41:37 -070038/* Users of this header can define HWC_REMOVE_DEPRECATED_VERSIONS to test that
39 * they still work with just the current version declared, before the
40 * deprecated versions are actually removed.
41 *
42 * To find code that still depends on the old versions, set the #define to 1
43 * here. Code that explicitly sets it to zero (rather than simply not defining
44 * it) will still see the old versions.
45 */
46#if !defined(HWC_REMOVE_DEPRECATED_VERSIONS)
47#define HWC_REMOVE_DEPRECATED_VERSIONS 0
48#endif
49
50/*****************************************************************************/
51
Mathias Agopian5d3de302010-08-05 15:24:35 -070052/**
53 * The id of this module
54 */
55#define HWC_HARDWARE_MODULE_ID "hwcomposer"
56
57/**
58 * Name of the sensors device to open
59 */
60#define HWC_HARDWARE_COMPOSER "composer"
61
Mathias Agopian5d3de302010-08-05 15:24:35 -070062typedef struct hwc_rect {
63 int left;
64 int top;
65 int right;
66 int bottom;
67} hwc_rect_t;
68
69typedef struct hwc_region {
70 size_t numRects;
71 hwc_rect_t const* rects;
72} hwc_region_t;
73
Mathias Agopianeb8fb502012-02-03 15:54:11 -080074typedef struct hwc_color {
75 uint8_t r;
76 uint8_t g;
77 uint8_t b;
78 uint8_t a;
79} hwc_color_t;
80
Jesse Halld479ad22012-06-05 23:41:37 -070081typedef struct hwc_layer_1 {
Mathias Agopian5d3de302010-08-05 15:24:35 -070082 /*
Jesse Halld18c83f2012-08-16 16:21:13 -070083 * Initially set to HWC_FRAMEBUFFER, HWC_BACKGROUND, or
84 * HWC_FRAMEBUFFER_TARGET.
85 *
Mathias Agopianeb8fb502012-02-03 15:54:11 -080086 * HWC_FRAMEBUFFER
Jesse Halld18c83f2012-08-16 16:21:13 -070087 * Indicates the layer will be drawn into the framebuffer
88 * using OpenGL ES. The HWC can toggle this value to HWC_OVERLAY to
89 * indicate it will handle the layer.
Mathias Agopianeb8fb502012-02-03 15:54:11 -080090 *
91 * HWC_BACKGROUND
Jesse Halld18c83f2012-08-16 16:21:13 -070092 * Indicates this is a special "background" layer. The only valid field
93 * is backgroundColor. The HWC can toggle this value to HWC_FRAMEBUFFER
94 * to indicate it CANNOT handle the background color.
Mathias Agopianeb8fb502012-02-03 15:54:11 -080095 *
Jesse Halld18c83f2012-08-16 16:21:13 -070096 * HWC_FRAMEBUFFER_TARGET
97 * Indicates this layer is the framebuffer surface used as the target of
98 * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY
99 * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and
Jesse Hall6b01e2e2012-09-14 17:21:22 -0700100 * this layer should be ignored during set().
Jesse Halld18c83f2012-08-16 16:21:13 -0700101 *
102 * This flag (and the framebuffer surface layer) will only be used if the
103 * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions,
104 * the OpenGL ES target surface is communicated by the (dpy, sur) fields
105 * in hwc_compositor_device_1_t.
Mathias Agopian5d3de302010-08-05 15:24:35 -0700106 */
107 int32_t compositionType;
108
109 /* see hwc_layer_t::hints above */
110 uint32_t hints;
111
112 /* see hwc_layer_t::flags above */
113 uint32_t flags;
114
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800115 union {
116 /* color of the background. hwc_color_t.a is ignored */
117 hwc_color_t backgroundColor;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700118
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800119 struct {
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800120 /* handle of buffer to compose. This handle is guaranteed to have been
121 * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If
122 * the layer's handle is unchanged across two consecutive prepare calls and
123 * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the
124 * HWComposer implementation may assume that the contents of the buffer have
125 * not changed. */
126 buffer_handle_t handle;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700127
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800128 /* transformation to apply to the buffer during composition */
129 uint32_t transform;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700130
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800131 /* blending to apply during composition */
132 int32_t blending;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700133
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800134 /* area of the source to consider, the origin is the top-left corner of
135 * the buffer */
136 hwc_rect_t sourceCrop;
137
138 /* where to composite the sourceCrop onto the display. The sourceCrop
139 * is scaled using linear filtering to the displayFrame. The origin is the
140 * top-left corner of the screen.
141 */
142 hwc_rect_t displayFrame;
143
144 /* visible region in screen space. The origin is the
145 * top-left corner of the screen.
146 * The visible region INCLUDES areas overlapped by a translucent layer.
147 */
148 hwc_region_t visibleRegionScreen;
Jesse Halld479ad22012-06-05 23:41:37 -0700149
150 /* Sync fence object that will be signaled when the buffer's
151 * contents are available. May be -1 if the contents are already
152 * available. This field is only valid during set(), and should be
153 * ignored during prepare(). The set() call must not wait for the
154 * fence to be signaled before returning, but the HWC must wait for
155 * all buffers to be signaled before reading from them.
156 *
Jesse Hall0a0a4162012-08-21 12:06:28 -0700157 * HWC_FRAMEBUFFER layers will never have an acquire fence, since
158 * reads from them are complete before the framebuffer is ready for
159 * display.
160 *
Jesse Halld479ad22012-06-05 23:41:37 -0700161 * The HWC takes ownership of the acquireFenceFd and is responsible
162 * for closing it when no longer needed.
163 */
164 int acquireFenceFd;
165
166 /* During set() the HWC must set this field to a file descriptor for
167 * a sync fence object that will signal after the HWC has finished
168 * reading from the buffer. The field is ignored by prepare(). Each
169 * layer should have a unique file descriptor, even if more than one
170 * refer to the same underlying fence object; this allows each to be
171 * closed independently.
172 *
173 * If buffer reads can complete at significantly different times,
174 * then using independent fences is preferred. For example, if the
175 * HWC handles some layers with a blit engine and others with
176 * overlays, then the blit layers can be reused immediately after
177 * the blit completes, but the overlay layers can't be reused until
178 * a subsequent frame has been displayed.
179 *
Jesse Hall0a0a4162012-08-21 12:06:28 -0700180 * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't
181 * produce a release fence for them. The releaseFenceFd will be -1
182 * for these layers when set() is called.
183 *
Jesse Halld479ad22012-06-05 23:41:37 -0700184 * The HWC client taks ownership of the releaseFenceFd and is
185 * responsible for closing it when no longer needed.
186 */
187 int releaseFenceFd;
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800188 };
189 };
Mathias Agopian5d3de302010-08-05 15:24:35 -0700190
Jesse Halld479ad22012-06-05 23:41:37 -0700191 /* Allow for expansion w/o breaking binary compatibility.
192 * Pad layer to 96 bytes, assuming 32-bit pointers.
193 */
194 int32_t reserved[24 - 18];
195
196} hwc_layer_1_t;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700197
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700198/* This represents a display, typically an EGLDisplay object */
199typedef void* hwc_display_t;
200
201/* This represents a surface, typically an EGLSurface object */
202typedef void* hwc_surface_t;
203
Mathias Agopian5d3de302010-08-05 15:24:35 -0700204/*
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700205 * hwc_display_contents_1_t::flags values
Mathias Agopian5d3de302010-08-05 15:24:35 -0700206 */
207enum {
208 /*
209 * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list
Jesse Halld479ad22012-06-05 23:41:37 -0700210 * passed to (*prepare)() has changed by more than just the buffer handles
211 * and acquire fences.
Mathias Agopian5d3de302010-08-05 15:24:35 -0700212 */
213 HWC_GEOMETRY_CHANGED = 0x00000001,
214};
215
Louis Huemiller871815b2010-10-25 17:00:52 -0700216/*
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700217 * Description of the contents to output on a display.
218 *
219 * This is the top-level structure passed to the prepare and set calls to
220 * negotiate and commit the composition of a display image.
Louis Huemiller871815b2010-10-25 17:00:52 -0700221 */
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700222typedef struct hwc_display_contents_1 {
223 /* File descriptor referring to a Sync HAL fence object which will signal
Jesse Hall7cb03d72012-09-06 16:57:12 -0700224 * when this composition is retired. For a physical display, a composition
225 * is retired when it has been replaced on-screen by a subsequent set. For
226 * a virtual display, the composition is retired when the writes to
227 * outputBuffer are complete and can be read. The fence object is created
228 * and returned by the set call; this field will be -1 on entry to prepare
229 * and set. SurfaceFlinger will close the returned file descriptor.
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700230 */
Jesse Hall7cb03d72012-09-06 16:57:12 -0700231 int retireFenceFd;
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700232
Jesse Hall7cb03d72012-09-06 16:57:12 -0700233 union {
234 /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */
235 struct {
236 /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES
237 * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to
238 * prepare. The set call should commit this surface atomically to
239 * the display along with any overlay layers.
240 */
241 hwc_display_t dpy;
242 hwc_surface_t sur;
243 };
244
245 /* Fields only relevant for HWC_DEVICE_VERSION_1_2 and later. */
246 struct {
247 /* outbuf is the buffer that receives the composed image for
248 * virtual displays. Writes to the outbuf must wait until
249 * outbufAcquireFenceFd signals. A fence that will signal when
250 * writes to outbuf are complete should be returned in
251 * retireFenceFd.
252 *
253 * For physical displays, outbuf will be NULL.
254 */
255 buffer_handle_t outbuf;
256
257 /* File descriptor for a fence that will signal when outbuf is
258 * ready to be written. The h/w composer is responsible for closing
259 * this when no longer needed.
260 *
261 * Will be -1 whenever outbuf is NULL, or when the outbuf can be
262 * written immediately.
263 */
264 int outbufAcquireFenceFd;
265 };
266 };
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700267
268 /* List of layers that will be composed on the display. The buffer handles
Jesse Hallac3f7e12012-07-31 15:18:32 -0700269 * in the list will be unique. If numHwLayers is 0, all composition will be
270 * performed by SurfaceFlinger.
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700271 */
Mathias Agopian5d3de302010-08-05 15:24:35 -0700272 uint32_t flags;
273 size_t numHwLayers;
Jesse Halld479ad22012-06-05 23:41:37 -0700274 hwc_layer_1_t hwLayers[0];
Mathias Agopian5d3de302010-08-05 15:24:35 -0700275
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700276} hwc_display_contents_1_t;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700277
Mathias Agopiand6afef62011-08-01 16:34:42 -0700278/* see hwc_composer_device::registerProcs()
Jesse Hall0a0a4162012-08-21 12:06:28 -0700279 * All of the callbacks are required and non-NULL unless otherwise noted.
Mathias Agopiand6afef62011-08-01 16:34:42 -0700280 */
281typedef struct hwc_procs {
282 /*
283 * (*invalidate)() triggers a screen refresh, in particular prepare and set
284 * will be called shortly after this call is made. Note that there is
285 * NO GUARANTEE that the screen refresh will happen after invalidate()
286 * returns (in particular, it could happen before).
287 * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and
288 * it is safe to call invalidate() from any of hwc_composer_device
289 * hooks, unless noted otherwise.
290 */
Jesse Hall0a0a4162012-08-21 12:06:28 -0700291 void (*invalidate)(const struct hwc_procs* procs);
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700292
293 /*
294 * (*vsync)() is called by the h/w composer HAL when a vsync event is
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700295 * received and HWC_EVENT_VSYNC is enabled on a display
296 * (see: hwc_event_control).
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700297 *
Jesse Hall2c137592012-08-29 10:37:37 -0700298 * the "disp" parameter indicates which display the vsync event is for.
Jamie Gennis6b7adef2012-04-30 12:57:11 -0700299 * the "timestamp" parameter is the system monotonic clock timestamp in
300 * nanosecond of when the vsync event happened.
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700301 *
302 * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL.
303 *
304 * It is expected that vsync() is called from a thread of at least
Mathias Agopianeb671602012-04-24 15:42:37 -0700305 * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible,
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700306 * typically less than 0.5 ms.
307 *
Mathias Agopian6d3fec72012-04-10 21:22:28 -0700308 * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling
309 * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation
310 * can either stop or continue to process VSYNC events, but must not
311 * crash or cause other problems.
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700312 */
Jesse Hall2c137592012-08-29 10:37:37 -0700313 void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp);
314
315 /*
316 * (*hotplug)() is called by the h/w composer HAL when a display is
317 * connected or disconnected. The PRIMARY display is always connected and
318 * the hotplug callback should not be called for it.
319 *
320 * The disp parameter indicates which display type this event is for.
321 * The connected parameter indicates whether the display has just been
322 * connected (1) or disconnected (0).
323 *
324 * The hotplug() callback may call back into the h/w composer on the same
325 * thread to query refresh rate and dpi for the display. Additionally,
326 * other threads may be calling into the h/w composer while the callback
327 * is in progress.
328 *
Jesse Halld91697a2012-09-19 22:53:30 -0700329 * The h/w composer must serialize calls to the hotplug callback; only
330 * one thread may call it at a time.
331 *
Jesse Hall2c137592012-08-29 10:37:37 -0700332 * This callback will be NULL if the h/w composer is using
333 * HWC_DEVICE_API_VERSION_1_0.
334 */
335 void (*hotplug)(const struct hwc_procs* procs, int disp, int connected);
336
Mathias Agopiand6afef62011-08-01 16:34:42 -0700337} hwc_procs_t;
338
339
340/*****************************************************************************/
Mathias Agopian5d3de302010-08-05 15:24:35 -0700341
342typedef struct hwc_module {
343 struct hw_module_t common;
344} hwc_module_t;
345
Jesse Halld479ad22012-06-05 23:41:37 -0700346typedef struct hwc_composer_device_1 {
Mathias Agopian5d3de302010-08-05 15:24:35 -0700347 struct hw_device_t common;
348
349 /*
350 * (*prepare)() is called for each frame before composition and is used by
351 * SurfaceFlinger to determine what composition steps the HWC can handle.
352 *
353 * (*prepare)() can be called more than once, the last call prevails.
354 *
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700355 * The HWC responds by setting the compositionType field in each layer to
356 * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the
357 * composition for the layer is handled by SurfaceFlinger with OpenGL ES,
358 * in the later case, the HWC will have to handle the layer's composition.
Mathias Agopian5d3de302010-08-05 15:24:35 -0700359 *
360 * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the
361 * list's geometry has changed, that is, when more than just the buffer's
362 * handles have been updated. Typically this happens (but is not limited to)
363 * when a window is added, removed, resized or moved.
364 *
Jesse Hall43b51d92012-08-22 11:42:57 -0700365 * For HWC 1.0, numDisplays will always be one, and displays[0] will be
366 * non-NULL.
367 *
368 * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries
369 * for unsupported or disabled/disconnected display types will be NULL.
370 *
371 * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more.
372 * The extra entries correspond to enabled virtual displays, and will be
373 * non-NULL. In HWC 1.2, support for one virtual display is required, and
374 * no more than one will be used. Future HWC versions might require more.
Jesse Hallac3f7e12012-07-31 15:18:32 -0700375 *
Mathias Agopian5d3de302010-08-05 15:24:35 -0700376 * returns: 0 on success. An negative error code on error. If an error is
377 * returned, SurfaceFlinger will assume that none of the layer will be
378 * handled by the HWC.
379 */
Jesse Halld479ad22012-06-05 23:41:37 -0700380 int (*prepare)(struct hwc_composer_device_1 *dev,
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700381 size_t numDisplays, hwc_display_contents_1_t** displays);
Mathias Agopian5d3de302010-08-05 15:24:35 -0700382
383 /*
384 * (*set)() is used in place of eglSwapBuffers(), and assumes the same
385 * functionality, except it also commits the work list atomically with
386 * the actual eglSwapBuffers().
387 *
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700388 * The layer lists are guaranteed to be the same as the ones returned from
389 * the last call to (*prepare)().
Mathias Agopian5d3de302010-08-05 15:24:35 -0700390 *
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700391 * When this call returns the caller assumes that the displays will be
392 * updated in the near future with the content of their work lists, without
393 * artifacts during the transition from the previous frame.
Mathias Agopian5d3de302010-08-05 15:24:35 -0700394 *
Jesse Hallac3f7e12012-07-31 15:18:32 -0700395 * A display with zero layers indicates that the entire composition has
396 * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)()
397 * behaves just like eglSwapBuffers().
Mathias Agopian5d3de302010-08-05 15:24:35 -0700398 *
Jesse Hall43b51d92012-08-22 11:42:57 -0700399 * For HWC 1.0, numDisplays will always be one, and displays[0] will be
400 * non-NULL.
401 *
402 * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries
403 * for unsupported or disabled/disconnected display types will be NULL.
404 *
405 * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more.
406 * The extra entries correspond to enabled virtual displays, and will be
407 * non-NULL. In HWC 1.2, support for one virtual display is required, and
408 * no more than one will be used. Future HWC versions might require more.
Mathias Agopian71212e32011-11-21 17:35:15 -0800409 *
Mathias Agopianfb410362011-11-15 21:27:52 -0800410 * IMPORTANT NOTE: there is an implicit layer containing opaque black
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700411 * pixels behind all the layers in the list. It is the responsibility of
412 * the hwcomposer module to make sure black pixels are output (or blended
413 * from).
Mathias Agopianfb410362011-11-15 21:27:52 -0800414 *
Mathias Agopian5d3de302010-08-05 15:24:35 -0700415 * returns: 0 on success. An negative error code on error:
416 * HWC_EGL_ERROR: eglGetError() will provide the proper error code
417 * Another code for non EGL errors.
Mathias Agopian5d3de302010-08-05 15:24:35 -0700418 */
Jesse Halld479ad22012-06-05 23:41:37 -0700419 int (*set)(struct hwc_composer_device_1 *dev,
Jesse Hallf9d6cd72012-07-31 14:29:00 -0700420 size_t numDisplays, hwc_display_contents_1_t** displays);
Jesse Halld479ad22012-06-05 23:41:37 -0700421
Erik Gilling158549c2010-12-01 16:34:08 -0800422 /*
Jesse Hall0a0a4162012-08-21 12:06:28 -0700423 * eventControl(..., event, enabled)
424 * Enables or disables h/w composer events for a display.
Erik Gilling158549c2010-12-01 16:34:08 -0800425 *
Jesse Hall0a0a4162012-08-21 12:06:28 -0700426 * eventControl can be called from any thread and takes effect
427 * immediately.
428 *
429 * Supported events are:
430 * HWC_EVENT_VSYNC
431 *
432 * returns -EINVAL if the "event" parameter is not one of the value above
433 * or if the "enabled" parameter is not 0 or 1.
Erik Gilling158549c2010-12-01 16:34:08 -0800434 */
Jesse Hall2c137592012-08-29 10:37:37 -0700435 int (*eventControl)(struct hwc_composer_device_1* dev, int disp,
Jesse Hall0a0a4162012-08-21 12:06:28 -0700436 int event, int enabled);
Mathias Agopian5d3de302010-08-05 15:24:35 -0700437
Mathias Agopiand6afef62011-08-01 16:34:42 -0700438 /*
Jesse Hall0a0a4162012-08-21 12:06:28 -0700439 * blank(..., blank)
440 * Blanks or unblanks a display's screen.
Mathias Agopiand6afef62011-08-01 16:34:42 -0700441 *
Jesse Hall0a0a4162012-08-21 12:06:28 -0700442 * Turns the screen off when blank is nonzero, on when blank is zero.
443 * Multiple sequential calls with the same blank value must be supported.
444 * The screen state transition must be be complete when the function
445 * returns.
Mathias Agopiand6afef62011-08-01 16:34:42 -0700446 *
Jesse Hall0a0a4162012-08-21 12:06:28 -0700447 * returns 0 on success, negative on error.
Mathias Agopiand6afef62011-08-01 16:34:42 -0700448 */
Jesse Hall2c137592012-08-29 10:37:37 -0700449 int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank);
Mathias Agopiand6afef62011-08-01 16:34:42 -0700450
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800451 /*
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800452 * Used to retrieve information about the h/w composer
453 *
454 * Returns 0 on success or -errno on error.
455 */
Jesse Halld479ad22012-06-05 23:41:37 -0700456 int (*query)(struct hwc_composer_device_1* dev, int what, int* value);
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800457
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700458 /*
Jesse Hall0a0a4162012-08-21 12:06:28 -0700459 * (*registerProcs)() registers callbacks that the h/w composer HAL can
460 * later use. It will be called immediately after the composer device is
461 * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks
462 * from within registerProcs(). registerProcs() must save the hwc_procs_t
463 * pointer which is needed when calling a registered callback.
464 */
465 void (*registerProcs)(struct hwc_composer_device_1* dev,
466 hwc_procs_t const* procs);
467
468 /*
469 * This field is OPTIONAL and can be NULL.
470 *
471 * If non NULL it will be called by SurfaceFlinger on dumpsys
472 */
473 void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len);
474
475 /*
Jesse Hall2c137592012-08-29 10:37:37 -0700476 * (*getDisplayConfigs)() returns handles for the configurations available
477 * on the connected display. These handles must remain valid as long as the
478 * display is connected.
479 *
480 * Configuration handles are written to configs. The number of entries
481 * allocated by the caller is passed in *numConfigs; getDisplayConfigs must
482 * not try to write more than this number of config handles. On return, the
483 * total number of configurations available for the display is returned in
484 * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL.
485 *
486 * HWC_DEVICE_API_VERSION_1_1 does not provide a way to choose a config.
487 * For displays that support multiple configurations, the h/w composer
488 * implementation should choose one and report it as the first config in
489 * the list. Reporting the not-chosen configs is not required.
490 *
Jesse Halld91697a2012-09-19 22:53:30 -0700491 * Returns 0 on success or -errno on error. If disp is a hotpluggable
492 * display type and no display is connected, an error should be returned.
Jesse Hall2c137592012-08-29 10:37:37 -0700493 *
494 * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later.
495 * It should be NULL for previous versions.
496 */
497 int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp,
498 uint32_t* configs, size_t* numConfigs);
499
500 /*
501 * (*getDisplayAttributes)() returns attributes for a specific config of a
502 * connected display. The config parameter is one of the config handles
503 * returned by getDisplayConfigs.
504 *
505 * The list of attributes to return is provided in the attributes
506 * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each
507 * requested attribute is written in order to the values array. The
508 * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values
509 * array will have one less value than the attributes array.
510 *
511 * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later.
512 * It should be NULL for previous versions.
Jesse Halld91697a2012-09-19 22:53:30 -0700513 *
514 * If disp is a hotpluggable display type and no display is connected,
515 * or if config is not a valid configuration for the display, a negative
516 * value should be returned.
Jesse Hall2c137592012-08-29 10:37:37 -0700517 */
Jesse Halld91697a2012-09-19 22:53:30 -0700518 int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp,
Jesse Hall2c137592012-08-29 10:37:37 -0700519 uint32_t config, const uint32_t* attributes, int32_t* values);
520
521 /*
Mathias Agopianb08d45d2012-03-24 15:56:29 -0700522 * Reserved for future use. Must be NULL.
523 */
524 void* reserved_proc[4];
Mathias Agopianeb8fb502012-02-03 15:54:11 -0800525
Jesse Halld479ad22012-06-05 23:41:37 -0700526} hwc_composer_device_1_t;
Mathias Agopian5d3de302010-08-05 15:24:35 -0700527
528/** convenience API for opening and closing a device */
529
Jesse Halld479ad22012-06-05 23:41:37 -0700530static inline int hwc_open_1(const struct hw_module_t* module,
531 hwc_composer_device_1_t** device) {
Mathias Agopian5d3de302010-08-05 15:24:35 -0700532 return module->methods->open(module,
533 HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device);
534}
535
Jesse Halld479ad22012-06-05 23:41:37 -0700536static inline int hwc_close_1(hwc_composer_device_1_t* device) {
Mathias Agopian5d3de302010-08-05 15:24:35 -0700537 return device->common.close(&device->common);
538}
539
Mathias Agopian5d3de302010-08-05 15:24:35 -0700540/*****************************************************************************/
541
Jesse Halld479ad22012-06-05 23:41:37 -0700542#if !HWC_REMOVE_DEPRECATED_VERSIONS
543#include <hardware/hwcomposer_v0.h>
544#endif
545
Mathias Agopian5d3de302010-08-05 15:24:35 -0700546__END_DECLS
547
548#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */