hwcomposer.h revision 43b51d9fdd7a447c9de7bf30960a1963c93ff5c3
15d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
25d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Copyright (C) 2010 The Android Open Source Project
35d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
45d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
55d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * you may not use this file except in compliance with the License.
65d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * You may obtain a copy of the License at
75d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
85d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
95d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian *
105d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Unless required by applicable law or agreed to in writing, software
115d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
125d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * See the License for the specific language governing permissions and
145d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * limitations under the License.
155d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
165d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
195d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
205d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <stdint.h>
215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <sys/cdefs.h>
225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
2345e2371cb954a8f8e0aee16d1ee8bec7eae9b897Louis Huemiller#include <hardware/gralloc.h>
245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <hardware/hardware.h>
255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#include <cutils/native_handle.h>
265d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
27e291f71e0a25ac9bb39fb754c599b710ab8f59d5Mathias Agopian#include <hardware/hwcomposer_defs.h>
28e291f71e0a25ac9bb39fb754c599b710ab8f59d5Mathias Agopian
295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__BEGIN_DECLS
305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/
32e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling
33d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/* for compatibility */
34b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian#define HWC_MODULE_API_VERSION      HWC_MODULE_API_VERSION_0_1
35b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian#define HWC_DEVICE_API_VERSION      HWC_DEVICE_API_VERSION_0_1
3681c323dd54d5f0ea1e75ab392187608049b2326cMathias Agopian#define HWC_API_VERSION             HWC_DEVICE_API_VERSION
37e99520400f228e45b1feff28eb4105b8e5599196Erik Gilling
38d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/* Users of this header can define HWC_REMOVE_DEPRECATED_VERSIONS to test that
39d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * they still work with just the current version declared, before the
40d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * deprecated versions are actually removed.
41d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall *
42d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * To find code that still depends on the old versions, set the #define to 1
43d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * here. Code that explicitly sets it to zero (rather than simply not defining
44d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall * it) will still see the old versions.
45d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall */
46d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#if !defined(HWC_REMOVE_DEPRECATED_VERSIONS)
47d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#define HWC_REMOVE_DEPRECATED_VERSIONS 0
48d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#endif
49d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
50d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall/*****************************************************************************/
51d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/**
535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * The id of this module
545d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_MODULE_ID "hwcomposer"
565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/**
585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian * Name of the sensors device to open
595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
605d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#define HWC_HARDWARE_COMPOSER   "composer"
615d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
62d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstruct hwc_composer_device_1;
63d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_methods_1 {
64b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian
65b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    /*
66b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * eventControl(..., event, enabled)
67f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * Enables or disables h/w composer events for a display.
68b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
69b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * eventControl can be called from any thread and takes effect
70b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * immediately.
71b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
72b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *  Supported events are:
73b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *      HWC_EVENT_VSYNC
74b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
75b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * returns -EINVAL if the "event" parameter is not one of the value above
76b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * or if the "enabled" parameter is not 0 or 1.
77b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     */
78b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    int (*eventControl)(
79f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall            struct hwc_composer_device_1* dev, int dpy,
80f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall            int event, int enabled);
81b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian
8238fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross    /*
8338fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     * blank(..., blank)
84f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * Blanks or unblanks a display's screen.
8538fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     *
8638fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     * Turns the screen off when blank is nonzero, on when blank is zero.
87ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * Multiple sequential calls with the same blank value must be supported.
88705d2912b70ae0dc8d035d475cf75f64c1a4c4b6Colin Cross     * The screen state transition must be be complete when the function
89705d2912b70ae0dc8d035d475cf75f64c1a4c4b6Colin Cross     * returns.
9038fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     *
9138fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     * returns 0 on success, negative on error.
9238fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross     */
93f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    int (*blank)(struct hwc_composer_device_1* dev, int dpy, int blank);
9438fccf483b19a0dd2431cb8515e7a2cc5546b373Colin Cross
95d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_methods_1_t;
96b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian
975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_rect {
985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int left;
995d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int top;
1005d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int right;
1015d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int bottom;
1025d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_rect_t;
1035d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1045d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_region {
1055d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    size_t numRects;
1065d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    hwc_rect_t const* rects;
1075d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_region_t;
1085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
109eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopiantypedef struct hwc_color {
110eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    uint8_t r;
111eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    uint8_t g;
112eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    uint8_t b;
113eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    uint8_t a;
114eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian} hwc_color_t;
115eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
116d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_layer_1 {
1175d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
118d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * Initially set to HWC_FRAMEBUFFER, HWC_BACKGROUND, or
119d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * HWC_FRAMEBUFFER_TARGET.
120d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *
121eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     * HWC_FRAMEBUFFER
122d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   Indicates the layer will be drawn into the framebuffer
123d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   using OpenGL ES. The HWC can toggle this value to HWC_OVERLAY to
124d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   indicate it will handle the layer.
125eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     *
126eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     * HWC_BACKGROUND
127d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   Indicates this is a special "background" layer. The only valid field
128d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   is backgroundColor. The HWC can toggle this value to HWC_FRAMEBUFFER
129d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   to indicate it CANNOT handle the background color.
130d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *
131d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * HWC_FRAMEBUFFER_TARGET
132d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   Indicates this layer is the framebuffer surface used as the target of
133d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY
134d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   or HWC_BACKGROUND, then no OpenGL ES composition will be done, and
135d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   this layer should be ignored during set(); the HWC_SKIP_LAYER flag
136d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   will indicate this case.
137eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     *
138d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   This flag (and the framebuffer surface layer) will only be used if the
139d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions,
140d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   the OpenGL ES target surface is communicated by the (dpy, sur) fields
141d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *   in hwc_compositor_device_1_t.
1425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
1435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    int32_t compositionType;
1445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* see hwc_layer_t::hints above */
1465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t hints;
1475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
1485d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /* see hwc_layer_t::flags above */
1495d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t flags;
1505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
151eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    union {
152eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian        /* color of the background.  hwc_color_t.a is ignored */
153eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian        hwc_color_t backgroundColor;
154eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
155eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian        struct {
156eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* handle of buffer to compose. This handle is guaranteed to have been
157eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If
158eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * the layer's handle is unchanged across two consecutive prepare calls and
159eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the
160eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * HWComposer implementation may assume that the contents of the buffer have
161eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * not changed. */
162eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            buffer_handle_t handle;
163eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
164eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* transformation to apply to the buffer during composition */
165eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            uint32_t transform;
166eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
167eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* blending to apply during composition */
168eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            int32_t blending;
169eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
170eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* area of the source to consider, the origin is the top-left corner of
171eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * the buffer */
172eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            hwc_rect_t sourceCrop;
173eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
174eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* where to composite the sourceCrop onto the display. The sourceCrop
175eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * is scaled using linear filtering to the displayFrame. The origin is the
176eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * top-left corner of the screen.
177eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             */
178eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            hwc_rect_t displayFrame;
179eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
180eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            /* visible region in screen space. The origin is the
181eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * top-left corner of the screen.
182eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             * The visible region INCLUDES areas overlapped by a translucent layer.
183eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian             */
184eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian            hwc_region_t visibleRegionScreen;
185d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
186d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall            /* Sync fence object that will be signaled when the buffer's
187d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * contents are available. May be -1 if the contents are already
188d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * available. This field is only valid during set(), and should be
189d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * ignored during prepare(). The set() call must not wait for the
190d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * fence to be signaled before returning, but the HWC must wait for
191d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * all buffers to be signaled before reading from them.
192d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             *
193d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * The HWC takes ownership of the acquireFenceFd and is responsible
194d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * for closing it when no longer needed.
195d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             */
196d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall            int acquireFenceFd;
197d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
198d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall            /* During set() the HWC must set this field to a file descriptor for
199d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * a sync fence object that will signal after the HWC has finished
200d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * reading from the buffer. The field is ignored by prepare(). Each
201d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * layer should have a unique file descriptor, even if more than one
202d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * refer to the same underlying fence object; this allows each to be
203d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * closed independently.
204d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             *
205d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * If buffer reads can complete at significantly different times,
206d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * then using independent fences is preferred. For example, if the
207d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * HWC handles some layers with a blit engine and others with
208d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * overlays, then the blit layers can be reused immediately after
209d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * the blit completes, but the overlay layers can't be reused until
210d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * a subsequent frame has been displayed.
211d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             *
212d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * The HWC client taks ownership of the releaseFenceFd and is
213d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             * responsible for closing it when no longer needed.
214d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall             */
215d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall            int releaseFenceFd;
216eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian        };
217eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    };
2185d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
219d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    /* Allow for expansion w/o breaking binary compatibility.
220d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall     * Pad layer to 96 bytes, assuming 32-bit pointers.
221d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall     */
222d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    int32_t reserved[24 - 18];
223d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
224d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_layer_1_t;
2255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
226f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a display, typically an EGLDisplay object */
227f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_display_t;
228f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall
229f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall/* This represents a surface, typically an EGLSurface object  */
230f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef void* hwc_surface_t;
231f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall
2325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*
233f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * hwc_display_contents_1_t::flags values
2345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian */
2355d3de309f44f6a72f2a46db792f3865088897039Mathias Agopianenum {
2365d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
2375d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list
238d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall     * passed to (*prepare)() has changed by more than just the buffer handles
239d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall     * and acquire fences.
2405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
2415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    HWC_GEOMETRY_CHANGED = 0x00000001,
2425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian};
2435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
244871815b5f144048b63a18ef764f82e89394899faLouis Huemiller/*
245f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * Description of the contents to output on a display.
246f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall *
247f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * This is the top-level structure passed to the prepare and set calls to
248f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall * negotiate and commit the composition of a display image.
249871815b5f144048b63a18ef764f82e89394899faLouis Huemiller */
250f9d6cd7dee62789b220033c926c87deab8991bdeJesse Halltypedef struct hwc_display_contents_1 {
251f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    /* File descriptor referring to a Sync HAL fence object which will signal
252f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * when this display image is no longer visible, i.e. when the following
253f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * set() takes effect. The fence object is created and returned by the set
254f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * call; this field will be -1 on entry to prepare and set. SurfaceFlinger
255f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * will close the returned file descriptor.
256f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     */
257f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    int flipFenceFd;
258f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall
259d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall    /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES composition for
260d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * HWC versions before HWC_DEVICE_VERSION_1_1. They aren't relevant to
261d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * prepare. The set call should commit this surface atomically to the
262d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * display along with any overlay layers.
263d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     *
264d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * For HWC_DEVICE_VERSION_1_1 and later, these will always be set to
265d18c83fc044a5f1d74ebe59bea7763b75c4d00d7Jesse Hall     * EGL_NO_DISPLAY and EGL_NO_SURFACE.
266f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     */
267f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    hwc_display_t dpy;
268f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    hwc_surface_t sur;
269f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall
270f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    /* List of layers that will be composed on the display. The buffer handles
271ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * in the list will be unique. If numHwLayers is 0, all composition will be
272ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * performed by SurfaceFlinger.
273f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     */
2745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    uint32_t flags;
2755d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    size_t numHwLayers;
276d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    hwc_layer_1_t hwLayers[0];
2775d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
278f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall} hwc_display_contents_1_t;
2795d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
280d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/* see hwc_composer_device::registerProcs()
281d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * Any of the callbacks can be NULL, in which case the corresponding
282d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian * functionality is not supported.
283d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian */
284d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopiantypedef struct hwc_procs {
285d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    /*
286d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * (*invalidate)() triggers a screen refresh, in particular prepare and set
287d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * will be called shortly after this call is made. Note that there is
288d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * NO GUARANTEE that the screen refresh will happen after invalidate()
289d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * returns (in particular, it could happen before).
290d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and
291d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * it is safe to call invalidate() from any of hwc_composer_device
292d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * hooks, unless noted otherwise.
293d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     */
294d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    void (*invalidate)(struct hwc_procs* procs);
295b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian
296b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    /*
297b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * (*vsync)() is called by the h/w composer HAL when a vsync event is
298f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * received and HWC_EVENT_VSYNC is enabled on a display
299f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * (see: hwc_event_control).
300b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
301f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * the "dpy" parameter indicates which display the vsync event is for.
3026b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis     * the "timestamp" parameter is the system monotonic clock timestamp in
3036b7adef0ef38f568099eab38d6865f402c92235bJamie Gennis     *   nanosecond of when the vsync event happened.
304b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
305b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL.
306b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
307b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * It is expected that vsync() is called from a thread of at least
308eb67160b995a504dd70a8f29d228ec837341eb07Mathias Agopian     * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible,
309b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * typically less than 0.5 ms.
310b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     *
3116d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian     * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling
3126d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian     * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation
3136d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian     * can either stop or continue to process VSYNC events, but must not
3146d3fec70d86fe8e8fb71b233d2de727fee3f6f3fMathias Agopian     * crash or cause other problems.
315b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     */
316f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall    void (*vsync)(struct hwc_procs* procs, int dpy, int64_t timestamp);
317d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian} hwc_procs_t;
318d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
319d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
320d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian/*****************************************************************************/
3215d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3225d3de309f44f6a72f2a46db792f3865088897039Mathias Agopiantypedef struct hwc_module {
3235d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    struct hw_module_t common;
3245d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian} hwc_module_t;
3255d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
326d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Halltypedef struct hwc_composer_device_1 {
3275d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    struct hw_device_t common;
3285d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3295d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
3305d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() is called for each frame before composition and is used by
3315d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * SurfaceFlinger to determine what composition steps the HWC can handle.
3325d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
3335d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() can be called more than once, the last call prevails.
3345d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
335f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * The HWC responds by setting the compositionType field in each layer to
336f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the
337f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * composition for the layer is handled by SurfaceFlinger with OpenGL ES,
338f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * in the later case, the HWC will have to handle the layer's composition.
3395d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
3405d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the
3415d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * list's geometry has changed, that is, when more than just the buffer's
3425d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * handles have been updated. Typically this happens (but is not limited to)
3435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * when a window is added, removed, resized or moved.
3445d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
34543b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.0, numDisplays will always be one, and displays[0] will be
34643b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * non-NULL.
34743b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     *
34843b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries
34943b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * for unsupported or disabled/disconnected display types will be NULL.
35043b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     *
35143b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more.
35243b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * The extra entries correspond to enabled virtual displays, and will be
35343b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * non-NULL. In HWC 1.2, support for one virtual display is required, and
35443b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * no more than one will be used. Future HWC versions might require more.
355ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     *
3565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returns: 0 on success. An negative error code on error. If an error is
3575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returned, SurfaceFlinger will assume that none of the layer will be
3585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * handled by the HWC.
3595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
360d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    int (*prepare)(struct hwc_composer_device_1 *dev,
361f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall                    size_t numDisplays, hwc_display_contents_1_t** displays);
3625d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
3635d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    /*
3645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * (*set)() is used in place of eglSwapBuffers(), and assumes the same
3655d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * functionality, except it also commits the work list atomically with
3665d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * the actual eglSwapBuffers().
3675d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
368f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * The layer lists are guaranteed to be the same as the ones returned from
369f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * the last call to (*prepare)().
3705d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
371f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * When this call returns the caller assumes that the displays will be
372f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * updated in the near future with the content of their work lists, without
373f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * artifacts during the transition from the previous frame.
3745d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
375ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * A display with zero layers indicates that the entire composition has
376ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)()
377ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * behaves just like eglSwapBuffers().
3785d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *
37943b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.0, numDisplays will always be one, and displays[0] will be
38043b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * non-NULL.
38143b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     *
38243b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.1, numDisplays will always be HWC_NUM_DISPLAY_TYPES. Entries
38343b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * for unsupported or disabled/disconnected display types will be NULL.
38443b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     *
38543b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * For HWC 1.2 and later, numDisplays will be HWC_NUM_DISPLAY_TYPES or more.
38643b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * The extra entries correspond to enabled virtual displays, and will be
38743b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * non-NULL. In HWC 1.2, support for one virtual display is required, and
38843b51d9fdd7a447c9de7bf30960a1963c93ff5c3Jesse Hall     * no more than one will be used. Future HWC versions might require more.
38971212e3fca328630aba1ebfa1299a8719b80f476Mathias Agopian     *
390fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     * IMPORTANT NOTE: there is an implicit layer containing opaque black
391f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * pixels behind all the layers in the list. It is the responsibility of
392f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * the hwcomposer module to make sure black pixels are output (or blended
393f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall     * from).
394fb410365ca67d36d4c81d7826712c6a05437612fMathias Agopian     *
3955d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     * returns: 0 on success. An negative error code on error:
3965d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *    HWC_EGL_ERROR: eglGetError() will provide the proper error code
3975d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     *    Another code for non EGL errors.
3985d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian     */
399d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    int (*set)(struct hwc_composer_device_1 *dev,
400f9d6cd7dee62789b220033c926c87deab8991bdeJesse Hall                size_t numDisplays, hwc_display_contents_1_t** displays);
401d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
402158549c89405186d9ecaefd3811cfae3949056eeErik Gilling    /*
403b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * This field is OPTIONAL and can be NULL.
404158549c89405186d9ecaefd3811cfae3949056eeErik Gilling     *
405d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * If non NULL it will be called by SurfaceFlinger on dumpsys
406158549c89405186d9ecaefd3811cfae3949056eeErik Gilling     */
407d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len);
4085d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
409d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian    /*
410b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * This field is OPTIONAL and can be NULL.
411d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     *
412d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * (*registerProcs)() registers a set of callbacks the h/w composer HAL
413d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * can later use. It is FORBIDDEN to call any of the callbacks from
414d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * within registerProcs(). registerProcs() must save the hwc_procs_t pointer
415d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * which is needed when calling a registered callback.
416d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * Each call to registerProcs replaces the previous set of callbacks.
417d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * registerProcs is called with NULL to unregister all callbacks.
418d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     *
419d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * Any of the callbacks can be NULL, in which case the corresponding
420d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     * functionality is not supported.
421d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian     */
422d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    void (*registerProcs)(struct hwc_composer_device_1* dev,
423d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian            hwc_procs_t const* procs);
424d6afef62ff8ea1fde3a060ac5c5d887c7523b359Mathias Agopian
425eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian    /*
426b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * This field is OPTIONAL and can be NULL.
427eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     *
428eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     * Used to retrieve information about the h/w composer
429eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     *
430eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     * Returns 0 on success or -errno on error.
431eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian     */
432d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    int (*query)(struct hwc_composer_device_1* dev, int what, int* value);
433eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
434b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    /*
435b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     * Reserved for future use. Must be NULL.
436b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     */
437b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    void* reserved_proc[4];
438eb8fb508148d809166a30783a14e186fda0e31c9Mathias Agopian
439b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian    /*
440ac3f7e195cadcf1f826340976a228fd5bbcdb807Jesse Hall     * This field is REQUIRED and must not be NULL.
441b08d45dff634673e6dc5901a65f4c04bfdabf76eMathias Agopian     */
442d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall    hwc_methods_1_t const *methods;
4435d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
444d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall} hwc_composer_device_1_t;
4455d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
4465d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/** convenience API for opening and closing a device */
4475d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
448d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_open_1(const struct hw_module_t* module,
449d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall        hwc_composer_device_1_t** device) {
4505d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    return module->methods->open(module,
4515d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian            HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device);
4525d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}
4535d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
454d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hallstatic inline int hwc_close_1(hwc_composer_device_1_t* device) {
4555d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian    return device->common.close(&device->common);
4565d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian}
4575d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
4585d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian/*****************************************************************************/
4595d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
460d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#if !HWC_REMOVE_DEPRECATED_VERSIONS
461d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#include <hardware/hwcomposer_v0.h>
462d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall#endif
463d479ad22a0254fa0b5358fe82fa404e3e96c631aJesse Hall
4645d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian__END_DECLS
4655d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian
4665d3de309f44f6a72f2a46db792f3865088897039Mathias Agopian#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */
467